Commit f7f65b37e97031303104075dfcb4ebf58fa5296c
1 parent
3fc235ab
OA单专享礼包分享图
Showing
5 changed files
with
1011 additions
and
572 deletions
components/diy_goodsGroup/diy_goodsGroup.js
@@ -139,8 +139,8 @@ Component({ | @@ -139,8 +139,8 @@ Component({ | ||
139 | this.data.g_id = nav_item.data; | 139 | this.data.g_id = nav_item.data; |
140 | var arr = []; | 140 | var arr = []; |
141 | 141 | ||
142 | - for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { | ||
143 | - arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); | 142 | + for (var i = 0; i < this.data.g_id.length; i += parseInt(this.data.goodscount)) { |
143 | + arr.push(this.data.g_id.slice(i, i + parseInt(this.data.goodscount))); | ||
144 | } | 144 | } |
145 | this.data.firist_type_data = arr; | 145 | this.data.firist_type_data = arr; |
146 | this.init(this.data.classstyle_id, this.data.wgroup); | 146 | this.init(this.data.classstyle_id, this.data.wgroup); |
pages/giftpack/giftpacklist/giftpacklist.js
1 | var e = getApp(), | 1 | var e = getApp(), |
2 | - a = e.globalData.setting, | ||
3 | - os = a, | ||
4 | - t = e.request, | ||
5 | - d = e.globalData; | 2 | + a = e.globalData.setting, |
3 | + os = a, | ||
4 | + t = e.request, | ||
5 | + d = e.globalData; | ||
6 | var ut = require("../../../utils/util.js"); | 6 | var ut = require("../../../utils/util.js"); |
7 | var com = require("../public/buy_com.js"); | 7 | var com = require("../public/buy_com.js"); |
8 | 8 | ||
9 | Page({ | 9 | Page({ |
10 | - data: { | ||
11 | - url: a.url, //接口网址 | ||
12 | - iurl: a.imghost, //图片前缀网址 | ||
13 | - isBuy: 0, | ||
14 | - getGiftID: '', //礼包id | ||
15 | - giftImage: '', | ||
16 | - giftTitle: '', | ||
17 | - giftDate: '', | ||
18 | - giftPrice: '', | ||
19 | - giftIntegral: '', | ||
20 | - giftPosPrice: '', | ||
21 | - giftQty: '', | ||
22 | - giftRemark: '', | ||
23 | - giftType: '', | ||
24 | - actTitle: '', | ||
25 | - getUrl: '', | ||
26 | - wareCard: [], | ||
27 | - orderSn: "", //订单编号 | ||
28 | - lbId: "", | ||
29 | - code: "", //核销码 | ||
30 | - c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 | ||
31 | - is_lb: 0, //是否有礼包 | ||
32 | - default_color: null, | ||
33 | - first_leader: e.globalData.first_leader || 0, // 推荐人ID | ||
34 | - | ||
35 | - //门店相关 | ||
36 | - ismend: 0, | ||
37 | - is_sec_mend: 0, | ||
38 | - sto_sele_name: "", //选中的门店名称 | ||
39 | - sto_sele_id: "", //选中的门店id | ||
40 | - sto_sele_distr: "", //选择的门店的配送方式 | ||
41 | - is_show_sto_cat: 1, //是否显示门店分类 | ||
42 | - only_pk: null, | ||
43 | - all_sto: null, | ||
44 | - sec_sto: null, //选择了的门店分类 | ||
45 | - pickpu_list: null, //读出的所有门店list | ||
46 | - def_pickpu_list: null, //一开始5个门店list | ||
47 | - sec_pick_index: 0, //第二级门店选择ID | ||
48 | - fir_pick_index: 0, //第一级门店选择ID | ||
49 | - all_pick_list: null,//所有的门店先记录起来 | ||
50 | - | ||
51 | - select_store: 0, //选择更多 | ||
52 | - index: 1, | ||
53 | - more_store: 0, //选择门店 | ||
54 | - sort_store: 0, //门店分类 | ||
55 | - choice_sort_store: 0, //选择分类门店 | ||
56 | - new_user: 0, //新用户 | ||
57 | - | ||
58 | - def_pick_store: null, // 默认的门店 | ||
59 | - fir_def_store: null, //客户默认的门店的 | ||
60 | - lat: null, //维度 | ||
61 | - lon: null, //经度 | ||
62 | - | ||
63 | - is_get_local_ok: 0, //获取坐标是否完成 | ||
64 | - region_name: "门店分类", //区域的名字 | ||
65 | - is_gps: 1, | ||
66 | - open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
67 | - default_store: {}, //创建添加默认门店地址的对象 | ||
68 | - | ||
69 | - store:0, | ||
70 | - openSpecModal:0 | ||
71 | - }, | ||
72 | - onLoad: function (options) { | ||
73 | - | ||
74 | - var th=this; | ||
75 | - | ||
76 | - this.setData({ | ||
77 | - params:options, | ||
78 | - }) | ||
79 | - | ||
80 | - getApp().getConfig2(function (e) { | ||
81 | - var json_d = JSON.parse(e.switch_list); | ||
82 | - th.setData({ | ||
83 | - bconfig: e, | ||
84 | - sys_switch:json_d | ||
85 | - }); | ||
86 | - }) | ||
87 | - }, | ||
88 | - init(){ | ||
89 | - let options = this.data?.params; // this.data == null ? undefined:this.data.params | ||
90 | - var th = this; | ||
91 | - this.setData({ | ||
92 | - getUserID: d.user_id, | ||
93 | - getStorageID: a.stoid, | ||
94 | - }) | ||
95 | - this.setData({ | ||
96 | - isBuy: options.isBuy, | ||
97 | - getGiftID: options.lbId, | ||
98 | - orderSn: options.orderSn, | ||
99 | - flag: options.flag, // 如果从商品详情页的促销处点击专享礼包跳转到此页,则flag为1 | ||
100 | - }) | ||
101 | - if (options.lbId) th.data.lbId = options.lbId; | ||
102 | - //-- 获取分享人的ID -- | ||
103 | - var first_leader = options.first_leader || getApp().globalData.first_leader; | ||
104 | - if (first_leader) { | ||
105 | - this.setData({ | ||
106 | - first_leader, | ||
107 | - }) | ||
108 | - //-- user_id代过来免登录 -- | ||
109 | - getApp().globalData.first_leader = first_leader; | ||
110 | - //调用接口判断是不是会员 | ||
111 | - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
112 | - if (res.data.code == 0) { | ||
113 | - getApp().globalData.guide_id = res.data.data.id; | ||
114 | - } | ||
115 | - }) | ||
116 | - } | ||
117 | - th.close(); | ||
118 | - | ||
119 | - | ||
120 | - if(this.data.flag == 1) { | ||
121 | - this.getZxlbDetails(); | ||
122 | - } else { | ||
123 | - if (this.data.isBuy == 0) { | ||
124 | - this.GetMyGiftList(); | ||
125 | - } else if (this.data.isBuy == 1) { | ||
126 | - this.GetBuyGiftList(); | ||
127 | - }; | ||
128 | - }; | ||
129 | - }, | ||
130 | - | ||
131 | - onShow: function () { | ||
132 | - getApp().check_can_share(); | ||
133 | - getApp().is_Single_page(this,function () { | ||
134 | - //--先判断会员状态-- | ||
135 | - var user_info = getApp().globalData.userInfo; | ||
136 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
137 | - getApp().goto('/pages/togoin/togoin'); | ||
138 | - return false; | ||
139 | - } | ||
140 | - this.init(); | ||
141 | - }) | ||
142 | - }, | ||
143 | - GetBuyPrice: function (e) { | ||
144 | - var that = this.data; | ||
145 | - var th = this; | ||
146 | - //如果还没有开始的话 | ||
147 | - if (th.data.isStart != 1) { | ||
148 | - getApp().my_warnning("活动还没有开始", 0, th); | ||
149 | - return false; | ||
150 | - } | ||
151 | - | ||
152 | - this.data.payMoney=th.data.sele_g.payMoney; | ||
153 | - th.setData({ buyType:2 }) | ||
154 | - if(th.data.sele_g.is_pickup){ | ||
155 | - th.setData({ | ||
156 | - openSpecModal:1 | 10 | + data: { |
11 | + url: a.url, //接口网址 | ||
12 | + iurl: a.imghost, //图片前缀网址 | ||
13 | + isBuy: 0, | ||
14 | + getGiftID: '', //礼包id | ||
15 | + giftImage: '', | ||
16 | + giftTitle: '', | ||
17 | + giftDate: '', | ||
18 | + giftPrice: '', | ||
19 | + giftIntegral: '', | ||
20 | + giftPosPrice: '', | ||
21 | + giftQty: '', | ||
22 | + giftRemark: '', | ||
23 | + giftType: '', | ||
24 | + actTitle: '', | ||
25 | + getUrl: '', | ||
26 | + wareCard: [], | ||
27 | + orderSn: "", //订单编号 | ||
28 | + lbId: "", | ||
29 | + code: "", //核销码 | ||
30 | + c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 | ||
31 | + is_lb: 0, //是否有礼包 | ||
32 | + default_color: null, | ||
33 | + first_leader: e.globalData.first_leader || 0, // 推荐人ID | ||
34 | + | ||
35 | + //门店相关 | ||
36 | + ismend: 0, | ||
37 | + is_sec_mend: 0, | ||
38 | + sto_sele_name: "", //选中的门店名称 | ||
39 | + sto_sele_id: "", //选中的门店id | ||
40 | + sto_sele_distr: "", //选择的门店的配送方式 | ||
41 | + is_show_sto_cat: 1, //是否显示门店分类 | ||
42 | + only_pk: null, | ||
43 | + all_sto: null, | ||
44 | + sec_sto: null, //选择了的门店分类 | ||
45 | + pickpu_list: null, //读出的所有门店list | ||
46 | + def_pickpu_list: null, //一开始5个门店list | ||
47 | + sec_pick_index: 0, //第二级门店选择ID | ||
48 | + fir_pick_index: 0, //第一级门店选择ID | ||
49 | + all_pick_list: null,//所有的门店先记录起来 | ||
50 | + | ||
51 | + select_store: 0, //选择更多 | ||
52 | + index: 1, | ||
53 | + more_store: 0, //选择门店 | ||
54 | + sort_store: 0, //门店分类 | ||
55 | + choice_sort_store: 0, //选择分类门店 | ||
56 | + new_user: 0, //新用户 | ||
57 | + | ||
58 | + def_pick_store: null, // 默认的门店 | ||
59 | + fir_def_store: null, //客户默认的门店的 | ||
60 | + lat: null, //维度 | ||
61 | + lon: null, //经度 | ||
62 | + | ||
63 | + is_get_local_ok: 0, //获取坐标是否完成 | ||
64 | + region_name: "门店分类", //区域的名字 | ||
65 | + is_gps: 1, | ||
66 | + open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
67 | + default_store: {}, //创建添加默认门店地址的对象 | ||
68 | + | ||
69 | + store: 0, | ||
70 | + openSpecModal: 0, | ||
71 | + | ||
72 | + sto_sele_name_1: '', | ||
73 | + share_goods_img:'', //礼包的分享图 | ||
74 | + canvasHidden:true, | ||
75 | + | ||
76 | + screenWidth: 0 | ||
77 | + }, | ||
78 | + onLoad: function (options) { | ||
79 | + | ||
80 | + var th = this; | ||
81 | + | ||
82 | + this.setData({ | ||
83 | + params: options, | ||
157 | }) | 84 | }) |
158 | - }else{ | ||
159 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
160 | - my_confirm.open( | ||
161 | - "是否确定购买该礼包", | ||
162 | - "取消", | ||
163 | - "确定", | ||
164 | - function () { | ||
165 | - my_confirm.open_cancel(0); | ||
166 | - }, | ||
167 | - function () { | ||
168 | - my_confirm.open_cancel(0); | ||
169 | - com.buy_libao(th) | ||
170 | - } | ||
171 | 85 | ||
172 | - ) | ||
173 | - } | 86 | + getApp().getConfig(function (e) { |
87 | + th.setData({sto_sele_name_1: e.store_name}) | ||
88 | + }) | ||
174 | 89 | ||
90 | + getApp().getConfig2(function (e) { | ||
91 | + var json_d = JSON.parse(e.switch_list); | ||
92 | + th.setData({ | ||
93 | + bconfig: e, | ||
94 | + sys_switch: json_d | ||
95 | + }); | ||
96 | + }) | ||
175 | 97 | ||
98 | + //获取用户设备信息,屏幕宽度 | ||
99 | + wx.getSystemInfo({ | ||
100 | + success: res => { | ||
101 | + th.setData({ | ||
102 | + screenWidth: res.screenWidth | ||
103 | + }) | ||
104 | + } | ||
105 | + }); | ||
176 | 106 | ||
107 | + }, | ||
108 | + init() { | ||
109 | + let options = this.data?.params; // this.data == null ? undefined:this.data.params | ||
110 | + var th = this; | ||
111 | + this.setData({ | ||
112 | + getUserID: d.user_id, | ||
113 | + getStorageID: a.stoid, | ||
114 | + }) | ||
177 | 115 | ||
178 | - }, | ||
179 | - GetBuyIntegral: function (e) { | ||
180 | - var that = this.data; | ||
181 | - var th = this; | 116 | + if(!options.lbId && options.scene){ |
117 | + var gid_str = decodeURIComponent(t.scene); | ||
118 | + gid_str = gid_str.split("_"); | ||
182 | 119 | ||
183 | - //如果还没有开始的话 | ||
184 | - if (th.data.isStart != 1) { | ||
185 | - getApp().my_warnning("活动还没有开始", 0, th); | ||
186 | - return false; | ||
187 | - } | 120 | + options.lbId=gid_str[0]; |
121 | + options.first_leader=gid_str[1]; | ||
122 | + options.isBuy=1; | ||
123 | + } | ||
188 | 124 | ||
189 | - th.setData({ buyType:1 }); | ||
190 | - if(th.data.sele_g.is_pickup){ | ||
191 | - th.setData({ | ||
192 | - openSpecModal:1 | 125 | + |
126 | + this.setData({ | ||
127 | + isBuy: options.isBuy, | ||
128 | + getGiftID: options.lbId, | ||
129 | + orderSn: options.orderSn, | ||
130 | + flag: options.flag, // 如果从商品详情页的促销处点击专享礼包跳转到此页,则flag为1 | ||
193 | }) | 131 | }) |
194 | - }else { | ||
195 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
196 | - my_confirm.open( | ||
197 | - "是否确定兑换该礼包", | ||
198 | - "取消", | ||
199 | - "确定", | ||
200 | - function () { | ||
201 | - my_confirm.open_cancel(0); | ||
202 | - }, | ||
203 | - function () { | ||
204 | - my_confirm.open_cancel(0); | ||
205 | - com.buy_libao(th) | ||
206 | - }) | ||
207 | - } | ||
208 | - | ||
209 | - | ||
210 | - | ||
211 | - | ||
212 | - }, | ||
213 | - | ||
214 | - GetMyGiftList: function () { | ||
215 | - var _this = this; | ||
216 | - var th = this; | ||
217 | - getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { | ||
218 | - isShowLoading: true, | ||
219 | - data: { | ||
220 | - "storeId": a.stoid, //商家ID | ||
221 | - "userId": d.user_id, //用户ID | ||
222 | - "orderSn": th.data.orderSn | ||
223 | - }, | ||
224 | - success: function (res) { | ||
225 | - if (res.data.code == 0) { | ||
226 | - th.setData({ | ||
227 | - giftImage: th.data.iurl + res.data.data.lbUrl, | ||
228 | - giftTitle: res.data.data.giftTitle, | ||
229 | - default_color: res.data.data.bgcolor | ||
230 | - }) | ||
231 | - | ||
232 | - if(res.data.data.iswarelbtype==1) { | ||
233 | - th.setData({iswarelbtype:1}) | ||
234 | - } | ||
235 | - | ||
236 | - if (!res.data.data.giftRemark || res.data.data.giftRemark == '') { | ||
237 | - th.setData({ | ||
238 | - giftRemark: '暂无详情......' | 132 | + if (options.lbId) th.data.lbId = options.lbId; |
133 | + //-- 获取分享人的ID -- | ||
134 | + var first_leader = options.first_leader || getApp().globalData.first_leader; | ||
135 | + if (first_leader) { | ||
136 | + this.setData({ | ||
137 | + first_leader, | ||
239 | }) | 138 | }) |
240 | - } else { | ||
241 | - th.setData({ | ||
242 | - giftRemark: res.data.data.giftRemark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | 139 | + //-- user_id代过来免登录 -- |
140 | + getApp().globalData.first_leader = first_leader; | ||
141 | + //调用接口判断是不是会员 | ||
142 | + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
143 | + if (res.data.code == 0) { | ||
144 | + getApp().globalData.guide_id = res.data.data.id; | ||
145 | + } | ||
243 | }) | 146 | }) |
244 | - } | ||
245 | - | ||
246 | - //---获取日期的时间戳--- | ||
247 | - var t_endtime = res.data.data.endTime; | ||
248 | - t_endtime = t_endtime.replace(/-/g, '/'); | ||
249 | - var t_date = new Date(t_endtime) / 1000; | ||
250 | - var t_now = ut.gettimestamp(); | ||
251 | - | ||
252 | - var t_starttime = res.data.data.starTime; | ||
253 | - t_starttime = t_starttime.replace(/-/g, '/'); | ||
254 | - var t_sdate = new Date(t_starttime) / 1000; | ||
255 | - | ||
256 | - if (res.data.data.goodsUseState) th.setData({ | ||
257 | - c_state: 1 | ||
258 | - }) | ||
259 | - else if (t_date <= t_now) | 147 | + } |
148 | + th.close(); | ||
149 | + | ||
150 | + | ||
151 | + if (this.data.flag == 1) { | ||
152 | + this.getZxlbDetails(); | ||
153 | + } else { | ||
154 | + if (this.data.isBuy == 0) { | ||
155 | + this.GetMyGiftList(); | ||
156 | + } else if (this.data.isBuy == 1) { | ||
157 | + this.GetBuyGiftList(); | ||
158 | + } | ||
159 | + | ||
160 | + } | ||
161 | + | ||
162 | + }, | ||
163 | + | ||
164 | + onShow: function () { | ||
165 | + getApp().check_can_share(); | ||
166 | + getApp().is_Single_page(this, function () { | ||
167 | + //--先判断会员状态-- | ||
168 | + var user_info = getApp().globalData.userInfo; | ||
169 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
170 | + getApp().goto('/pages/togoin/togoin'); | ||
171 | + return false; | ||
172 | + } | ||
173 | + this.init(); | ||
174 | + }) | ||
175 | + }, | ||
176 | + GetBuyPrice: function (e) { | ||
177 | + var that = this.data; | ||
178 | + var th = this; | ||
179 | + //如果还没有开始的话 | ||
180 | + if (th.data.isStart != 1) { | ||
181 | + getApp().my_warnning("活动还没有开始", 0, th); | ||
182 | + return false; | ||
183 | + } | ||
184 | + | ||
185 | + this.data.payMoney = th.data.sele_g.payMoney; | ||
186 | + th.setData({buyType: 2}) | ||
187 | + if (th.data.sele_g.is_pickup) { | ||
260 | th.setData({ | 188 | th.setData({ |
261 | - c_state: 2 | 189 | + openSpecModal: 1 |
262 | }) | 190 | }) |
263 | - else if (t_sdate > t_now) | 191 | + } else { |
192 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
193 | + my_confirm.open( | ||
194 | + "是否确定购买该礼包", | ||
195 | + "取消", | ||
196 | + "确定", | ||
197 | + function () { | ||
198 | + my_confirm.open_cancel(0); | ||
199 | + }, | ||
200 | + function () { | ||
201 | + my_confirm.open_cancel(0); | ||
202 | + com.buy_libao(th) | ||
203 | + } | ||
204 | + ) | ||
205 | + } | ||
206 | + | ||
207 | + | ||
208 | + }, | ||
209 | + GetBuyIntegral: function (e) { | ||
210 | + var that = this.data; | ||
211 | + var th = this; | ||
212 | + | ||
213 | + //如果还没有开始的话 | ||
214 | + if (th.data.isStart != 1) { | ||
215 | + getApp().my_warnning("活动还没有开始", 0, th); | ||
216 | + return false; | ||
217 | + } | ||
218 | + | ||
219 | + th.setData({buyType: 1}); | ||
220 | + if (th.data.sele_g.is_pickup) { | ||
264 | th.setData({ | 221 | th.setData({ |
265 | - c_state: -1 | 222 | + openSpecModal: 1 |
266 | }) | 223 | }) |
267 | - th.setData({ | ||
268 | - giftDate: res.data.data.endTime, | ||
269 | - giftPosPrice: res.data.data.giftPosPrice, | ||
270 | - giftQty: res.data.data.giftQty, | ||
271 | - giftIntegral: res.data.data.payIntegral, | ||
272 | - giftPrice: res.data.data.payMoney, | ||
273 | - giftType: res.data.data.actType, | ||
274 | - actTitle: res.data.data.actTitle, | ||
275 | - wareCard: res.data.data.wareCard, | ||
276 | - lbId: res.data.data.lbId | ||
277 | - }) | ||
278 | - //判断是否有礼包 | ||
279 | - for (var i = 0; i < res.data.data.wareCard.length; i++) { | ||
280 | - if (res.data.data.wareCard[i].lbType == 1) { | ||
281 | - th.setData({ | ||
282 | - is_lb: 1 | ||
283 | - }) | ||
284 | - break; | 224 | + } else { |
225 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
226 | + my_confirm.open( | ||
227 | + "是否确定兑换该礼包", | ||
228 | + "取消", | ||
229 | + "确定", | ||
230 | + function () { | ||
231 | + my_confirm.open_cancel(0); | ||
232 | + }, | ||
233 | + function () { | ||
234 | + my_confirm.open_cancel(0); | ||
235 | + com.buy_libao(th) | ||
236 | + }) | ||
237 | + } | ||
238 | + | ||
239 | + | ||
240 | + }, | ||
241 | + | ||
242 | + GetMyGiftList: function () { | ||
243 | + var _this = this; | ||
244 | + var th = this; | ||
245 | + getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { | ||
246 | + isShowLoading: true, | ||
247 | + data: { | ||
248 | + "storeId": a.stoid, //商家ID | ||
249 | + "userId": d.user_id, //用户ID | ||
250 | + "orderSn": th.data.orderSn | ||
251 | + }, | ||
252 | + success: function (res) { | ||
253 | + if (res.data.code == 0) { | ||
254 | + th.setData({ | ||
255 | + giftImage: th.data.iurl + res.data.data.lbUrl, | ||
256 | + giftTitle: res.data.data.giftTitle, | ||
257 | + default_color: res.data.data.bgcolor | ||
258 | + }) | ||
259 | + | ||
260 | + if (res.data.data.iswarelbtype == 1) { | ||
261 | + th.setData({iswarelbtype: 1}) | ||
262 | + } | ||
263 | + | ||
264 | + if (!res.data.data.giftRemark || res.data.data.giftRemark == '') { | ||
265 | + th.setData({ | ||
266 | + giftRemark: '暂无详情......' | ||
267 | + }) | ||
268 | + } else { | ||
269 | + th.setData({ | ||
270 | + giftRemark: res.data.data.giftRemark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | ||
271 | + }) | ||
272 | + } | ||
273 | + | ||
274 | + //---获取日期的时间戳--- | ||
275 | + var t_endtime = res.data.data.endTime; | ||
276 | + t_endtime = t_endtime.replace(/-/g, '/'); | ||
277 | + var t_date = new Date(t_endtime) / 1000; | ||
278 | + var t_now = ut.gettimestamp(); | ||
279 | + | ||
280 | + var t_starttime = res.data.data.starTime; | ||
281 | + t_starttime = t_starttime.replace(/-/g, '/'); | ||
282 | + var t_sdate = new Date(t_starttime) / 1000; | ||
283 | + | ||
284 | + if (res.data.data.goodsUseState) th.setData({ | ||
285 | + c_state: 1 | ||
286 | + }) | ||
287 | + else if (t_date <= t_now) | ||
288 | + th.setData({ | ||
289 | + c_state: 2 | ||
290 | + }) | ||
291 | + else if (t_sdate > t_now) | ||
292 | + th.setData({ | ||
293 | + c_state: -1 | ||
294 | + }) | ||
295 | + th.setData({ | ||
296 | + giftDate: res.data.data.endTime, | ||
297 | + giftPosPrice: res.data.data.giftPosPrice, | ||
298 | + giftQty: res.data.data.giftQty, | ||
299 | + giftIntegral: res.data.data.payIntegral, | ||
300 | + giftPrice: res.data.data.payMoney, | ||
301 | + giftType: res.data.data.actType, | ||
302 | + actTitle: res.data.data.actTitle, | ||
303 | + wareCard: res.data.data.wareCard, | ||
304 | + lbId: res.data.data.lbId | ||
305 | + }) | ||
306 | + //判断是否有礼包 | ||
307 | + for (var i = 0; i < res.data.data.wareCard.length; i++) { | ||
308 | + if (res.data.data.wareCard[i].lbType == 1) { | ||
309 | + th.setData({ | ||
310 | + is_lb: 1 | ||
311 | + }) | ||
312 | + break; | ||
313 | + } | ||
314 | + } | ||
315 | + | ||
316 | + if (res.data.data.pickup_id) { | ||
317 | + getApp().request.get("/api/weshop/pickup/get/" + os.stoid + "/" + res.data.data.pickup_id, { | ||
318 | + success: function (res) { | ||
319 | + if (res.data.code == 0) { | ||
320 | + th.setData({pick_up: res.data.data}); | ||
321 | + } | ||
322 | + } | ||
323 | + }); | ||
324 | + | ||
325 | + } | ||
326 | + | ||
327 | + | ||
328 | + } else { | ||
329 | + getApp().my_warnning(res.data.msg, 0, th); | ||
330 | + return false; | ||
331 | + } | ||
332 | + } | ||
333 | + }); | ||
334 | + | ||
335 | + }, | ||
336 | + GetBuyGiftList: function () { | ||
337 | + var _this2 = this; | ||
338 | + var th = this.data; | ||
339 | + getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { | ||
340 | + isShowLoading: true, | ||
341 | + data: { | ||
342 | + "storeId": a.stoid, //商家ID | ||
343 | + "userId": d.user_id, //用户ID | ||
344 | + "giftBagId": th.getGiftID | ||
345 | + }, | ||
346 | + success: function success(res) { | ||
347 | + if (res.data.code == 0) { | ||
348 | + _this2.setData({ | ||
349 | + giftImage: th.iurl + res.data.data.lbUrl, | ||
350 | + giftTitle: res.data.data.giftTitle, | ||
351 | + default_color: res.data.data.bgcolor | ||
352 | + }) | ||
353 | + if (res.data.data.giftRemark == '') { | ||
354 | + _this2.setData({ | ||
355 | + giftRemark: '暂无详情......' | ||
356 | + }) | ||
357 | + } else { | ||
358 | + _this2.setData({ | ||
359 | + giftRemark: res.data.data.giftRemark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | ||
360 | + }) | ||
361 | + } | ||
362 | + | ||
363 | + var isStart = 0; | ||
364 | + var now = ut.gettimestamp(); | ||
365 | + | ||
366 | + var str = res.data.data.starTime.replace(/-/g, '/'); | ||
367 | + var start = Date.parse(new Date(str)); | ||
368 | + start = start / 1000; | ||
369 | + if (start < now) isStart = 1; | ||
370 | + | ||
371 | + _this2.setData({ | ||
372 | + giftDate: res.data.data.endTime, | ||
373 | + giftStart: res.data.data.starTime, | ||
374 | + giftPosPrice: res.data.data.giftPosPrice, | ||
375 | + giftQty: res.data.data.giftQty, | ||
376 | + giftIntegral: res.data.data.payIntegral, | ||
377 | + giftPrice: res.data.data.payMoney, | ||
378 | + giftType: res.data.data.actType, | ||
379 | + actTitle: res.data.data.actTitle, | ||
380 | + wareCard: res.data.data.wareCard, | ||
381 | + isStart: isStart, | ||
382 | + sele_g: res.data.data | ||
383 | + }) | ||
384 | + | ||
385 | + | ||
386 | + var sele_g = res.data.data; | ||
387 | + //需不需要门店,不需要门店返回 | ||
388 | + if (!sele_g.is_pickup) return false; | ||
389 | + | ||
390 | + com.wait_for_store_config(_this2); | ||
391 | + com.set_user_mo_store(_this2, os, function () { | ||
392 | + if (sele_g.pickup_list && _this2.data.def_pick_store) { | ||
393 | + com.check_def_pk(_this2); | ||
394 | + } | ||
395 | + }); | ||
396 | + com.get_sto(_this2, os); | ||
397 | + | ||
398 | + | ||
399 | + } else { | ||
400 | + getApp().my_warnning(res.data.msg, 0, _this2); | ||
401 | + return false; | ||
402 | + } | ||
285 | } | 403 | } |
286 | - } | 404 | + }); |
405 | + | ||
406 | + }, | ||
407 | + | ||
408 | + getZxlbDetails: function () { | ||
409 | + | ||
410 | + var th = this; | ||
411 | + getApp().request.get('/api/weshop/marketing/giftbag/detail/getNew', { | ||
412 | + isShowLoading: true, | ||
413 | + data: { | ||
414 | + "storeId": a.stoid, //商家ID | ||
415 | + //"userId": d.user_id, //用户ID | ||
416 | + "giftBagId": th.data.lbId | ||
417 | + }, | ||
418 | + success: function (res) { | ||
419 | + if (res.data.code == 0) { | ||
420 | + th.setData({ | ||
421 | + giftImage: th.data.iurl + res.data.data.lbUrl, | ||
422 | + giftTitle: res.data.data.lbTitle, | ||
423 | + default_color: res.data.data.bgcolor | ||
424 | + }) | ||
425 | + if (res.data.data.lbIntro == '') { | ||
426 | + th.setData({ | ||
427 | + giftRemark: '暂无详情......' | ||
428 | + }) | ||
429 | + } else { | ||
430 | + th.setData({ | ||
431 | + giftRemark: res.data.data.lbIntro.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | ||
432 | + }) | ||
433 | + } | ||
287 | 434 | ||
288 | - if(res.data.data.pickup_id){ | ||
289 | - getApp().request.get("/api/weshop/pickup/get/"+os.stoid+"/"+res.data.data.pickup_id,{ | ||
290 | - success: function (res) { | ||
291 | - if(res.data.code==0){ | ||
292 | - th.setData({pick_up:res.data.data}); | ||
293 | - } | ||
294 | - } | ||
295 | - }); | 435 | + //---获取日期的时间戳--- |
436 | + let exchangeType = res.data.data.exchangeType; | ||
437 | + let exchangeDay = res.data.data.exchangeDay; | ||
438 | + let exchangeStartTime = res.data.data.exchangeStartTime; | ||
439 | + let exchangeEndTime = res.data.data.exchangeEndTime; | ||
440 | + // let t_endtime; | ||
296 | 441 | ||
297 | - } | 442 | + if (exchangeType == 2) { |
443 | + if (exchangeStartTime == 0 || !exchangeStartTime) { | ||
444 | + exchangeStartTime = ut.gettimestamp(); | ||
445 | + } | ||
446 | + exchangeStartTime = ut.formatTime(exchangeStartTime, 0); | ||
447 | + exchangeEndTime = ut.formatTime(exchangeEndTime, 0); | ||
448 | + } | ||
298 | 449 | ||
299 | 450 | ||
300 | - } else { | ||
301 | - getApp().my_warnning(res.data.msg, 0, th); | ||
302 | - return false; | 451 | + th.setData({ |
452 | + // giftDate: t_endtime, | ||
453 | + giftPosPrice: res.data.data.oldPrice, | ||
454 | + giftQty: res.data.data.lbNum, | ||
455 | + giftIntegral: res.data.data.exchangeIntegral, | ||
456 | + giftPrice: res.data.data.lbPrice, | ||
457 | + giftType: res.data.data.actType, | ||
458 | + actTitle: res.data.data.actTitle, | ||
459 | + wareCard: res.data.data.wareCard, | ||
460 | + lbId: res.data.data.lbId, | ||
461 | + exchangeType: exchangeType, | ||
462 | + exchangeDay: exchangeDay, | ||
463 | + exchangeStartTime: exchangeStartTime, | ||
464 | + exchangeEndTime: exchangeEndTime, | ||
465 | + }) | ||
466 | + //判断是否有礼包 | ||
467 | + for (var i = 0; i < res.data.data.wareCard.length; i++) { | ||
468 | + if (res.data.data.wareCard[i].lbType == 1) { | ||
469 | + th.setData({ | ||
470 | + is_lb: 1 | ||
471 | + }) | ||
472 | + break; | ||
473 | + } | ||
474 | + } | ||
475 | + } else { | ||
476 | + getApp().my_warnning(res.data.msg, 0, th); | ||
477 | + return false; | ||
478 | + } | ||
479 | + } | ||
480 | + }); | ||
481 | + | ||
482 | + }, | ||
483 | + | ||
484 | + | ||
485 | + //显示核销码 | ||
486 | + code_show: function (e) { | ||
487 | + var th = this; | ||
488 | + //--获取成功的时候-- | ||
489 | + var no = th.data.code; | ||
490 | + var qc_com = th.selectComponent("#qc_com"); //组件的id | ||
491 | + var obj = { | ||
492 | + val: no, | ||
493 | + content: "请将二维码展示给核销员,收货更快捷" | ||
494 | + }; | ||
495 | + qc_com.open(obj) | ||
496 | + }, | ||
497 | + //获取核销码 | ||
498 | + getcode: function (e) { | ||
499 | + var th = this; | ||
500 | + var orderSn = th.data.orderSn; //订单号 | ||
501 | + let codeId = e.currentTarget.dataset.codeid; | ||
502 | + var json = { | ||
503 | + "storeId": a.stoid, | ||
504 | + "orderSn": orderSn, | ||
303 | } | 505 | } |
304 | - } | ||
305 | - }); | ||
306 | - | ||
307 | - }, | ||
308 | - GetBuyGiftList: function () { | ||
309 | - var _this2 = this; | ||
310 | - var th = this.data; | ||
311 | - getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { | ||
312 | - isShowLoading: true, | ||
313 | - data: { | ||
314 | - "storeId": a.stoid, //商家ID | ||
315 | - "userId": d.user_id, //用户ID | ||
316 | - "giftBagId": th.getGiftID | ||
317 | - }, | ||
318 | - success: function success(res) { | ||
319 | - if (res.data.code == 0) { | ||
320 | - _this2.setData({ | ||
321 | - giftImage: th.iurl + res.data.data.lbUrl, | ||
322 | - giftTitle: res.data.data.giftTitle, | ||
323 | - default_color: res.data.data.bgcolor | ||
324 | - }) | ||
325 | - if (res.data.data.giftRemark == '') { | ||
326 | - _this2.setData({ | ||
327 | - giftRemark: '暂无详情......' | ||
328 | - }) | ||
329 | - } else { | ||
330 | - _this2.setData({ | ||
331 | - giftRemark: res.data.data.giftRemark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | ||
332 | - }) | ||
333 | - } | ||
334 | - | ||
335 | - var isStart = 0; | ||
336 | - var now = ut.gettimestamp(); | ||
337 | - | ||
338 | - var str = res.data.data.starTime.replace(/-/g, '/'); | ||
339 | - var start = Date.parse(new Date(str)); | ||
340 | - start = start / 1000; | ||
341 | - if (start < now) isStart = 1; | ||
342 | - | ||
343 | - _this2.setData({ | ||
344 | - giftDate: res.data.data.endTime, | ||
345 | - giftStart: res.data.data.starTime, | ||
346 | - giftPosPrice: res.data.data.giftPosPrice, | ||
347 | - giftQty: res.data.data.giftQty, | ||
348 | - giftIntegral: res.data.data.payIntegral, | ||
349 | - giftPrice: res.data.data.payMoney, | ||
350 | - giftType: res.data.data.actType, | ||
351 | - actTitle: res.data.data.actTitle, | ||
352 | - wareCard: res.data.data.wareCard, | ||
353 | - isStart: isStart, | ||
354 | - sele_g:res.data.data | ||
355 | - }) | ||
356 | - | ||
357 | - | ||
358 | - var sele_g=res.data.data; | ||
359 | - //需不需要门店,不需要门店返回 | ||
360 | - if(!sele_g.is_pickup) return false; | ||
361 | - | ||
362 | - com.wait_for_store_config(_this2); | ||
363 | - com.set_user_mo_store(_this2,os,function () { | ||
364 | - if(sele_g.pickup_list && _this2.data.def_pick_store){ | ||
365 | - com.check_def_pk(_this2); | 506 | + if (codeId && codeId !== "") { |
507 | + json.id = codeId | ||
508 | + } | ||
509 | + var data = JSON.stringify(json); | ||
510 | + var url = th.data.url + "/api/weshop/marketing/gift/goods/verify/code/get"; //预约接口地址 | ||
511 | + getApp().request.json_post(url, json, | ||
512 | + function (res) { | ||
513 | + if (res.data.code == 0) { | ||
514 | + th.setData({ | ||
515 | + code: res.data.data | ||
516 | + }) | ||
517 | + th.code_show(); | ||
518 | + } else { | ||
519 | + getApp().my_warnning(res.data.msg, 0, th); | ||
366 | } | 520 | } |
367 | - }); | ||
368 | - com.get_sto(_this2,os); | 521 | + }, |
522 | + function (res) { | ||
369 | 523 | ||
524 | + }, | ||
525 | + "put" | ||
526 | + ) | ||
370 | 527 | ||
371 | - } else { | ||
372 | - getApp().my_warnning(res.data.msg, 0, _this2); | ||
373 | - return false; | 528 | + }, |
529 | + //界面跳转 | ||
530 | + goto: function (e) { | ||
531 | + var th = this; | ||
532 | + var url = e.currentTarget.dataset.url; | ||
533 | + getApp().goto(url); | ||
534 | + }, | ||
535 | + //图片失败,默认图片 | ||
536 | + bind_bnerr2: function (e) { | ||
537 | + var _errImg = e.target.dataset.errorimg; | ||
538 | + var _errObj = {}; | ||
539 | + _errObj[_errImg] = "/miniapp/images/giftbag/gift01.png"; | ||
540 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
541 | + }, | ||
542 | + | ||
543 | + //图片失败,默认图片 | ||
544 | + bind_bnerr: function (e) { | ||
545 | + var _errImg = e.target.dataset.errorimg; | ||
546 | + var _errObj = {}; | ||
547 | + _errObj[_errImg] = this.data.iurl + "miniapp/images/big_back.jpg"; | ||
548 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
549 | + //this.setData({ giftImage: this.data.iurl + "/miniapp/images/giftbag/gift01.png"}); | ||
550 | + | ||
551 | + }, | ||
552 | + | ||
553 | + //关闭导航 | ||
554 | + close: function () { | ||
555 | + var th = this; | ||
556 | + var nav_b = th.selectComponent("#nav_b"); //组件的id | ||
557 | + nav_b.close_box(); | ||
558 | + nav_b.set_name("礼包", "/pages/giftpack/buygiftpack/giftpackbuy"); | ||
559 | + }, | ||
560 | + | ||
561 | + //--- 分享设置 -- | ||
562 | + onShareAppMessage: function (e) { | ||
563 | + getApp().globalData.no_clear = 1; | ||
564 | + var curPage = this; | ||
565 | + var pagePath = curPage.route; //当前页面url | ||
566 | + if (pagePath.indexOf('/') != 0) { | ||
567 | + pagePath = '/' + pagePath; | ||
374 | } | 568 | } |
375 | - } | ||
376 | - }); | ||
377 | - | ||
378 | - }, | ||
379 | - | ||
380 | - getZxlbDetails: function () { | ||
381 | - | ||
382 | - var th = this; | ||
383 | - getApp().request.get('/api/weshop/marketing/giftbag/detail/getNew', { | ||
384 | - isShowLoading: true, | ||
385 | - data: { | ||
386 | - "storeId": a.stoid, //商家ID | ||
387 | - //"userId": d.user_id, //用户ID | ||
388 | - "giftBagId": th.data.lbId | ||
389 | - }, | ||
390 | - success: function (res) { | ||
391 | - if (res.data.code == 0) { | ||
392 | - th.setData({ | ||
393 | - giftImage: th.data.iurl + res.data.data.lbUrl, | ||
394 | - giftTitle: res.data.data.lbTitle, | ||
395 | - default_color: res.data.data.bgcolor | ||
396 | - }) | ||
397 | - if (res.data.data.lbIntro == '') { | ||
398 | - th.setData({ | ||
399 | - giftRemark: '暂无详情......' | ||
400 | - }) | ||
401 | - } else { | ||
402 | - th.setData({ | ||
403 | - giftRemark: res.data.data.lbIntro.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block"') | ||
404 | - }) | ||
405 | - } | ||
406 | - | ||
407 | - //---获取日期的时间戳--- | ||
408 | - let exchangeType = res.data.data.exchangeType; | ||
409 | - let exchangeDay = res.data.data.exchangeDay; | ||
410 | - let exchangeStartTime = res.data.data.exchangeStartTime; | ||
411 | - let exchangeEndTime = res.data.data.exchangeEndTime; | ||
412 | - // let t_endtime; | ||
413 | - | ||
414 | - if(exchangeType == 2) { | ||
415 | - if(exchangeStartTime == 0 || !exchangeStartTime) { | ||
416 | - exchangeStartTime = ut.gettimestamp(); | ||
417 | - }; | ||
418 | - exchangeStartTime = ut.formatTime(exchangeStartTime, 0); | ||
419 | - exchangeEndTime = ut.formatTime(exchangeEndTime, 0); | ||
420 | - } | ||
421 | - | ||
422 | - | ||
423 | - th.setData({ | ||
424 | - // giftDate: t_endtime, | ||
425 | - giftPosPrice: res.data.data.oldPrice, | ||
426 | - giftQty: res.data.data.lbNum, | ||
427 | - giftIntegral: res.data.data.exchangeIntegral, | ||
428 | - giftPrice: res.data.data.lbPrice, | ||
429 | - giftType: res.data.data.actType, | ||
430 | - actTitle: res.data.data.actTitle, | ||
431 | - wareCard: res.data.data.wareCard, | ||
432 | - lbId: res.data.data.lbId, | ||
433 | - exchangeType: exchangeType, | ||
434 | - exchangeDay: exchangeDay, | ||
435 | - exchangeStartTime: exchangeStartTime, | ||
436 | - exchangeEndTime: exchangeEndTime, | ||
437 | - }) | ||
438 | - //判断是否有礼包 | ||
439 | - for (var i = 0; i < res.data.data.wareCard.length; i++) { | ||
440 | - if (res.data.data.wareCard[i].lbType == 1) { | ||
441 | - th.setData({ | ||
442 | - is_lb: 1 | ||
443 | - }) | ||
444 | - break; | ||
445 | - } | ||
446 | - } | ||
447 | - } else { | ||
448 | - getApp().my_warnning(res.data.msg, 0, th); | ||
449 | - return false; | ||
450 | - } | ||
451 | - } | ||
452 | - }); | ||
453 | - | ||
454 | - }, | ||
455 | - | ||
456 | - | ||
457 | - //显示核销码 | ||
458 | - code_show: function (e) { | ||
459 | - var th = this; | ||
460 | - //--获取成功的时候-- | ||
461 | - var no = th.data.code; | ||
462 | - var qc_com = th.selectComponent("#qc_com"); //组件的id | ||
463 | - var obj = { | ||
464 | - val: no, | ||
465 | - content: "请将二维码展示给核销员,收货更快捷" | ||
466 | - }; | ||
467 | - qc_com.open(obj) | ||
468 | - }, | ||
469 | - //获取核销码 | ||
470 | - getcode: function (e) { | ||
471 | - var th = this; | ||
472 | - var orderSn = th.data.orderSn; //订单号 | ||
473 | - let codeId = e.currentTarget.dataset.codeid; | ||
474 | - var json = { | ||
475 | - "storeId": a.stoid, | ||
476 | - "orderSn": orderSn, | ||
477 | - } | ||
478 | - if (codeId && codeId !== "") { | ||
479 | - json.id = codeId | ||
480 | - } | ||
481 | - var data = JSON.stringify(json); | ||
482 | - var url = th.data.url + "/api/weshop/marketing/gift/goods/verify/code/get"; //预约接口地址 | ||
483 | - getApp().request.json_post(url, json, | ||
484 | - function (res) { | ||
485 | - if (res.data.code == 0) { | ||
486 | - th.setData({ | ||
487 | - code: res.data.data | ||
488 | - }) | ||
489 | - th.code_show(); | ||
490 | - } else { | ||
491 | - getApp().my_warnning(res.data.msg, 0, th); | 569 | + pagePath += "?isBuy=1" + "&lbId=" + this.data.getGiftID + "&first_leader=" + this.data.getUserID; |
570 | + // if (this.data.isBuy == 0) { | ||
571 | + // pagePath += "&orderSn=" + this.data.orderSn; | ||
572 | + // } else { | ||
573 | + // pagePath += "&lbId=" + this.data.getGiftID; | ||
574 | + // } | ||
575 | + // console.log('pagePath', pagePath); | ||
576 | + return { | ||
577 | + title: "礼包详情", | ||
578 | + path: pagePath, | ||
492 | } | 579 | } |
493 | - }, | ||
494 | - function (res) { | ||
495 | - | ||
496 | - }, | ||
497 | - "put" | ||
498 | - ) | ||
499 | - | ||
500 | - }, | ||
501 | - //界面跳转 | ||
502 | - goto: function (e) { | ||
503 | - var th = this; | ||
504 | - var url = e.currentTarget.dataset.url; | ||
505 | - getApp().goto(url); | ||
506 | - }, | ||
507 | - //图片失败,默认图片 | ||
508 | - bind_bnerr2: function (e) { | ||
509 | - var _errImg = e.target.dataset.errorimg; | ||
510 | - var _errObj = {}; | ||
511 | - _errObj[_errImg] = "/miniapp/images/giftbag/gift01.png"; | ||
512 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
513 | - }, | ||
514 | - | ||
515 | - //图片失败,默认图片 | ||
516 | - bind_bnerr: function (e) { | ||
517 | - var _errImg = e.target.dataset.errorimg; | ||
518 | - var _errObj = {}; | ||
519 | - _errObj[_errImg] = this.data.iurl + "miniapp/images/big_back.jpg"; | ||
520 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
521 | - //this.setData({ giftImage: this.data.iurl + "/miniapp/images/giftbag/gift01.png"}); | ||
522 | - | ||
523 | - }, | ||
524 | - | ||
525 | - //关闭导航 | ||
526 | - close: function () { | ||
527 | - var th = this; | ||
528 | - var nav_b = th.selectComponent("#nav_b"); //组件的id | ||
529 | - nav_b.close_box(); | ||
530 | - nav_b.set_name("礼包", "/pages/giftpack/buygiftpack/giftpackbuy"); | ||
531 | - }, | ||
532 | - | ||
533 | - //--- 分享设置 -- | ||
534 | - onShareAppMessage: function (e) { | ||
535 | - getApp().globalData.no_clear=1; | ||
536 | - var curPage = this; | ||
537 | - var pagePath = curPage.route; //当前页面url | ||
538 | - if (pagePath.indexOf('/') != 0) { | ||
539 | - pagePath = '/' + pagePath; | ||
540 | - } | ||
541 | - pagePath += "?isBuy=1" + "&lbId=" + this.data.getGiftID + "&first_leader=" + this.data.getUserID; | ||
542 | - // if (this.data.isBuy == 0) { | ||
543 | - // pagePath += "&orderSn=" + this.data.orderSn; | ||
544 | - // } else { | ||
545 | - // pagePath += "&lbId=" + this.data.getGiftID; | ||
546 | - // } | ||
547 | - // console.log('pagePath', pagePath); | ||
548 | - return { | ||
549 | - title: "礼包详情", | ||
550 | - path: pagePath, | ||
551 | - } | ||
552 | - }, | 580 | + }, |
553 | 581 | ||
554 | /** | 582 | /** |
555 | * 用户分享朋友圈 | 583 | * 用户分享朋友圈 |
556 | */ | 584 | */ |
557 | onShareTimeline() { | 585 | onShareTimeline() { |
558 | - getApp().globalData.no_clear=1; | 586 | + getApp().globalData.no_clear = 1; |
559 | 587 | ||
560 | - var pagePath ="&isBuy=1" + "&lbId=" + this.data.lbId + "&first_leader=" + this.data.getUserID; | ||
561 | - var user_id=getApp().globalData.user_id; | ||
562 | - if(!user_id) user_id=0; | 588 | + var pagePath = "&isBuy=1" + "&lbId=" + this.data.lbId + "&first_leader=" + this.data.getUserID; |
589 | + var user_id = getApp().globalData.user_id; | ||
590 | + if (!user_id) user_id = 0; | ||
563 | 591 | ||
564 | return { | 592 | return { |
565 | title: "礼包详情", | 593 | title: "礼包详情", |
566 | - query: 'first_leader='+user_id+pagePath | 594 | + query: 'first_leader=' + user_id + pagePath |
567 | } | 595 | } |
568 | }, | 596 | }, |
569 | 597 | ||
570 | - //免费领取 | ||
571 | - GetFree: function (e) { | ||
572 | - var that = this.data; | ||
573 | - var th = this; | 598 | + //免费领取 |
599 | + GetFree: function (e) { | ||
600 | + var that = this.data; | ||
601 | + var th = this; | ||
574 | 602 | ||
575 | - //如果还没有开始的话 | ||
576 | - if (th.data.isStart != 1) { | ||
577 | - getApp().my_warnning("活动还没有开始", 0, th); | ||
578 | - return false; | ||
579 | - } | 603 | + //如果还没有开始的话 |
604 | + if (th.data.isStart != 1) { | ||
605 | + getApp().my_warnning("活动还没有开始", 0, th); | ||
606 | + return false; | ||
607 | + } | ||
580 | 608 | ||
581 | - th.setData({ buyType:3 }); | ||
582 | - if(th.data.sele_g.is_pickup){ | ||
583 | - th.setData({ | ||
584 | - openSpecModal:1 | ||
585 | - }) | ||
586 | - }else { | 609 | + th.setData({buyType: 3}); |
610 | + if (th.data.sele_g.is_pickup) { | ||
611 | + th.setData({ | ||
612 | + openSpecModal: 1 | ||
613 | + }) | ||
614 | + } else { | ||
587 | 615 | ||
588 | 616 | ||
589 | - // var id = e.currentTarget.dataset.id;//活动id | ||
590 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
591 | - my_confirm.open( | ||
592 | - "是否确定领取该礼包", | ||
593 | - "取消", | ||
594 | - "确定", | ||
595 | - function () { | ||
596 | - my_confirm.open_cancel(0); | ||
597 | - }, | ||
598 | - function () { | ||
599 | - my_confirm.open_cancel(0); | ||
600 | - com.buy_libao(th) | ||
601 | - }) | ||
602 | - } | 617 | + // var id = e.currentTarget.dataset.id;//活动id |
618 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
619 | + my_confirm.open( | ||
620 | + "是否确定领取该礼包", | ||
621 | + "取消", | ||
622 | + "确定", | ||
623 | + function () { | ||
624 | + my_confirm.open_cancel(0); | ||
625 | + }, | ||
626 | + function () { | ||
627 | + my_confirm.open_cancel(0); | ||
628 | + com.buy_libao(th) | ||
629 | + }) | ||
630 | + } | ||
603 | 631 | ||
604 | 632 | ||
605 | - }, | 633 | + }, |
606 | 634 | ||
607 | //--- 设置一下默认库存的数量 ---- | 635 | //--- 设置一下默认库存的数量 ---- |
608 | set_def_storage(ee) { | 636 | set_def_storage(ee) { |
@@ -623,7 +651,7 @@ Page({ | @@ -623,7 +651,7 @@ Page({ | ||
623 | var bconfig = th.data.bconfig; | 651 | var bconfig = th.data.bconfig; |
624 | 652 | ||
625 | //如果开启了,则不在选择门店 | 653 | //如果开启了,则不在选择门店 |
626 | - if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ | 654 | + if (this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store) { |
627 | return false; | 655 | return false; |
628 | } | 656 | } |
629 | if (!th.data.only_pk && !th.data.def_pickpu_list) { | 657 | if (!th.data.only_pk && !th.data.def_pickpu_list) { |
@@ -653,12 +681,12 @@ Page({ | @@ -653,12 +681,12 @@ Page({ | ||
653 | is_gps: 1 | 681 | is_gps: 1 |
654 | }); | 682 | }); |
655 | //th.onShow(); | 683 | //th.onShow(); |
656 | - com.get_sto(th,os); | 684 | + com.get_sto(th, os); |
657 | }, | 685 | }, |
658 | fail: function (res) { | 686 | fail: function (res) { |
659 | //th.onShow(); | 687 | //th.onShow(); |
660 | th.data.is_get_local_ok = 1; | 688 | th.data.is_get_local_ok = 1; |
661 | - com.get_sto(th,os); | 689 | + com.get_sto(th, os); |
662 | if (res.errCode == 2) { | 690 | if (res.errCode == 2) { |
663 | th.setData({ | 691 | th.setData({ |
664 | is_gps: 0 | 692 | is_gps: 0 |
@@ -676,7 +704,7 @@ Page({ | @@ -676,7 +704,7 @@ Page({ | ||
676 | }) | 704 | }) |
677 | } else { | 705 | } else { |
678 | th.data.is_get_local_ok = 1; | 706 | th.data.is_get_local_ok = 1; |
679 | - com.get_sto(th,os); | 707 | + com.get_sto(th, os); |
680 | } | 708 | } |
681 | 709 | ||
682 | if (ind != undefined && ind != null) { | 710 | if (ind != undefined && ind != null) { |
@@ -719,16 +747,14 @@ Page({ | @@ -719,16 +747,14 @@ Page({ | ||
719 | openSpecModal: !0, | 747 | openSpecModal: !0, |
720 | openSpecModal_ind: openindstore, | 748 | openSpecModal_ind: openindstore, |
721 | }); | 749 | }); |
722 | - } | ||
723 | - else if (openindstore == 4) { //4就是拼团 | 750 | + } else if (openindstore == 4) { //4就是拼团 |
724 | th.setData({ | 751 | th.setData({ |
725 | openSpecModal_pt: 1, //打开拼团购买界面 | 752 | openSpecModal_pt: 1, //打开拼团购买界面 |
726 | store: 0, //关闭门店 | 753 | store: 0, //关闭门店 |
727 | choice_sort_store: 0, //关闭门店2级 | 754 | choice_sort_store: 0, //关闭门店2级 |
728 | sort_store: 0, //关闭门店2级 | 755 | sort_store: 0, //关闭门店2级 |
729 | }); | 756 | }); |
730 | - } | ||
731 | - else { | 757 | + } else { |
732 | th.setData({ | 758 | th.setData({ |
733 | store: 0, | 759 | store: 0, |
734 | choice_sort_store: 0, | 760 | choice_sort_store: 0, |
@@ -844,7 +870,7 @@ Page({ | @@ -844,7 +870,7 @@ Page({ | ||
844 | openSpecModal: !0, | 870 | openSpecModal: !0, |
845 | }); | 871 | }); |
846 | 872 | ||
847 | - var user_id=getApp().globalData.user_id; | 873 | + var user_id = getApp().globalData.user_id; |
848 | var def_pickup_id = item.pickup_id; | 874 | var def_pickup_id = item.pickup_id; |
849 | getApp().request.put('/api/weshop/users/update', { | 875 | getApp().request.put('/api/weshop/users/update', { |
850 | data: { | 876 | data: { |
@@ -870,10 +896,379 @@ Page({ | @@ -870,10 +896,379 @@ Page({ | ||
870 | this.setData({openSpecModal: 0}); | 896 | this.setData({openSpecModal: 0}); |
871 | }, | 897 | }, |
872 | 898 | ||
873 | - buy_libao:function () { | 899 | + buy_libao: function () { |
874 | com.buy_libao(this) | 900 | com.buy_libao(this) |
875 | - } | 901 | + }, |
902 | + | ||
903 | + | ||
904 | + clickShare() { | ||
905 | + if (!getApp().globalData.user_id) { | ||
906 | + getApp().goto("/pages/togoin/togoin"); | ||
907 | + return false; | ||
908 | + } | ||
909 | + this.setData({ | ||
910 | + share_hidden: true, | ||
911 | + }); | ||
912 | + }, | ||
913 | + | ||
914 | + send() { | ||
915 | + this.setData({ | ||
916 | + share_hidden: false, | ||
917 | + }); | ||
918 | + }, | ||
919 | + | ||
920 | + cancel() { | ||
921 | + this.setData({ | ||
922 | + share_hidden: false, | ||
923 | + }); | ||
924 | + }, | ||
876 | 925 | ||
877 | 926 | ||
927 | + //--定义的保存图片方法,分享团--- | ||
928 | + saveImageToPhotosAlbum: function () { | ||
929 | + //--先判断会员状态-- | ||
930 | + var user_info = getApp().globalData.userInfo; | ||
931 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
932 | + //getApp().my_warnning("请先登录",0,this); | ||
933 | + wx.navigateTo({url: '/pages/togoin/togoin',}) | ||
934 | + return false; | ||
935 | + } | ||
936 | + | ||
937 | + if (this.data.share_hidden) { | ||
938 | + this.setData({share_hidden: false,}); | ||
939 | + } | ||
940 | + | ||
941 | + wx.showLoading({title: '生成中...',}) | ||
942 | + var that = this, th = that; | ||
943 | + //设置画板显示,才能开始绘图 | ||
944 | + that.setData({ | ||
945 | + canvasHidden: false | ||
946 | + }) | ||
947 | + | ||
948 | + var app = getApp(); | ||
949 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | ||
950 | + var scene = th.data.lbId + ""; | ||
951 | + | ||
952 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | ||
953 | + if (user_id > 0) { | ||
954 | + scene += "_" + user_id; | ||
955 | + } | ||
956 | + ///二微码 | ||
957 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | ||
958 | + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/giftpack/giftpacklist/giftpacklist"; | ||
959 | + | ||
960 | + console.log("11111"); | ||
961 | + console.log(path3); | ||
962 | + | ||
963 | + // 读取文件成功则OK-- | ||
964 | + wx.getImageInfo({ | ||
965 | + src: path3, | ||
966 | + success: function (res) { | ||
967 | + th.get_goods_temp(function () { | ||
968 | + var vpath = res.path; | ||
969 | + var context = wx.createCanvasContext('share'); | ||
970 | + th.drawPoster(context, unit, th.data.share_goods_img, vpath, 0); | ||
971 | + | ||
972 | + //把画板内容绘制成图片,并回调 画板图片路径 | ||
973 | + context.draw(false, function () { | ||
974 | + setTimeout(function () { | ||
975 | + wx.canvasToTempFilePath({ | ||
976 | + x: 0, | ||
977 | + y: 0, | ||
978 | + width: 750, | ||
979 | + height: 1217, | ||
980 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | ||
981 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | ||
982 | + canvasId: 'share', | ||
983 | + success: function (res) { | ||
984 | + | ||
985 | + | ||
986 | + console.log(res.tempFilePath) | ||
987 | + | ||
988 | + that.setData({ | ||
989 | + shareImgPath: res.tempFilePath, | ||
990 | + canvasHidden: true | ||
991 | + }) | ||
992 | + | ||
993 | + if (!res.tempFilePath) { | ||
994 | + wx.showModal({ | ||
995 | + title: '提示', | ||
996 | + content: '图片绘制中,请稍后重试', | ||
997 | + showCancel: false | ||
998 | + }) | ||
999 | + return false; | ||
1000 | + } | ||
1001 | + | ||
1002 | + that.setData({ | ||
1003 | + showPoster: true, | ||
1004 | + }); | ||
1005 | + wx.hideLoading(); | ||
1006 | + } | ||
1007 | + }) | ||
1008 | + }, 800) | ||
1009 | + | ||
1010 | + }); | ||
1011 | + }) | ||
1012 | + }, | ||
1013 | + fail: function (res) { | ||
1014 | + console.log(res); | ||
1015 | + wx.hideLoading(); | ||
1016 | + | ||
1017 | + } | ||
1018 | + }); | ||
1019 | + }, | ||
1020 | + | ||
1021 | + //-- 小程序绘制海报 -- | ||
1022 | + drawPoster(context, unit, img, vpath, type) { | ||
1023 | + // 1.灰色背景 | ||
1024 | + context.setFillStyle('#f2f1f6'); | ||
1025 | + context.rect(0, 0, 554 * unit, 899 * unit); | ||
1026 | + context.fill(); | ||
1027 | + | ||
1028 | + // 2.商城名称 | ||
1029 | + let shopName = this.data.sto_sele_name_1; | ||
1030 | + context.setTextAlign('center'); | ||
1031 | + context.setFontSize(26 * unit); | ||
1032 | + context.setFillStyle('black'); | ||
1033 | + context.fillText(shopName, 277 * unit, 60 * unit); | ||
1034 | + | ||
1035 | + // 3.推荐来源 | ||
1036 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | ||
1037 | + context.setTextAlign('center'); | ||
1038 | + context.setFontSize(22 * unit); | ||
1039 | + context.setFillStyle('#96959a'); | ||
1040 | + context.fillText(fromText, 277 * unit, 105 * unit); | ||
1041 | + | ||
1042 | + // 4.海报背景 | ||
1043 | + context.setFillStyle('white'); | ||
1044 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | ||
1045 | + | ||
1046 | + // 5.商品图片 | ||
1047 | + // 图片的x坐标 | ||
1048 | + let bg_x = 37 * unit | ||
1049 | + // 图片的y坐标 | ||
1050 | + let bg_y = 157 * unit | ||
1051 | + // 图片宽度 | ||
1052 | + let bg_w = 480 * unit | ||
1053 | + // 图片高度 | ||
1054 | + let bg_h = 474 * unit | ||
1055 | + // 图片圆角 | ||
1056 | + let bg_r = 4 | ||
1057 | + // 绘制海报背景图片圆角 | ||
1058 | + context.save() | ||
1059 | + context.beginPath() | ||
1060 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | ||
1061 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | ||
1062 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | ||
1063 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | ||
1064 | + context.clip() | ||
1065 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | ||
1066 | + context.restore(); | ||
1067 | + | ||
1068 | + // 6.强烈推荐 | ||
1069 | + let src = ''; | ||
1070 | + context.beginPath(); | ||
1071 | + if (type == 0) { // 普通 | ||
1072 | + src = '../../../images/share/q_tj.png'; | ||
1073 | + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | ||
1074 | + context.setFontSize(16 * unit) | ||
1075 | + context.setFillStyle("white") | ||
1076 | + context.setTextAlign('left'); | ||
1077 | + context.fillText('强烈推荐', 64 * unit, 668 * unit); | ||
1078 | + } | ||
1079 | + | ||
1080 | + | ||
1081 | + let price = this.data.giftPrice; | ||
1082 | + let giftIntegral = this.data.giftIntegral; | ||
1083 | + context.setFontSize(32 * unit); | ||
1084 | + context.setFillStyle('#DE1117'); | ||
1085 | + | ||
1086 | + var price_txt=""; | ||
1087 | + if(price || giftIntegral){ | ||
1088 | + if(price){ | ||
1089 | + price_txt='¥' + price; | ||
1090 | + if(giftIntegral) price_txt+='+'; | ||
1091 | + } | ||
1092 | + if(giftIntegral) price_txt+=giftIntegral+'积分'; | ||
1093 | + }else{ | ||
1094 | + price_txt="¥0"; | ||
1095 | + } | ||
1096 | + | ||
1097 | + context.fillText(price_txt, 54 * unit, 735 * unit); | ||
1098 | + | ||
1099 | + | ||
1100 | + // 8.商品标题 | ||
1101 | + context.setFontSize(20 * unit); | ||
1102 | + context.setFillStyle('#898989'); | ||
1103 | + this.draw_Text(context, this.data.giftTitle, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | ||
1104 | + | ||
1105 | + // 9.小程序码 | ||
1106 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | ||
1107 | + context.setFontSize(16 * unit); | ||
1108 | + context.setFillStyle('#777'); | ||
1109 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | ||
1110 | + | ||
1111 | + // 10.竖线 | ||
1112 | + context.beginPath(); | ||
1113 | + context.setFillStyle('#eee'); | ||
1114 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | ||
1115 | + context.fill(); | ||
1116 | + }, | ||
1117 | + | ||
1118 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
1119 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit, lineNum) { | ||
1120 | + var lineWidth = 0; | ||
1121 | + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | ||
1122 | + var han = 0; | ||
1123 | + for (let i = 0; i < str.length; i++) { | ||
1124 | + if(lineNum) { | ||
1125 | + if(han == lineNum) return; | ||
1126 | + }; | ||
1127 | + if (han == 2) return; | ||
1128 | + //lineWidth += ctx.measureText(str[i]).width; | ||
1129 | + lineWidth += ut.measureText(str[i], 21.3 * unit); | ||
1130 | + if (lineWidth > canvasWidth) { | ||
1131 | + han++; | ||
1132 | + | ||
1133 | + if (han == 2 || han == lineNum) | ||
1134 | + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | ||
1135 | + else | ||
1136 | + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | ||
1137 | + | ||
1138 | + initHeight += 22; //22为字体的高度 | ||
1139 | + lineWidth = 0; | ||
1140 | + lastSubStrIndex = i; | ||
1141 | + titleHeight += 20; | ||
1142 | + } | ||
1143 | + if (i == str.length - 1) { //绘制剩余部分 | ||
1144 | + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | ||
1145 | + } | ||
1146 | + }; | ||
1147 | + }, | ||
1148 | + | ||
1149 | + //--获取商品图片的本地缓存,回调写法-- | ||
1150 | + get_goods_temp: function (tt) { | ||
1151 | + var ee = this; | ||
1152 | + if (ee.data.share_goods_img) { | ||
1153 | + tt(); | ||
1154 | + return false; | ||
1155 | + } | ||
1156 | + var img_url = ee.data.giftImage; | ||
1157 | + //获取商品是分享图信息 | ||
1158 | + wx.getImageInfo({ | ||
1159 | + src: img_url, | ||
1160 | + success: function (res) { | ||
1161 | + //res.path是网络图片的本地地址 | ||
1162 | + ee.data.share_goods_img = res.path; | ||
1163 | + tt(); | ||
1164 | + }, | ||
1165 | + fail: function (res) { | ||
1166 | + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | ||
1167 | + tt(); | ||
1168 | + } | ||
1169 | + }); | ||
1170 | + }, | ||
1171 | + | ||
1172 | + closePoster() { | ||
1173 | + this.setData({ | ||
1174 | + showPoster: false, | ||
1175 | + }); | ||
1176 | + }, | ||
1177 | + | ||
1178 | + // 保存图片到手机 | ||
1179 | + savePic() { | ||
1180 | + console.log('保存图片'); | ||
1181 | + var self = this; | ||
1182 | + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | ||
1183 | + this.getSetting().then((res) => { | ||
1184 | + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | ||
1185 | + if (!res.authSetting['scope.writePhotosAlbum']) { | ||
1186 | + this.authorize().then(() => { | ||
1187 | + // 同意授权后保存下载文件 | ||
1188 | + this.saveImage(self.data.shareImgPath) | ||
1189 | + .then(() => { | ||
1190 | + self.setData({ | ||
1191 | + showPoster: false | ||
1192 | + }); | ||
1193 | + }); | ||
1194 | + }) | ||
1195 | + } else { | ||
1196 | + // 如果已经授权,保存下载文件 | ||
1197 | + this.saveImage(self.data.shareImgPath) | ||
1198 | + .then(() => { | ||
1199 | + self.setData({ | ||
1200 | + showPoster: false | ||
1201 | + }); | ||
1202 | + }); | ||
1203 | + } | ||
1204 | + | ||
1205 | + }) | ||
1206 | + }, | ||
1207 | + | ||
1208 | + // 获取用户已经授予了哪些权限 | ||
1209 | + getSetting() { | ||
1210 | + return new Promise((resolve, reject) => { | ||
1211 | + wx.getSetting({ | ||
1212 | + success: res => { | ||
1213 | + resolve(res) | ||
1214 | + } | ||
1215 | + }) | ||
1216 | + }) | ||
1217 | + }, | ||
1218 | + // 发起首次授权请求 | ||
1219 | + authorize() { | ||
1220 | + // isFirst 用来记录是否为首次发起授权, | ||
1221 | + // 如果首次授权拒绝后,isFirst赋值为1 | ||
1222 | + let isFirst = wx.getStorageSync('isFirst') || 0; | ||
1223 | + return new Promise((resolve, reject) => { | ||
1224 | + wx.authorize({ | ||
1225 | + scope: 'scope.writePhotosAlbum', | ||
1226 | + // 同意授权 | ||
1227 | + success: () => { | ||
1228 | + resolve(); | ||
1229 | + }, | ||
1230 | + // 拒绝授权,这里是用户拒绝授权后的回调 | ||
1231 | + fail: res => { | ||
1232 | + if (isFirst === 0) { | ||
1233 | + wx.setStorageSync('isFirst', 1); | ||
1234 | + wx.showToast({ | ||
1235 | + title: '保存失败', | ||
1236 | + icon: 'none', | ||
1237 | + duration: 1000 | ||
1238 | + }) | ||
1239 | + } else { | ||
1240 | + this.showModal(); | ||
1241 | + } | ||
1242 | + console.log('拒绝授权'); | ||
1243 | + reject(); | ||
1244 | + } | ||
1245 | + }) | ||
1246 | + }) | ||
1247 | + }, | ||
1248 | + // 保存图片到系统相册 | ||
1249 | + saveImage(saveUrl) { | ||
1250 | + var self = this; | ||
1251 | + return new Promise((resolve, reject) => { | ||
1252 | + wx.saveImageToPhotosAlbum({ | ||
1253 | + filePath: saveUrl, | ||
1254 | + success: (res) => { | ||
1255 | + wx.showToast({ | ||
1256 | + title: '保存成功', | ||
1257 | + duration: 1000, | ||
1258 | + }); | ||
1259 | + self.setData({ | ||
1260 | + showPlaybill: 'true' | ||
1261 | + }); | ||
1262 | + resolve(); | ||
1263 | + }, | ||
1264 | + fail: () => { | ||
1265 | + wx.showToast({ | ||
1266 | + title: '保存失败', | ||
1267 | + duration: 1000, | ||
1268 | + }); | ||
1269 | + } | ||
1270 | + }) | ||
1271 | + }) | ||
1272 | + }, | ||
878 | 1273 | ||
879 | }); | 1274 | }); |
880 | \ No newline at end of file | 1275 | \ No newline at end of file |
pages/giftpack/giftpacklist/giftpacklist.json
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | "warn": "/components/long_warn/long_warn", | 4 | "warn": "/components/long_warn/long_warn", |
5 | "my_confirm": "/components/my_confirm/my_confirm", | 5 | "my_confirm": "/components/my_confirm/my_confirm", |
6 | "qr_code": "/components/qr_code/qr_code", | 6 | "qr_code": "/components/qr_code/qr_code", |
7 | - "nav_b": "/components/nav_b/nav_b" | 7 | + "nav_b": "/components/nav_b/nav_b", |
8 | + "share": "/components/share/share" | ||
8 | } | 9 | } |
9 | } | 10 | } |
10 | \ No newline at end of file | 11 | \ No newline at end of file |
pages/giftpack/giftpacklist/giftpacklist.wxml
@@ -9,7 +9,15 @@ | @@ -9,7 +9,15 @@ | ||
9 | </view> | 9 | </view> |
10 | 10 | ||
11 | <view class="top_title data-v-3a5b7e36"> | 11 | <view class="top_title data-v-3a5b7e36"> |
12 | - <text class="data-v-3a5b7e36 ellipsis-2">{{giftTitle}}</text> | 12 | + <text class="data-v-3a5b7e36 ellipsis-2" style="width:90%;">{{giftTitle}}</text> |
13 | + | ||
14 | + <!-- 这个是分享按钮 --> | ||
15 | + <view wx:if="{{c_state<2}}" class="xc-share-frame t-c" bindtap="clickShare"> | ||
16 | + <view class="iconfont icon-share fs40" ></view> | ||
17 | + <view class="fs22 c-7b">分享</view> | ||
18 | + </view> | ||
19 | + | ||
20 | + | ||
13 | </view> | 21 | </view> |
14 | <view class="top_time data-v-3a5b7e36" wx:if="{{!flag}}"> | 22 | <view class="top_time data-v-3a5b7e36" wx:if="{{!flag}}"> |
15 | <block wx:if="{{isBuy==1 && giftTitle && isStart!=1}}" > | 23 | <block wx:if="{{isBuy==1 && giftTitle && isStart!=1}}" > |
@@ -17,6 +25,7 @@ | @@ -17,6 +25,7 @@ | ||
17 | {{"活动开始时间:"+giftStart}} | 25 | {{"活动开始时间:"+giftStart}} |
18 | </text> | 26 | </text> |
19 | </block> | 27 | </block> |
28 | + | ||
20 | <block wx:else> | 29 | <block wx:else> |
21 | <text class="data-v-3a5b7e36" wx:if="{{isBuy==0 && iswarelbtype}}">{{"兑换结束时间:"+giftDate}}</text> | 30 | <text class="data-v-3a5b7e36" wx:if="{{isBuy==0 && iswarelbtype}}">{{"兑换结束时间:"+giftDate}}</text> |
22 | <text class="data-v-3a5b7e36" wx:if="{{flag == 1}}"> | 31 | <text class="data-v-3a5b7e36" wx:if="{{flag == 1}}"> |
@@ -34,6 +43,8 @@ | @@ -34,6 +43,8 @@ | ||
34 | </view> | 43 | </view> |
35 | 44 | ||
36 | <view class="top_price data-v-3a5b7e36"> | 45 | <view class="top_price data-v-3a5b7e36"> |
46 | + | ||
47 | + | ||
37 | <block wx:if="{{giftPrice>0}}"> | 48 | <block wx:if="{{giftPrice>0}}"> |
38 | <text class="data-v-3a5b7e36">{{"¥"+giftPrice}}</text> | 49 | <text class="data-v-3a5b7e36">{{"¥"+giftPrice}}</text> |
39 | </block> | 50 | </block> |
@@ -46,6 +57,10 @@ | @@ -46,6 +57,10 @@ | ||
46 | <block wx:if="{{giftType>0}}"> | 57 | <block wx:if="{{giftType>0}}"> |
47 | <text class="data-v-3a5b7e36">{{actTitle}}</text> | 58 | <text class="data-v-3a5b7e36">{{actTitle}}</text> |
48 | </block> | 59 | </block> |
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | ||
49 | </view> | 64 | </view> |
50 | <view class="top_foot data-v-3a5b7e36"> | 65 | <view class="top_foot data-v-3a5b7e36"> |
51 | <view class="top_foot_price data-v-3a5b7e36"> | 66 | <view class="top_foot_price data-v-3a5b7e36"> |
@@ -209,4 +224,26 @@ | @@ -209,4 +224,26 @@ | ||
209 | <!-- 制作一个圆球导航 --> | 224 | <!-- 制作一个圆球导航 --> |
210 | <nav_b id="nav_b"></nav_b> | 225 | <nav_b id="nav_b"></nav_b> |
211 | 226 | ||
212 | -<include src="../public/buy_com.wxml"></include> | ||
213 | \ No newline at end of file | 227 | \ No newline at end of file |
228 | +<include src="../public/buy_com.wxml"></include> | ||
229 | +<canvas canvas-id='share' style='width:750rpx;height:1217rpx;background-color:white;' wx:if="{{!canvasHidden}}"></canvas> | ||
230 | +<share id="share_button" bind:send="send" bind:cancel="cancel" bind:share_img="saveImageToPhotosAlbum" wx:if="{{share_hidden}}"></share> | ||
231 | + | ||
232 | + | ||
233 | +<view wx:if="{{showPoster}}"> | ||
234 | + <view class="mask" catchtap="closePoster"></view> | ||
235 | + <view class="poster-container"> | ||
236 | + <view class="poster-wrapper"> | ||
237 | + <view class="poster" bindtap="previewPoster"> | ||
238 | + <!-- <view class="poster" bindtap="previewImage"> --> | ||
239 | + <image src="{{shareImgPath}}" class="poster-img"></image> | ||
240 | + <view class="btn-close" catchtap="closePoster"> | ||
241 | + <text class="iconfont icon-close"></text> | ||
242 | + </view> | ||
243 | + </view> | ||
244 | + <view class="btn-container"> | ||
245 | + <!-- <button class="btn-share" open-type="share" bindtap="">微信好友分享</button> --> | ||
246 | + <button class="btn-share" bindtap="savePic">保存到相册</button> | ||
247 | + </view> | ||
248 | + </view> | ||
249 | + </view> | ||
250 | +</view> | ||
214 | \ No newline at end of file | 251 | \ No newline at end of file |
pages/giftpack/giftpacklist/giftpacklist.wxss
@@ -26,6 +26,7 @@ | @@ -26,6 +26,7 @@ | ||
26 | .top_title.data-v-3a5b7e36 { | 26 | .top_title.data-v-3a5b7e36 { |
27 | font-size: 30rpx; | 27 | font-size: 30rpx; |
28 | margin-bottom: 10rpx; | 28 | margin-bottom: 10rpx; |
29 | + position: relative; | ||
29 | } | 30 | } |
30 | 31 | ||
31 | .top_time.data-v-3a5b7e36 { | 32 | .top_time.data-v-3a5b7e36 { |
@@ -38,6 +39,7 @@ | @@ -38,6 +39,7 @@ | ||
38 | color: #d61b30; | 39 | color: #d61b30; |
39 | margin-top: 30rpx; | 40 | margin-top: 30rpx; |
40 | margin-bottom: 5rpx; | 41 | margin-bottom: 5rpx; |
42 | + position: relative; | ||
41 | } | 43 | } |
42 | 44 | ||
43 | .top_foot.data-v-3a5b7e36 { | 45 | .top_foot.data-v-3a5b7e36 { |
@@ -244,3 +246,7 @@ page.data-v-3a5b7e36 { | @@ -244,3 +246,7 @@ page.data-v-3a5b7e36 { | ||
244 | 246 | ||
245 | .foot_button_intalge.data-v-3a5b7e36.gray{ background-color: #aaa; } | 247 | .foot_button_intalge.data-v-3a5b7e36.gray{ background-color: #aaa; } |
246 | 248 | ||
249 | +.xc-share-frame { | ||
250 | + position: absolute; right:0; top: -10rpx; | ||
251 | +} | ||
252 | + |