|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<view class="pc-page">
|
|
|
- <web-view :src="url" />
|
|
|
+ <web-view :src="url" @message="handleGetMessage"/>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -9,15 +9,19 @@ import {pcBaseUrl} from '../utils/config'
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
- url:''
|
|
|
+ url:'',
|
|
|
+
|
|
|
+ msgObj:{},//{path:小程序页面地址,params:页面参数,title:分享的标题}
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
+ console.log('pc页面onload数据',options);
|
|
|
let paramsObj={
|
|
|
-
|
|
|
+ ...options,
|
|
|
token:this.$store.state.user.token,
|
|
|
timestamp:new Date().getTime(),//防止缓存
|
|
|
}
|
|
|
+ console.log('要处理的参数',paramsObj);
|
|
|
let paramsObjStr=''
|
|
|
for (const key in paramsObj) {
|
|
|
if(!paramsObjStr){
|
|
@@ -26,8 +30,8 @@ export default {
|
|
|
paramsObjStr=`${paramsObjStr}&${key}=${paramsObj[key]}`
|
|
|
}
|
|
|
}
|
|
|
- console.log('字符串:',paramsObjStr);
|
|
|
- this.url=`${pcBaseUrl}/?${paramsObjStr}`
|
|
|
+ console.log('拼接字符串:',paramsObjStr);
|
|
|
+ this.url=`${pcBaseUrl}${options.h5Url||'/'}?${paramsObjStr}`
|
|
|
},
|
|
|
onShow() {
|
|
|
uni.hideHomeButton({
|
|
@@ -35,6 +39,31 @@ export default {
|
|
|
console.log(e);
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ onShareAppMessage({webViewUrl}) {
|
|
|
+ // console.log(webViewUrl);
|
|
|
+ let paramsStr=''
|
|
|
+ for(const key in this.msgObj.params){
|
|
|
+ if(!paramsStr){
|
|
|
+ paramsStr=`${key}=${this.msgObj.params[key]}`
|
|
|
+ }else{
|
|
|
+ paramsStr=`${paramsStr}&${key}=${this.msgObj.params[key]}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ title: this.msgObj.title||'弘则研究',
|
|
|
+ path: `${this.msgObj.path}?${paramsStr}`,
|
|
|
+ imageUrl:this.msgObj.shareImg||''
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ // 获取到用户点击转发时从h5页面传来的参数
|
|
|
+ handleGetMessage(e){
|
|
|
+ const data=e.detail.data[e.detail.data.length-1]
|
|
|
+ console.log('h5传来的数据',data);
|
|
|
+ this.msgObj=data
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|