no message
Showing
7 changed files
with
84 additions
and
11 deletions
... | @@ -28,6 +28,7 @@ App({ | ... | @@ -28,6 +28,7 @@ App({ |
28 | tlMemberCode: "", | 28 | tlMemberCode: "", |
29 | giftInfo: null, // 来自 gift-shop | 29 | giftInfo: null, // 来自 gift-shop |
30 | addressEditInfo: null, // 编辑时的临时对象 | 30 | addressEditInfo: null, // 编辑时的临时对象 |
31 | // postMessageData: null, | ||
31 | }, | 32 | }, |
32 | //重写分享方法 | 33 | //重写分享方法 |
33 | share: function () { | 34 | share: function () { | ... | ... |
... | @@ -35,6 +35,7 @@ module.exports = { | ... | @@ -35,6 +35,7 @@ module.exports = { |
35 | signInfo: '/sign/info', // post 签到信息 用户注册接口 | 35 | signInfo: '/sign/info', // post 签到信息 用户注册接口 |
36 | sign: '/sign', // post 签到动作 用户注册接口 | 36 | sign: '/sign', // post 签到动作 用户注册接口 |
37 | signRecord: '/sign/record', // post 签到记录 用户注册接口 | 37 | signRecord: '/sign/record', // post 签到记录 用户注册接口 |
38 | saveOpenid:'/member/save/subscription/openid', //保存 openid | ||
38 | 39 | ||
39 | areaQuery: 'https://api.k.wxpai.cn/bizproxy/kdapi/area', // post 区域查询 | 40 | areaQuery: 'https://api.k.wxpai.cn/bizproxy/kdapi/area', // post 区域查询 |
40 | 41 | ... | ... |
... | @@ -25,13 +25,58 @@ Page({ | ... | @@ -25,13 +25,58 @@ Page({ |
25 | }, | 25 | }, |
26 | onShow() { | 26 | onShow() { |
27 | this.initData(); | 27 | this.initData(); |
28 | |||
28 | }, | 29 | }, |
29 | onLoad(options) { | 30 | onLoad(options) { |
30 | 31 | // app.router.push({ | |
32 | // path: "webview" | ||
33 | // }) | ||
31 | }, | 34 | }, |
32 | initData() { | 35 | initData() { |
33 | this.queryMember().then((result) => { | 36 | this.queryMember().then((result) => { |
34 | this.querySignInfo(); | 37 | let subscriptionOpenid = result.subscriptionOpenid; |
38 | if (subscriptionOpenid) { | ||
39 | // member表 已有openid 继续流程 | ||
40 | this.querySignInfo(); | ||
41 | } else { | ||
42 | // member表无openid ,重h5授权回来的local拿,成功就继续往下走 | ||
43 | this.querySaveOpenid().then((result) => { | ||
44 | this.queryMember().then((result) => { | ||
45 | this.querySignInfo(); | ||
46 | }) | ||
47 | }).catch((err) => { | ||
48 | // 如果均没有,则去h5授权 | ||
49 | app.router.push({ | ||
50 | path: "webview" | ||
51 | }) | ||
52 | }); | ||
53 | } | ||
54 | }); | ||
55 | }, | ||
56 | |||
57 | /** | ||
58 | * 保存openid | ||
59 | */ | ||
60 | querySaveOpenid() { | ||
61 | return new Promise((resolve, reject) => { | ||
62 | let openid = app.store.getItem("openid"); | ||
63 | if (openid) { | ||
64 | app.post({ | ||
65 | toast: false, | ||
66 | url: app.api.saveOpenid, | ||
67 | data: { | ||
68 | subscriptionOpenid: openid | ||
69 | } | ||
70 | }).then((result) => { | ||
71 | console.log("result:", result); | ||
72 | app.store.clear("openid"); | ||
73 | resolve(); | ||
74 | }).catch((err) => { | ||
75 | reject(); | ||
76 | }); | ||
77 | } else { | ||
78 | reject(); | ||
79 | } | ||
35 | }); | 80 | }); |
36 | }, | 81 | }, |
37 | 82 | ||
... | @@ -157,7 +202,7 @@ Page({ | ... | @@ -157,7 +202,7 @@ Page({ |
157 | this.setData({ | 202 | this.setData({ |
158 | userInfo: result | 203 | userInfo: result |
159 | }) | 204 | }) |
160 | resolve(); | 205 | resolve(result); |
161 | }) | 206 | }) |
162 | }); | 207 | }); |
163 | }, | 208 | }, | ... | ... |
... | @@ -2,24 +2,48 @@ let app = getApp(); | ... | @@ -2,24 +2,48 @@ let app = getApp(); |
2 | Page({ | 2 | Page({ |
3 | data: { | 3 | data: { |
4 | isShow: false, // 控制组件显示隐藏 | 4 | isShow: false, // 控制组件显示隐藏 |
5 | url: '' | 5 | url: '', |
6 | message: "-", | ||
7 | }, | ||
8 | onShareAppMessage(options) { | ||
9 | return { | ||
10 | title: 'title', | ||
11 | path: this.url, | ||
12 | success: function (res) { | ||
13 | // that.web_url = return_url | ||
14 | // 转发成功 | ||
15 | wx.showToast({ | ||
16 | title: "转发成功", | ||
17 | icon: 'success', | ||
18 | duration: 2000 | ||
19 | }) | ||
20 | |||
21 | }, | ||
22 | fail: function (res) { | ||
23 | // 转发失败 | ||
24 | } | ||
25 | } | ||
6 | }, | 26 | }, |
7 | onLoad(options = {}) { | 27 | onLoad(options = {}) { |
8 | let url = options.url; | 28 | let url = options.url; |
29 | url = "https://k.wxpai.cn/IdgW/index.html" | ||
30 | console.log("url:", url); | ||
9 | if (url) { | 31 | if (url) { |
10 | this.setData({ | 32 | this.setData({ |
11 | url: url, | 33 | url: url, |
12 | isShow: true | 34 | isShow: true |
13 | }) | 35 | }) |
14 | } else { | 36 | } else { |
15 | wx.showToast({ | 37 | // wx.showToast({ |
16 | title: '未找到页面地址', | 38 | // title: '未找到页面地址', |
17 | title: 'none', | 39 | // title: 'none', |
18 | }); | 40 | // }); |
19 | } | 41 | } |
20 | }, | 42 | }, |
21 | 43 | ||
22 | onBindMessage(e) { | 44 | onBindMessage(e) { |
23 | console.log("webview message:", e); | 45 | let postMessageData = e.detail.data[0] |
46 | let openid = postMessageData.openid; | ||
47 | app.store.setItem("openid", openid); | ||
24 | } | 48 | } |
25 | }) | 49 | }) | ... | ... |
1 | <view class="loading-wrap"> | 1 | <view class="loading-wrap"> |
2 | <view class="loading"> | 2 | <view class="loading"> |
3 | <view class="icon"></view> | 3 | <view class="icon"></view> |
4 | <view class="text">加载中...</view> | 4 | <view class="text">{{message}}</view> |
5 | </view> | 5 | </view> |
6 | </view> | 6 | </view> |
7 | <!-- <view class="message">{{message}}</view> --> | ||
7 | <web-view wx:if="{{isShow}}" src="{{url}}" bindload="loadSucc" bindmessage="onBindMessage" /> | 8 | <web-view wx:if="{{isShow}}" src="{{url}}" bindload="loadSucc" bindmessage="onBindMessage" /> | ... | ... |
... | @@ -19,6 +19,7 @@ const routerPath = { | ... | @@ -19,6 +19,7 @@ const routerPath = { |
19 | signInRecord: '/pages/sign-in-record/sign-in-record', // 签到记录 | 19 | signInRecord: '/pages/sign-in-record/sign-in-record', // 签到记录 |
20 | rank: '/pages/rank/rank', // 排行榜 | 20 | rank: '/pages/rank/rank', // 排行榜 |
21 | rankGift: '/pages/rank-gift/rank-gift', // 排行榜奖励 | 21 | rankGift: '/pages/rank-gift/rank-gift', // 排行榜奖励 |
22 | webview: '/pages/webview/webview', | ||
22 | example: '/pages/example/example', | 23 | example: '/pages/example/example', |
23 | more: '/pages/more/more', | 24 | more: '/pages/more/more', |
24 | } | 25 | } | ... | ... |
-
Please register or sign in to post a comment