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,6 +1,6 @@
{ {
"name" : "", "name" : "",
"appid": "__UNI__ED923AB", "appid" : "__UNI__149BA20",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
@ -55,11 +55,7 @@
"desc" : "为了更好地为您提供服务" "desc" : "为了更好地为您提供服务"
} }
}, },
"requiredPrivateInfos": [ "requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ],
"chooseLocation",
"getLocation",
"chooseAddress"
],
"__usePrivacyCheck__" : true "__usePrivacyCheck__" : true
}, },
"mp-alipay" : { "mp-alipay" : {

View File

@ -1,5 +1,6 @@
{ {
"pages": [ // pageshttps://uniapp.dcloud.io/collocation/pages "pages": [
// pageshttps://uniapp.dcloud.io/collocation/pages
{ {
"path": "app/pages/index/index", "path": "app/pages/index/index",
"style": { "style": {
@ -8,12 +9,10 @@
// #endif // #endif
"navigationBarTitleText": "%pages.index.index%", "navigationBarTitleText": "%pages.index.index%",
"usingComponents": { "usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index", "diy-group": "../../../../addon/components/diy/group/index"
"fixed-group": "../../../../addon/components/fixed/group/index"
}, },
"componentPlaceholder": { "componentPlaceholder": {
"diy-group": "view", "diy-group": "view"
"fixed-group": "view"
} }
} }
}, },
@ -76,15 +75,45 @@
// #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": { "componentPlaceholder": {
"diy-group": "view", "diy-group": "view"
"fixed-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", "path": "app/pages/index/close",
"style": { "style": {
@ -97,146 +126,6 @@
"navigationBarTitleText": "%pages.index.nosite%" "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", "path": "app/pages/pay/browser",
"style": { "style": {
@ -320,13 +209,152 @@
} }
], ],
"subPackages": [ "subPackages": [
{
"root": "addon",
"pages": [
// {{ PAGE_BEGAIN }} // {{ PAGE_BEGAIN }}
// {{ PAGE_END }}} // {{ PAGE_END }}
{ {
"path": "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%"
}
} }
] ]
} }
@ -344,7 +372,7 @@
"pagePath": "app/pages/index/index" "pagePath": "app/pages/index/index"
}, },
{ {
"pagePath": "app/pages/member/index" "pagePath": "app/pages/index/nosite"
} }
] ]
}, },
@ -352,12 +380,10 @@
"easycom": { "easycom": {
"custom": { "custom": {
"diy-group": "@/addon/components/diy/group/index.vue", "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", "^u-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "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", "^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
"diy-(\W.*)": "@/app/components/diy/$1/index.vue", "diy-(\W.*)": "@/app/components/diy/$1/index.vue"
"fixed-(\W.*)": "@/app/components/fixed/$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;
} }
} }