Commit d94b5a2e261e5d4cf5bf9bf74a9546839f19f42e

Authored by abson
1 parent a1c7edf8

专享礼包分享朋友重构 导购问题

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