提交
This commit is contained in:
parent
5b0462afce
commit
e8887d5eb6
|
|
@ -280,11 +280,14 @@ class ConfigManager {
|
|||
* @returns {Boolean} 是否为微信版本
|
||||
*/
|
||||
static GetVersion() {
|
||||
//#ifdef MP-WEIXIN
|
||||
let version = this.get('version');
|
||||
if (version == wx_version) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
//#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,5 +25,109 @@ class AppPlatform extends BasePlatform {
|
|||
// 降级方案
|
||||
alert(`请手动分享:${url}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写获取用户中心菜单列表,处理App特有的菜单需求
|
||||
* @returns {Array} 菜单项数组
|
||||
*/
|
||||
getUserMenuList() {
|
||||
// 获取基础菜单列表
|
||||
const baseMenuList = super.getUserMenuList();
|
||||
|
||||
// 添加App特有的菜单项
|
||||
const appSpecificMenus = [
|
||||
{
|
||||
id: 10,
|
||||
show: true,
|
||||
title: '清除缓存',
|
||||
icon: 'my/s10.png',
|
||||
path: '',
|
||||
handler: this.handleClearCache.bind(this)
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
show: true,
|
||||
title: '检查更新',
|
||||
icon: 'my/s11.png',
|
||||
path: '',
|
||||
handler: this.handleCheckUpdate.bind(this)
|
||||
}
|
||||
];
|
||||
|
||||
// 返回合并后的菜单列表
|
||||
return [...baseMenuList, ...appSpecificMenus];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理清除缓存
|
||||
*/
|
||||
handleClearCache() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要清除缓存吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 清除除了登录信息外的缓存
|
||||
const token = uni.getStorageSync('token');
|
||||
const userinfo = uni.getStorageSync('userinfo');
|
||||
uni.clearStorageSync();
|
||||
uni.setStorageSync('token', token);
|
||||
uni.setStorageSync('userinfo', userinfo);
|
||||
|
||||
uni.showToast({
|
||||
title: '缓存已清除',
|
||||
icon: 'success'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检查更新
|
||||
*/
|
||||
handleCheckUpdate() {
|
||||
// App特有的更新检查逻辑
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
||||
const version = widgetInfo.version;
|
||||
|
||||
uni.request({
|
||||
url: 'https://your-api-url/check-update',
|
||||
data: {
|
||||
version: version,
|
||||
platform: uni.getSystemInfoSync().platform
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data && res.data.hasUpdate) {
|
||||
uni.showModal({
|
||||
title: '发现新版本',
|
||||
content: res.data.updateDesc || '有新版本可用,是否立即更新?',
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
// 打开下载页面或应用商店
|
||||
plus.runtime.openURL(res.data.downloadUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '已是最新版本',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// #endif
|
||||
|
||||
// 非APP环境下的处理
|
||||
// #ifndef APP-PLUS
|
||||
uni.showToast({
|
||||
title: '当前已是最新版本',
|
||||
icon: 'none'
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
export default AppPlatform;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { navigateTo } from '@/common/router'
|
||||
/**
|
||||
* 多端平台抽象基类(父类)
|
||||
* 定义所有端必须实现的方法
|
||||
|
|
@ -71,8 +72,117 @@ class BasePlatform {
|
|||
getOrderNo() {
|
||||
throw new Error('子类必须实现 getOrderNo 方法');
|
||||
}
|
||||
delOrderNo(){
|
||||
|
||||
delOrderNo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户中心菜单列表
|
||||
* @returns {Array} 菜单项数组,每项包含id, show, title, icon, path和handler
|
||||
*/
|
||||
getUserMenuList() {
|
||||
let m = [
|
||||
{
|
||||
id: 1,
|
||||
show: true,
|
||||
title: '消费记录',
|
||||
icon: 'my/s1.png',
|
||||
path: '/pages/other/order_list',
|
||||
handler: this.navigateToPath.bind(this)
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
show: true,
|
||||
title: '我的收藏',
|
||||
icon: 'my/s3.png',
|
||||
path: '/package/mine/collect',
|
||||
handler: this.navigateToPath.bind(this)
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
show: true,
|
||||
title: '优惠券',
|
||||
icon: 'my/s4.png',
|
||||
path: '/pages/user/coupon',
|
||||
handler: this.navigateToPath.bind(this)
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
show: true,
|
||||
title: '邀请好友',
|
||||
icon: 'my/s5.png',
|
||||
path: '/pages/user/tui-guang',
|
||||
handler: this.navigateToPath.bind(this)
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
show: true,
|
||||
title: '加入福利群',
|
||||
icon: 'my/s6.png',
|
||||
path: '',
|
||||
handler: this.handleJoinGroup.bind(this)
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
show: true,
|
||||
title: '用户协议',
|
||||
icon: 'my/s7.png',
|
||||
path: '/pages/guize/guize?type=4',
|
||||
handler: this.navigateToPath.bind(this)
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
if (uni.getStorageSync('token') != null && uni.getStorageSync('token') != "") {
|
||||
m.push({
|
||||
id: 8,
|
||||
show: true,
|
||||
title: '退出登录',
|
||||
icon: 'my/exit.png',
|
||||
path: '',
|
||||
handler: this.handleLogout.bind(this)
|
||||
})
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航到指定页面
|
||||
* @param {Object} item 菜单项
|
||||
*/
|
||||
navigateToPath(item) {
|
||||
navigateTo(item.path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理加入福利群
|
||||
* @param {Object} item 菜单项
|
||||
* @param {Object} context 页面上下文
|
||||
*/
|
||||
handleJoinGroup(item, context) {
|
||||
if (context && context.$refs && context.$refs.qunliao_show) {
|
||||
context.$refs.qunliao_show.open();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理退出登录
|
||||
*/
|
||||
handleLogout() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userinfo');
|
||||
uni.switchTab({
|
||||
url: '/pages/user/index'
|
||||
});
|
||||
// window.location.href = window.location.href;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
export default BasePlatform;
|
||||
|
|
@ -171,5 +171,30 @@ class H5Platform extends BasePlatform {
|
|||
resolve(pay_order_num);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写获取用户中心菜单列表,处理H5特有的菜单需求
|
||||
* @returns {Array} 菜单项数组
|
||||
*/
|
||||
getUserMenuList() {
|
||||
// 获取基础菜单列表
|
||||
const baseMenuList = super.getUserMenuList();
|
||||
|
||||
// H5环境下可能需要修改某些菜单项的行为
|
||||
return baseMenuList.map(item => {
|
||||
// 示例:在H5环境下可能需要特殊处理某些菜单项
|
||||
if (item.id === 6) { // 加入福利群菜单
|
||||
return {
|
||||
...item,
|
||||
// 重新绑定处理函数,可能需要增加H5特有的逻辑
|
||||
handler: (menuItem, context) => {
|
||||
this.handleJoinGroup(menuItem, context);
|
||||
// 在H5环境下可能需要额外的处理,比如尝试复制群号等
|
||||
}
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
}
|
||||
export default H5Platform;
|
||||
|
|
@ -140,5 +140,29 @@ class MiniProgramPlatform extends BasePlatform {
|
|||
});
|
||||
}
|
||||
delOrderNo(){}
|
||||
|
||||
/**
|
||||
* 重写获取用户中心菜单列表,添加微信小程序特有菜单
|
||||
* @returns {Array} 菜单项数组
|
||||
*/
|
||||
getUserMenuList() {
|
||||
// 获取基础菜单列表
|
||||
const baseMenuList = super.getUserMenuList();
|
||||
|
||||
// 添加客服菜单项(仅微信小程序)
|
||||
const customServiceMenu = {
|
||||
id: 9,
|
||||
show: true,
|
||||
title: '客服',
|
||||
icon: 'my/s9.png',
|
||||
path: '',
|
||||
isCustomService: true,
|
||||
// 客服按钮不需要处理函数,由微信小程序原生组件处理
|
||||
handler: () => {}
|
||||
};
|
||||
|
||||
// 将客服菜单插入到第二个位置
|
||||
return [...baseMenuList.slice(0, 1), customServiceMenu, ...baseMenuList.slice(1)];
|
||||
}
|
||||
}
|
||||
export default MiniProgramPlatform;
|
||||
|
|
@ -16,7 +16,7 @@ class RequestManager {
|
|||
* @returns {Boolean} 是否在白名单中
|
||||
*/
|
||||
static isUrlInWhitelist(url) {
|
||||
|
||||
|
||||
// 检查URL是否包含白名单中的任一项
|
||||
return apiWhiteList.some(whiteItem => url.indexOf(whiteItem) > -1);
|
||||
}
|
||||
|
|
@ -63,8 +63,8 @@ class RequestManager {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
const url = param.url || ''
|
||||
const method = param.method || 'POST'
|
||||
const data = param.data || {}
|
||||
|
|
@ -227,21 +227,29 @@ class RequestManager {
|
|||
icon: 'none'
|
||||
})
|
||||
}, 100)
|
||||
|
||||
|
||||
reject(res.data)
|
||||
} else if (res.data.status < 0) {
|
||||
var pages = getCurrentPages()
|
||||
if (res.data.msg != null) {
|
||||
if (res.data.msg.indexOf("没有找到用户信息") > -1) {
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userinfo');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取当前页面路径和参数
|
||||
var currentPage = pages[pages.length - 1];
|
||||
if (currentPage) {
|
||||
var currentRoute = currentPage.route;
|
||||
var currentParams = currentPage.options || {};
|
||||
|
||||
|
||||
// 只有非登录页面才保存重定向信息
|
||||
if (currentRoute && currentRoute !== 'pages/user/login') {
|
||||
// 构建完整的重定向URL
|
||||
var redirectPath = '/' + currentRoute;
|
||||
|
||||
|
||||
// 如果有参数,拼接参数
|
||||
if (Object.keys(currentParams).length > 0) {
|
||||
var paramString = Object.keys(currentParams)
|
||||
|
|
@ -249,13 +257,13 @@ class RequestManager {
|
|||
.join('&');
|
||||
redirectPath += '?' + paramString;
|
||||
}
|
||||
|
||||
|
||||
// 保存重定向URL到缓存
|
||||
console.log('保存重定向URL:', redirectPath);
|
||||
uni.setStorageSync('redirect', redirectPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log(requestUrl);
|
||||
if (RequestManager.isUrlInWhitelist(requestUrl)) {
|
||||
reject(res.data)
|
||||
|
|
@ -274,7 +282,7 @@ class RequestManager {
|
|||
.catch(err => {
|
||||
console.error('登录页面跳转失败:', err);
|
||||
});
|
||||
|
||||
|
||||
reject(res.data)
|
||||
} else {
|
||||
reject(res.data)
|
||||
|
|
|
|||
|
|
@ -51,16 +51,13 @@
|
|||
|
||||
<view class="money-card">
|
||||
<view class="other-num">
|
||||
<!-- <view class="other-item" @click="$c.to({ url: '/pages/user/yetx' })">
|
||||
<view v-if="zuanshi" class="other-item" @click="$c.to({ url: '/pages/user/yetx' })">
|
||||
<view class="title">{{ $config.getAppSetting('balance_name') }}</view>
|
||||
|
||||
<view class="flex row">
|
||||
<view class="num" style="">{{ formatNumber(userinfo.money) }}</view>
|
||||
<image :src="$img1('my/ic_recharge.png')" style="width: 83rpx; height: 48rpx; margin-left: 10rpx;" mode=""></image>
|
||||
<image @click.stop="$c.to({ url: '/pages/user/jf_jl' })" :src="$img1('my/ic_recharge.png')" style="width: 83rpx; height: 48rpx; margin-left: 10rpx;" mode=""></image>
|
||||
</view>
|
||||
|
||||
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="other-item" @click="$c.to({ url: '/pages/user/bi_jl' })">
|
||||
<view class="title">{{ $config.getAppSetting('currency1_name') }}</view>
|
||||
<view class="num" style="color: #333333;">{{ formatNumber(userinfo.integral) }}
|
||||
|
|
@ -72,7 +69,7 @@
|
|||
<view class="num" style="color: #333333;">{{ formatNumber(userinfo.money2) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</v
|
||||
</view>
|
||||
|
||||
<view v-if="taskList.length > 0" class="task">
|
||||
|
|
@ -113,7 +110,8 @@
|
|||
<view class="qita-title">其他服务</view>
|
||||
<view class="menu-card">
|
||||
<template v-for="(item, i) in menuList">
|
||||
<view v-if="item.show" class="menu-item" :key="i" @click="menuTo(item)">
|
||||
<!-- 普通菜单项 -->
|
||||
<view v-if="item.show && !item.isCustomService" class="menu-item" :key="i" @click="handleMenuClick(item)">
|
||||
<view class="icon">
|
||||
<image :src="$img1(item.icon)" mode=""></image>
|
||||
</view>
|
||||
|
|
@ -121,19 +119,18 @@
|
|||
{{ item.title }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="isShowKefu(i)" class="menu-item relative">
|
||||
|
||||
<!-- 微信小程序客服菜单项 -->
|
||||
<view v-if="item.show && item.isCustomService" class="menu-item relative" :key="`service-${i}`">
|
||||
<view class="icon">
|
||||
<image :src="$img1('my/s9.png')" mode=""></image>
|
||||
<image :src="$img1(item.icon)" mode=""></image>
|
||||
</view>
|
||||
<view class="title">
|
||||
客服
|
||||
{{ item.title }}
|
||||
</view>
|
||||
<button class="hide" open-type="contact"></button>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
@ -164,56 +161,8 @@ export default {
|
|||
z_imgPath: this.$z_img2,
|
||||
userinfo: '',
|
||||
moneyArr: [100, 200, 500, 1000, 3000],
|
||||
menuList: [{
|
||||
id: 1,
|
||||
show: true,
|
||||
title: '消费记录',
|
||||
icon: 'my/s1.png',
|
||||
path: '/pages/other/order_list'
|
||||
},
|
||||
|
||||
{
|
||||
id: 3,
|
||||
show: true,
|
||||
title: '我的收藏',
|
||||
icon: 'my/s3.png',
|
||||
path: '/package/mine/collect'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
show: true,
|
||||
title: '优惠券',
|
||||
icon: 'my/s4.png',
|
||||
path: '/pages/user/coupon'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
show: true,
|
||||
title: '邀请好友',
|
||||
icon: 'my/s5.png',
|
||||
path: '/pages/user/tui-guang'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
show: true,
|
||||
title: '加入福利群',
|
||||
icon: 'my/s6.png',
|
||||
path: ''
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
show: true,
|
||||
title: '用户协议',
|
||||
icon: 'my/s7.png',
|
||||
path: '/pages/guize/guize?type=4'
|
||||
},{
|
||||
id: 8,
|
||||
show: true,
|
||||
title: '退出登录',
|
||||
icon: 'my/exit.png',
|
||||
path: ''
|
||||
},
|
||||
],
|
||||
menuList: [],
|
||||
zuanshi:false,
|
||||
// 星钻充值金额
|
||||
money_1: '',
|
||||
// 二维码
|
||||
|
|
@ -269,6 +218,9 @@ export default {
|
|||
this.getdata()
|
||||
// this.getmycollect()
|
||||
let that = this
|
||||
// 获取平台菜单列表
|
||||
this.menuList = this.$platform.getUserMenuList();
|
||||
this.zuanshi=this.$platform.code!="MP-WEIXIN";
|
||||
const curPages = getCurrentPages()[0]; // 获取当前页面实例
|
||||
if (typeof curPages.getTabBar === 'function' && curPages.getTabBar()) {
|
||||
this.$mp.page.getTabBar().setData({
|
||||
|
|
@ -288,14 +240,6 @@ export default {
|
|||
url: '/pages/user/change'
|
||||
})
|
||||
},
|
||||
isShowKefu(index){
|
||||
if(index==0){
|
||||
if(this.$platform.code=='MP-WEIXIN'){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
receiveCoupon() {
|
||||
const coupon_id = uni.getStorageSync('_ou_coupon_id')
|
||||
|
||||
|
|
@ -352,17 +296,13 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
menuTo(item) {
|
||||
switch (item.id) {
|
||||
case 6:
|
||||
this.$refs.qunliao_show.open()
|
||||
break
|
||||
default:
|
||||
this.$customRouter.navigateTo(item.path)
|
||||
// this.$c.to({
|
||||
// url: item.path
|
||||
// })
|
||||
break
|
||||
/**
|
||||
* 处理菜单项点击
|
||||
* @param {Object} item 菜单项
|
||||
*/
|
||||
handleMenuClick(item) {
|
||||
if (item.handler) {
|
||||
item.handler(item, this);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user