优化小宝

This commit is contained in:
tangxinyue 2026-01-16 17:23:26 +08:00
parent 56f24cd7ab
commit 79862a3fa0
10 changed files with 699 additions and 678 deletions

View File

@ -21,15 +21,11 @@ import {
} from './store'
export function createApp() {
const app = createSSRApp(App)
// 将store挂载到全局
app.config.globalProperties.$store = store
// 从缓存读取系统信息已在App.vue中获取
const systemInfo = uni.getStorageSync('systemInfo') || {}
app.config.globalProperties.$system = systemInfo.platform == 'ios' ? 'iOS' : 'Android'
app.config.globalProperties.$systemInfo = systemInfo
uni.setStorageSync('version', '1.1.0')
uni.setStorageSync('version', '1.0.0')
app.use(globalMethods);
return {
app

View File

@ -1,36 +1,37 @@
{
"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": {
"darkmode": false,
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"optimization" : {
"subPackages" : true
"optimization": {
"subPackages": true
},
"runmode" : "liberate", //
"runmode": "liberate", //
/* */
"modules" : {
"Camera" : {},
"Payment" : {}
"modules": {
"Camera": {},
"Payment": {}
},
/* */
"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\"/>",
@ -49,46 +50,46 @@
]
},
/* ios */
"ios" : {
"dSYMs" : false
"ios": {
"dSYMs": false
},
/* SDK */
"sdkConfigs" : {
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "123456",
"UniversalLinks" : "123456"
"sdkConfigs": {
"payment": {
"weixin": {
"__platform__": ["ios", "android"],
"appid": "123456",
"UniversalLinks": "123456"
},
"alipay" : {
"__platform__" : [ "ios", "android" ]
"alipay": {
"__platform__": ["ios", "android"]
}
}
}
},
"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

@ -197,20 +197,23 @@ onLoad(async () => {
//
updateStatusBarHeight()
data.windowHeight = await deviceUtil.getWindowHeight()
})
onShow(() => {
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#F0F3F8')
plus.navigator.setStatusBarStyle("light");
// #endif
//
data.menuList = fastEntranceData()
//
const cachedBalance = storage.get('balance')
if (cachedBalance !== null) {
data.balance = cachedBalance
}
})
onShow(() => {
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#F0F3F8', "#ffffff")
// #endif
//
data.menuList = fastEntranceData()
getRecentBills()
})
@ -228,6 +231,7 @@ const fastEntranceData = () => {
//
const getRecentBills = () => {
const allBillList = getBillList()
//
const sortedList = [...allBillList].sort((a, b) => {
const timeA = a.itemInfoList.find(info => info.key == 'createTime')?.value || 0
@ -235,9 +239,12 @@ const getRecentBills = () => {
return new Date(timeB) - new Date(timeA)
})
console.log('sortedList', sortedList)
// 3
const recentBills = sortedList.filter(item => item.payMethod == '余额').slice(0, 3)
console.log('recentBills', recentBills)
//
data.changeDetailList = recentBills.map(item => {
const createTime = item.itemInfoList.find(info => info.key == 'createTime')?.value || new Date()
@ -717,7 +724,7 @@ const onMenuScroll = (e) => {
.title-right>.text {
font-size: 14px;
color: var(--text-color);
color: #979797;
}
.right-icon {

View File

@ -473,6 +473,9 @@ let { billData, datePickerData, selectItemInfo } = toRefs(data)
onShow(() => {
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#F5F5F5')
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500);
// #endif
})
@ -791,6 +794,9 @@ const onRightClick = async () => {
billData.value.payMethod = "余额"
}
addBill(billData.value)
const allBillList = getBillList()
console.log("getBillDataList------", allBillList)
}
uni.showToast({

View File

@ -319,6 +319,9 @@ onShow(() => {
getBillData(data.billId)
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#F5F5F5')
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500);
// #endif
})

View File

@ -12,7 +12,7 @@
<template v-slot:center>
<view class="nav-bar-search flex-align-center flex-1">
<image class="search-icon" src="/static/image/bill/bill-list/search-black.png" mode=""></image>
<input type="text" class="search-input flex-1" placeholder="请输入搜索内容" />
<input type="text" class="search-input flex-1" placeholder="请输入交易记录" />
<view class="line h100"></view>
<view class="search-button">搜索</view>
</view>
@ -249,7 +249,9 @@ onShow(() => {
timingFunc: 'easeIn'
}
})
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500);
// #endif
})
@ -258,6 +260,8 @@ onShow(() => {
*/
const getBillDataList = () => {
const allBillList = getBillList()
console.log("getBillDataList------", allBillList)
//
const groupList = []
allBillList.forEach(item => {

View File

@ -75,7 +75,9 @@ onLoad((options) => {
onShow(() => {
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#ffffff')
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500);
// #endif
})

View File

@ -100,59 +100,59 @@
</view>
</template>
<script setup>
import {
import {
util,
uiUtil
} from '@/utils/common.js'
import {
} from '@/utils/common.js'
import {
storage
} from '@/utils/storage.js'
import {
} from '@/utils/storage.js'
import {
get
} from '@/utils/requests.js'
import {
} from '@/utils/requests.js'
import {
ref,
reactive,
toRefs
} from 'vue';
import {
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
} from '@dcloudio/uni-app';
import {
import {
getCurrentInstance
} from 'vue'
} from 'vue'
// 菜单列表
const menuList = [{
// 菜单列表
const menuList = [{
icon: "yuemoni",
name: "余额模拟",
isHot: false,
path: "/pages/balance/index"
},
{
},
{
icon: "zhangdanshencheng",
name: "账单生成",
isHot: false,
path: "/pages/bill/bill-list/bill-list"
},
{
},
{
icon: "licaiheika",
name: "理财黑卡",
isHot: true,
path: ""
},
{
},
{
icon: "huabei",
name: "花呗",
isHot: false,
path: ""
},
},
]
]
const data = reactive({
const data = reactive({
statusBarHeight: 0,
windowWidth: 0,
windowHeight: 0,
@ -161,9 +161,9 @@
noticeInfo: {},
vision: "",
platform: '' // 添加平台信息
})
})
const {
const {
statusBarHeight,
windowWidth,
windowHeight,
@ -172,19 +172,18 @@
noticeInfo,
vision,
platform
} = toRefs(data);
onLoad(async () => {
// 启动时获取数据
fetchUserData()
} = toRefs(data);
onLoad(async () => {
// 获取平台信息
const systemInfo = uni.getSystemInfoSync()
data.platform = systemInfo.platform
data.vision = uni.getStorageSync('version')
})
})
onShow(() => {
onShow(() => {
// 启动时获取数据
fetchUserData()
// 每次显示时刷新数据
setUserData()
// 获取系统信息
@ -194,13 +193,16 @@
data.windowHeight = systemInfo.windowHeight;
// #ifdef APP-PLUS
util.setAndroidSystemBarColor('#F0F4F9')
setTimeout(() => {
plus.navigator.setStatusBarStyle("dark");
}, 500)
// #endif
})
})
/**
/**
* 获取用户数据(从服务器)
*/
const fetchUserData = async () => {
const fetchUserData = async () => {
try {
// 先设置默认值,避免页面显示异常
setUserData()
@ -230,12 +232,12 @@
} catch (error) {
console.error('获取用户数据异常:', error)
}
}
}
/**
/**
* 获取用户信息
*/
const fetchUserInfo = async () => {
const fetchUserInfo = async () => {
const data = await get('', 'api/user', {})
if (data.code === 0) {
uni.setStorageSync('userInfo', data.data)
@ -243,12 +245,12 @@
} else {
throw new Error(data.message || '获取用户信息失败')
}
}
}
/**
/**
* 获取用户配置
*/
const fetchUserConfig = async () => {
const fetchUserConfig = async () => {
const data = await get('', 'api/user/config', {})
if (data.code === 0) {
uni.setStorageSync('config', data.data)
@ -256,13 +258,13 @@
} else {
throw new Error(data.message || '获取用户配置失败')
}
}
}
/**
/**
* 设置用户数据(从本地存储读取)
*/
const setUserData = () => {
const setUserData = () => {
// 用户信息 - 提供默认值
const userInfoData = storage.get("userInfo")
data.userInfo = userInfoData || {
@ -293,63 +295,63 @@
}
data.videoHelpList = []
}
}
}
const clickMenu = (item) => {
const clickMenu = (item) => {
if (!item.path) {
uiUtil.showError('开发中')
} else {
util.goPage(item.path)
}
}
}
const openVip = () => {
const openVip = () => {
console.log('openVip')
util.goPage('/pages/common/recharge/index')
}
}
/**
/**
* 点击视频教程
* @param item
*/
const clickVideoHelp = (item) => {
const clickVideoHelp = (item) => {
const url = item.url
util.goPage(`/pages/common/webview/webview?url=${encodeURIComponent(url)}&title=${item.text}`)
}
}
/**
/**
* 点击公告
*/
const clickNotice = () => {
const clickNotice = () => {
if (!noticeInfo.value.url) return
const url = noticeInfo.value.url + `&uni_id=${userInfo.value.user_id}`
util.goPage(`/pages/common/webview/webview?url=${encodeURIComponent(url)}&title=${noticeInfo.value.title}`)
}
}
/**
/**
* 退出模拟器
*/
const exit = () => {
const exit = () => {
plus.runtime.quit()
}
}
const noticeContainer = ref(null);
const noticeInner = ref(null);
const noticeBox = ref(null);
const noticeContainer = ref(null);
const noticeInner = ref(null);
const noticeBox = ref(null);
// #ifndef H5
const animation = uni.requireNativePlugin('animation');
const dom = uni.requireNativePlugin('dom');
// #endif
// #ifndef H5
const animation = uni.requireNativePlugin('animation');
const dom = uni.requireNativePlugin('dom');
// #endif
let marqueeTimer = null;
const currentMarqueeId = ref(0);
const lastMarqueeText = ref('');
let marqueeTimer = null;
const currentMarqueeId = ref(0);
const lastMarqueeText = ref('');
/**
/**
* 开始走马灯
*/
const startMarquee = () => {
const startMarquee = () => {
// 避免不必要的重置:如果文本没有变化且正在运行,则忽略
if (lastMarqueeText.value === noticeInfo.value.text && currentMarqueeId.value > 0) {
return;
@ -397,12 +399,12 @@
});
});
}, 1000); // 增加延时确保渲染
}
}
/**
/**
* 执行滚动动画循环
*/
const runMarqueeAnimation = (containerWidth, textWidth, myId) => {
const runMarqueeAnimation = (containerWidth, textWidth, myId) => {
// ID 校验如果当前ID不匹配说明已被新动画取代停止递归
if (myId !== currentMarqueeId.value) return;
if (!noticeInner.value) return;
@ -439,30 +441,30 @@
runMarqueeAnimation(containerWidth, textWidth, myId);
});
});
}
}
</script>
<style>
.container {
.container {
background-color: #F0F4F9;
}
}
.index-bg-img {
.index-bg-img {
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
}
.nav-bar-box {
.nav-bar-box {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
background-color: transparent;
}
}
.content-box {
.content-box {
position: fixed;
top: 0rpx;
left: 0;
@ -472,31 +474,31 @@
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
.status-box {
.status-box {
width: 100%;
}
}
.nav-box {
.nav-box {
height: 44px;
background-color: transparent;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
}
.left-box {
.left-box {
width: 60px;
height: 44px;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
}
}
.title {
.title {
flex: 1;
height: 44px;
font-size: 32rpx;
@ -507,33 +509,33 @@
display: flex;
align-items: center;
justify-content: center;
}
}
.right-box {
.right-box {
width: 60px;
height: 44px;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
}
}
.user-box {
.user-box {
position: relative;
margin: 24rpx 32rpx 0;
height: 120rpx;
z-index: 10;
}
}
.user-bg {
.user-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 120rpx;
}
}
.user-info-box {
.user-info-box {
position: absolute;
display: flex;
flex-direction: row;
@ -545,49 +547,49 @@
width: 100%;
height: 120rpx;
z-index: 1;
}
}
.user-info {
.user-info {
flex: 1;
}
}
.user-avatar {
.user-avatar {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
margin-right: 20rpx;
}
}
.name-box {
.name-box {
display: flex;
flex-direction: row;
align-items: center;
}
}
.phone-text {
.phone-text {
font-size: 28rpx;
color: #FFFFFF;
font-weight: bold;
margin-right: 12rpx;
}
}
.vip-logo {
.vip-logo {
width: 60rpx;
height: 20rpx;
}
}
.vip-end-time {
.vip-end-time {
font-size: 24rpx;
color: #FFFFFF;
margin-top: 8rpx;
}
}
.open-vip-btn {
.open-vip-btn {
height: 40rpx;
width: 116rpx;
}
}
.notice-box {
.notice-box {
display: flex;
flex-direction: row;
align-items: center;
@ -597,9 +599,9 @@
padding: 0 16rpx;
height: 64rpx;
overflow: hidden;
}
}
.sound-box {
.sound-box {
height: 64rpx;
width: 50rpx;
display: flex;
@ -607,35 +609,35 @@
justify-content: center;
position: relative;
z-index: 10;
}
}
.notice-content-wrapper {
.notice-content-wrapper {
flex: 1;
flex-direction: row;
overflow: hidden;
}
}
.notice-inner {
.notice-inner {
flex-direction: row;
align-items: center;
}
}
.notice-content {
.notice-content {
font-size: 24rpx;
color: #767676;
}
}
.group-box {
.group-box {
margin: 32rpx;
margin-bottom: 0;
}
}
.title-img {
.title-img {
width: 140rpx;
height: 44rpx;
}
}
.video-help-box {
.video-help-box {
display: flex;
flex-direction: row;
align-items: center;
@ -644,43 +646,43 @@
padding: 24rpx 32rpx;
border-radius: 24rpx;
margin-top: 16rpx;
}
}
.video-help-item {
.video-help-item {
text-align: center;
flex-direction: column;
}
}
.video-help-img {
.video-help-img {
width: 96rpx;
height: 96rpx;
}
}
.video-help-title {
.video-help-title {
font-size: 24rpx;
color: #1A1A1A;
text-align: center;
}
}
.menu-box {
.menu-box {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
margin-top: 16rpx;
}
}
.item-box {
.item-box {
position: relative;
height: 156rpx;
display: flex;
flex-direction: column;
justify-content: flex-end;
margin-bottom: 32rpx;
}
}
.menu-item {
.menu-item {
display: flex;
position: relative;
flex-direction: row;
@ -690,46 +692,46 @@
border-radius: 16rpx;
padding: 16rpx 32rpx;
height: 140rpx;
}
}
.menu-item-name {
.menu-item-name {
font-weight: bold;
font-size: 32rpx;
color: #000000;
}
}
.name-img {
.name-img {
height: 28rpx;
}
}
.hot-icon {
.hot-icon {
position: absolute;
top: 0;
left: 0;
width: 68rpx;
height: 30rpx;
z-index: 99;
}
}
.activity-box {
.activity-box {
margin: 0 32rpx;
}
}
.footer-box {
.footer-box {
display: flex;
align-items: center;
justify-content: center;
margin-top: 40rpx;
margin-bottom: 10rpx;
}
}
.vision-text {
.vision-text {
font-size: 24rpx;
color: #767676;
}
}
.ios-padding-bottom {
.ios-padding-bottom {
margin-bottom: 50rpx;
}
}
</style>

View File

@ -39,6 +39,9 @@ export const store = reactive({
});
// 定义操作方法
export const useStore = () => {
// 用户相关操作
@ -83,10 +86,6 @@ export const useStore = () => {
return store.billList
}
// 手动保存账单列表(替代自动监听)
const saveBillList = debounce(() => {
storage.set('bill_list', store.billList)
}, 500)
// 优化后的监听:使用防抖减少存储频率
const debouncedSaveSettings = debounce((newValue) => {
@ -105,7 +104,12 @@ export const useStore = () => {
{ deep: true }
);
// 移除billList的自动监听改为手动调用saveBillList
// 监听billList改变自动保存
watch(
() => store.billList,
(newValue) => storage.set('bill_list', newValue),
{ deep: true }
);
// 获取系统信息(从缓存读取)
const getSystemInfo = () => {
@ -124,7 +128,6 @@ export const useStore = () => {
updateBill,
deleteBill,
getBillList,
saveBillList,
getSystemInfo
};
};

View File

@ -387,7 +387,6 @@ export const util = {
let window = plus.android.invoke(activity, "getWindow");
plus.android.invoke(window, "setNavigationBarColor", colorInt);
uni.setNavigationBarColor({
frontColor: frontColor,
animation: { // 动画效果
duration: 100,
timingFunc: 'easeIn'
@ -395,7 +394,6 @@ export const util = {
})
setTimeout(function () {
uni.setNavigationBarColor({
frontColor: frontColor,
animation: { // 动画效果
duration: 100,
timingFunc: 'easeIn'
@ -407,7 +405,6 @@ export const util = {
} catch (err) {
console.log("状态栏修改失败", err);
uni.setNavigationBarColor({
frontColor: frontColor,
animation: { // 动画效果
duration: 100,
timingFunc: 'easeIn'