完成支付宝分包
This commit is contained in:
parent
f44238d9bc
commit
bcb487daab
16
App.vue
16
App.vue
|
|
@ -4,7 +4,21 @@ export default {
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
console.log('App Launch', options)
|
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)
|
this.initConfig(options)
|
||||||
|
|
||||||
// 启动完成
|
// 启动完成
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,7 @@
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
toRefs,
|
toRefs,
|
||||||
ref,
|
ref
|
||||||
defineExpose,
|
|
||||||
defineProps,
|
|
||||||
defineEmits
|
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import addBillJson from '@/static/json/add-bill.json'
|
import addBillJson from '@/static/json/add-bill.json'
|
||||||
|
|
||||||
|
|
|
||||||
8
main.js
8
main.js
|
|
@ -20,15 +20,11 @@ export function createApp() {
|
||||||
// 将store挂载到全局
|
// 将store挂载到全局
|
||||||
app.config.globalProperties.$store = store
|
app.config.globalProperties.$store = store
|
||||||
|
|
||||||
// 获取系统信息并挂载到全局
|
// 从缓存读取系统信息(已在App.vue中获取)
|
||||||
const systemInfo = uni.getSystemInfoSync()
|
const systemInfo = uni.getStorageSync('systemInfo') || {}
|
||||||
app.config.globalProperties.$platform = systemInfo.platform
|
app.config.globalProperties.$platform = systemInfo.platform
|
||||||
app.config.globalProperties.$systemInfo = systemInfo
|
app.config.globalProperties.$systemInfo = systemInfo
|
||||||
|
|
||||||
// 获取系统信息
|
|
||||||
const { getSystemInfo } = useStore()
|
|
||||||
getSystemInfo()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,34 @@
|
||||||
{
|
{
|
||||||
"name" : "alipay-emulator",
|
"name": "alipay-emulator",
|
||||||
"appid" : "__UNI__D535736",
|
"appid": "__UNI__D535736",
|
||||||
"description" : "",
|
"description": "",
|
||||||
"versionName" : "1.0.0",
|
"versionName": "1.0.0",
|
||||||
"versionCode" : "100",
|
"versionCode": "100",
|
||||||
"transformPx" : false,
|
"transformPx": false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
"app-plus" : {
|
"app-plus": {
|
||||||
"usingComponents" : true,
|
"usingComponents": true,
|
||||||
"nvueStyleCompiler" : "uni-app",
|
"nvueStyleCompiler": "uni-app",
|
||||||
"compilerVersion" : 3,
|
"compilerVersion": 3,
|
||||||
"splashscreen" : {
|
"splashscreen": {
|
||||||
"alwaysShowBeforeRender" : true,
|
"alwaysShowBeforeRender": true,
|
||||||
"waiting" : true,
|
"waiting": true,
|
||||||
"autoclose" : true,
|
"autoclose": true,
|
||||||
"delay" : 0
|
"delay": 0
|
||||||
},
|
},
|
||||||
|
"optimization": {
|
||||||
|
"subPackages": true
|
||||||
|
},
|
||||||
|
"runmode": "liberate", // 开启分包优化后,必须配置资源释放模式
|
||||||
/* 模块配置 */
|
/* 模块配置 */
|
||||||
"modules" : {
|
"modules": {
|
||||||
"Camera" : {}
|
"Camera": {}
|
||||||
},
|
},
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
"distribute" : {
|
"distribute": {
|
||||||
/* android打包配置 */
|
/* android打包配置 */
|
||||||
"android" : {
|
"android": {
|
||||||
"permissions" : [
|
"permissions": [
|
||||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||||
|
|
@ -43,35 +47,35 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
/* ios打包配置 */
|
||||||
"ios" : {
|
"ios": {
|
||||||
"dSYMs" : false
|
"dSYMs": false
|
||||||
},
|
},
|
||||||
/* SDK配置 */
|
/* SDK配置 */
|
||||||
"sdkConfigs" : {}
|
"sdkConfigs": {}
|
||||||
},
|
},
|
||||||
"nvueLaunchMode" : ""
|
"nvueLaunchMode": ""
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"quickapp" : {},
|
"quickapp": {},
|
||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin": {
|
||||||
"appid" : "",
|
"appid": "",
|
||||||
"setting" : {
|
"setting": {
|
||||||
"urlCheck" : false
|
"urlCheck": false
|
||||||
},
|
},
|
||||||
"usingComponents" : true
|
"usingComponents": true
|
||||||
},
|
},
|
||||||
"mp-alipay" : {
|
"mp-alipay": {
|
||||||
"usingComponents" : true
|
"usingComponents": true
|
||||||
},
|
},
|
||||||
"mp-baidu" : {
|
"mp-baidu": {
|
||||||
"usingComponents" : true
|
"usingComponents": true
|
||||||
},
|
},
|
||||||
"mp-toutiao" : {
|
"mp-toutiao": {
|
||||||
"usingComponents" : true
|
"usingComponents": true
|
||||||
},
|
},
|
||||||
"uniStatistics" : {
|
"uniStatistics": {
|
||||||
"enable" : false
|
"enable": false
|
||||||
},
|
},
|
||||||
"vueVersion" : "3"
|
"vueVersion": "3"
|
||||||
}
|
}
|
||||||
141
pages.json
141
pages.json
|
|
@ -7,65 +7,92 @@
|
||||||
"navigationBarTitleText": "uni-app",
|
"navigationBarTitleText": "uni-app",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/balance/index",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "余额页面",
|
|
||||||
"navigationStyle": "custom",
|
|
||||||
"navigationBarTextStyle": "white"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/bill/bill-list/bill-list",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "账单列表页面",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/bill/add-bill/add-bill",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "新增账单",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/common/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",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "webView页面",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"subPackages": [
|
||||||
|
{
|
||||||
|
"root": "pages/balance",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "余额页面",
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
"navigationBarTextStyle": "white"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "add-bill/add-bill",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "新增账单",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "bill-detail/bill-detail",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "账单详情页",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"root": "pages/common",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "hot-icon/hot-icon",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "热门图标",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": {
|
"globalStyle": {
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarTitleText": "uni-app",
|
"navigationBarTitleText": "uni-app",
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,7 @@
|
||||||
<view class="group-box">
|
<view class="group-box">
|
||||||
<image class="title-img" src="/static/image/index/monixiaobao.png"></image>
|
<image class="title-img" src="/static/image/index/monixiaobao.png"></image>
|
||||||
<view class="menu-box">
|
<view class="menu-box">
|
||||||
<view class="item-box" v-for="item in menuList" :key="item.name"
|
<view class="item-box" v-for="item in menuList" :key="item.name" @click="clickMenu(item)">
|
||||||
@click="util.goPage(item.path)">
|
|
||||||
<view class="menu-item" :style="{ width: (windowWidth - 50) / 2 + 'px' }">
|
<view class="menu-item" :style="{ width: (windowWidth - 50) / 2 + 'px' }">
|
||||||
<!-- <text class="menu-item-name">{{ item.name }}</text> -->
|
<!-- <text class="menu-item-name">{{ item.name }}</text> -->
|
||||||
<image class="name-img" :src="'/static/image/index/menu-name/' + item.icon + '.png'"
|
<image class="name-img" :src="'/static/image/index/menu-name/' + item.icon + '.png'"
|
||||||
|
|
@ -88,7 +87,7 @@
|
||||||
<view class="activity-box">
|
<view class="activity-box">
|
||||||
<image class="alipay-year-bill" :style="{ width: (windowWidth - 32) + 'px' }"
|
<image class="alipay-year-bill" :style="{ width: (windowWidth - 32) + 'px' }"
|
||||||
src="/static/image/index/alipay-year-bill.png" mode="widthFix"
|
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>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -103,7 +102,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
util,
|
util,
|
||||||
deviceUtil
|
uiUtil
|
||||||
} from '@/utils/common.js'
|
} from '@/utils/common.js'
|
||||||
import {
|
import {
|
||||||
storage
|
storage
|
||||||
|
|
@ -285,6 +284,14 @@ const setUserData = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clickMenu = (item) => {
|
||||||
|
if (!item.path) {
|
||||||
|
uiUtil.showError('开发中')
|
||||||
|
} else {
|
||||||
|
util.goPage(item.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击视频教程
|
* 点击视频教程
|
||||||
* @param item
|
* @param item
|
||||||
|
|
@ -685,10 +692,6 @@ const runMarqueeAnimation = (containerWidth, textWidth, myId) => {
|
||||||
margin: 0 32rpx;
|
margin: 0 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alipay-year-bill {
|
|
||||||
/* width: 100%; */
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-box {
|
.footer-box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
|
|
@ -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({
|
export const store = reactive({
|
||||||
// 用户信息
|
// 用户信息
|
||||||
|
|
@ -15,11 +26,12 @@ export const store = reactive({
|
||||||
notifications: true
|
notifications: true
|
||||||
},
|
},
|
||||||
|
|
||||||
// 系统信息
|
// 系统信息(从缓存读取,避免重复调用)
|
||||||
systemInfo: {
|
systemInfo: uni.getStorageSync('systemInfo') || {
|
||||||
statusBarHeight: 0,
|
statusBarHeight: 0,
|
||||||
windowHeight: 0,
|
windowHeight: 0,
|
||||||
windowWidth: 0
|
windowWidth: 0,
|
||||||
|
platform: ''
|
||||||
},
|
},
|
||||||
|
|
||||||
// 账单列表
|
// 账单列表
|
||||||
|
|
@ -71,8 +83,16 @@ export const useStore = () => {
|
||||||
return store.billList
|
return store.billList
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据持久化
|
// 手动保存账单列表(替代自动监听)
|
||||||
// 监听store变化,自动保存到本地存储
|
const saveBillList = debounce(() => {
|
||||||
|
storage.set('bill_list', store.billList)
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
// 优化后的监听:使用防抖减少存储频率
|
||||||
|
const debouncedSaveSettings = debounce((newValue) => {
|
||||||
|
storage.set('settings', newValue)
|
||||||
|
}, 500)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => store.userInfo,
|
() => store.userInfo,
|
||||||
(newValue) => storage.set('userInfo', newValue),
|
(newValue) => storage.set('userInfo', newValue),
|
||||||
|
|
@ -81,28 +101,18 @@ export const useStore = () => {
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => store.settings,
|
() => store.settings,
|
||||||
(newValue) => storage.set('settings', newValue),
|
(newValue) => debouncedSaveSettings(newValue),
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
// 移除billList的自动监听,改为手动调用saveBillList
|
||||||
() => store.billList,
|
|
||||||
(newValue) => storage.set('bill_list', newValue),
|
|
||||||
{ deep: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取系统信息
|
// 获取系统信息(从缓存读取)
|
||||||
const getSystemInfo = () => {
|
const getSystemInfo = () => {
|
||||||
uni.getSystemInfo({
|
const cachedInfo = uni.getStorageSync('systemInfo')
|
||||||
success: (res) => {
|
if (cachedInfo) {
|
||||||
store.systemInfo.statusBarHeight = res.statusBarHeight || 0;
|
store.systemInfo = cachedInfo
|
||||||
store.systemInfo.windowHeight = res.windowHeight || 0;
|
}
|
||||||
store.systemInfo.windowWidth = res.windowWidth || 0;
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('获取系统信息失败:', err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -114,6 +124,7 @@ export const useStore = () => {
|
||||||
updateBill,
|
updateBill,
|
||||||
deleteBill,
|
deleteBill,
|
||||||
getBillList,
|
getBillList,
|
||||||
|
saveBillList,
|
||||||
getSystemInfo
|
getSystemInfo
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue