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"> <script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { launchInterceptor } from '@/utils/interceptor' 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 useMemberStore from '@/stores/member'
import useConfigStore from '@/stores/config' import useConfigStore from '@/stores/config'
import useSystemStore from '@/stores/system' import useSystemStore from '@/stores/system'
@ -82,8 +82,11 @@
loginConfig = deepClone(configStore.login) loginConfig = deepClone(configStore.login)
} }
//
let url: any = currRoute() 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) && 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)) { (loginConfig.is_username || loginConfig.is_mobile || loginConfig.is_bind_mobile)) {
return false return false
@ -165,6 +168,7 @@
// #ifdef H5 // #ifdef H5
if (isWeixinBrowser()) { if (isWeixinBrowser()) {
if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return; if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return;
//
if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) { if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) {
uni.removeStorageSync('wechat_login_back') // uni.removeStorageSync('wechat_login_back') //
if (data.query.code) { if (data.query.code) {
@ -187,6 +191,7 @@
}) })
onShow(() => { onShow(() => {
}) })
onHide(() => { onHide(() => {

View File

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

View File

@ -1,363 +1,389 @@
{ {
"pages": [ // pageshttps://uniapp.dcloud.io/collocation/pages "pages": [
{ // pageshttps://uniapp.dcloud.io/collocation/pages
"path": "app/pages/index/index", {
"style": { "path": "app/pages/index/index",
// #ifndef H5 "style": {
"navigationStyle": "custom", // #ifndef H5
// #endif "navigationStyle": "custom",
"navigationBarTitleText": "%pages.index.index%", // #endif
"usingComponents": { "navigationBarTitleText": "%pages.index.index%",
"diy-group": "../../../../addon/components/diy/group/index", "usingComponents": {
"fixed-group": "../../../../addon/components/fixed/group/index" "diy-group": "../../../../addon/components/diy/group/index"
}, },
"componentPlaceholder": { "componentPlaceholder": {
"diy-group": "view", "diy-group": "view"
"fixed-group": "view" }
} }
} },
}, {
{ "path": "app/pages/auth/index",
"path": "app/pages/auth/index", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.auth.index%"
"navigationBarTitleText": "%pages.auth.index%" }
} },
}, {
{ "path": "app/pages/auth/agreement",
"path": "app/pages/auth/agreement", "style": {
"style": { "navigationBarTitleText": "%pages.auth.agreement%"
"navigationBarTitleText": "%pages.auth.agreement%" }
} },
}, {
{ "path": "app/pages/auth/bind",
"path": "app/pages/auth/bind", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.auth.bind%"
"navigationBarTitleText": "%pages.auth.bind%" }
} },
}, {
{ "path": "app/pages/auth/login",
"path": "app/pages/auth/login", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.auth.login%"
"navigationBarTitleText": "%pages.auth.login%" }
} },
}, {
{ "path": "app/pages/auth/register",
"path": "app/pages/auth/register", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.auth.register%"
"navigationBarTitleText": "%pages.auth.register%" }
} },
}, {
{ "path": "app/pages/auth/resetpwd",
"path": "app/pages/auth/resetpwd", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.auth.resetpwd%"
"navigationBarTitleText": "%pages.auth.resetpwd%" }
} },
}, {
{ "path": "app/pages/index/diy",
"path": "app/pages/index/diy", "style": {
"style": { // #ifndef H5
// #ifndef H5 "navigationStyle": "custom",
"navigationStyle": "custom", // #endif
// #endif "navigationBarTitleText": "%pages.index.diy%",
"navigationBarTitleText": "%pages.index.diy%", "usingComponents": {
"usingComponents": { "diy-group": "../../../../addon/components/diy/group/index"
"diy-group": "../../../../addon/components/diy/group/index", },
"fixed-group": "../../../../addon/components/fixed/group/index" "componentPlaceholder": {
}, "diy-group": "view"
"componentPlaceholder": { }
"diy-group": "view", }
"fixed-group": "view" },
} {
} "path": "app/pages/index/diy_form",
}, "style": {
{ // #ifndef H5
"path": "app/pages/index/close", "navigationStyle": "custom",
"style": { // #endif
"navigationBarTitleText": "%pages.index.close%" "navigationBarTitleText": "%pages.index.diy_form%",
} "usingComponents": {
}, "diy-group": "../../../../addon/components/diy/group/index"
{ },
"path": "app/pages/index/nosite", "componentPlaceholder": {
"style": { "diy-group": "view"
"navigationBarTitleText": "%pages.index.nosite%" }
} }
}, },
{ {
"path": "app/pages/member/apply_cash_out", "path": "app/pages/index/diy_form_result",
"style": { "style": {
"navigationBarTitleText": "%pages.member.apply_cash_out%" // #ifndef H5
}, "navigationStyle": "custom",
"needLogin": true // #endif
}, "navigationBarTitleText": "%pages.index.diy_form_result%"
{ },
"path": "app/pages/member/commission", "needLogin": true
"style": { },
// #ifndef H5 {
"navigationStyle": "custom", "path": "app/pages/index/diy_form_detail",
// #endif "style": {
"navigationBarTitleText": "%pages.member.commission%" "navigationBarTitleText": "%pages.index.diy_form_detail%"
}, },
"needLogin": true "needLogin": true
}, },
{ {
"path": "app/pages/member/balance", "path": "app/pages/index/close",
"style": { "style": {
// #ifndef H5 "navigationBarTitleText": "%pages.index.close%"
"navigationStyle": "custom", }
// #endif },
"navigationBarTitleText": "%pages.member.balance%" {
}, "path": "app/pages/index/nosite",
"needLogin": true "style": {
}, "navigationBarTitleText": "%pages.index.nosite%"
{ }
"path": "app/pages/member/level", },
"style": { {
// #ifndef H5 "path": "app/pages/pay/browser",
"navigationStyle": "custom", "style": {
// #endif "navigationBarTitleText": "%pages.pay.browser%"
"navigationBarTitleText": "%pages.member.level%" }
}, },
"needLogin": true {
}, "path": "app/pages/pay/result",
{ "style": {
"path": "app/pages/member/detailed_account", // #ifndef H5
"style": { "navigationStyle": "custom",
"navigationBarTitleText": "%pages.member.detailed_account%" // #endif
} "navigationBarTitleText": "%pages.pay.result%"
}, }
{ },
"path": "app/pages/member/cash_out", {
"style": { "path": "app/pages/setting/index",
"navigationBarTitleText": "%pages.member.cash_out%" "style": {
} "navigationBarTitleText": "%pages.setting.index%"
}, },
{ "needLogin": true
"path": "app/pages/member/cash_out_detail", },
"style": { {
"navigationBarTitleText": "%pages.member.cash_out_detail%" "path": "app/pages/webview/index",
} "style": {
}, "navigationBarTitleText": "%pages.webview.index%"
{ }
"path": "app/pages/member/index", },
"style": { {
// #ifndef H5 "path": "app/pages/verify/index",
"navigationStyle": "custom", "style": {
// #endif "navigationBarTitleText": "%pages.verify.index%"
"navigationBarTitleText": "%pages.member.index%", },
"usingComponents": { "needLogin": true
"diy-group": "../../../../addon/components/diy/group/index", },
"fixed-group": "../../../../addon/components/fixed/group/index" {
}, "path": "app/pages/verify/verify",
"componentPlaceholder": { "style": {
"diy-group": "view", "navigationBarTitleText": "%pages.verify.verify%"
"fixed-group": "view" },
} "needLogin": true
} },
}, {
{ "path": "app/pages/verify/detail",
"path": "app/pages/member/personal", "style": {
"style": { "navigationBarTitleText": "%pages.verify.detail%"
"navigationBarTitleText": "%pages.member.personal%" },
}, "needLogin": true
"needLogin": true },
}, {
{ "path": "app/pages/verify/record",
"path": "app/pages/member/point", "style": {
"style": { "navigationBarTitleText": "%pages.verify.record%"
// #ifndef H5 },
"navigationStyle": "custom", "needLogin": true
// #endif },
"navigationBarTitleText": "%pages.member.point%" {
}, "path": "app/pages/weapp/order_shipping",
"needLogin": true "style": {
}, "navigationBarTitleText": "%pages.weapp.order_shipping%"
{ }
"path": "app/pages/member/point_detail", },
"style": { {
"navigationBarTitleText": "%pages.member.point_detail%" "path": "app/pages/friendspay/share",
}, "style": {
"needLogin": true // #ifndef H5
}, "navigationStyle": "custom",
{ // #endif
"path": "app/pages/member/account", "navigationBarTitleText": "%pages.friendspay.share%"
"style": { },
"navigationBarTitleText": "%pages.member.account%" "needLogin": true
}, },
"needLogin": true {
}, "path": "app/pages/friendspay/money",
{ "style": {
"path": "app/pages/member/account_edit", // #ifndef H5
"style": { "navigationStyle": "custom",
"navigationBarTitleText": "%pages.member.account_edit%" // #endif
}, "navigationBarTitleText": "%pages.friendspay.money%"
"needLogin": true }
}, }
{ ],
"path": "app/pages/member/address", "subPackages": [
"style": { // {{ PAGE_BEGAIN }}
"navigationBarTitleText": "%pages.member.address%" // {{ PAGE_END }}
}, {
"needLogin": true "root": "app/components",
}, "pages": []
{ },
"path": "app/pages/member/address_edit", {
"style": { "root": "app/pages/member",
"navigationBarTitleText": "%pages.member.address_edit%" "pages": [
}, {
"needLogin": true "path": "apply_cash_out",
}, "style": {
{ "navigationBarTitleText": "%pages.member.apply_cash_out%"
"path": "app/pages/member/sign_in", },
"style": { "needLogin": true
// #ifndef H5 },
"navigationStyle": "custom", {
// #endif "path": "commission",
"navigationBarTitleText": "%pages.member.sign_in%" "style": {
}, // #ifndef H5
"needLogin": true "navigationStyle": "custom",
}, // #endif
{ "navigationBarTitleText": "%pages.member.commission%"
"path": "app/pages/member/contact", },
"style": { "needLogin": true
"navigationBarTitleText": "%pages.member.contact%" },
} {
}, "path": "balance",
{ "style": {
"path": "app/pages/pay/browser", // #ifndef H5
"style": { "navigationStyle": "custom",
"navigationBarTitleText": "%pages.pay.browser%" // #endif
} "navigationBarTitleText": "%pages.member.balance%"
}, },
{ "needLogin": true
"path": "app/pages/pay/result", },
"style": { {
// #ifndef H5 "path": "level",
"navigationStyle": "custom", "style": {
// #endif // #ifndef H5
"navigationBarTitleText": "%pages.pay.result%" "navigationStyle": "custom",
} // #endif
}, "navigationBarTitleText": "%pages.member.level%"
{ },
"path": "app/pages/setting/index", "needLogin": true
"style": { },
"navigationBarTitleText": "%pages.setting.index%" {
}, "path": "detailed_account",
"needLogin": true "style": {
}, "navigationBarTitleText": "%pages.member.detailed_account%"
{ }
"path": "app/pages/webview/index", },
"style": { {
"navigationBarTitleText": "%pages.webview.index%" "path": "cash_out",
} "style": {
}, "navigationBarTitleText": "%pages.member.cash_out%"
{ }
"path": "app/pages/verify/index", },
"style": { {
"navigationBarTitleText": "%pages.verify.index%" "path": "cash_out_detail",
}, "style": {
"needLogin": true "navigationBarTitleText": "%pages.member.cash_out_detail%"
}, }
{ },
"path": "app/pages/verify/verify", {
"style": { "path": "index",
"navigationBarTitleText": "%pages.verify.verify%" "style": {
}, // #ifndef H5
"needLogin": true "navigationStyle": "custom",
}, // #endif
{ "navigationBarTitleText": "%pages.member.index%",
"path": "app/pages/verify/detail", "usingComponents": {
"style": { "diy-group": "../../../../addon/components/diy/group/index"
"navigationBarTitleText": "%pages.verify.detail%" },
}, "componentPlaceholder": {
"needLogin": true "diy-group": "view"
}, }
{ }
"path": "app/pages/verify/record", },
"style": { {
"navigationBarTitleText": "%pages.verify.record%" "path": "personal",
}, "style": {
"needLogin": true "navigationBarTitleText": "%pages.member.personal%"
}, },
{ "needLogin": true
"path": "app/pages/weapp/order_shipping", },
"style": { {
"navigationBarTitleText": "%pages.weapp.order_shipping%" "path": "point",
} "style": {
}, // #ifndef H5
{ "navigationStyle": "custom",
"path": "app/pages/friendspay/share", // #endif
"style": { "navigationBarTitleText": "%pages.member.point%"
// #ifndef H5 },
"navigationStyle": "custom", "needLogin": true
// #endif },
"navigationBarTitleText": "%pages.friendspay.share%" {
}, "path": "point_detail",
"needLogin": true "style": {
}, "navigationBarTitleText": "%pages.member.point_detail%"
{ },
"path": "app/pages/friendspay/money", "needLogin": true
"style": { },
// #ifndef H5 {
"navigationStyle": "custom", "path": "account",
// #endif "style": {
"navigationBarTitleText": "%pages.friendspay.money%" "navigationBarTitleText": "%pages.member.account%"
} },
} "needLogin": true
], },
"subPackages": [ {
{ "path": "account_edit",
"root": "addon", "style": {
"pages": [ "navigationBarTitleText": "%pages.member.account_edit%"
// {{ PAGE_BEGAIN }} },
// {{ PAGE_END }}} "needLogin": true
{ },
"path": "end" {
} "path": "address",
] "style": {
} "navigationBarTitleText": "%pages.member.address%"
], },
"globalStyle": { "needLogin": true
"navigationBarTextStyle": "black", },
"navigationBarTitleText": "", {
"navigationBarBackgroundColor": "#ffffff", "path": "address_edit",
"backgroundColor": "#F6F6F6", "style": {
"backgroundColorTop": "#F6F6F6", "navigationBarTitleText": "%pages.member.address_edit%"
"backgroundColorBottom": "#F6F6F6" },
}, "needLogin": true
"tabBar": { },
"list": [{ {
"pagePath": "app/pages/index/index" "path": "sign_in",
}, "style": {
{ // #ifndef H5
"pagePath": "app/pages/member/index" "navigationStyle": "custom",
} // #endif
] "navigationBarTitleText": "%pages.member.sign_in%"
}, },
"uniIdRouter": {}, "needLogin": true
"easycom": { },
"custom": { {
"diy-group": "@/addon/components/diy/group/index.vue", "path": "contact",
"fixed-group": "@/addon/components/fixed/group/index.vue", "style": {
"^u-(.*)": "uview-plus/components/u-$1/u-$1.vue", "navigationBarTitleText": "%pages.member.contact%"
"^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" }
} ],
} "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 * @param {Object} date
*/ */
export function timeTurnTimeStamp(date: string) { export function timeTurnTimeStamp(dateStr: string) {
var f = date.split(' ', 2); let timestamp;
var d = (f[0] ? f[0] : '').split('-', 3); let date;
var t = (f[1] ? f[1] : '').split(':', 3);
return (new Date( // 尝试解析 'YYYY年M月D日'
parseInt(d[0], 10) || null, try {
(parseInt(d[1], 10) || 1) - 1, let dateStr1 = dateStr.replace('年', '-').replace('月', '-').replace('日', '');
parseInt(d[2], 10) || null, date = new Date(dateStr1);
parseInt(t[0], 10) || null, timestamp = date.getTime();
parseInt(t[1], 10) || null, } catch (e) {
parseInt(t[2], 10) || null // 尝试解析 'YYYY-MM-DD'
)).getTime() / 1000; 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); }, 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 { language } from '@/locale'
import { checkNeedLogin } from '@/utils/auth' 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 { memberLog } from '@/app/api/auth'
import useConfigStore from "@/stores/config";
import { useShare } from '@/hooks/useShare' import { useShare } from '@/hooks/useShare'
/** /**
@ -12,7 +11,7 @@ export const redirectInterceptor = (route: { path: string, query: object }) => {
route.path = `/${ route.path }` route.path = `/${ route.path }`
// 检测当前访问的是系统app还是插件 // 检测当前访问的是系统app还是插件
setAddonName(route.path) setThemeColor(route.path)
// #ifdef MP // #ifdef MP
route.path.indexOf('addon') != -1 && language.loadAllLocaleMessages('addon', uni.getLocale()) route.path.indexOf('addon') != -1 && language.loadAllLocaleMessages('addon', uni.getLocale())
@ -39,7 +38,7 @@ export const launchInterceptor = () => {
launch.path = `/${ launch.path }` launch.path = `/${ launch.path }`
// 检测当前访问的是系统app还是插件 // 检测当前访问的是系统app还是插件
setAddonName(launch.path); setThemeColor(launch.path);
// 加载语言包 // 加载语言包
language.loadAllLocaleMessages('app', uni.getLocale()) 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: '' }) 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 = () => { const loadShare = () => {
@ -106,6 +76,7 @@ const loadShare = () => {
'addon/shop_giftcard/pages/detail', 'addon/shop_giftcard/pages/detail',
'addon/shop_giftcard/pages/give', 'addon/shop_giftcard/pages/give',
'app/pages/index/diy', 'app/pages/index/diy',
'app/pages/index/diy_form',
'app/pages/friendspay/share', 'app/pages/friendspay/share',
'app/pages/friendspay/money' 'app/pages/friendspay/money'
] ]

View File

@ -152,7 +152,7 @@ class Request {
break; break;
case 403: case 403:
if (currRoute().indexOf('app/pages/index/nosite') != -1) return; 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; break;
} }
} }