This commit is contained in:
zhangxingye 2025-02-22 17:54:35 +08:00
parent 165b21e927
commit 17c37727e8
6 changed files with 581 additions and 471 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { launchInterceptor } from '@/utils/interceptor'
import { getToken, isWeixinBrowser, currRoute, deepClone } from '@/utils/common'
import { getToken, isWeixinBrowser, currRoute, deepClone, setThemeColor } from '@/utils/common'
import useMemberStore from '@/stores/member'
import useConfigStore from '@/stores/config'
import useSystemStore from '@/stores/system'
@ -82,8 +82,11 @@
loginConfig = deepClone(configStore.login)
}
//
let url: any = currRoute()
//
setThemeColor(url)
//
if ((['app/pages/auth/index', 'app/pages/auth/login', 'app/pages/auth/register', 'app/pages/auth/resetpwd'].indexOf(url) != -1) &&
(loginConfig.is_username || loginConfig.is_mobile || loginConfig.is_bind_mobile)) {
return false
@ -165,6 +168,7 @@
// #ifdef H5
if (isWeixinBrowser()) {
if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return;
//
if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) {
uni.removeStorageSync('wechat_login_back') //
if (data.query.code) {
@ -184,9 +188,10 @@
}
})
})
})
onShow(() => {
})
onHide(() => {

View File

@ -1,24 +1,24 @@
{
"name": "",
"appid": "__UNI__ED923AB",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
"name" : "",
"appid" : "__UNI__149BA20",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules": {},
"distribute": {
"android": {
"permissions": [
"modules" : {},
"distribute" : {
"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\"/>",
@ -36,63 +36,59 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios": {},
"sdkConfigs": {}
"ios" : {},
"sdkConfigs" : {}
}
},
"quickapp": {},
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents": true,
"permission": {
"scope.userLocation": {
"desc": "为了更好地为您提供服务"
"usingComponents" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "为了更好地为您提供服务"
},
"scope.writePhotosAlbum": {
"desc": "为了更好地为您提供服务"
"scope.writePhotosAlbum" : {
"desc" : "为了更好地为您提供服务"
}
},
"requiredPrivateInfos": [
"chooseLocation",
"getLocation",
"chooseAddress"
],
"__usePrivacyCheck__": true
"requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ],
"__usePrivacyCheck__" : 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",
"h5": {
"router": {
"mode": "history",
"base": "/wap/"
"vueVersion" : "3",
"h5" : {
"router" : {
"mode" : "history",
"base" : "/wap/"
},
"sdkConfigs": {
"maps": {
"qqmap": {
"key": ""
"sdkConfigs" : {
"maps" : {
"qqmap" : {
"key" : ""
}
}
},
"async" : {
"loading" : "",
"error" : "",
"delay" : 0,
"timeout" : 3000
"loading" : "",
"error" : "",
"delay" : 0,
"timeout" : 3000
}
},
"fallbackLocale": "zh-Hans"
}
"fallbackLocale" : "zh-Hans"
}

View File

@ -1,363 +1,389 @@
{
"pages": [ // pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "app/pages/index/index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.index%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index",
"fixed-group": "../../../../addon/components/fixed/group/index"
},
"componentPlaceholder": {
"diy-group": "view",
"fixed-group": "view"
}
}
},
{
"path": "app/pages/auth/index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.index%"
}
},
{
"path": "app/pages/auth/agreement",
"style": {
"navigationBarTitleText": "%pages.auth.agreement%"
}
},
{
"path": "app/pages/auth/bind",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.bind%"
}
},
{
"path": "app/pages/auth/login",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.login%"
}
},
{
"path": "app/pages/auth/register",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.register%"
}
},
{
"path": "app/pages/auth/resetpwd",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.resetpwd%"
}
},
{
"path": "app/pages/index/diy",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.diy%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index",
"fixed-group": "../../../../addon/components/fixed/group/index"
},
"componentPlaceholder": {
"diy-group": "view",
"fixed-group": "view"
}
}
},
{
"path": "app/pages/index/close",
"style": {
"navigationBarTitleText": "%pages.index.close%"
}
},
{
"path": "app/pages/index/nosite",
"style": {
"navigationBarTitleText": "%pages.index.nosite%"
}
},
{
"path": "app/pages/member/apply_cash_out",
"style": {
"navigationBarTitleText": "%pages.member.apply_cash_out%"
},
"needLogin": true
},
{
"path": "app/pages/member/commission",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.commission%"
},
"needLogin": true
},
{
"path": "app/pages/member/balance",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.balance%"
},
"needLogin": true
},
{
"path": "app/pages/member/level",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.level%"
},
"needLogin": true
},
{
"path": "app/pages/member/detailed_account",
"style": {
"navigationBarTitleText": "%pages.member.detailed_account%"
}
},
{
"path": "app/pages/member/cash_out",
"style": {
"navigationBarTitleText": "%pages.member.cash_out%"
}
},
{
"path": "app/pages/member/cash_out_detail",
"style": {
"navigationBarTitleText": "%pages.member.cash_out_detail%"
}
},
{
"path": "app/pages/member/index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.index%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index",
"fixed-group": "../../../../addon/components/fixed/group/index"
},
"componentPlaceholder": {
"diy-group": "view",
"fixed-group": "view"
}
}
},
{
"path": "app/pages/member/personal",
"style": {
"navigationBarTitleText": "%pages.member.personal%"
},
"needLogin": true
},
{
"path": "app/pages/member/point",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.point%"
},
"needLogin": true
},
{
"path": "app/pages/member/point_detail",
"style": {
"navigationBarTitleText": "%pages.member.point_detail%"
},
"needLogin": true
},
{
"path": "app/pages/member/account",
"style": {
"navigationBarTitleText": "%pages.member.account%"
},
"needLogin": true
},
{
"path": "app/pages/member/account_edit",
"style": {
"navigationBarTitleText": "%pages.member.account_edit%"
},
"needLogin": true
},
{
"path": "app/pages/member/address",
"style": {
"navigationBarTitleText": "%pages.member.address%"
},
"needLogin": true
},
{
"path": "app/pages/member/address_edit",
"style": {
"navigationBarTitleText": "%pages.member.address_edit%"
},
"needLogin": true
},
{
"path": "app/pages/member/sign_in",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.sign_in%"
},
"needLogin": true
},
{
"path": "app/pages/member/contact",
"style": {
"navigationBarTitleText": "%pages.member.contact%"
}
},
{
"path": "app/pages/pay/browser",
"style": {
"navigationBarTitleText": "%pages.pay.browser%"
}
},
{
"path": "app/pages/pay/result",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.pay.result%"
}
},
{
"path": "app/pages/setting/index",
"style": {
"navigationBarTitleText": "%pages.setting.index%"
},
"needLogin": true
},
{
"path": "app/pages/webview/index",
"style": {
"navigationBarTitleText": "%pages.webview.index%"
}
},
{
"path": "app/pages/verify/index",
"style": {
"navigationBarTitleText": "%pages.verify.index%"
},
"needLogin": true
},
{
"path": "app/pages/verify/verify",
"style": {
"navigationBarTitleText": "%pages.verify.verify%"
},
"needLogin": true
},
{
"path": "app/pages/verify/detail",
"style": {
"navigationBarTitleText": "%pages.verify.detail%"
},
"needLogin": true
},
{
"path": "app/pages/verify/record",
"style": {
"navigationBarTitleText": "%pages.verify.record%"
},
"needLogin": true
},
{
"path": "app/pages/weapp/order_shipping",
"style": {
"navigationBarTitleText": "%pages.weapp.order_shipping%"
}
},
{
"path": "app/pages/friendspay/share",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.friendspay.share%"
},
"needLogin": true
},
{
"path": "app/pages/friendspay/money",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.friendspay.money%"
}
}
],
"subPackages": [
{
"root": "addon",
"pages": [
// {{ PAGE_BEGAIN }}
// {{ PAGE_END }}}
{
"path": "end"
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#F6F6F6",
"backgroundColorTop": "#F6F6F6",
"backgroundColorBottom": "#F6F6F6"
},
"tabBar": {
"list": [{
"pagePath": "app/pages/index/index"
},
{
"pagePath": "app/pages/member/index"
}
]
},
"uniIdRouter": {},
"easycom": {
"custom": {
"diy-group": "@/addon/components/diy/group/index.vue",
"fixed-group": "@/addon/components/fixed/group/index.vue",
"^u-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
"diy-(\W.*)": "@/app/components/diy/$1/index.vue",
"fixed-(\W.*)": "@/app/components/fixed/$1/index.vue"
}
}
"pages": [
// pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "app/pages/index/index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.index%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index"
},
"componentPlaceholder": {
"diy-group": "view"
}
}
},
{
"path": "app/pages/auth/index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.index%"
}
},
{
"path": "app/pages/auth/agreement",
"style": {
"navigationBarTitleText": "%pages.auth.agreement%"
}
},
{
"path": "app/pages/auth/bind",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.bind%"
}
},
{
"path": "app/pages/auth/login",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.login%"
}
},
{
"path": "app/pages/auth/register",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.register%"
}
},
{
"path": "app/pages/auth/resetpwd",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.resetpwd%"
}
},
{
"path": "app/pages/index/diy",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.diy%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index"
},
"componentPlaceholder": {
"diy-group": "view"
}
}
},
{
"path": "app/pages/index/diy_form",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.diy_form%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index"
},
"componentPlaceholder": {
"diy-group": "view"
}
}
},
{
"path": "app/pages/index/diy_form_result",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.diy_form_result%"
},
"needLogin": true
},
{
"path": "app/pages/index/diy_form_detail",
"style": {
"navigationBarTitleText": "%pages.index.diy_form_detail%"
},
"needLogin": true
},
{
"path": "app/pages/index/close",
"style": {
"navigationBarTitleText": "%pages.index.close%"
}
},
{
"path": "app/pages/index/nosite",
"style": {
"navigationBarTitleText": "%pages.index.nosite%"
}
},
{
"path": "app/pages/pay/browser",
"style": {
"navigationBarTitleText": "%pages.pay.browser%"
}
},
{
"path": "app/pages/pay/result",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.pay.result%"
}
},
{
"path": "app/pages/setting/index",
"style": {
"navigationBarTitleText": "%pages.setting.index%"
},
"needLogin": true
},
{
"path": "app/pages/webview/index",
"style": {
"navigationBarTitleText": "%pages.webview.index%"
}
},
{
"path": "app/pages/verify/index",
"style": {
"navigationBarTitleText": "%pages.verify.index%"
},
"needLogin": true
},
{
"path": "app/pages/verify/verify",
"style": {
"navigationBarTitleText": "%pages.verify.verify%"
},
"needLogin": true
},
{
"path": "app/pages/verify/detail",
"style": {
"navigationBarTitleText": "%pages.verify.detail%"
},
"needLogin": true
},
{
"path": "app/pages/verify/record",
"style": {
"navigationBarTitleText": "%pages.verify.record%"
},
"needLogin": true
},
{
"path": "app/pages/weapp/order_shipping",
"style": {
"navigationBarTitleText": "%pages.weapp.order_shipping%"
}
},
{
"path": "app/pages/friendspay/share",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.friendspay.share%"
},
"needLogin": true
},
{
"path": "app/pages/friendspay/money",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.friendspay.money%"
}
}
],
"subPackages": [
// {{ PAGE_BEGAIN }}
// {{ PAGE_END }}
{
"root": "app/components",
"pages": []
},
{
"root": "app/pages/member",
"pages": [
{
"path": "apply_cash_out",
"style": {
"navigationBarTitleText": "%pages.member.apply_cash_out%"
},
"needLogin": true
},
{
"path": "commission",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.commission%"
},
"needLogin": true
},
{
"path": "balance",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.balance%"
},
"needLogin": true
},
{
"path": "level",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.level%"
},
"needLogin": true
},
{
"path": "detailed_account",
"style": {
"navigationBarTitleText": "%pages.member.detailed_account%"
}
},
{
"path": "cash_out",
"style": {
"navigationBarTitleText": "%pages.member.cash_out%"
}
},
{
"path": "cash_out_detail",
"style": {
"navigationBarTitleText": "%pages.member.cash_out_detail%"
}
},
{
"path": "index",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.index%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index"
},
"componentPlaceholder": {
"diy-group": "view"
}
}
},
{
"path": "personal",
"style": {
"navigationBarTitleText": "%pages.member.personal%"
},
"needLogin": true
},
{
"path": "point",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.point%"
},
"needLogin": true
},
{
"path": "point_detail",
"style": {
"navigationBarTitleText": "%pages.member.point_detail%"
},
"needLogin": true
},
{
"path": "account",
"style": {
"navigationBarTitleText": "%pages.member.account%"
},
"needLogin": true
},
{
"path": "account_edit",
"style": {
"navigationBarTitleText": "%pages.member.account_edit%"
},
"needLogin": true
},
{
"path": "address",
"style": {
"navigationBarTitleText": "%pages.member.address%"
},
"needLogin": true
},
{
"path": "address_edit",
"style": {
"navigationBarTitleText": "%pages.member.address_edit%"
},
"needLogin": true
},
{
"path": "sign_in",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.sign_in%"
},
"needLogin": true
},
{
"path": "contact",
"style": {
"navigationBarTitleText": "%pages.member.contact%"
}
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#F6F6F6",
"backgroundColorTop": "#F6F6F6",
"backgroundColorBottom": "#F6F6F6"
},
"tabBar": {
"list": [{
"pagePath": "app/pages/index/index"
},
{
"pagePath": "app/pages/index/nosite"
}
]
},
"uniIdRouter": {},
"easycom": {
"custom": {
"diy-group": "@/addon/components/diy/group/index.vue",
"^u-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
"diy-(\W.*)": "@/app/components/diy/$1/index.vue"
}
}
}

View File

@ -382,18 +382,52 @@ export function timeStampTurnTime(timeStamp: any, type = "") {
*
* @param {Object} date
*/
export function timeTurnTimeStamp(date: string) {
var f = date.split(' ', 2);
var d = (f[0] ? f[0] : '').split('-', 3);
var t = (f[1] ? f[1] : '').split(':', 3);
return (new Date(
parseInt(d[0], 10) || null,
(parseInt(d[1], 10) || 1) - 1,
parseInt(d[2], 10) || null,
parseInt(t[0], 10) || null,
parseInt(t[1], 10) || null,
parseInt(t[2], 10) || null
)).getTime() / 1000;
export function timeTurnTimeStamp(dateStr: string) {
let timestamp;
let date;
// 尝试解析 'YYYY年M月D日'
try {
let dateStr1 = dateStr.replace('年', '-').replace('月', '-').replace('日', '');
date = new Date(dateStr1);
timestamp = date.getTime();
} catch (e) {
// 尝试解析 'YYYY-MM-DD'
try {
date = new Date(dateStr);
timestamp = date.getTime();
} catch (e) {
// 尝试解析 'YYYY/MM/DD'
try {
date = new Date(dateStr.replace(/\//g, "-"));
timestamp = date.getTime();
} catch (e) {
// 尝试解析 'YYYY年M月D日 HH时mm分'
try {
let dateStr1 = dateStr.replace('年', '-').replace('月', '-').replace('日', ' ').replace('时', ':').replace('分', '');
date = new Date(dateStr1);
timestamp = date.getTime();
} catch (e) {
// 尝试解析 'YYYY-MM-DD HH:mm'
try {
date = new Date(dateStr);
timestamp = date.getTime();
} catch (e) {
// 尝试解析 'YYYY/MM/DD HH:mm'
try {
date = new Date(dateStr.replace(/\//g, "-"));
timestamp = date.getTime();
} catch (e) {
// 如果所有格式都失败返回null
console.error("无法解析日期字符串:", dateStr);
return null;
}
}
}
}
}
}
return (timestamp / 1000);
}
/**
@ -544,3 +578,81 @@ export function goback(data: any) {
}
}, 600);
}
// 获取微信OpenId、微信公众号OpenId
export function getWinxinOpenId() {
const memberStore = useMemberStore();
const memberInfo = memberStore.info;
let obj = {
weapp: '',
wechat: ''
}
if (memberInfo) {
obj.weapp = memberInfo.weapp_openid;
obj.wechat = memberInfo.wx_openid;
}
return obj;
}
// 获取有效期
export function getValidTime(minutes: any = 1) {
var date = new Date();
date.setSeconds(60 * minutes);
let validTime: any = parseInt(date.getTime() / 1000); // 定位信息 5分钟内有效过期后将重新获取定位信息
return validTime;
}
/**
* 访app
*
*
* @param path
*/
export function setThemeColor (path: string) {
let pathArr = path.split('/')
let index = !pathArr[0] ? 1 : 0;
let route = pathArr[index] == 'addon' ? pathArr[(index+1)] : 'app';
// 设置底部导航
const configStore = useConfigStore()
if (configStore.addon != route) {
configStore.addon = route;
}
// 设置插件应用的主色调,排除系统
const theme_color_list = uni.getStorageSync('theme_color_list');
const current_theme_color = uni.getStorageSync('current_theme_color');
let theme = '';
if (route != 'app') {
try {
theme = theme_color_list[route];
if(theme && theme.value){
configStore.themeColor = theme.value
uni.setStorageSync('current_theme_color', JSON.stringify(theme.value));
}else if( !theme && current_theme_color){
configStore.themeColor = ''
}else{
theme = theme_color_list.app || Object.values(theme_color_list)[0];
configStore.themeColor = theme.value
uni.setStorageSync('current_theme_color', JSON.stringify(theme.value));
}
} catch (e) {
// 设置插件应用的主色调发生错误,若不存在则使用最后有效的主色调
if(!current_theme_color && theme_color_list){
theme = theme_color_list.app || Object.values(theme_color_list)[0];
configStore.themeColor = theme.value
uni.setStorageSync('current_theme_color', JSON.stringify(theme.value));
}else{
configStore.themeColor = '';
}
}
}else if(!current_theme_color && theme_color_list){
theme = theme_color_list.app || Object.values(theme_color_list)[0];
configStore.themeColor = theme.value
uni.setStorageSync('current_theme_color', JSON.stringify(theme.value));
}
}

View File

@ -1,8 +1,7 @@
import { language } from '@/locale'
import { checkNeedLogin } from '@/utils/auth'
import { getToken, currRoute } from '@/utils/common'
import { getToken, currRoute, setThemeColor } from '@/utils/common'
import { memberLog } from '@/app/api/auth'
import useConfigStore from "@/stores/config";
import { useShare } from '@/hooks/useShare'
/**
@ -12,7 +11,7 @@ export const redirectInterceptor = (route: { path: string, query: object }) => {
route.path = `/${ route.path }`
// 检测当前访问的是系统app还是插件
setAddonName(route.path)
setThemeColor(route.path)
// #ifdef MP
route.path.indexOf('addon') != -1 && language.loadAllLocaleMessages('addon', uni.getLocale())
@ -39,7 +38,7 @@ export const launchInterceptor = () => {
launch.path = `/${ launch.path }`
// 检测当前访问的是系统app还是插件
setAddonName(launch.path);
setThemeColor(launch.path);
// 加载语言包
language.loadAllLocaleMessages('app', uni.getLocale())
@ -62,35 +61,6 @@ export const launchInterceptor = () => {
if (getToken()) memberLog({ route: launch.path, params: JSON.stringify(launch.query || {}), pre_route: '' })
}
/**
* 访app
*
*
* @param path
*/
const setAddonName = async(path: string) => {
let pathArr = path.split('/')
let route = pathArr[1] == 'addon' ? pathArr[2] : 'app';
// 设置底部导航
const configStore = useConfigStore()
if (configStore.addon != route) {
configStore.addon = route;
}
// 设置插件应用的主色调,排除系统
if (route != 'app') {
try {
const theme = await import(`../addon/${ route }/utils/theme.json`)
configStore.themeColor = theme.default
uni.setStorageSync('current_theme_color', JSON.stringify(theme.default));
} catch (e) {
// 设置插件应用的主色调发生错误,若不存在则使用最后有效的主色调
}
}
}
// 加载分享
const loadShare = () => {
@ -106,6 +76,7 @@ const loadShare = () => {
'addon/shop_giftcard/pages/detail',
'addon/shop_giftcard/pages/give',
'app/pages/index/diy',
'app/pages/index/diy_form',
'app/pages/friendspay/share',
'app/pages/friendspay/money'
]

View File

@ -152,7 +152,7 @@ class Request {
break;
case 403:
if (currRoute().indexOf('app/pages/index/nosite') != -1) return;
redirect({ url: '/app/pages/index/nosite', mode: 'reLaunch' })
redirect({ url: '/app/pages/index/nosite', mode: 'switchTab' })
break;
}
}