Commit d94b5a2e261e5d4cf5bf9bf74a9546839f19f42e
1 parent
a1c7edf8
专享礼包分享朋友重构 导购问题
Showing
5 changed files
with
110 additions
and
89 deletions
pages/giftpack/buygiftpack/giftpackbuy.js
... | ... | @@ -29,14 +29,20 @@ Page({ |
29 | 29 | first_leader: e.globalData.first_leader || 0, // 推荐人ID |
30 | 30 | }, |
31 | 31 | onLoad: function (options) { |
32 | - | |
32 | + this.setData({ | |
33 | + params: options, | |
34 | + }) | |
35 | + | |
36 | + }, | |
37 | + init() { | |
33 | 38 | var th = this; |
34 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
35 | - my_confirm.open_cancel(0); | |
36 | - th.setData({ | |
39 | + let options = this.data?.params; | |
40 | + this.setData({ | |
37 | 41 | getStorageID: a.stoid, |
38 | 42 | getUserID: d.user_id |
39 | 43 | }); |
44 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
45 | + my_confirm.open_cancel(0); | |
40 | 46 | //-- 获取分享人的ID -- |
41 | 47 | var first_leader = options.first_leader || getApp().globalData.first_leader; |
42 | 48 | if (first_leader) { |
... | ... | @@ -52,8 +58,6 @@ Page({ |
52 | 58 | } |
53 | 59 | }) |
54 | 60 | } |
55 | - | |
56 | - | |
57 | 61 | getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, { |
58 | 62 | data: { |
59 | 63 | enabled: 1 |
... | ... | @@ -72,19 +76,18 @@ Page({ |
72 | 76 | }); |
73 | 77 | } |
74 | 78 | }) |
75 | - | |
76 | - | |
79 | + this.getList(); | |
77 | 80 | }, |
78 | 81 | onShow: function () { |
79 | 82 | //--先判断会员状态-- |
80 | - getApp().is_Single_page(this,function(){ | |
83 | + getApp().is_Single_page(this, function () { | |
81 | 84 | var user_info = getApp().globalData.userInfo; |
82 | 85 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
83 | - getApp().goto('/pages/togoin/togoin'); | |
84 | - return false; | |
86 | + getApp().goto('/pages/togoin/togoin'); | |
87 | + return false; | |
85 | 88 | } |
86 | - this.getList(); | |
87 | 89 | }) |
90 | + this.init(); | |
88 | 91 | }, |
89 | 92 | |
90 | 93 | //购买礼包 |
... | ... | @@ -190,7 +193,7 @@ Page({ |
190 | 193 | if (getApp().globalData.guide_id) { |
191 | 194 | json.guide_id = getApp().globalData.guide_id; |
192 | 195 | } |
193 | - console.log(json,'json'); | |
196 | + console.log(json, 'json'); | |
194 | 197 | var data = JSON.stringify(json); |
195 | 198 | var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; |
196 | 199 | getApp().request.json_post(url, json, |
... | ... | @@ -201,7 +204,7 @@ Page({ |
201 | 204 | getApp().my_warnning(res.data.msg, 0, th); |
202 | 205 | } |
203 | 206 | }, |
204 | - function (res) {}) | |
207 | + function (res) { }) | |
205 | 208 | |
206 | 209 | }) |
207 | 210 | |
... | ... | @@ -245,7 +248,7 @@ Page({ |
245 | 248 | getApp().my_warnning(res.data.msg, 0, th); |
246 | 249 | } |
247 | 250 | }, |
248 | - function (res) {}) | |
251 | + function (res) { }) | |
249 | 252 | }) |
250 | 253 | }, |
251 | 254 | |
... | ... | @@ -271,12 +274,14 @@ Page({ |
271 | 274 | wareCard: arr3, |
272 | 275 | total: res.data.data.total, |
273 | 276 | ismore: ismore, |
274 | - is_read: 1 | |
277 | + is_read: 1, | |
278 | + is_get:1 | |
275 | 279 | }), wx.stopPullDownRefresh(); //停止下拉刷新 |
276 | 280 | } else { |
277 | 281 | th.setData({ |
278 | 282 | is_read: 1, |
279 | - ismore: 1 | |
283 | + ismore: 1, | |
284 | + is_get:1 | |
280 | 285 | }) |
281 | 286 | } |
282 | 287 | } |
... | ... | @@ -326,7 +331,7 @@ Page({ |
326 | 331 | if (pagePath.indexOf('/') != 0) { |
327 | 332 | pagePath = '/' + pagePath; |
328 | 333 | } |
329 | - pagePath += "?first_leader="+this.data.getUserID; | |
334 | + pagePath += "?first_leader=" + this.data.getUserID; | |
330 | 335 | return { |
331 | 336 | title: "专享礼包", |
332 | 337 | path: pagePath, |
... | ... | @@ -340,7 +345,7 @@ Page({ |
340 | 345 | if (pagePath.indexOf('/') != 0) { |
341 | 346 | pagePath = '/' + pagePath; |
342 | 347 | } |
343 | - pagePath += "?first_leader="+this.data.getUserID; | |
348 | + pagePath += "?first_leader=" + this.data.getUserID; | |
344 | 349 | return { |
345 | 350 | title: '专享礼包', |
346 | 351 | imageUrl: this.data.ad_data.ad_code, | ... | ... |
pages/giftpack/buygiftpack/giftpackbuy.wxml
... | ... | @@ -94,7 +94,7 @@ |
94 | 94 | </view> |
95 | 95 | </view> |
96 | 96 | </block> |
97 | - <block wx:if="{{is_read && wareCard.length<1}}"> | |
97 | + <block wx:if="{{is_read && wareCard.length<1 && is_get}}"> | |
98 | 98 | <view class="foot_empty"> |
99 | 99 | <view> |
100 | 100 | <image src="{{iurl+'/miniapp/images/giftbag/gift07.png'}}" lazy-load="true"></image> | ... | ... |
pages/giftpack/giftpacklist/giftpacklist.js
... | ... | @@ -32,14 +32,22 @@ Page({ |
32 | 32 | first_leader: e.globalData.first_leader || 0, // 推荐人ID |
33 | 33 | }, |
34 | 34 | onLoad: function (options) { |
35 | + this.setData({ | |
36 | + params:options, | |
37 | + }) | |
38 | + }, | |
39 | + init(){ | |
40 | + let options = this.data?.params; | |
35 | 41 | var th = this; |
36 | - th.setData({ | |
42 | + this.setData({ | |
43 | + getUserID: d.user_id, | |
44 | + getStorageID: a.stoid, | |
45 | + }) | |
46 | + this.setData({ | |
37 | 47 | isBuy: options.isBuy, |
38 | 48 | getGiftID: options.lbId, |
39 | 49 | orderSn: options.orderSn, |
40 | - getUserID: d.user_id, | |
41 | 50 | }) |
42 | - | |
43 | 51 | if (options.lbId) th.data.lbId = options.lbId; |
44 | 52 | //-- 获取分享人的ID -- |
45 | 53 | var first_leader = options.first_leader || getApp().globalData.first_leader; |
... | ... | @@ -57,6 +65,11 @@ Page({ |
57 | 65 | }) |
58 | 66 | } |
59 | 67 | th.close(); |
68 | + if (this.data.isBuy == 0) { | |
69 | + this.GetMyGiftList(); | |
70 | + } else { | |
71 | + this.GetBuyGiftList(); | |
72 | + } | |
60 | 73 | }, |
61 | 74 | |
62 | 75 | onShow: function () { |
... | ... | @@ -67,11 +80,7 @@ Page({ |
67 | 80 | getApp().goto('/pages/togoin/togoin'); |
68 | 81 | return false; |
69 | 82 | } |
70 | - if (this.data.isBuy == 0) { | |
71 | - this.GetMyGiftList(); | |
72 | - } else { | |
73 | - this.GetBuyGiftList(); | |
74 | - } | |
83 | + this.init(); | |
75 | 84 | }) |
76 | 85 | }, |
77 | 86 | GetBuyPrice: function (e) { | ... | ... |
pages/giftpack/mygiftpack/mygiftpack.js
... | ... | @@ -25,19 +25,24 @@ Page({ |
25 | 25 | curpage: 1, //当前分页数 |
26 | 26 | pageSize: 10, //页大小 |
27 | 27 | total: 0, //总数量 |
28 | - ad_data:null, | |
28 | + ad_data: null, | |
29 | 29 | first_leader: e.globalData.first_leader || 0, // 推荐人ID |
30 | 30 | }, |
31 | + onLoad: function (options) { | |
32 | + this.setData({ | |
33 | + params: options, | |
34 | + }) | |
35 | + }, | |
31 | 36 | |
32 | - onLoad: function(options) { | |
37 | + init() { | |
38 | + let options = this.data?.params; | |
33 | 39 | var th = this; |
34 | - th.setData({ | |
40 | + this.setData({ | |
35 | 41 | getStorageID: a.stoid, |
36 | 42 | getUserID: d.user_id, |
37 | 43 | loadingType: 0, |
38 | 44 | getDate: i.formatTime(new Date().getTime()) |
39 | 45 | }); |
40 | - | |
41 | 46 | //-- 获取分享人的ID -- |
42 | 47 | var first_leader = options.first_leader || getApp().globalData.first_leader; |
43 | 48 | if (first_leader) { |
... | ... | @@ -53,39 +58,39 @@ Page({ |
53 | 58 | } |
54 | 59 | }) |
55 | 60 | } |
56 | - | |
57 | - getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, { | |
58 | - data: { | |
59 | - enabled: 1 | |
60 | - } | |
61 | - }).then(res => { | |
62 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ | |
63 | - var a = res.data.data.pageData; | |
64 | - var tt = { | |
65 | - 'ad_code': os.imghost + a[0].ad_code, | |
66 | - 'media_link': '', | |
67 | - 'ad_weapplink':a[0].ad_weapplink, | |
68 | - 'bgcolor':a[0].bgcolor, | |
69 | - }; | |
70 | - th.setData({ad_data:tt}); | |
71 | - } | |
72 | - }) | |
73 | 61 | |
62 | + getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, { | |
63 | + data: { | |
64 | + enabled: 1 | |
65 | + } | |
66 | + }).then(res => { | |
67 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | |
68 | + var a = res.data.data.pageData; | |
69 | + var tt = { | |
70 | + 'ad_code': os.imghost + a[0].ad_code, | |
71 | + 'media_link': '', | |
72 | + 'ad_weapplink': a[0].ad_weapplink, | |
73 | + 'bgcolor': a[0].bgcolor, | |
74 | + }; | |
75 | + th.setData({ ad_data: tt }); | |
76 | + } | |
77 | + }) | |
78 | + this.getList(); | |
74 | 79 | }, |
75 | - onShow: function() { | |
80 | + onShow: function () { | |
76 | 81 | //--先判断会员状态-- |
77 | - getApp().is_Single_page(this,function () { | |
82 | + getApp().is_Single_page(this, function () { | |
78 | 83 | var user_info = getApp().globalData.userInfo; |
79 | 84 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
80 | - getApp().goto('/pages/togoin/togoin'); | |
81 | - return false; | |
85 | + getApp().goto('/pages/togoin/togoin'); | |
86 | + return false; | |
82 | 87 | } |
83 | - this.getList(); | |
88 | + this.init() | |
84 | 89 | }) |
85 | - | |
90 | + | |
86 | 91 | |
87 | 92 | }, |
88 | - getList: function() { | |
93 | + getList: function () { | |
89 | 94 | var th = this; |
90 | 95 | |
91 | 96 | getApp().request.get('/api/weshop/marketing/my/giftbag/page', { |
... | ... | @@ -96,7 +101,7 @@ Page({ |
96 | 101 | page: th.data.curpage, |
97 | 102 | pageSize: th.data.pageSize |
98 | 103 | }, |
99 | - success: function(res) { | |
104 | + success: function (res) { | |
100 | 105 | if (res.data.code == 0) { |
101 | 106 | th.data.curpage++; |
102 | 107 | var arr1 = th.data.wareCard; |
... | ... | @@ -108,12 +113,14 @@ Page({ |
108 | 113 | wareCard: arr3, |
109 | 114 | total: res.data.data.total, |
110 | 115 | ismore: ismore, |
111 | - is_read: 1 | |
116 | + is_read: 1, | |
117 | + is_get:1, | |
112 | 118 | }), wx.stopPullDownRefresh(); //停止下拉刷新 |
113 | 119 | } else { |
114 | 120 | th.setData({ |
115 | 121 | is_read: 1, |
116 | - ismore:1 | |
122 | + ismore: 1, | |
123 | + is_get:1, | |
117 | 124 | }) |
118 | 125 | } |
119 | 126 | |
... | ... | @@ -123,7 +130,7 @@ Page({ |
123 | 130 | |
124 | 131 | }, |
125 | 132 | //销毁界面跳转 |
126 | - redirectTo: function(e) { | |
133 | + redirectTo: function (e) { | |
127 | 134 | var th = this; |
128 | 135 | var url = e.currentTarget.dataset.url; |
129 | 136 | //销毁跳转 |
... | ... | @@ -132,13 +139,13 @@ Page({ |
132 | 139 | }); |
133 | 140 | }, |
134 | 141 | //不销毁界面跳转 |
135 | - navigateTo: function(e) { | |
142 | + navigateTo: function (e) { | |
136 | 143 | var th = this; |
137 | 144 | var url = e.currentTarget.dataset.url; |
138 | 145 | getApp().goto(url); |
139 | 146 | }, |
140 | 147 | //下拉事件 |
141 | - onReachBottom: function() { | |
148 | + onReachBottom: function () { | |
142 | 149 | var th = this; |
143 | 150 | if (th.data.total <= th.data.pageSize) return; |
144 | 151 | if (th.data.ismore) return; |
... | ... | @@ -146,7 +153,7 @@ Page({ |
146 | 153 | }, |
147 | 154 | |
148 | 155 | //图片失败,默认图片 |
149 | - bind_bnerr2: function(e) { | |
156 | + bind_bnerr2: function (e) { | |
150 | 157 | var _errImg = e.target.dataset.errorimg; |
151 | 158 | var _errObj = {}; |
152 | 159 | _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; |
... | ... | @@ -154,33 +161,33 @@ Page({ |
154 | 161 | }, |
155 | 162 | |
156 | 163 | |
157 | -//--- 分享设置 -- | |
158 | -onShareAppMessage: function (e) { | |
159 | - var curPage=this; | |
160 | - var pagePath = curPage.route; //当前页面url | |
161 | - if (pagePath.indexOf('/') != 0) { | |
162 | - pagePath = '/' + pagePath; | |
163 | - } | |
164 | - pagePath += "?first_leader="+ this.data.getUserID; | |
165 | - return { | |
166 | - title: "专享礼包", | |
167 | - path:pagePath, | |
168 | - } | |
169 | -}, | |
164 | + //--- 分享设置 -- | |
165 | + onShareAppMessage: function (e) { | |
166 | + var curPage = this; | |
167 | + var pagePath = curPage.route; //当前页面url | |
168 | + if (pagePath.indexOf('/') != 0) { | |
169 | + pagePath = '/' + pagePath; | |
170 | + } | |
171 | + pagePath += "?first_leader=" + this.data.getUserID; | |
172 | + return { | |
173 | + title: "专享礼包", | |
174 | + path: pagePath, | |
175 | + } | |
176 | + }, | |
170 | 177 | |
171 | - onShareTimeline() { | |
172 | - var curPage=this; | |
173 | - var pagePath = curPage.route; //当前页面url | |
174 | - if (pagePath.indexOf('/') != 0) { | |
175 | - pagePath = '/' + pagePath; | |
178 | + onShareTimeline() { | |
179 | + var curPage = this; | |
180 | + var pagePath = curPage.route; //当前页面url | |
181 | + if (pagePath.indexOf('/') != 0) { | |
182 | + pagePath = '/' + pagePath; | |
183 | + } | |
184 | + pagePath += "?first_leader=" + this.data.getUserID; | |
185 | + return { | |
186 | + title: '专享礼包', | |
187 | + imageUrl: this.data.ad_data.ad_code, | |
188 | + path: pagePath, | |
176 | 189 | } |
177 | - pagePath += "?first_leader="+ this.data.getUserID; | |
178 | - return { | |
179 | - title: '专享礼包', | |
180 | - imageUrl: this.data.ad_data.ad_code, | |
181 | - path: pagePath, | |
182 | - } | |
183 | - }, | |
190 | + }, | |
184 | 191 | |
185 | 192 | |
186 | 193 | }); |
187 | 194 | \ No newline at end of file | ... | ... |
pages/giftpack/mygiftpack/mygiftpack.wxml
... | ... | @@ -96,7 +96,7 @@ |
96 | 96 | </view> |
97 | 97 | </view> |
98 | 98 | </block> |
99 | - <block wx:if="{{is_read && wareCard.length<1}}"> | |
99 | + <block wx:if="{{is_read && wareCard.length<1 && is_get}}"> | |
100 | 100 | <view class="foot_empty"> |
101 | 101 | <view> |
102 | 102 | <image src="{{iurl+'/miniapp/images/giftbag/gift07.png'}}" lazy-load="true"></image> | ... | ... |