Commit d5653e8a by zhangxingmin

push

parent 688f6e97
<script> <!--<script>-->
import initApp from "@/util/router.js"; <!--import initApp from "@/util/router.js";-->
import {interceptor} from "@/util/interceptor"; <!--import {interceptor} from "@/util/interceptor";-->
import {baseURL,apiURL,cffpURL,companyInfo} from "@/environments/environment"; <!--import {baseURL,apiURL,cffpURL,companyInfo} from "@/environments/environment";-->
import api from './api/api'; <!--import api from './api/api';-->
export default { <!--export default {-->
data() { <!-- data() {-->
return { <!-- return {-->
invitationHandled: false <!-- invitationHandled: false-->
} <!-- }-->
}, <!-- },-->
onLaunch: function() { <!-- onLaunch: function() {-->
console.log('App Launch'); <!-- console.log('App Launch');-->
if(!uni.getStorageSync('loginType')){ <!-- if(!uni.getStorageSync('loginType')){-->
uni.clearStorageSync(); <!-- uni.clearStorageSync();-->
uni.setStorageSync('loginType','visitor'); <!-- uni.setStorageSync('loginType','visitor');-->
} <!-- }-->
this.handleExternalUrlParams(); <!-- this.handleExternalUrlParams();-->
// App更新逻辑 <!-- // App更新逻辑-->
// #ifdef APP-PLUS <!-- // #ifdef APP-PLUS-->
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { <!-- plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {-->
uni.getSystemInfo({ <!-- uni.getSystemInfo({-->
success:(systemInfo)=> { <!-- success:(systemInfo)=> {-->
uni.request({ <!-- uni.request({-->
url: `${apiURL}/appVersion/checkIsUpdate`, <!-- url: `${apiURL}/appVersion/checkIsUpdate`,-->
method:'POST', <!-- method:'POST',-->
data: { <!-- data: {-->
appType: 1, <!-- appType: 1,-->
version: wgtinfo.version, <!-- version: wgtinfo.version,-->
systemType:systemInfo.osName.toLowerCase() === 'ios' ? 2 : 1 <!-- systemType:systemInfo.osName.toLowerCase() === 'ios' ? 2 : 1-->
}, <!-- },-->
success: (result) => { <!-- success: (result) => {-->
const data = result.data.data['appVersionInfo']; <!-- const data = result.data.data['appVersionInfo'];-->
if (data.status==1 && data.isForceUpdate && data.wgtUrl) { <!-- if (data.status==1 && data.isForceUpdate && data.wgtUrl) {-->
uni.downloadFile({ <!-- uni.downloadFile({-->
url: `${baseURL}${data.wgtUrl}`, <!-- url: `${baseURL}${data.wgtUrl}`,-->
success: (downloadResult) => { <!-- success: (downloadResult) => {-->
if (downloadResult.statusCode === 200) { <!-- if (downloadResult.statusCode === 200) {-->
plus.runtime.install(downloadResult.tempFilePath, { <!-- plus.runtime.install(downloadResult.tempFilePath, {-->
force: true <!-- force: true-->
}, function() { <!-- }, function() {-->
plus.runtime.restart(); <!-- plus.runtime.restart();-->
}, function(e) { <!-- }, function(e) {-->
console.error('install fail...'); <!-- console.error('install fail...');-->
}); <!-- });-->
} <!-- }-->
} <!-- }-->
}); <!-- });-->
} <!-- }-->
} <!-- }-->
}); <!-- });-->
} <!-- }-->
}) <!-- })-->
}) <!-- })-->
// #endif <!-- // #endif-->
interceptor(); <!-- interceptor();-->
initApp(); <!-- initApp();-->
}, <!-- },-->
onShow: function(options) { <!-- onShow: function(options) {-->
console.log('App Show', options); <!-- console.log('App Show', options);-->
this.checkUserStatus(); <!-- this.checkUserStatus();-->
// #ifdef APP-PLUS <!-- // #ifdef APP-PLUS-->
if(options && options.query) { <!-- if(options && options.query) {-->
this.saveUrlParams(options.query); <!-- this.saveUrlParams(options.query);-->
} <!-- }-->
// #endif <!-- // #endif-->
}, <!-- },-->
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;-->
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-->
}, <!-- },-->
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);-->
} <!-- }-->
}, <!-- },-->
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);-->
} <!-- }-->
}); <!-- });-->
}, <!-- },-->
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;-->
}, <!-- },-->
parseAppLaunchArgs(args) { <!-- parseAppLaunchArgs(args) {-->
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 {};-->
}, <!-- },-->
saveUrlParams(params) { <!-- saveUrlParams(params) {-->
if(Object.keys(params).length > 0) { <!-- if(Object.keys(params).length > 0) {-->
console.log('获取到外部链接参数:', params); <!-- console.log('获取到外部链接参数:', params);-->
try { <!-- try {-->
if(params.addSystemType){ <!-- if(params.addSystemType){-->
uni.setStorageSync('addSystemType', params.addSystemType); <!-- uni.setStorageSync('addSystemType', params.addSystemType);-->
} <!-- }-->
} catch(e) { <!-- } catch(e) {-->
console.error('存储外部链接参数失败:', e); <!-- console.error('存储外部链接参数失败:', e);-->
} <!-- }-->
} <!-- }-->
} <!-- }-->
} <!-- }-->
} <!--}-->
</script> <!--</script>-->
<style> <style>
@import "@/static/font1/iconfont.css"; @import "@/static/font1/iconfont.css";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment