|
@@ -10,32 +10,18 @@ const mapObj=new Map([
|
|
|
['pages/activity/activity','/activity/list'],
|
|
|
['pages-activity/detail','/activity/detail']
|
|
|
])//map映射小程序页面路径对应h5页面路径
|
|
|
+import {apiUserInfo} from '@/api/user'
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
url:'',
|
|
|
msgObj:{},//{path:小程序页面地址,params:页面参数,title:分享的标题,shareImg:分享的图片}
|
|
|
+
|
|
|
+ times:0,//检查token次数
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- console.log('pc页面onload数据',options);
|
|
|
- let paramsObj={
|
|
|
- ...options,
|
|
|
- token:this.$store.state.user.token||uni.getStorageSync("token"),
|
|
|
- timestamp:new Date().getTime(),//防止缓存
|
|
|
- }
|
|
|
- delete paramsObj.xcxPath
|
|
|
- console.log('要处理的参数',paramsObj);
|
|
|
- let paramsObjStr=''
|
|
|
- for (const key in paramsObj) {
|
|
|
- if(!paramsObjStr){
|
|
|
- paramsObjStr=`${key}=${paramsObj[key]}`
|
|
|
- }else{
|
|
|
- paramsObjStr=`${paramsObjStr}&${key}=${paramsObj[key]}`
|
|
|
- }
|
|
|
- }
|
|
|
- console.log('拼接字符串:',paramsObjStr);
|
|
|
- this.url=`${pcBaseUrl}${mapObj.get(decodeURIComponent(options.xcxPath))||'/'}?${paramsObjStr}`
|
|
|
+ this.init(options)
|
|
|
},
|
|
|
onShareAppMessage({webViewUrl}) {
|
|
|
// console.log(webViewUrl);
|
|
@@ -60,6 +46,45 @@ export default {
|
|
|
const data=e.detail.data[e.detail.data.length-1]
|
|
|
console.log('h5传来的数据',data);
|
|
|
this.msgObj=data
|
|
|
+ },
|
|
|
+
|
|
|
+ async init(options){
|
|
|
+ // 检查token是否有效 超过十次不在检测,提示重启小程序
|
|
|
+ const res=await apiUserInfo()
|
|
|
+ this.times++
|
|
|
+ if(res.code!==200){
|
|
|
+ console.log('pc页面检查token次:',this.times);
|
|
|
+ if(this.times<11){
|
|
|
+ setTimeout(() => {
|
|
|
+ this.init(options)
|
|
|
+ }, 1000);
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ title: '请重启小程序',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('pc页面onload数据',options);
|
|
|
+ let paramsObj={
|
|
|
+ ...options,
|
|
|
+ token:this.$store.state.user.token||uni.getStorageSync("token"),
|
|
|
+ timestamp:new Date().getTime(),//防止缓存
|
|
|
+ }
|
|
|
+ delete paramsObj.xcxPath
|
|
|
+ console.log('要处理的参数',paramsObj);
|
|
|
+ let paramsObjStr=''
|
|
|
+ for (const key in paramsObj) {
|
|
|
+ if(!paramsObjStr){
|
|
|
+ paramsObjStr=`${key}=${paramsObj[key]}`
|
|
|
+ }else{
|
|
|
+ paramsObjStr=`${paramsObjStr}&${key}=${paramsObj[key]}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('拼接字符串:',paramsObjStr);
|
|
|
+ this.url=`${pcBaseUrl}${mapObj.get(decodeURIComponent(options.xcxPath))||'/'}?${paramsObjStr}`
|
|
|
}
|
|
|
},
|
|
|
|