Jacob
2026-10-12 4a45efcec76cbe047d069aef04e315082ff0775d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
   <web-view class="web-view" :topBar="false" :update-title="false" :fullscreen="true" :src="url"
       :style="{ width: windowW + 'px', height: windowH + 'px' }" @message="onHandleMessage"></web-view>
</template>
 
<script>
import {
   mapGetters
} from "vuex";
import { toLogin } from "../../../libs/login";
export default {
   //computed: mapGetters(['chatUrl']),
   data() {
       return {
           windowH: 0,
           windowW: 0,
           url: '',
           paramUrl: '',
           shareObj: null,
           isShare: '0'
       }
   },
   onShow() {
       let that = this;
       let pages = getCurrentPages(),
           currPage = pages[pages.length - 1];
       console.log('------------------page onShow start-----------------');
       console.log('route', currPage.route);
       console.log('options', currPage.options);
       console.log('------------------page onShow end-----------------');
       let options = currPage.options;
       if (options.webUel) {
           that.paramUrl = decodeURIComponent(options.webUel);
       }
       that.url = '';
       if (options.isShare) {
           that.isShare = options.isShare;
       }
       if (that.isShare == '0') {
           wx.hideShareMenu({
               menus: ["shareAppMessage"]
           });
 
       } else {
           wx.showShareMenu({
               menus: ["shareAppMessage"]
           })
       }
       // uni.setNavigationBarTitle({
       //     title: options.title ? decodeURIComponent(options.title) : ''
       // })
       try {
           const res = uni.getSystemInfoSync();
           that.windowW = res.windowWidth;
           that.windowH = res.windowHeight;
       } catch (e) {
           // error
       }
 
       if (!options.needLogin || options.needLogin !== 'false') {
           if (that.$store.getters.isBelong) {
               that.belongInfoReadyFn({
                   isRegister: false
               })
           } else {
               uni.$once('BELONG_READY', that.belongInfoReadyFn);
           }
       } else {
           if (that.paramUrl) {
               that.url = that.paramUrl;
           }
       }
 
   },
   onShareAppMessage: function () {
       if (!this.isShare || this.isShare == '0') {
           return {};
       }
       if (this.shareObj) {
           let pages = getCurrentPages(),
               currPage = pages[pages.length - 1];
           let options = currPage.options;
           this.addTrack('yy_contentPageShare', {
               'sharePosition_var': options.from == 'button' ? '页面分享按钮' : '页面顶部',
               'shareMethod_var': '微信好友',
               'pageTitle_var': this.shareObj.activityTitle ? this.shareObj.activityTitle : '',
               'pageType_var': this.shareObj.activityTitle ? this.shareObj.activityTitle : '',
               'pagePath_var': currPage.route,
               'productID_var': '-',
               'productName_var': '-',
               'contentId_var': '-',
               'contentName_var': '-',
               'contentType_var': '-',
               'contentLabel_var': '-',
           });
           console.log(this.shareObj);
           let path = this.shareObj.path;
           let shareUrl = '';
           if (path) {
               shareUrl = '/pages/users/web_page/index?isShare=' + options.isShare + '&needLogin=' + (options.needLogin?options.needLogin:'true') + '&webUel=' + encodeURIComponent(path);
           } else {
               shareUrl = currPage.$page.fullPath;
           }
           return {
               title: this.shareObj.title,
               imageUrl: this.shareObj.imageUrl,
               desc: this.shareObj.desc ? this.shareObj.desc : '',
               path: shareUrl
           };
       } else {
           return {}
       }
   },
   methods: {
       belongInfoReadyFn(data) {
           let that = this;
           console.log(1111, 'belongInfoReadyFn');
           let pages = getCurrentPages(),
               currPage = pages[pages.length - 1];
           let options = currPage.options;
           if (that.$store.getters.isLogin) {
               if (this.paramUrl.indexOf('token') < 0) {
                   this.url = this.paramUrl + (this.paramUrl.indexOf('?') < 0 ? '?' : '&') + 'token=' + that.$store.getters.token + '&unionId=' + that.$store.getters.unionId;
               } else {
                   this.url = this.paramUrl.replace("{{token}}", that.$store.getters.token).replace("{{unionId}}", that.$store.getters.unionId);
               }
               if (this.url.indexOf('title=') < 0 && options.title) {
                   this.url = this.url + (this.url.indexOf('?') < 0 ? '?' : '&') + 'title=' + encodeURIComponent(options.title);
               }
           } else {
               uni.navigateTo({
                   url: '/pages/users/web_page/login?back_url=' + encodeURIComponent(currPage.$page.fullPath)
               })
           }
       },
       onHandleMessage: function (data) {
           console.error("接收到消息:" + JSON.stringify(data.detail));
           this.shareObj = data.detail.data[0];
       }
   },
}
</script>
<style>
uni-page-head {
   display: none;
}
</style>