Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
d568cd6d
Commit
d568cd6d
authored
Jul 23, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
a2e2e7a4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
140 additions
and
138 deletions
+140
-138
App.vue
+140
-138
No files found.
App.vue
View file @
d568cd6d
...
@@ -89,144 +89,146 @@ export default {
...
@@ -89,144 +89,146 @@ export default {
onHide
:
function
()
{
onHide
:
function
()
{
console
.
log
(
'App Hide'
)
console
.
log
(
'App Hide'
)
},
},
methods
:
{
// methods: {
// 检查用户状态的方法
// // 检查用户状态的方法
async
checkUserStatus
()
{
// async checkUserStatus() {
// 只有已登录用户才需要检查
// // 只有已登录用户才需要检查
if
(
uni
.
getStorageSync
(
'loginType'
)
==
'codelogin'
&&
uni
.
getStorageSync
(
'cffp_userId'
))
{
// if (uni.getStorageSync('loginType') == 'codelogin' && uni.getStorageSync('cffp_userId')) {
try
{
// try {
const
res
=
await
api
.
queryInfo
({
userId
:
uni
.
getStorageSync
(
'cffp_userId'
)});
// const res = await api.queryInfo({userId: uni.getStorageSync('cffp_userId')});
if
(
!
res
[
'success'
])
{
// if (!res['success']) {
// 用户已注销,清除缓存
// // 用户已注销,清除缓存
this
.
clearLoginState
();
// this.clearLoginState();
//
// 如果不是在白名单页面,跳转到登录页
// // 如果不是在白名单页面,跳转到登录页
const
pages
=
getCurrentPages
();
// const pages = getCurrentPages();
if
(
pages
.
length
>
0
)
{
// if (pages.length > 0) {
const
currentRoute
=
pages
[
pages
.
length
-
1
].
route
;
// const currentRoute = pages[pages.length - 1].route;
console
.
log
(
'currentRoute'
,
currentRoute
);
// console.log('currentRoute', currentRoute);
const
whiteList
=
[
// const whiteList = [
'/myPackageA/login/login'
,
// '/myPackageA/login/login',
'/pages/invitationRegister/invitationlogin'
,
// '/pages/invitationRegister/invitationlogin',
'/myPackageA/applyFranchise/applyFranchise'
,
// '/myPackageA/applyFranchise/applyFranchise',
'/pages/applyFranchise/applyFranchise'
,
// '/pages/applyFranchise/applyFranchise',
'/myPackageA/ruleAndContract/clause'
,
// '/myPackageA/ruleAndContract/clause',
'/pages/courselist/courselist'
,
// '/pages/courselist/courselist',
'/pages/courseDetail/courseDetail'
,
// '/pages/courseDetail/courseDetail',
'/pages/orderDetail/orderDetail'
,
// '/pages/orderDetail/orderDetail',
'/pages/orderStatus/orderStatus'
,
// '/pages/orderStatus/orderStatus',
'/pages/index/index'
// '/pages/index/index'
]
// 根据需要调整
// ] // 根据需要调整
if
(
!
whiteList
.
includes
(
currentRoute
))
{
// if (!whiteList.includes(currentRoute)) {
uni
.
navigateTo
({
// uni.navigateTo({
url
:
'/myPackageA/login/login'
// url: '/myPackageA/login/login'
});
// });
}
// }
}
// }
}
// }
if
(
res
[
'success'
])
{
// if (res['success']) {
const
cffp_userInfo
=
{
// const cffp_userInfo = {
name
:
res
[
'data'
][
'realName'
],
// name: res['data']['realName'],
mobile
:
res
[
'data'
][
'mobile'
],
// mobile: res['data']['mobile'],
partnerType
:
res
[
'data'
][
'partnerType'
],
// partnerType: res['data']['partnerType'],
nickName
:
res
[
'data'
][
'nickName'
],
// nickName: res['data']['nickName'],
}
// }
uni
.
setStorageSync
(
'cffp_userInfo'
,
JSON
.
stringify
(
cffp_userInfo
))
// uni.setStorageSync('cffp_userInfo', JSON.stringify(cffp_userInfo))
}
// }
}
catch
(
err
)
{
// } catch (err) {
console
.
error
(
'检查用户状态失败:'
,
err
);
// console.error('检查用户状态失败:', err);
}
// }
}
// }
},
// },
// 清除登录状态
// // 清除登录状态
clearLoginState
()
{
// clearLoginState() {
uni
.
clearStorageSync
();
// uni.clearStorageSync();
uni
.
setStorageSync
(
'loginType'
,
'visitor'
);
// uni.setStorageSync('loginType', 'visitor');
// 可以在这里添加其他需要清除的状态
// // 可以在这里添加其他需要清除的状态
},
// },
// 处理外部链接参数
// // 处理外部链接参数
handleExternalUrlParams
()
{
// handleExternalUrlParams() {
// #ifdef H5
// // #ifdef H5
this
.
handleH5UrlParams
();
// this.handleH5UrlParams();
// #endif
// // #endif
//
// #ifdef APP-PLUS
// // #ifdef APP-PLUS
this
.
handleAppUrlParams
();
// this.handleAppUrlParams();
// #endif
// // #endif
},
// },
//
// 处理H5平台的URL参数
// // 处理H5平台的URL参数
handleH5UrlParams
()
{
// handleH5UrlParams() {
const
url
=
window
.
location
.
href
;
// const url = window.location.href;
if
(
url
.
indexOf
(
'?'
)
>
-
1
)
{
// if (url.indexOf('?') > -1) {
const
queryString
=
url
.
split
(
'?'
)[
1
];
// const queryString = url.split('?')[1];
const
params
=
this
.
parseQueryString
(
queryString
);
// const params = this.parseQueryString(queryString);
this
.
saveUrlParams
(
params
);
// this.saveUrlParams(params);
}
// }
//
},
// },
//
// 处理App平台的URL参数
// // 处理App平台的URL参数
handleAppUrlParams
()
{
// handleAppUrlParams() {
// 处理冷启动参数
// // 处理冷启动参数
plus
.
runtime
.
getProperty
(
plus
.
runtime
.
appid
,
(
widgetInfo
)
=>
{
// plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
const
args
=
plus
.
runtime
.
arguments
;
// const args = plus.runtime.arguments;
if
(
args
)
{
// if (args) {
const
params
=
this
.
parseAppLaunchArgs
(
args
);
// const params = this.parseAppLaunchArgs(args);
this
.
saveUrlParams
(
params
);
// this.saveUrlParams(params);
}
// }
});
// });
//
// 监听热启动事件
// // 监听热启动事件
plus
.
runtime
.
addEventListener
(
'newintent'
,
(
e
)
=>
{
// plus.runtime.addEventListener('newintent', (e) => {
const
args
=
e
.
arguments
;
// const args = e.arguments;
if
(
args
)
{
// if (args) {
const
params
=
this
.
parseAppLaunchArgs
(
args
);
// const params = this.parseAppLaunchArgs(args);
this
.
saveUrlParams
(
params
);
// this.saveUrlParams(params);
}
// }
});
// });
},
// },
//
// 解析H5的查询字符串
// // 解析H5的查询字符串
parseQueryString
(
queryString
)
{
// parseQueryString(queryString) {
const
params
=
{};
// const params = {};
const
pairs
=
queryString
.
split
(
'&'
);
// const pairs = queryString.split('&');
for
(
let
i
=
0
;
i
<
pairs
.
length
;
i
++
)
{
// for (let i = 0; i
<
pairs
.
length
;
i
++
)
{
const
pair
=
pairs
[
i
].
split
(
'='
);
// const pair = pairs[i].split('=');
if
(
pair
.
length
===
2
)
{
// if (pair.length === 2) {
params
[
decodeURIComponent
(
pair
[
0
])]
=
decodeURIComponent
(
pair
[
1
]
||
''
);
// params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
}
// }
}
// }
return
params
;
// return params;
},
// },
//
// 解析App启动参数
// // 解析App启动参数
parseAppLaunchArgs
(
args
)
{
// parseAppLaunchArgs(args) {
// 处理 scheme://path?key=value 格式
// // 处理 scheme://path?key=value 格式
if
(
args
.
indexOf
(
'?'
)
>
-
1
)
{
// if (args.indexOf('?') > -1) {
const
queryString
=
args
.
split
(
'?'
)[
1
];
// const queryString = args.split('?')[1];
return
this
.
parseQueryString
(
queryString
);
// return this.parseQueryString(queryString);
}
// }
return
{};
// return {};
},
// },
//
// 保存URL参数到本地存储
// // 保存URL参数到本地存储
saveUrlParams
(
params
)
{
// saveUrlParams(params) {
if
(
Object
.
keys
(
params
).
length
>
0
)
{
// if (Object.keys(params).length > 0) {
console
.
log
(
'获取到外部链接参数:'
,
params
);
// console.log('获取到外部链接参数:', params);
//
// 使用uni.setStorageSync存储到本地
// // 使用uni.setStorageSync存储到本地
try
{
// try {
if
(
params
.
addSystemType
){
// if (params.addSystemType) {
uni
.
setStorageSync
(
'addSystemType'
,
params
.
addSystemType
);
// uni.setStorageSync('addSystemType', params.addSystemType);
}
// }
// // 可以在这里添加事件通知其他页面参数已准备好
// // // 可以在这里添加事件通知其他页面参数已准备好
// uni.$emit('externalParamsReady', params);
// // uni.$emit('externalParamsReady', params);
}
catch
(
e
)
{
// } catch (e) {
console
.
error
(
'存储外部链接参数失败:'
,
e
);
// console.error('存储外部链接参数失败:', e);
}
// }
}
// }
}
// }
//
// }
}
}
</
script
>
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment