完成支付宝分包

This commit is contained in:
tangxinyue 2026-01-15 18:42:49 +08:00
parent f44238d9bc
commit bcb487daab
8 changed files with 190 additions and 138 deletions

16
App.vue
View File

@ -4,7 +4,21 @@ export default {
const startTime = Date.now()
console.log('App Launch', options)
// 1.
// 1.
const systemInfo = uni.getSystemInfoSync()
uni.setStorageSync('systemInfo', {
platform: systemInfo.platform,
system: systemInfo.system,
osName: systemInfo.osName,
osVersion: systemInfo.osVersion,
statusBarHeight: systemInfo.statusBarHeight,
windowWidth: systemInfo.windowWidth,
windowHeight: systemInfo.windowHeight,
isIOS: systemInfo.platform === 'ios',
isAndroid: systemInfo.platform === 'android'
})
// 2.
this.initConfig(options)
//

View File

@ -83,10 +83,7 @@
import {
reactive,
toRefs,
ref,
defineExpose,
defineProps,
defineEmits
ref
} from 'vue'
import addBillJson from '@/static/json/add-bill.json'

View File

@ -20,15 +20,11 @@ export function createApp() {
// 将store挂载到全局
app.config.globalProperties.$store = store
// 获取系统信息并挂载到全局
const systemInfo = uni.getSystemInfoSync()
// 从缓存读取系统信息已在App.vue中获取
const systemInfo = uni.getStorageSync('systemInfo') || {}
app.config.globalProperties.$platform = systemInfo.platform
app.config.globalProperties.$systemInfo = systemInfo
// 获取系统信息
const { getSystemInfo } = useStore()
getSystemInfo()
return {
app
}

View File

@ -1,30 +1,34 @@
{
"name" : "alipay-emulator",
"appid" : "__UNI__D535736",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"name": "alipay-emulator",
"appid": "__UNI__D535736",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"optimization": {
"subPackages": true
},
"runmode": "liberate", //
/* */
"modules" : {
"Camera" : {}
"modules": {
"Camera": {}
},
/* */
"distribute" : {
"distribute": {
/* android */
"android" : {
"permissions" : [
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
@ -43,35 +47,35 @@
]
},
/* ios */
"ios" : {
"dSYMs" : false
"ios": {
"dSYMs": false
},
/* SDK */
"sdkConfigs" : {}
"sdkConfigs": {}
},
"nvueLaunchMode" : ""
"nvueLaunchMode": ""
},
/* */
"quickapp" : {},
"quickapp": {},
/* */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents" : true
"usingComponents": true
},
"mp-alipay" : {
"usingComponents" : true
"mp-alipay": {
"usingComponents": true
},
"mp-baidu" : {
"usingComponents" : true
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao" : {
"usingComponents" : true
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics" : {
"enable" : false
"uniStatistics": {
"enable": false
},
"vueVersion" : "3"
"vueVersion": "3"
}

View File

@ -7,9 +7,14 @@
"navigationBarTitleText": "uni-app",
"navigationStyle": "custom"
}
},
}
],
"subPackages": [
{
"path": "pages/balance/index",
"root": "pages/balance",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "余额页面",
"navigationStyle": "custom",
@ -17,55 +22,77 @@
}
},
{
"path": "pages/bill/bill-list/bill-list",
"path": "fast-entrance-management/fast-entrance-management",
"style": {
"navigationBarTitleText": "快速入口页面",
"navigationStyle": "custom"
}
}
]
},
{
"root": "pages/bill",
"pages": [
{
"path": "bill-list/bill-list",
"style": {
"navigationBarTitleText": "账单列表页面",
"navigationStyle": "custom"
}
},
{
"path": "pages/bill/add-bill/add-bill",
"path": "add-bill/add-bill",
"style": {
"navigationBarTitleText": "新增账单",
"navigationStyle": "custom"
}
},
{
"path": "pages/common/hot-icon/hot-icon",
"path": "bill-detail/bill-detail",
"style": {
"navigationBarTitleText": "账单详情页",
"navigationStyle": "custom"
}
}
]
},
{
"root": "pages/common",
"pages": [
{
"path": "hot-icon/hot-icon",
"style": {
"navigationBarTitleText": "热门图标",
"navigationStyle": "custom"
}
},
{
"path": "pages/balance/fast-entrance-management/fast-entrance-management",
"style": {
"navigationBarTitleText": "快速入口页面",
"navigationStyle": "custom"
}
},
{
"path": "pages/bill/bill-detail/bill-detail",
"style": {
"navigationBarTitleText": "账单详情页",
"navigationStyle": "custom"
}
},
{
"path": "pages/index/alipay-annual-bill/alipay-annual-bill",
"style": {
"navigationBarTitleText": "支付宝年度账单",
"navigationStyle": "custom"
}
},
{
"path": "pages/common/webview/webview",
"path": "webview/webview",
"style": {
"navigationBarTitleText": "webView页面",
"navigationStyle": "custom"
}
},
{
"path": "alipay-annual-bill/alipay-annual-bill",
"style": {
"navigationBarTitleText": "支付宝年度账单",
"navigationStyle": "custom"
}
}
]
}
],
"preloadRule": {
"pages/index/index": {
"network": "all",
"packages": [
"pages/balance",
"pages/bill",
"pages/common"
]
}
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",

View File

@ -70,8 +70,7 @@
<view class="group-box">
<image class="title-img" src="/static/image/index/monixiaobao.png"></image>
<view class="menu-box">
<view class="item-box" v-for="item in menuList" :key="item.name"
@click="util.goPage(item.path)">
<view class="item-box" v-for="item in menuList" :key="item.name" @click="clickMenu(item)">
<view class="menu-item" :style="{ width: (windowWidth - 50) / 2 + 'px' }">
<!-- <text class="menu-item-name">{{ item.name }}</text> -->
<image class="name-img" :src="'/static/image/index/menu-name/' + item.icon + '.png'"
@ -88,7 +87,7 @@
<view class="activity-box">
<image class="alipay-year-bill" :style="{ width: (windowWidth - 32) + 'px' }"
src="/static/image/index/alipay-year-bill.png" mode="widthFix"
@click="util.goPage(`/pages/index/alipay-annual-bill/alipay-annual-bill`)"></image>
@click="util.goPage(`/pages/common/alipay-annual-bill/alipay-annual-bill`)"></image>
</view>
</view>
@ -103,7 +102,7 @@
<script setup>
import {
util,
deviceUtil
uiUtil
} from '@/utils/common.js'
import {
storage
@ -285,6 +284,14 @@ const setUserData = () => {
}
}
const clickMenu = (item) => {
if (!item.path) {
uiUtil.showError('开发中')
} else {
util.goPage(item.path)
}
}
/**
* 点击视频教程
* @param item
@ -685,10 +692,6 @@ const runMarqueeAnimation = (containerWidth, textWidth, myId) => {
margin: 0 32rpx;
}
.alipay-year-bill {
/* width: 100%; */
}
.footer-box {
display: flex;
align-items: center;

View File

@ -3,6 +3,17 @@ import { storage } from '../utils/storage';
// 防抖函数
const debounce = (fn, delay = 300) => {
let timer = null
return function (...args) {
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, args)
}, delay)
}
}
// 定义应用的全局状态
export const store = reactive({
// 用户信息
@ -15,11 +26,12 @@ export const store = reactive({
notifications: true
},
// 系统信息
systemInfo: {
// 系统信息(从缓存读取,避免重复调用)
systemInfo: uni.getStorageSync('systemInfo') || {
statusBarHeight: 0,
windowHeight: 0,
windowWidth: 0
windowWidth: 0,
platform: ''
},
// 账单列表
@ -71,8 +83,16 @@ export const useStore = () => {
return store.billList
}
// 数据持久化
// 监听store变化自动保存到本地存储
// 手动保存账单列表(替代自动监听)
const saveBillList = debounce(() => {
storage.set('bill_list', store.billList)
}, 500)
// 优化后的监听:使用防抖减少存储频率
const debouncedSaveSettings = debounce((newValue) => {
storage.set('settings', newValue)
}, 500)
watch(
() => store.userInfo,
(newValue) => storage.set('userInfo', newValue),
@ -81,28 +101,18 @@ export const useStore = () => {
watch(
() => store.settings,
(newValue) => storage.set('settings', newValue),
(newValue) => debouncedSaveSettings(newValue),
{ deep: true }
);
watch(
() => store.billList,
(newValue) => storage.set('bill_list', newValue),
{ deep: true }
);
// 移除billList的自动监听改为手动调用saveBillList
// 获取系统信息
// 获取系统信息(从缓存读取)
const getSystemInfo = () => {
uni.getSystemInfo({
success: (res) => {
store.systemInfo.statusBarHeight = res.statusBarHeight || 0;
store.systemInfo.windowHeight = res.windowHeight || 0;
store.systemInfo.windowWidth = res.windowWidth || 0;
},
fail: (err) => {
console.error('获取系统信息失败:', err);
const cachedInfo = uni.getStorageSync('systemInfo')
if (cachedInfo) {
store.systemInfo = cachedInfo
}
});
};
return {
@ -114,6 +124,7 @@ export const useStore = () => {
updateBill,
deleteBill,
getBillList,
saveBillList,
getSystemInfo
};
};