Commit b168f0ebb26e50de10f0eb717e3a6a1ce879b496

Authored by WXD-SEASON\season
2 parents 3ea4d263 de190e5c

Merge branch 'dev_oa_luo13' into dev

components/store_popup/store_popup.js
@@ -314,10 +314,12 @@ Component({ @@ -314,10 +314,12 @@ Component({
314 314
315 }, 315 },
316 close_popup() { 316 close_popup() {
  317 + this.triggerEvent('closeback',{})
317 this.setData({ 318 this.setData({
318 store: 0, 319 store: 0,
319 keyword:'' 320 keyword:''
320 }) 321 })
  322 +
321 }, 323 },
322 //选择更多门店 324 //选择更多门店
323 more_store: function () { 325 more_store: function () {
components/store_popup/store_popup.wxml
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 <block wx:if="{{choice_sort_store==0}}"> 28 <block wx:if="{{choice_sort_store==0}}">
29 <!-- 需要for循环 --> 29 <!-- 需要for循环 -->
30 <block wx:if="{{is_show_sto_cat==1}}"> 30 <block wx:if="{{is_show_sto_cat==1}}">
31 - <view class="store_choose flex" wx:for="{{def_pickpu_list}}" bindtap="choose_for_store_fir" data-ind="{{index}}"> 31 + <view class="store_choose flex" wx:for="{{def_pickpu_list}}" wx:key="{{index}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
32 <view class="store flex-vertical"> 32 <view class="store flex-vertical">
33 <!-- 需要点击事件 --> 33 <!-- 需要点击事件 -->
34 <block wx:if="{{index==fir_pick_index}}"> 34 <block wx:if="{{index==fir_pick_index}}">
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 </view> 54 </view>
55 </block> 55 </block>
56 <block wx:else> 56 <block wx:else>
57 - <view class="store_choose flex" wx:for="{{only_pk}}" bindtap="choose_for_store_fir" data-ind="{{index}}"> 57 + <view class="store_choose flex" wx:for="{{only_pk}}" wx:key="{{index}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
58 <view class="store flex-vertical"> 58 <view class="store flex-vertical">
59 <!-- 需要点击事件 --> 59 <!-- 需要点击事件 -->
60 <block wx:if="{{index==fir_pick_index}}"> 60 <block wx:if="{{index==fir_pick_index}}">
@@ -82,7 +82,7 @@ @@ -82,7 +82,7 @@
82 </block> 82 </block>
83 <block wx:else> 83 <block wx:else>
84 <!-- 如果是点击选择门店分类后显示分类下的门店 --> 84 <!-- 如果是点击选择门店分类后显示分类下的门店 -->
85 - <view class="store_choose flex" wx:for="{{sec_sto.s_arr}}" data-ind="{{index}}" bindtap="choose_for_store"> 85 + <view class="store_choose flex" wx:for="{{sec_sto.s_arr}}" wx:key="{{index}}" data-ind="{{index}}" bindtap="choose_for_store">
86 <view class="store flex-vertical"> 86 <view class="store flex-vertical">
87 <!-- 需要点击事件 --> 87 <!-- 需要点击事件 -->
88 <block wx:if="{{index==sec_pick_index}}"> 88 <block wx:if="{{index==sec_pick_index}}">
@@ -133,7 +133,7 @@ @@ -133,7 +133,7 @@
133 </view> 133 </view>
134 </view> 134 </view>
135 <view class="sort_store_list"> 135 <view class="sort_store_list">
136 - <view class="sort-store-frame" wx:for="{{all_sto}}" data-index="{{index}}" bindtap="choice_sort_store" data-region="{{item.name}}"> 136 + <view class="sort-store-frame" wx:for="{{all_sto}}" wx:key="{{index}}" data-index="{{index}}" bindtap="choice_sort_store" data-region="{{item.name}}">
137 <view class="sort-store flex-vertical-between"> 137 <view class="sort-store flex-vertical-between">
138 <view class="fs30" di>{{item.name}}</view> 138 <view class="fs30" di>{{item.name}}</view>
139 <view class="black_rights-frame"> 139 <view class="black_rights-frame">
packageB/pages/luckactivity/luckinfo/luckinfo.js
@@ -4,1406 +4,1489 @@ const app = getApp(); @@ -4,1406 +4,1489 @@ const app = getApp();
4 let imghost = app.globalData.setting.imghost; 4 let imghost = app.globalData.setting.imghost;
5 let self = null; 5 let self = null;
6 let imgDraw = { 6 let imgDraw = {
7 - "width": "554px",  
8 - "height": "899px",  
9 - "background": imghost + "miniapp/images/share_bg.png",  
10 - "views": [  
11 - { //0.头像  
12 - "type": "image",  
13 - // "url": app.globalData.userInfo.head_pic,  
14 - "css": {  
15 - "background": "white",  
16 - "width": "80px",  
17 - "height": "80px",  
18 - "top": "24px",  
19 - "left": "40px",  
20 - "borderRadius": "80px",  
21 - }  
22 - },  
23 - { //1.昵称  
24 - "type": "text",  
25 - // "text": "",  
26 - "css": {  
27 - "color": "#000000",  
28 - "width": "400px",  
29 - "top": "25px",  
30 - "left": "140px",  
31 - "fontSize": "26px",  
32 - "maxLines": "1",  
33 - }  
34 - },  
35 - { //2.强烈推荐  
36 - "type": "text",  
37 - "text": "强烈推荐",  
38 - "css": {  
39 - "color": "#fff",  
40 - "background": "#FF6768",  
41 - "width": "105px",  
42 - "height": "26px",  
43 - "lineHeight": "26px",  
44 - "top": "70px",  
45 - "left": "140px",  
46 - "borderRadius": "10px",  
47 - "fontSize": "18px",  
48 - "textAlign": "center"  
49 -  
50 - }  
51 - },  
52 - { //3.分享标题  
53 - "type": "text",  
54 - "text": "",  
55 - "css": {  
56 - "width": "554px",  
57 - "padding": "20px",  
58 - "left": "20px",  
59 - "top": "160px",  
60 - "fontSize": "28px",  
61 - "textAlign": "left",  
62 - "maxLines": "1",  
63 - }  
64 - },  
65 - { //4.分享内容  
66 - "type": "text",  
67 - // "text": "",  
68 - "css": {  
69 - "color": "#000000",  
70 - "width": "554px",  
71 - "padding": "20px",  
72 - "left": "20px",  
73 - "top": "190px",  
74 - "fontSize": "26px",  
75 - "textAlign": "center",  
76 - "maxLines": "1",  
77 - }  
78 - },  
79 - { //5.分享图片  
80 - "type": "image",  
81 - "url": "/packageB/images/luckDraw/jiang.png",  
82 - "css": {  
83 - "width": "auto",  
84 - "height": "380px",  
85 - "top": "220px",  
86 - "left": "277px",  
87 - "align": "center",  
88 - "mode": "aspectFill",  
89 - }  
90 - },  
91 - { //6  
92 - "type": "image",  
93 - "url": "/images/share/s_gou.png",  
94 - "css": {  
95 - "width": "30px",  
96 - "height": "30px",  
97 - "top": "630px",  
98 - "left": "18px",  
99 - "rotate": "0",  
100 - "borderRadius": "30px",  
101 - }  
102 - },  
103 - { //7  
104 - "type": "text",  
105 - "text": "正品保障",  
106 - "css": {  
107 - "color": "red",  
108 - "width": "110px",  
109 - "top": "630px",  
110 - "left": "52px",  
111 - "fontSize": "22px",  
112 - }  
113 - },  
114 - { //8  
115 - "type": "image",  
116 - "url": "/images/share/s_gou.png",  
117 - "css": {  
118 - "width": "30px",  
119 - "height": "30px",  
120 - "top": "630px",  
121 - "left": "208px",  
122 - "borderRadius": "30px",  
123 - }  
124 - },  
125 - { //9  
126 - "type": "text",  
127 - "text": "纯实体店",  
128 - "css": {  
129 - "color": "red",  
130 - "width": "129px",  
131 - "top": "630px",  
132 - "left": "243px",  
133 - "fontSize": "22px",  
134 - }  
135 - },  
136 - { //10  
137 - "type": "image",  
138 - "url": "/images/share/s_gou.png",  
139 - "css": {  
140 - "width": "30px",  
141 - "height": "30px",  
142 - "top": "630px",  
143 - "left": "410px",  
144 - "borderRadius": "30px",  
145 - }  
146 - },  
147 - { //11  
148 - "type": "text",  
149 - "text": "官方验证",  
150 - "css": {  
151 - "color": "red",  
152 - "width": "121px",  
153 - "top": "630px",  
154 - "left": "450px",  
155 - "fontSize": "22px",  
156 - }  
157 - },  
158 - { //12.横线  
159 - "type": "rect",  
160 - "css": {  
161 - "color": "#eee",  
162 - "width": "548px",  
163 - "height": "1px",  
164 - "top": "676px",  
165 - "left": "277px",  
166 - "align": "center",  
167 - }  
168 - },  
169 - { //13  
170 - "type": "text",  
171 - "text": "特惠活动时间仅限",  
172 - "css": {  
173 - "color": "#000000",  
174 - "width": "245px",  
175 - "top": "730px",  
176 - "left": "28px",  
177 - "fontSize": "24px",  
178 - "textAlign": "left"  
179 - }  
180 - },  
181 - { //14.时间  
182 - "type": "text",  
183 - // "text": "",  
184 - "css": {  
185 - "width": "377px",  
186 - "top": "770px",  
187 - "left": "28px",  
188 - "fontSize": "24px",  
189 - }  
190 - },  
191 - { //15  
192 - "type": "text",  
193 - "text": "长按识别小程序码有惊喜哦!",  
194 - "css": {  
195 - "color": "#7c7c7c",  
196 - "width": "348px",  
197 - "top": "820px",  
198 - "left": "27px",  
199 - "fontSize": "24px",  
200 - }  
201 - },  
202 -  
203 - { //16.码  
204 - "type": "image",  
205 - // "url": "",  
206 - "css": {  
207 - "width": "150px",  
208 - "height": "150px",  
209 - "top": "715px",  
210 - "left": "380px",  
211 - "mode": "scaleToFill"  
212 - }  
213 - },  
214 -  
215 - ]  
216 - };  
217 - 7 + "width": "554px",
  8 + "height": "899px",
  9 + "background": imghost + "miniapp/images/share_bg.png",
  10 + "views": [
  11 + { //0.头像
  12 + "type": "image",
  13 + // "url": app.globalData.userInfo.head_pic,
  14 + "css": {
  15 + "background": "white",
  16 + "width": "80px",
  17 + "height": "80px",
  18 + "top": "24px",
  19 + "left": "40px",
  20 + "borderRadius": "80px",
  21 + }
  22 + },
  23 + { //1.昵称
  24 + "type": "text",
  25 + // "text": "",
  26 + "css": {
  27 + "color": "#000000",
  28 + "width": "400px",
  29 + "top": "25px",
  30 + "left": "140px",
  31 + "fontSize": "26px",
  32 + "maxLines": "1",
  33 + }
  34 + },
  35 + { //2.强烈推荐
  36 + "type": "text",
  37 + "text": "强烈推荐",
  38 + "css": {
  39 + "color": "#fff",
  40 + "background": "#FF6768",
  41 + "width": "105px",
  42 + "height": "26px",
  43 + "lineHeight": "26px",
  44 + "top": "70px",
  45 + "left": "140px",
  46 + "borderRadius": "10px",
  47 + "fontSize": "18px",
  48 + "textAlign": "center"
  49 +
  50 + }
  51 + },
  52 + { //3.分享标题
  53 + "type": "text",
  54 + "text": "",
  55 + "css": {
  56 + "width": "554px",
  57 + "padding": "20px",
  58 + "left": "20px",
  59 + "top": "160px",
  60 + "fontSize": "28px",
  61 + "textAlign": "left",
  62 + "maxLines": "1",
  63 + }
  64 + },
  65 + { //4.分享内容
  66 + "type": "text",
  67 + // "text": "",
  68 + "css": {
  69 + "color": "#000000",
  70 + "width": "554px",
  71 + "padding": "20px",
  72 + "left": "20px",
  73 + "top": "190px",
  74 + "fontSize": "26px",
  75 + "textAlign": "center",
  76 + "maxLines": "1",
  77 + }
  78 + },
  79 + { //5.分享图片
  80 + "type": "image",
  81 + "url": "/packageB/images/luckDraw/jiang.png",
  82 + "css": {
  83 + "width": "auto",
  84 + "height": "380px",
  85 + "top": "220px",
  86 + "left": "277px",
  87 + "align": "center",
  88 + "mode": "aspectFill",
  89 + }
  90 + },
  91 + { //6
  92 + "type": "image",
  93 + "url": "/images/share/s_gou.png",
  94 + "css": {
  95 + "width": "30px",
  96 + "height": "30px",
  97 + "top": "630px",
  98 + "left": "18px",
  99 + "rotate": "0",
  100 + "borderRadius": "30px",
  101 + }
  102 + },
  103 + { //7
  104 + "type": "text",
  105 + "text": "正品保障",
  106 + "css": {
  107 + "color": "red",
  108 + "width": "110px",
  109 + "top": "630px",
  110 + "left": "52px",
  111 + "fontSize": "22px",
  112 + }
  113 + },
  114 + { //8
  115 + "type": "image",
  116 + "url": "/images/share/s_gou.png",
  117 + "css": {
  118 + "width": "30px",
  119 + "height": "30px",
  120 + "top": "630px",
  121 + "left": "208px",
  122 + "borderRadius": "30px",
  123 + }
  124 + },
  125 + { //9
  126 + "type": "text",
  127 + "text": "纯实体店",
  128 + "css": {
  129 + "color": "red",
  130 + "width": "129px",
  131 + "top": "630px",
  132 + "left": "243px",
  133 + "fontSize": "22px",
  134 + }
  135 + },
  136 + { //10
  137 + "type": "image",
  138 + "url": "/images/share/s_gou.png",
  139 + "css": {
  140 + "width": "30px",
  141 + "height": "30px",
  142 + "top": "630px",
  143 + "left": "410px",
  144 + "borderRadius": "30px",
  145 + }
  146 + },
  147 + { //11
  148 + "type": "text",
  149 + "text": "官方验证",
  150 + "css": {
  151 + "color": "red",
  152 + "width": "121px",
  153 + "top": "630px",
  154 + "left": "450px",
  155 + "fontSize": "22px",
  156 + }
  157 + },
  158 + { //12.横线
  159 + "type": "rect",
  160 + "css": {
  161 + "color": "#eee",
  162 + "width": "548px",
  163 + "height": "1px",
  164 + "top": "676px",
  165 + "left": "277px",
  166 + "align": "center",
  167 + }
  168 + },
  169 + { //13
  170 + "type": "text",
  171 + "text": "特惠活动时间仅限",
  172 + "css": {
  173 + "color": "#000000",
  174 + "width": "245px",
  175 + "top": "730px",
  176 + "left": "28px",
  177 + "fontSize": "24px",
  178 + "textAlign": "left"
  179 + }
  180 + },
  181 + { //14.时间
  182 + "type": "text",
  183 + // "text": "",
  184 + "css": {
  185 + "width": "377px",
  186 + "top": "770px",
  187 + "left": "28px",
  188 + "fontSize": "24px",
  189 + }
  190 + },
  191 + { //15
  192 + "type": "text",
  193 + "text": "长按识别小程序码有惊喜哦!",
  194 + "css": {
  195 + "color": "#7c7c7c",
  196 + "width": "348px",
  197 + "top": "820px",
  198 + "left": "27px",
  199 + "fontSize": "24px",
  200 + }
  201 + },
  202 +
  203 + { //16.码
  204 + "type": "image",
  205 + // "url": "",
  206 + "css": {
  207 + "width": "150px",
  208 + "height": "150px",
  209 + "top": "715px",
  210 + "left": "380px",
  211 + "mode": "scaleToFill"
  212 + }
  213 + },
  214 +
  215 + ]
  216 +};
  217 +
218 218
219 Page({ 219 Page({
220 data: { 220 data: {
221 - imgDraw: imgDraw,  
222 -  
223 - start: false,  
224 - list: null,  
225 - isLoading: false, // 检测是否已经发送请求,防止重复发送请求  
226 - noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据  
227 - pageNum: 1, // 当前页数  
228 - imghost: imghost,  
229 - num: 3,  
230 - canStart: false,  
231 -  
232 - 221 + imgDraw: imgDraw,
  222 +
  223 + start: false,
  224 + list: null,
  225 + isLoading: false, // 检测是否已经发送请求,防止重复发送请求
  226 + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据
  227 + pageNum: 1, // 当前页数
  228 + imghost: imghost,
  229 + num: 3,
  230 + canStart: false,
  231 + // store:1,
233 prizes: [], 232 prizes: [],
234 - defaultConfig: {  
235 - offsetDegree: 22.5,  
236 - }, 233 + defaultConfig: {
  234 + offsetDegree: 22.5,
  235 + },
237 // defaultStyle: { 236 // defaultStyle: {
238 // fontColor: '#d64737', 237 // fontColor: '#d64737',
239 // fontSize: '14px' 238 // fontSize: '14px'
240 // }, 239 // },
241 blocks: [{ 240 blocks: [{
242 - padding: '76rpx',  
243 - imgs: [{  
244 - src: imghost + 'miniapp/images/luckDraw/weel.png?v=3',  
245 - width: '700rpx',  
246 - height: '700rpx',  
247 - rotate: true,  
248 - }],  
249 - }], 241 + padding: '76rpx',
  242 + imgs: [{
  243 + src: imghost + 'miniapp/images/luckDraw/weel.png?v=3',
  244 + width: '700rpx',
  245 + height: '700rpx',
  246 + rotate: true,
  247 + }],
  248 + }],
250 buttons: [{ 249 buttons: [{
251 - radius: '60rpx',  
252 - imgs: [{  
253 - src: imghost + 'miniapp/images/luckDraw/pointer.png?v=3',  
254 - width: '188rpx',  
255 - height: '230rpx',  
256 - top: '-130rpx',  
257 - }],  
258 - }], 250 + radius: '60rpx',
  251 + imgs: [{
  252 + src: imghost + 'miniapp/images/luckDraw/pointer.png?v=3',
  253 + width: '188rpx',
  254 + height: '230rpx',
  255 + top: '-130rpx',
  256 + }],
  257 + }],
  258 + },
  259 +
  260 + onLoad(options) {
  261 + self = this;
  262 + let first_leader = null;
  263 + this.data.options = options;
  264 +
  265 +
  266 + wx.setNavigationBarTitle({
  267 + title: options.title,
  268 + });
  269 +
  270 +
  271 + app.isLogin().then(function (data) {//进入页面前已经授权登录成功
  272 + self.setData({
  273 + userInfo: data,
  274 + });
  275 + });
  276 +
  277 +
  278 +
  279 + //从分享的跳转过来
  280 + if (options.id == undefined || options.id == null || options.id == '') {
  281 + var scene = decodeURIComponent(options.scene);
  282 + scene = scene.split('_');
  283 + first_leader = scene[0];
  284 + this.data.options.id = scene[1];
  285 + };
  286 +
  287 + if (first_leader) {
  288 + // console.log("log---", first_leader);
  289 + app.globalData.first_leader = first_leader;
  290 + //调用接口判断是不是会员
  291 + app.request.promiseGet("/api/weshop/shoppingGuide/get/" + app.globalData.setting.stoid + "/" + first_leader, {}).then(res => {
  292 + if (res.data.code == 0) {
  293 + app.globalData.guide_id = res.data.data.id;
  294 + }
  295 + })
  296 + };
  297 +
259 }, 298 },
260 -  
261 - onLoad(options) {  
262 - self = this;  
263 - let first_leader = null;  
264 - this.data.options = options;  
265 -  
266 -  
267 - wx.setNavigationBarTitle({  
268 - title: options.title,  
269 - });  
270 -  
271 -  
272 - app.isLogin().then(function(data) {//进入页面前已经授权登录成功  
273 - self.setData({  
274 - userInfo: data,  
275 - });  
276 - });  
277 -  
278 -  
279 -  
280 - //从分享的跳转过来  
281 - if (options.id == undefined || options.id == null || options.id == '') {  
282 - var scene = decodeURIComponent(options.scene);  
283 - scene = scene.split('_');  
284 - first_leader = scene[0];  
285 - this.data.options.id = scene[1];  
286 - };  
287 -  
288 - if(first_leader) {  
289 - // console.log("log---", first_leader);  
290 - app.globalData.first_leader = first_leader;  
291 - //调用接口判断是不是会员  
292 - app.request.promiseGet("/api/weshop/shoppingGuide/get/" + app.globalData.setting.stoid +"/" + first_leader,{}).then(res=>{  
293 - if(res.data.code==0){  
294 - app.globalData.guide_id = res.data.data.id;  
295 - }  
296 - })  
297 - };  
298 -  
299 - },  
300 -  
301 - onShow() {  
302 - // console.log('show~~`');  
303 -  
304 - if(app.globalData.userInfo) {  
305 - if(!this.data.isLogin) {  
306 -  
307 - // 下载头像  
308 - let path = app.globalData.userInfo.head_pic;  
309 - path = path.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");  
310 - path = path.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");  
311 - wx.downloadFile({  
312 - url: path, //仅为示例,并非真实的资源  
313 - success (res) {  
314 - // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容  
315 - if (res.statusCode === 200) {  
316 - self.setData({  
317 - 'imgDraw.views[0].url': res.tempFilePath,//头像  
318 - });  
319 -  
320 - }  
321 - }  
322 - });  
323 -  
324 -  
325 - this.setData({  
326 - userInfo: app.globalData.userInfo,  
327 - isLogin: true,  
328 - 'imgDraw.views[1].text': app.globalData.userInfo.nickname,//昵称  
329 - });  
330 -  
331 -  
332 - // console.log('imgDraw.views[1].text+++++++++', imgDraw.views[1], app.globalData.userInfo.nickname);  
333 - let user_id = app.globalData.userInfo.user_id;  
334 - let store_id = app.globalData.setting.stoid;  
335 - let id = this.data.options.id;  
336 - let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`;  
337 -  
338 - //获取小程序码  
339 - this.getMiniCode({  
340 - url: app.globalData.setting.url,  
341 - store_id: app.globalData.setting.stoid,  
342 - user_id: app.globalData.userInfo.user_id,  
343 - id: this.data.options.id,  
344 - });  
345 -  
346 -  
347 - app.request.get(url, {  
348 - success: function(res) {  
349 - if(res.data.code == 0) {  
350 - self.setData({  
351 - luckInfo: res.data.data,  
352 - });  
353 - WxParse.wxParse('content', 'html', self.data.luckInfo.remark, self);  
354 -  
355 - // 如果is_share为1,隐藏发送给朋友和分享到朋友圈功能  
356 - if(!self.data.luckInfo.is_share) {  
357 - wx.hideShareMenu();  
358 - };  
359 -  
360 - } else {  
361 - wx.showToast({  
362 - title: res.data.msg,  
363 - icon: 'none',  
364 - });  
365 - self.data.msg = res.data.msg;  
366 - // self.setData({  
367 - // bannerUrl: imghost + 'miniapp/images/luckDraw/bg.png?v=2',  
368 - // 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘  
369 - // 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针  
370 - // });  
371 -  
372 - };  
373 -  
374 - // console.log('luckInfo', res.data.data);  
375 - let luckInfo = res.data.data;  
376 -  
377 -  
378 -  
379 - self.setData({  
380 - 'imgDraw.views[3].text': self.data.luckInfo.act_name,//分享标题  
381 - // 'imgDraw.views[4].text': '快来一起抽奖吧,精美奖品等着你!',//分享内容  
382 - 'imgDraw.views[14].text': util.formar_no_full(luckInfo.begindate) + ' 至 ' + util.formar_no_full(luckInfo.enddate),//活动时间  
383 - });  
384 -  
385 -  
386 -  
387 - let luckStyle = null;  
388 -  
389 -  
390 - if(luckInfo && luckInfo.template_type != null && luckInfo.template_type == 1) { //获取模板  
391 - let url = `/api/weshop/marketing/marketingLuckTemplate/get/0/${luckInfo.template_id}`;  
392 - app.request.get(url, {  
393 - success: function(res) {  
394 - let template = null;  
395 - if(res.data.code == 0) {  
396 - template = res.data.data;  
397 - self.setData({  
398 - template,  
399 - bannerUrl: imghost + template.bannerUrl, //背景图  
400 - 'blocks[0].imgs[0].src': imghost + ((template&&template.wheelBaseUrl) ? template.wheelBaseUrl:'miniapp/images/luckDraw/weel.png?v=3'),  
401 - 'buttons[0].imgs[0].src': imghost + ((template&&template.wheelPointerUrl) ? template.wheelPointerUrl:'miniapp/images/luckDraw/pointer.png?v=3'), //指针  
402 - 'imgDraw.views[3].text': template.share_title ? template.share_title:self.data.luckInfo.act_name, //分享标题  
403 - 'imgDraw.views[5].url': imghost + (template&&template.share_image ? template.share_image:self.data.luckInfo.imageurl), //分享图片  
404 -  
405 - });  
406 -  
407 - let color = template&&template.colorCode ? template.colorCode:'#da104b';  
408 - luckStyle = `background: ${color} url(${self.data.bannerUrl}) no-repeat;`;  
409 - self.setData({  
410 - luckStyle,  
411 -  
412 - });  
413 - // self.setData({  
414 - // template: res.data.data,  
415 - // bannerUrl: imghost + res.data.data.bannerUrl, //背景图  
416 - // //bannerUrl: imghost + ((res.data.data&&res.data.data.bannerUrl) ? res.data.data.bannerUrl:'miniapp/images/luckDraw/bg.png?v=2'), //背景图  
417 - // 'blocks[0].imgs[0].src': imghost + res.data.data&&res.data.data.wheelBaseUrl) ? res.data.data.wheelBaseUrl:'miniapp/images/luckDraw/weel.png?v=2'), //转盘  
418 - // 'buttons[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelPointerUrl) ? res.data.data.wheelPointerUrl:'miniapp/images/luckDraw/pointer.png?v=2'), //指针  
419 - // 'imgDraw.views[3].text': (res.data.data&&res.data.data.title) ? res.data.data.title : self.data.luckInfo.act_name,//分享标题  
420 - // // 'imgDraw.views[4].text': (res.data.data&&res.data.data.share_content) ? res.data.data.share_content : '快来一起抽奖吧,精美奖品等着你!',//分享内容  
421 - // 'imgDraw.views[5].url': (res.data.data&&res.data.data.share_image) ? (imghost + res.data.data.share_image):(self.data.luckInfo.imageurl ? (imghost + self.data.luckInfo.imageurl):'/packpageB/images/luckDraw/jiang.png'),//分享图片  
422 - // 'imgDraw.views[14].text': util.formar_no_full(self.data.luckInfo.begindate) + ' 至 ' + util.formar_no_full(self.data.luckInfo.enddate),//活动时间  
423 - // });  
424 - } else {  
425 - luckStyle = `background: #da104b url(${imghost + 'miniapp/images/luckDraw/bg.png?v=2'}) no-repeat;`;  
426 - self.setData({  
427 - luckStyle,  
428 - 'imgDraw.views[5].url': self.data.luckInfo.imageurl ? (imghost + self.data.luckInfo.imageurl):'/packageB/images/luckDraw/jiang.png', //分享图片  
429 - 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘  
430 - 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针  
431 - });  
432 - // let color = template&&template.colorCode ? template.colorCode:'#da104b';  
433 -  
434 - // self.setData({  
435 - // luckStyle,  
436 - // });  
437 - };  
438 -  
439 - },  
440 - });  
441 - } else {  
442 -  
443 - if(luckInfo && luckInfo.imageurl) {  
444 - self.setData({  
445 - 'imgDraw.views[5].url': imghost + self.data.luckInfo.imageurl, //分享图片  
446 - });  
447 - };  
448 -  
449 - if(luckInfo && luckInfo.store_bannerUrl) {  
450 - self.setData({  
451 - bannerUrl: imghost + luckInfo.store_bannerUrl,  
452 - custom: true,  
453 - });  
454 - } else {  
455 - self.setData({  
456 - bannerUrl: imghost + 'miniapp/images/luckDraw/bg.png?v=2',  
457 - custom: false,  
458 - });  
459 - };  
460 -  
461 - let color = self.data.custom ? '#f0f0f0':'#da104b';  
462 - luckStyle = `background: ${color} url(${self.data.bannerUrl}) no-repeat;`;  
463 - self.setData({  
464 - luckStyle,  
465 - 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘  
466 - 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针  
467 - });  
468 -  
469 - };  
470 -  
471 -  
472 - if(self.data.luckInfo.msgInfo) {  
473 - wx.showToast({  
474 - title: self.data.luckInfo.msgInfo,  
475 - icon: 'none',  
476 - });  
477 - };  
478 -  
479 - },  
480 - });  
481 -  
482 - // 获取奖品展示的奖品  
483 - app.request.get('/api/weshop/marketing/marketingLuckList/page', {  
484 - data: {  
485 - store_id,  
486 - luck_formid: id,  
487 - },  
488 - success: function(res) {  
489 -  
490 - let award = res.data.data.pageData;  
491 - self.setData({  
492 - award,  
493 - });  
494 - // console.log('award', award);  
495 - self.prizeLayout(award);  
496 -  
497 - },  
498 - });  
499 -  
500 -  
501 - //获取兑奖记录  
502 - app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {  
503 - isShowLoading: false,  
504 - data: {  
505 - store_id: app.globalData.setting.stoid,  
506 - user_id: app.globalData.userInfo.user_id,  
507 - luck_formid: this.data.options.id,  
508 - luck_state: 1  
509 - },  
510 - success: function(res) {  
511 - if(res.data.code == 0) {  
512 - self.setData({  
513 - record: res.data.data.pageData,  
514 - });  
515 - }  
516 - },  
517 - });  
518 -  
519 -  
520 - //获取中奖人员名单  
521 - app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {  
522 - isShowLoading: false,  
523 - data: {  
524 - store_id: app.globalData.setting.stoid,  
525 - luck_formid: this.data.options.id,  
526 - luck_state: 1,  
527 - pageSize: 20,  
528 - },  
529 - success: function(res) {  
530 - if(res.data.code == 0) {  
531 - self.setData({  
532 - nameList: res.data.data.pageData,  
533 - });  
534 - };  
535 - },  
536 - });  
537 -  
538 -  
539 -  
540 -  
541 - };  
542 - };  
543 - },  
544 -  
545 - //获取小程序码  
546 - getMiniCode(objData) {  
547 - wx.getImageInfo({  
548 - src: `${objData.url}/api/wx/open/app/user/getWeAppEwm/${objData.store_id}?sceneValue=${objData.user_id}_${objData.id}&pageValue=packageB/pages/luckactivity/luckinfo/luckinfo`,  
549 - success (res) {  
550 - if(res.code != -1) {  
551 - self.setData({  
552 - 'imgDraw.views[16].url': res.path,  
553 - getMiniCode: true,  
554 - });  
555 - };  
556 - }  
557 - });  
558 - },  
559 -  
560 - // 设置转盘奖品布局  
561 - prizeLayout(award) {  
562 - let prizes = [];  
563 - // let length = award.length;  
564 - if(award) {  
565 - var length = award.length;  
566 - } else {  
567 - wx.showToast({  
568 - title: '请设置奖品',  
569 - icon: 'none',  
570 - });  
571 - return;  
572 - };  
573 -  
574 - let thx = {fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'rgba(255,255,255,.6)'}]};  
575 -  
576 - if(length == 1) {  
577 - [0,2,4,6].map(function(item, index) {  
578 - prizes[item] = {  
579 - id: award[0].id,  
580 - lbtype: award[0].lbtype,  
581 - fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
582 - imgs: [  
583 - {  
584 - src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
585 - width: '135rpx',  
586 - height: '107rpx',  
587 - top: '12%',  
588 - }  
589 - ],  
590 - };  
591 - });  
592 -  
593 - [1,3,5,7].map(function(item, index) {  
594 - prizes[item] = thx;  
595 - });  
596 -  
597 - this.data.thxIndexArr = [1,3,5,7];  
598 - };  
599 -  
600 - if(length == 2) {  
601 - [0,4].map(function(item, index) {  
602 - prizes[item] = {  
603 - id: award[0].id,  
604 - lbtype: award[0].lbtype,  
605 - fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
606 - imgs: [  
607 - {  
608 - src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
609 - width: '135rpx',  
610 - height: '107rpx',  
611 - top: '12%',  
612 - }  
613 - ],  
614 - };  
615 - });  
616 -  
617 - [2,6].map(function(item, index) {  
618 - prizes[item] = {  
619 - id: award[1].id,  
620 - lbtype: award[1].lbtype,  
621 - fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
622 - imgs: [  
623 - {  
624 - src: self.prizeSrc(award[1].lbtype) ? self.prizeSrc(award[1].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
625 - width: '135rpx',  
626 - height: '107rpx',  
627 - top: '12%',  
628 - }  
629 - ],  
630 - };  
631 - });  
632 -  
633 - [1,3,5,7].map(function(item, index) {  
634 - prizes[item] = thx;  
635 - });  
636 - this.data.thxIndexArr = [1,3,5,7];  
637 - };  
638 -  
639 -  
640 - if(length == 3) {  
641 - [0,4].map(function(item, index) {  
642 - prizes[item] = {  
643 - id: award[0].id,  
644 - lbtype: award[0].lbtype,  
645 - fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
646 - imgs: [  
647 - {  
648 - src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
649 - width: '135rpx',  
650 - height: '107rpx',  
651 - top: '12%',  
652 - }  
653 - ],  
654 - };  
655 - });  
656 -  
657 - [1,5].map(function(item, index) {  
658 - prizes[item] = {  
659 - id: award[1].id,  
660 - lbtype: award[1].lbtype,  
661 - fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
662 - imgs: [  
663 - {  
664 - src: self.prizeSrc(award[1].lbtype) ? self.prizeSrc(award[1].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
665 - width: '135rpx',  
666 - height: '107rpx',  
667 - top: '12%',  
668 - }  
669 - ],  
670 - };  
671 - });  
672 -  
673 - [2,6].map(function(item, index) {  
674 - prizes[item] = {  
675 - id: award[2].id,  
676 - lbtype: award[2].lbtype,  
677 - fonts: [{ text: award[2].luck_goods_name + ' x' + award[2].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
678 - imgs: [  
679 - {  
680 - src: self.prizeSrc(award[2].lbtype) ? self.prizeSrc(award[2].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
681 - width: '135rpx',  
682 - height: '107rpx',  
683 - top: '12%',  
684 - }  
685 - ],  
686 - };  
687 - });  
688 -  
689 - [3,7].map(function(item, index) {  
690 - prizes[item] = thx;  
691 - });  
692 -  
693 - this.data.thxIndexArr = [3,7];  
694 - };  
695 -  
696 -  
697 - if(length == 4) {  
698 - [0,2,4,6].map(function(item, index) {  
699 - prizes[item] = {  
700 - id: award[index].id,  
701 - lbtype: award[index].lbtype,  
702 - fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
703 - imgs: [  
704 - {  
705 - src: self.prizeSrc(award[index].lbtype) ? self.prizeSrc(award[index].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
706 - width: '135rpx',  
707 - height: '107rpx',  
708 - top: '12%',  
709 - }  
710 - ],  
711 - };  
712 - });  
713 -  
714 - [1,3,5,7].map(function(item, index) {  
715 - prizes[item] = thx;  
716 - });  
717 -  
718 - this.data.thxIndexArr = [1,3,5,7];  
719 - };  
720 -  
721 - if(length == 5) {  
722 - [0,2,3,5,6].map(function(item, index) {  
723 - prizes[item] = {  
724 - id: award[index].id,  
725 - lbtype: award[index].lbtype,  
726 - fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
727 - imgs: [  
728 - {  
729 - src: self.prizeSrc(award[index].lbtype) ? self.prizeSrc(award[index].lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
730 - width: '135rpx',  
731 - height: '107rpx',  
732 - top: '12%',  
733 - }  
734 - ],  
735 - };  
736 - });  
737 -  
738 - [1,4,7].map(function(item, index) {  
739 - prizes[item] = thx;  
740 - });  
741 -  
742 - this.data.thxIndexArr = [1,4,7];  
743 - };  
744 -  
745 - if(length == 6) {  
746 - prizes = award.map(function(item, index) {  
747 - return {  
748 - id: item.id,  
749 - lbtype: item.lbtype,  
750 - fonts: [{ text: item.luck_goods_name + ' x' + item.num, top: '18%', wordWrap:false, fontColor: 'transparent'}],  
751 - imgs: [  
752 - {  
753 - src: self.prizeSrc(item.lbtype) ? self.prizeSrc(item.lbtype): (imghost + 'miniapp/images/luckDraw/lb.png'),  
754 - width: '135rpx',  
755 - height: '107rpx',  
756 - top: '12%',  
757 - }  
758 - ],  
759 - };  
760 - });  
761 -  
762 - prizes.push(thx);  
763 - prizes.splice(3, 0, thx);  
764 -  
765 - this.data.thxIndexArr = [3,7];  
766 - };  
767 -  
768 - // console.log('prizes', prizes);  
769 -  
770 - this.setData({  
771 - prizes,  
772 - });  
773 - },  
774 -  
775 - // 根据lbtype指定奖品类别图标  
776 - prizeSrc(lbtype) {  
777 - let src = '';  
778 - switch(lbtype) {  
779 - case 1: { //积分  
780 - src = imghost + 'miniapp/images/luckDraw/jf.png';  
781 - break;  
782 - };  
783 - case 2: { //成长值  
784 - src = imghost + 'miniapp/images/luckDraw/czz.png';  
785 - break;  
786 - };  
787 - case 3: { //优惠券  
788 - src = imghost + 'miniapp/images/luckDraw/yhq.png';  
789 - break;  
790 - };  
791 - case 4: { //服务项目  
792 - src = imghost + 'miniapp/images/luckDraw/fw.png';  
793 - break;  
794 - };  
795 - case 5: { //赠品  
796 - src = imghost + 'miniapp/images/luckDraw/zp.png';  
797 - break;  
798 - };  
799 - case 6: { //礼包  
800 - src = imghost + 'miniapp/images/luckDraw/lb.png';  
801 - break;  
802 - };  
803 - };  
804 - return src;  
805 - },  
806 -  
807 - // 获取抽奖结果匹配对应奖品在奖品列表里的所有索引号  
808 - luckyIndex(arr, target) {  
809 - var results=[],  
810 - len = arr.length,  
811 - pos = 0;  
812 - while(pos < len){  
813 - // pos = arr[pos].indexOf(target, pos);  
814 - if(arr[pos].id == target) {  
815 - results.push(pos);//找到就存储索引  
816 -  
817 - };  
818 - pos += 1;//并从下个位置开始搜索  
819 - // if(pos === -1){//未找到就退出循环完成搜索  
820 - // break;  
821 - // };  
822 -  
823 - }  
824 - // console.log('当前奖品列表', this.data.prizes);  
825 - // console.log('中奖结果在当前奖品列表中的索引', results);  
826 -  
827 - return results;  
828 - },  
829 -  
830 - start () {  
831 - // self.data.start = true;  
832 - if(this.data.start) return;  
833 - this.data.start = true;  
834 -  
835 - if(!this.data.luckInfo) {  
836 - wx.showToast({  
837 - title: this.data.msg,  
838 - icon: 'none',  
839 - });  
840 - return;  
841 - };  
842 -  
843 - if(this.data.luckInfo.msgInfo) {  
844 - wx.showToast({  
845 - title: self.data.luckInfo.msgInfo,  
846 - icon: 'none',  
847 - success: function() {  
848 - self.setData({  
849 - start: false  
850 - });  
851 - }  
852 - });  
853 - return;  
854 - };  
855 - wx.showLoading({  
856 - title: '准备开始抽奖',  
857 - mask: true,  
858 - });  
859 - // 获取积分  
860 - app.request.promisePost('/api/weshop/marketing/marketingLuckForm/startLuckIntegral', {  
861 - isShowLoading: false,  
862 - data: {  
863 - storeId: app.globalData.setting.stoid,  
864 - userId: app.globalData.userInfo.user_id,  
865 - LuckId: this.data.options.id,  
866 - },  
867 - })  
868 - .then(function(res) {  
869 - if(res.data.code == -1) {  
870 - //积分不足,弹出提示  
871 - wx.hideLoading();  
872 - self.data.luckInfo.msgInfo = res.data.msg  
873 - wx.showToast({  
874 - title: res.data.msg,  
875 - icon: 'none',  
876 - success: function() {  
877 - self.data.start = false;  
878 - }  
879 - });  
880 - return;  
881 - };  
882 -  
883 - if(res.data.code == 0) {  
884 -  
885 - if(self.data.luckInfo.user_LuckNumDay > 0 || self.data.luckInfo.vip_act_num == 0) {  
886 - // console.log('start choujiang');  
887 - // let start = false;  
888 - if(self.data.start) {  
889 - // self.data.start = true;  
890 - // 获取抽奖组件实例  
891 - const $lucky = self.selectComponent('#myLucky');  
892 - // 调用play方法开始旋转  
893 - $lucky.play();  
894 - wx.hideLoading();  
895 - // 获取抽奖结果  
896 - app.request.post('/api/weshop/marketing/marketingLuckForm/startLuck', {  
897 - isShowLoading: false,  
898 - data: {  
899 - storeId: app.globalData.setting.stoid,  
900 - userId: app.globalData.userInfo.user_id,  
901 - LuckId: self.data.options.id,  
902 - },  
903 - success: function(res) {  
904 -  
905 - if(res.data.code == 0) {  
906 - // console.log('开始摇奖', res.data.data);  
907 - if(self.data.luckInfo.vip_act_num != 0) {  
908 - self.setData({  
909 - 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,  
910 - // isActive: true,  
911 - });  
912 - };  
913 -  
914 - self.setData({  
915 - // 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,  
916 - isActive: true,  
917 - wow: res.data.data,  
918 - });  
919 - // console.log('wow', self.data.wow);  
920 - // console.log('请求成功', res.data.data);  
921 - let luckyId = res.data.data.id;  
922 - let indexArr = self.luckyIndex(self.data.prizes, luckyId);  
923 - // console.log('抽奖奖品id', luckyId);  
924 - // console.log('奖品列表', self.data.prizes);  
925 - // console.log('奖品对应的索引数组', indexArr);  
926 - let random = Math.random() * indexArr.length >> 0;  
927 - // console.log('random', random);  
928 - let index = indexArr[random];  
929 -  
930 - $lucky.stop(index);  
931 -  
932 - // setTimeout(() => {  
933 - // Promise.resolve($lucky.stop(index)).then(()=>{  
934 - // self.data.start = false;  
935 - // });  
936 -  
937 - // }, 2000);  
938 -  
939 -  
940 - //获取兑奖记录  
941 - // app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {  
942 - // isShowLoading: false,  
943 - // data: {  
944 - // store_id: app.globalData.setting.stoid,  
945 - // user_id: app.globalData.userInfo.user_id,  
946 - // luck_formid: self.data.options.id,  
947 - // luck_state: 1  
948 - // },  
949 - // success: function(res) {  
950 - // if(res.data.code == 0) {  
951 - // // console.log('res===>', res.data.data.pageData);  
952 - // self.setData({  
953 - // record: res.data.data.pageData,  
954 - // });  
955 - // };  
956 - // },  
957 - // });  
958 -  
959 -  
960 - } else {  
961 - let thxIndexArr = self.data.thxIndexArr;  
962 - const random = Math.random() * thxIndexArr.length >> 0;  
963 - const index = thxIndexArr[random];  
964 - // console.log('谢谢参与数组', thxIndexArr);  
965 - // console.log('请求出错产生谢谢参与的随机数', index);  
966 - $lucky.stop(index);  
967 - // setTimeout(() => {  
968 - // Promise.resolve($lucky.stop(index)).then(()=>{  
969 - // self.data.start = false;  
970 - // });  
971 - // }, 2000);  
972 -  
973 -  
974 -  
975 -  
976 - if(res.data.code == -1) {  
977 - wx.showToast({  
978 - title: res.data.msg,  
979 - icon: 'none',  
980 - success: function() {  
981 - self.setData({  
982 - start: false  
983 - });  
984 - }  
985 - });  
986 - self.data.luckInfo.msgInfo = res.data.msg;  
987 - return;  
988 - // self.data.start = true;  
989 - };  
990 -  
991 -  
992 - if(res.data.code == -2 && self.data.luckInfo.vip_act_num != 0) {  
993 - self.setData({  
994 - 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,  
995 - });  
996 - };  
997 -  
998 -  
999 - };  
1000 -  
1001 -  
1002 - },  
1003 -  
1004 - fail: function(res) {  
1005 - // console.log('出错');  
1006 - wx.showToast({  
1007 - title: '数据请求失败',  
1008 - icon: 'error',  
1009 - });  
1010 - let thxIndexArr = self.data.thxIndexArr;  
1011 - const random = Math.random() * thxIndexArr.length >> 0;  
1012 - const index = thxIndexArr[random];  
1013 - $lucky.stop(index);  
1014 - // setTimeout(() => {  
1015 - // Promise.resolve($lucky.stop(index)).then(()=>{  
1016 - // self.data.start = false;  
1017 - // });  
1018 - // }, 2000);  
1019 - },  
1020 -  
1021 -  
1022 -  
1023 - });  
1024 -  
1025 - }  
1026 -  
1027 -  
1028 - } else {  
1029 - wx.showToast({  
1030 - title: '你今天的抽奖次数已用完啦!~',  
1031 - icon: 'none',  
1032 - success: function() {  
1033 - self.setData({  
1034 - start: false  
1035 - });  
1036 - }  
1037 - });  
1038 - };  
1039 -  
1040 - };  
1041 - });  
1042 -  
1043 -  
1044 -  
1045 -  
1046 - 299 +
  300 + onShow() {
  301 + // console.log('show~~`');
  302 +
  303 + if (app.globalData.userInfo) {
  304 + if (!this.data.isLogin) {
  305 +
  306 + // 下载头像
  307 + let path = app.globalData.userInfo.head_pic;
  308 + path = path.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
  309 + path = path.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
  310 + wx.downloadFile({
  311 + url: path, //仅为示例,并非真实的资源
  312 + success(res) {
  313 + // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  314 + if (res.statusCode === 200) {
  315 + self.setData({
  316 + 'imgDraw.views[0].url': res.tempFilePath,//头像
  317 + });
  318 +
  319 + }
  320 + }
  321 + });
  322 +
  323 +
  324 + this.setData({
  325 + userInfo: app.globalData.userInfo,
  326 + isLogin: true,
  327 + 'imgDraw.views[1].text': app.globalData.userInfo.nickname,//昵称
  328 + });
  329 +
  330 +
  331 + // console.log('imgDraw.views[1].text+++++++++', imgDraw.views[1], app.globalData.userInfo.nickname);
  332 + let user_id = app.globalData.userInfo.user_id;
  333 + let store_id = app.globalData.setting.stoid;
  334 + let id = this.data.options.id;
  335 + let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`;
  336 +
  337 + //获取小程序码
  338 + this.getMiniCode({
  339 + url: app.globalData.setting.url,
  340 + store_id: app.globalData.setting.stoid,
  341 + user_id: app.globalData.userInfo.user_id,
  342 + id: this.data.options.id,
  343 + });
  344 +
  345 +
  346 + app.request.get(url, {
  347 + success: function (res) {
  348 + if (res.data.code == 0) {
  349 + self.setData({
  350 + luckInfo: res.data.data,
  351 + });
  352 + WxParse.wxParse('content', 'html', self.data.luckInfo.remark, self);
  353 +
  354 + // 如果is_share为1,隐藏发送给朋友和分享到朋友圈功能
  355 + if (!self.data.luckInfo.is_share) {
  356 + wx.hideShareMenu();
  357 + };
  358 +
  359 + } else {
  360 + wx.showToast({
  361 + title: res.data.msg,
  362 + icon: 'none',
  363 + });
  364 + self.data.msg = res.data.msg;
  365 + // self.setData({
  366 + // bannerUrl: imghost + 'miniapp/images/luckDraw/bg.png?v=2',
  367 + // 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘
  368 + // 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针
  369 + // });
  370 +
  371 + };
  372 +
  373 + // console.log('luckInfo', res.data.data);
  374 + let luckInfo = res.data.data;
  375 +
  376 +
  377 +
  378 + self.setData({
  379 + 'imgDraw.views[3].text': self.data.luckInfo.act_name,//分享标题
  380 + // 'imgDraw.views[4].text': '快来一起抽奖吧,精美奖品等着你!',//分享内容
  381 + 'imgDraw.views[14].text': util.formar_no_full(luckInfo.begindate) + ' 至 ' + util.formar_no_full(luckInfo.enddate),//活动时间
  382 + });
  383 +
  384 +
  385 +
  386 + let luckStyle = null;
  387 +
  388 +
  389 + if (luckInfo && luckInfo.template_type != null && luckInfo.template_type == 1) { //获取模板
  390 + let url = `/api/weshop/marketing/marketingLuckTemplate/get/0/${luckInfo.template_id}`;
  391 + app.request.get(url, {
  392 + success: function (res) {
  393 + let template = null;
  394 + if (res.data.code == 0) {
  395 + template = res.data.data;
  396 + self.setData({
  397 + template,
  398 + bannerUrl: imghost + template.bannerUrl, //背景图
  399 + 'blocks[0].imgs[0].src': imghost + ((template && template.wheelBaseUrl) ? template.wheelBaseUrl : 'miniapp/images/luckDraw/weel.png?v=3'),
  400 + 'buttons[0].imgs[0].src': imghost + ((template && template.wheelPointerUrl) ? template.wheelPointerUrl : 'miniapp/images/luckDraw/pointer.png?v=3'), //指针
  401 + 'imgDraw.views[3].text': template.share_title ? template.share_title : self.data.luckInfo.act_name, //分享标题
  402 + 'imgDraw.views[5].url': imghost + (template && template.share_image ? template.share_image : self.data.luckInfo.imageurl), //分享图片
  403 +
  404 + });
  405 +
  406 + let color = template && template.colorCode ? template.colorCode : '#da104b';
  407 + luckStyle = `background: ${color} url(${self.data.bannerUrl}) no-repeat;`;
  408 + self.setData({
  409 + luckStyle,
  410 +
  411 + });
  412 + // self.setData({
  413 + // template: res.data.data,
  414 + // bannerUrl: imghost + res.data.data.bannerUrl, //背景图
  415 + // //bannerUrl: imghost + ((res.data.data&&res.data.data.bannerUrl) ? res.data.data.bannerUrl:'miniapp/images/luckDraw/bg.png?v=2'), //背景图
  416 + // 'blocks[0].imgs[0].src': imghost + res.data.data&&res.data.data.wheelBaseUrl) ? res.data.data.wheelBaseUrl:'miniapp/images/luckDraw/weel.png?v=2'), //转盘
  417 + // 'buttons[0].imgs[0].src': imghost + ((res.data.data&&res.data.data.wheelPointerUrl) ? res.data.data.wheelPointerUrl:'miniapp/images/luckDraw/pointer.png?v=2'), //指针
  418 + // 'imgDraw.views[3].text': (res.data.data&&res.data.data.title) ? res.data.data.title : self.data.luckInfo.act_name,//分享标题
  419 + // // 'imgDraw.views[4].text': (res.data.data&&res.data.data.share_content) ? res.data.data.share_content : '快来一起抽奖吧,精美奖品等着你!',//分享内容
  420 + // 'imgDraw.views[5].url': (res.data.data&&res.data.data.share_image) ? (imghost + res.data.data.share_image):(self.data.luckInfo.imageurl ? (imghost + self.data.luckInfo.imageurl):'/packpageB/images/luckDraw/jiang.png'),//分享图片
  421 + // 'imgDraw.views[14].text': util.formar_no_full(self.data.luckInfo.begindate) + ' 至 ' + util.formar_no_full(self.data.luckInfo.enddate),//活动时间
  422 + // });
  423 + } else {
  424 + luckStyle = `background: #da104b url(${imghost + 'miniapp/images/luckDraw/bg.png?v=2'}) no-repeat;`;
  425 + self.setData({
  426 + luckStyle,
  427 + 'imgDraw.views[5].url': self.data.luckInfo.imageurl ? (imghost + self.data.luckInfo.imageurl) : '/packageB/images/luckDraw/jiang.png', //分享图片
  428 + 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘
  429 + 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针
  430 + });
  431 + // let color = template&&template.colorCode ? template.colorCode:'#da104b';
  432 +
  433 + // self.setData({
  434 + // luckStyle,
  435 + // });
  436 + };
  437 +
  438 + },
  439 + });
  440 + } else {
  441 +
  442 + if (luckInfo && luckInfo.imageurl) {
  443 + self.setData({
  444 + 'imgDraw.views[5].url': imghost + self.data.luckInfo.imageurl, //分享图片
  445 + });
  446 + };
  447 +
  448 + if (luckInfo && luckInfo.store_bannerUrl) {
  449 + self.setData({
  450 + bannerUrl: imghost + luckInfo.store_bannerUrl,
  451 + custom: true,
  452 + });
  453 + } else {
  454 + self.setData({
  455 + bannerUrl: imghost + 'miniapp/images/luckDraw/bg.png?v=2',
  456 + custom: false,
  457 + });
  458 + };
  459 +
  460 + let color = self.data.custom ? '#f0f0f0' : '#da104b';
  461 + luckStyle = `background: ${color} url(${self.data.bannerUrl}) no-repeat;`;
  462 + self.setData({
  463 + luckStyle,
  464 + 'blocks[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/weel.png?v=3', //转盘
  465 + 'buttons[0].imgs[0].src': imghost + 'miniapp/images/luckDraw/pointer.png?v=3', //指针
  466 + });
  467 +
  468 + };
  469 +
  470 +
  471 + if (self.data.luckInfo.msgInfo) {
  472 + wx.showToast({
  473 + title: self.data.luckInfo.msgInfo,
  474 + icon: 'none',
  475 + });
  476 + };
  477 +
  478 + },
  479 + });
  480 +
  481 + // 获取奖品展示的奖品
  482 + app.request.get('/api/weshop/marketing/marketingLuckList/page', {
  483 + data: {
  484 + store_id,
  485 + luck_formid: id,
  486 + },
  487 + success: function (res) {
  488 +
  489 + let award = res.data.data.pageData;
  490 + self.setData({
  491 + award,
  492 + });
  493 + // console.log('award', award);
  494 + self.prizeLayout(award);
  495 +
  496 + },
  497 + });
  498 +
  499 +
  500 + //获取兑奖记录
  501 + app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {
  502 + isShowLoading: false,
  503 + data: {
  504 + store_id: app.globalData.setting.stoid,
  505 + user_id: app.globalData.userInfo.user_id,
  506 + luck_formid: this.data.options.id,
  507 + luck_state: 1
  508 + },
  509 + success: function (res) {
  510 + if (res.data.code == 0) {
  511 + self.setData({
  512 + record: res.data.data.pageData,
  513 + });
  514 + }
  515 + },
  516 + });
  517 +
  518 +
  519 + //获取中奖人员名单
  520 + app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {
  521 + isShowLoading: false,
  522 + data: {
  523 + store_id: app.globalData.setting.stoid,
  524 + luck_formid: this.data.options.id,
  525 + luck_state: 1,
  526 + pageSize: 20,
  527 + },
  528 + success: function (res) {
  529 + if (res.data.code == 0) {
  530 + self.setData({
  531 + nameList: res.data.data.pageData,
  532 + });
  533 + };
  534 + },
  535 + });
  536 +
  537 +
  538 +
  539 +
  540 + };
  541 + };
  542 + },
  543 +
  544 + //获取小程序码
  545 + getMiniCode(objData) {
  546 + wx.getImageInfo({
  547 + src: `${objData.url}/api/wx/open/app/user/getWeAppEwm/${objData.store_id}?sceneValue=${objData.user_id}_${objData.id}&pageValue=packageB/pages/luckactivity/luckinfo/luckinfo`,
  548 + success(res) {
  549 + if (res.code != -1) {
  550 + self.setData({
  551 + 'imgDraw.views[16].url': res.path,
  552 + getMiniCode: true,
  553 + });
  554 + };
  555 + }
  556 + });
  557 + },
  558 +
  559 + // 设置转盘奖品布局
  560 + prizeLayout(award) {
  561 + let prizes = [];
  562 + // let length = award.length;
  563 + if (award) {
  564 + var length = award.length;
  565 + } else {
  566 + wx.showToast({
  567 + title: '请设置奖品',
  568 + icon: 'none',
  569 + });
  570 + return;
  571 + };
  572 +
  573 + let thx = { fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap: false, fontColor: 'rgba(255,255,255,.6)' }] };
  574 +
  575 + if (length == 1) {
  576 + [0, 2, 4, 6].map(function (item, index) {
  577 + prizes[item] = {
  578 + id: award[0].id,
  579 + lbtype: award[0].lbtype,
  580 + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  581 + imgs: [
  582 + {
  583 + src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  584 + width: '135rpx',
  585 + height: '107rpx',
  586 + top: '12%',
  587 + }
  588 + ],
  589 + };
  590 + });
  591 +
  592 + [1, 3, 5, 7].map(function (item, index) {
  593 + prizes[item] = thx;
  594 + });
  595 +
  596 + this.data.thxIndexArr = [1, 3, 5, 7];
  597 + };
  598 +
  599 + if (length == 2) {
  600 + [0, 4].map(function (item, index) {
  601 + prizes[item] = {
  602 + id: award[0].id,
  603 + lbtype: award[0].lbtype,
  604 + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  605 + imgs: [
  606 + {
  607 + src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  608 + width: '135rpx',
  609 + height: '107rpx',
  610 + top: '12%',
  611 + }
  612 + ],
  613 + };
  614 + });
  615 +
  616 + [2, 6].map(function (item, index) {
  617 + prizes[item] = {
  618 + id: award[1].id,
  619 + lbtype: award[1].lbtype,
  620 + fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  621 + imgs: [
  622 + {
  623 + src: self.prizeSrc(award[1].lbtype) ? self.prizeSrc(award[1].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  624 + width: '135rpx',
  625 + height: '107rpx',
  626 + top: '12%',
  627 + }
  628 + ],
  629 + };
  630 + });
  631 +
  632 + [1, 3, 5, 7].map(function (item, index) {
  633 + prizes[item] = thx;
  634 + });
  635 + this.data.thxIndexArr = [1, 3, 5, 7];
  636 + };
  637 +
  638 +
  639 + if (length == 3) {
  640 + [0, 4].map(function (item, index) {
  641 + prizes[item] = {
  642 + id: award[0].id,
  643 + lbtype: award[0].lbtype,
  644 + fonts: [{ text: award[0].luck_goods_name + ' x' + award[0].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  645 + imgs: [
  646 + {
  647 + src: self.prizeSrc(award[0].lbtype) ? self.prizeSrc(award[0].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  648 + width: '135rpx',
  649 + height: '107rpx',
  650 + top: '12%',
  651 + }
  652 + ],
  653 + };
  654 + });
  655 +
  656 + [1, 5].map(function (item, index) {
  657 + prizes[item] = {
  658 + id: award[1].id,
  659 + lbtype: award[1].lbtype,
  660 + fonts: [{ text: award[1].luck_goods_name + ' x' + award[1].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  661 + imgs: [
  662 + {
  663 + src: self.prizeSrc(award[1].lbtype) ? self.prizeSrc(award[1].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  664 + width: '135rpx',
  665 + height: '107rpx',
  666 + top: '12%',
  667 + }
  668 + ],
  669 + };
  670 + });
  671 +
  672 + [2, 6].map(function (item, index) {
  673 + prizes[item] = {
  674 + id: award[2].id,
  675 + lbtype: award[2].lbtype,
  676 + fonts: [{ text: award[2].luck_goods_name + ' x' + award[2].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  677 + imgs: [
  678 + {
  679 + src: self.prizeSrc(award[2].lbtype) ? self.prizeSrc(award[2].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  680 + width: '135rpx',
  681 + height: '107rpx',
  682 + top: '12%',
  683 + }
  684 + ],
  685 + };
  686 + });
  687 +
  688 + [3, 7].map(function (item, index) {
  689 + prizes[item] = thx;
  690 + });
  691 +
  692 + this.data.thxIndexArr = [3, 7];
  693 + };
  694 +
  695 +
  696 + if (length == 4) {
  697 + [0, 2, 4, 6].map(function (item, index) {
  698 + prizes[item] = {
  699 + id: award[index].id,
  700 + lbtype: award[index].lbtype,
  701 + fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  702 + imgs: [
  703 + {
  704 + src: self.prizeSrc(award[index].lbtype) ? self.prizeSrc(award[index].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  705 + width: '135rpx',
  706 + height: '107rpx',
  707 + top: '12%',
  708 + }
  709 + ],
  710 + };
  711 + });
  712 +
  713 + [1, 3, 5, 7].map(function (item, index) {
  714 + prizes[item] = thx;
  715 + });
  716 +
  717 + this.data.thxIndexArr = [1, 3, 5, 7];
  718 + };
  719 +
  720 + if (length == 5) {
  721 + [0, 2, 3, 5, 6].map(function (item, index) {
  722 + prizes[item] = {
  723 + id: award[index].id,
  724 + lbtype: award[index].lbtype,
  725 + fonts: [{ text: award[index].luck_goods_name + ' x' + award[index].num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  726 + imgs: [
  727 + {
  728 + src: self.prizeSrc(award[index].lbtype) ? self.prizeSrc(award[index].lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  729 + width: '135rpx',
  730 + height: '107rpx',
  731 + top: '12%',
  732 + }
  733 + ],
  734 + };
  735 + });
  736 +
  737 + [1, 4, 7].map(function (item, index) {
  738 + prizes[item] = thx;
  739 + });
  740 +
  741 + this.data.thxIndexArr = [1, 4, 7];
  742 + };
  743 +
  744 + if (length == 6) {
  745 + prizes = award.map(function (item, index) {
  746 + return {
  747 + id: item.id,
  748 + lbtype: item.lbtype,
  749 + fonts: [{ text: item.luck_goods_name + ' x' + item.num, top: '18%', wordWrap: false, fontColor: 'transparent' }],
  750 + imgs: [
  751 + {
  752 + src: self.prizeSrc(item.lbtype) ? self.prizeSrc(item.lbtype) : (imghost + 'miniapp/images/luckDraw/lb.png'),
  753 + width: '135rpx',
  754 + height: '107rpx',
  755 + top: '12%',
  756 + }
  757 + ],
  758 + };
  759 + });
  760 +
  761 + prizes.push(thx);
  762 + prizes.splice(3, 0, thx);
  763 +
  764 + this.data.thxIndexArr = [3, 7];
  765 + };
  766 +
  767 + // console.log('prizes', prizes);
  768 +
  769 + this.setData({
  770 + prizes,
  771 + });
  772 + },
  773 +
  774 + // 根据lbtype指定奖品类别图标
  775 + prizeSrc(lbtype) {
  776 + let src = '';
  777 + switch (lbtype) {
  778 + case 1: { //积分
  779 + src = imghost + 'miniapp/images/luckDraw/jf.png';
  780 + break;
  781 + };
  782 + case 2: { //成长值
  783 + src = imghost + 'miniapp/images/luckDraw/czz.png';
  784 + break;
  785 + };
  786 + case 3: { //优惠券
  787 + src = imghost + 'miniapp/images/luckDraw/yhq.png';
  788 + break;
  789 + };
  790 + case 4: { //服务项目
  791 + src = imghost + 'miniapp/images/luckDraw/fw.png';
  792 + break;
  793 + };
  794 + case 5: { //赠品
  795 + src = imghost + 'miniapp/images/luckDraw/zp.png';
  796 + break;
  797 + };
  798 + case 6: { //礼包
  799 + src = imghost + 'miniapp/images/luckDraw/lb.png';
  800 + break;
  801 + };
  802 + };
  803 + return src;
  804 + },
  805 +
  806 + // 获取抽奖结果匹配对应奖品在奖品列表里的所有索引号
  807 + luckyIndex(arr, target) {
  808 + var results = [],
  809 + len = arr.length,
  810 + pos = 0;
  811 + while (pos < len) {
  812 + // pos = arr[pos].indexOf(target, pos);
  813 + if (arr[pos].id == target) {
  814 + results.push(pos);//找到就存储索引
  815 +
  816 + };
  817 + pos += 1;//并从下个位置开始搜索
  818 + // if(pos === -1){//未找到就退出循环完成搜索
  819 + // break;
  820 + // };
  821 +
  822 + }
  823 + // console.log('当前奖品列表', this.data.prizes);
  824 + // console.log('中奖结果在当前奖品列表中的索引', results);
  825 +
  826 + return results;
  827 + },
  828 +
  829 + start() {
1047 830
  831 + // self.data.start = true;
  832 + if (this.data.start) return;
  833 + this.data.start = true;
  834 +
  835 + if (!this.data.luckInfo) {
  836 + wx.showToast({
  837 + title: this.data.msg,
  838 + icon: 'none',
  839 + });
  840 + return;
  841 + };
  842 +
  843 + if (this.data.luckInfo.msgInfo) {
  844 + wx.showToast({
  845 + title: self.data.luckInfo.msgInfo,
  846 + icon: 'none',
  847 + success: function () {
  848 + self.setData({
  849 + start: false
  850 + });
  851 + }
  852 + });
  853 + return;
  854 + };
  855 + wx.showLoading({
  856 + title: '准备开始抽奖',
  857 + mask: true,
  858 + });
  859 + // 获取积分
  860 + app.request.promisePost('/api/weshop/marketing/marketingLuckForm/startLuckIntegral', {
  861 + isShowLoading: false,
  862 + data: {
  863 + storeId: app.globalData.setting.stoid,
  864 + userId: app.globalData.userInfo.user_id,
  865 + LuckId: this.data.options.id,
  866 + },
  867 + })
  868 + .then(function (res) {
  869 + if (res.data.code == -1) {
  870 + //积分不足,弹出提示
  871 + wx.hideLoading();
  872 + self.data.luckInfo.msgInfo = res.data.msg
  873 + wx.showToast({
  874 + title: res.data.msg,
  875 + icon: 'none',
  876 + success: function () {
  877 + self.data.start = false;
  878 + }
  879 + });
  880 + return;
  881 + };
  882 +
  883 + if (res.data.code == 0) {
  884 +
  885 + if (self.data.luckInfo.user_LuckNumDay > 0 || self.data.luckInfo.vip_act_num == 0) {
  886 + // console.log('start choujiang');
  887 + // let start = false;
  888 + if (self.data.start) {
  889 + // self.data.start = true;
  890 + // 获取抽奖组件实例
  891 + const $lucky = self.selectComponent('#myLucky');
  892 + // 调用play方法开始旋转
  893 + $lucky.play();
  894 + wx.hideLoading();
  895 + // 获取抽奖结果
  896 + app.request.post('/api/weshop/marketing/marketingLuckForm/startLuck', {
  897 + isShowLoading: false,
  898 + data: {
  899 + storeId: app.globalData.setting.stoid,
  900 + userId: app.globalData.userInfo.user_id,
  901 + LuckId: self.data.options.id,
  902 + },
  903 + success: function (res) {
  904 +
  905 + if (res.data.code == 0) {
  906 + // console.log('开始摇奖', res.data.data);
  907 + if (self.data.luckInfo.vip_act_num != 0) {
  908 + self.setData({
  909 + 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  910 + // isActive: true,
  911 + });
  912 + };
  913 +
  914 + self.setData({
  915 + // 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  916 + isActive: true,
  917 + wow: res.data.data,
  918 + });
  919 + // console.log('wow', self.data.wow);
  920 + // console.log('请求成功', res.data.data);
  921 + let luckyId = res.data.data.id;
  922 + let indexArr = self.luckyIndex(self.data.prizes, luckyId);
  923 + // console.log('抽奖奖品id', luckyId);
  924 + // console.log('奖品列表', self.data.prizes);
  925 + // console.log('奖品对应的索引数组', indexArr);
  926 + let random = Math.random() * indexArr.length >> 0;
  927 + // console.log('random', random);
  928 + let index = indexArr[random];
  929 +
  930 + $lucky.stop(index);
  931 +
  932 + // setTimeout(() => {
  933 + // Promise.resolve($lucky.stop(index)).then(()=>{
  934 + // self.data.start = false;
  935 + // });
  936 +
  937 + // }, 2000);
  938 +
  939 +
  940 + //获取兑奖记录
  941 + // app.request.get('/api/weshop/marketing/marketingLuckRecord/page', {
  942 + // isShowLoading: false,
  943 + // data: {
  944 + // store_id: app.globalData.setting.stoid,
  945 + // user_id: app.globalData.userInfo.user_id,
  946 + // luck_formid: self.data.options.id,
  947 + // luck_state: 1
  948 + // },
  949 + // success: function(res) {
  950 + // if(res.data.code == 0) {
  951 + // // console.log('res===>', res.data.data.pageData);
  952 + // self.setData({
  953 + // record: res.data.data.pageData,
  954 + // });
  955 + // };
  956 + // },
  957 + // });
  958 +
  959 +
  960 + } else {
  961 + let thxIndexArr = self.data.thxIndexArr;
  962 + const random = Math.random() * thxIndexArr.length >> 0;
  963 + const index = thxIndexArr[random];
  964 + // console.log('谢谢参与数组', thxIndexArr);
  965 + // console.log('请求出错产生谢谢参与的随机数', index);
  966 + $lucky.stop(index);
  967 + // setTimeout(() => {
  968 + // Promise.resolve($lucky.stop(index)).then(()=>{
  969 + // self.data.start = false;
  970 + // });
  971 + // }, 2000);
  972 +
  973 +
  974 +
  975 +
  976 + if (res.data.code == -1) {
  977 + wx.showToast({
  978 + title: res.data.msg,
  979 + icon: 'none',
  980 + success: function () {
  981 + self.setData({
  982 + start: false
  983 + });
  984 + }
  985 + });
  986 + self.data.luckInfo.msgInfo = res.data.msg;
  987 + return;
  988 + // self.data.start = true;
  989 + };
  990 +
  991 +
  992 + if (res.data.code == -2 && self.data.luckInfo.vip_act_num != 0) {
  993 + self.setData({
  994 + 'luckInfo.user_LuckNumDay': self.data.luckInfo.user_LuckNumDay - 1,
  995 + });
  996 + };
  997 +
  998 +
  999 + };
  1000 +
  1001 +
  1002 + },
  1003 +
  1004 + fail: function (res) {
  1005 + // console.log('出错');
  1006 + wx.showToast({
  1007 + title: '数据请求失败',
  1008 + icon: 'error',
  1009 + });
  1010 + let thxIndexArr = self.data.thxIndexArr;
  1011 + const random = Math.random() * thxIndexArr.length >> 0;
  1012 + const index = thxIndexArr[random];
  1013 + $lucky.stop(index);
  1014 + // setTimeout(() => {
  1015 + // Promise.resolve($lucky.stop(index)).then(()=>{
  1016 + // self.data.start = false;
  1017 + // });
  1018 + // }, 2000);
  1019 + },
  1020 +
  1021 +
  1022 +
  1023 + });
  1024 +
  1025 + }
  1026 +
  1027 +
  1028 + } else {
  1029 + wx.showToast({
  1030 + title: '你今天的抽奖次数已用完啦!~',
  1031 + icon: 'none',
  1032 + success: function () {
  1033 + self.setData({
  1034 + start: false
  1035 + });
  1036 + }
  1037 + });
  1038 + };
  1039 +
  1040 + };
  1041 + });
  1042 +
  1043 +
  1044 +
  1045 +
  1046 +
  1047 +
1048 }, 1048 },
1049 - end (event) { 1049 + end(event) {
1050 // 中奖奖品详情 1050 // 中奖奖品详情
1051 // console.log('抽奖结果:',event.detail); 1051 // console.log('抽奖结果:',event.detail);
1052 - let no_luck_urltype = this.data.luckInfo.no_luck_urltype;  
1053 - let lbtype = null;  
1054 - // let good_id = null;  
1055 - let resultTitle = event.detail.fonts[0].text.replace('\n','');  
1056 - // if(event.detail.id) {  
1057 - // console.log('~~~~~~----++++++',event.detail.id);  
1058 - // good_id = event.detail.id;  
1059 - // };  
1060 - if(event.detail.lbtype == 5) {  
1061 - lbtype = 5;  
1062 - } else {  
1063 - lbtype = -1;  
1064 - };  
1065 - this.setData({  
1066 - num: 3,  
1067 - hiddenCanvas: true,  
1068 - showResult: true,  
1069 - showMask: true,  
1070 - resultTitle,  
1071 - showPopup: false,  
1072 - currentLbtype: lbtype,  
1073 - // good_id,  
1074 - });  
1075 -  
1076 -  
1077 -  
1078 -  
1079 - if(no_luck_urltype == 1 && resultTitle == '谢谢参与') {  
1080 - if(this.data.luckInfo.no_luck_weappurl) {  
1081 - let num = this.data.num;  
1082 - let url = this.data.luckInfo.no_luck_weappurl;  
1083 - self.timer = setInterval(function() {  
1084 - if(num == 0) {  
1085 - clearInterval(self.timer);  
1086 - app.goto(url);  
1087 - } else {  
1088 - self.setData({  
1089 - num: --num,  
1090 - });  
1091 - }  
1092 - }, 500);  
1093 -  
1094 - };  
1095 -  
1096 - };  
1097 -  
1098 -  
1099 - if(self.data.luckInfo.give_user) {  
1100 - if(resultTitle == '谢谢参与') {  
1101 - if(self.data.luckInfo.give_type == 1) {  
1102 - if(self.data.luckInfo.give_integral > 0) {  
1103 - wx.showToast({  
1104 - title: `获得游戏奖励积分${self.data.luckInfo.give_integral}`,  
1105 - icon: 'none',  
1106 - });  
1107 - };  
1108 - } else if((self.data.luckInfo.give_type == 2)) {  
1109 - if(self.data.luckInfo.give_growth > 0) {  
1110 - wx.showToast({  
1111 - title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,  
1112 - icon: 'none',  
1113 - });  
1114 - };  
1115 - };  
1116 - };  
1117 - } else {  
1118 - if(self.data.luckInfo.give_type == 1) {  
1119 - if(self.data.luckInfo.give_integral > 0) {  
1120 - wx.showToast({  
1121 - title: `获得游戏奖励积分${self.data.luckInfo.give_integral}`,  
1122 - icon: 'none',  
1123 - });  
1124 - };  
1125 - } else if((self.data.luckInfo.give_type == 2)) {  
1126 - if(self.data.luckInfo.give_growth > 0) {  
1127 - wx.showToast({  
1128 - title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,  
1129 - icon: 'none',  
1130 - });  
1131 - };  
1132 - };  
1133 - };  
1134 -  
1135 - 1052 + let no_luck_urltype = this.data.luckInfo.no_luck_urltype;
  1053 + let lbtype = null;
  1054 + // let good_id = null;
  1055 + let resultTitle = event.detail.fonts[0].text.replace('\n', '');
  1056 + // if(event.detail.id) {
  1057 + // console.log('~~~~~~----++++++',event.detail.id);
  1058 + // good_id = event.detail.id;
  1059 + // };
  1060 + if (event.detail.lbtype == 5) {
  1061 + lbtype = 5;
  1062 + } else {
  1063 + lbtype = -1;
  1064 + };
  1065 + this.setData({
  1066 + num: 3,
  1067 + hiddenCanvas: true,
  1068 + showResult: true,
  1069 + showMask: true,
  1070 + resultTitle,
  1071 + showPopup: false,
  1072 + currentLbtype: lbtype,
  1073 + // good_id,
  1074 + });
  1075 +
  1076 +
  1077 +
  1078 +
  1079 + if (no_luck_urltype == 1 && resultTitle == '谢谢参与') {
  1080 + if (this.data.luckInfo.no_luck_weappurl) {
  1081 + let num = this.data.num;
  1082 + let url = this.data.luckInfo.no_luck_weappurl;
  1083 + self.timer = setInterval(function () {
  1084 + if (num == 0) {
  1085 + clearInterval(self.timer);
  1086 + app.goto(url);
  1087 + } else {
  1088 + self.setData({
  1089 + num: --num,
  1090 + });
  1091 + }
  1092 + }, 500);
  1093 +
  1094 + };
  1095 +
  1096 + };
  1097 +
  1098 +
  1099 + if (self.data.luckInfo.give_user) {
  1100 + if (resultTitle == '谢谢参与') {
  1101 + if (self.data.luckInfo.give_type == 1) {
  1102 + if (self.data.luckInfo.give_integral > 0) {
  1103 + wx.showToast({
  1104 + title: `获得游戏奖励积分${self.data.luckInfo.give_integral}`,
  1105 + icon: 'none',
  1106 + });
  1107 + };
  1108 + } else if ((self.data.luckInfo.give_type == 2)) {
  1109 + if (self.data.luckInfo.give_growth > 0) {
  1110 + wx.showToast({
  1111 + title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,
  1112 + icon: 'none',
  1113 + });
  1114 + };
  1115 + };
  1116 + };
  1117 + } else {
  1118 + if (self.data.luckInfo.give_type == 1) {
  1119 + if (self.data.luckInfo.give_integral > 0) {
  1120 + wx.showToast({
  1121 + title: `获得游戏奖励积分${self.data.luckInfo.give_integral}`,
  1122 + icon: 'none',
  1123 + });
  1124 + };
  1125 + } else if ((self.data.luckInfo.give_type == 2)) {
  1126 + if (self.data.luckInfo.give_growth > 0) {
  1127 + wx.showToast({
  1128 + title: `获得游戏奖励成长值${self.data.luckInfo.give_growth}`,
  1129 + icon: 'none',
  1130 + });
  1131 + };
  1132 + };
  1133 + };
  1134 +
  1135 +
  1136 + },
  1137 + //门店回调
  1138 + async callback(e) {
  1139 + let item = e.detail;
  1140 + console.log('门店信息');
  1141 + console.log(item);
  1142 +
  1143 + if (item && item.pickup_id) {
  1144 + if (this.data.wow) {
  1145 + let text = 'wow.goods_pickup_id'
  1146 + this.setData({
  1147 + [text]: item.pickup_id
  1148 + })
  1149 + this.showQr()
  1150 + } else {
  1151 + let action_item = this.data.action_item
  1152 + if (!action_item.currentTarget.dataset.verify_pickup_id) {
  1153 + action_item.verify_pickup_id = item.pickup_id
  1154 + }
  1155 + this.showQr(action_item)
  1156 + }
  1157 +
  1158 +
  1159 + } else {
  1160 + wx.showToast({
  1161 + title: '门店选择失败',
  1162 + icon: 'none',
  1163 + duration: 2000
  1164 + })
  1165 + }
  1166 + },
  1167 + //门店选择1
  1168 + select_product() {
  1169 + if (this.data.luckInfo.is_store==1) {
  1170 + this.setData({
  1171 + store: 1,
  1172 + showResult: false,
  1173 + })
  1174 + }else{
  1175 + this.clickReceive()
  1176 + }
  1177 + },
  1178 + //门店选择2
  1179 + select_product2(e) {
  1180 + if (e.currentTarget.dataset.verify_pickup_id) {
  1181 + this.showQr(e)
  1182 + } else {
  1183 + if (this.data.luckInfo.is_store==1) {
  1184 + this.setData({
  1185 + store: 1,
  1186 + showResult: false,
  1187 + showPopup: false,
  1188 + action_item: e,
  1189 + wow: ''
  1190 + })
  1191 + }else{
  1192 + this.showQr(e)
  1193 + }
  1194 + }
  1195 +
  1196 + },
  1197 + showPopup() {
  1198 + this.setData({
  1199 + list: null,
  1200 + pageNum: 1,
  1201 + noMore: false,
  1202 + });
  1203 + this.getData(true, '/api/weshop/marketing/marketingLuckRecord/page', {
  1204 + store_id: app.globalData.setting.stoid,
  1205 + user_id: app.globalData.userInfo.user_id,
  1206 + luck_formid: this.data.options.id,
  1207 + luck_state: 1,
  1208 + }).then(function (res) {
  1209 + self.setData({
  1210 + showPopup: true,
  1211 + showMask: true,
  1212 + hiddenCanvas: true,
  1213 + });
  1214 + });
  1215 +
  1216 + // this.setData({
  1217 + // showPopup: true,
  1218 + // showMask: true,
  1219 + // hiddenCanvas: true,
  1220 + // 'list.pageData': this.data.record,
  1221 + // // record: self.data.list.pageData,
  1222 + // });
  1223 +
  1224 + },
  1225 +
  1226 + closePopup() {
  1227 + this.setData({
  1228 + showPopup: false,
  1229 + showMask: false,
  1230 + hiddenCanvas: false,
  1231 + });
  1232 + },
  1233 +
  1234 + /**
  1235 + * 关闭中奖结果
  1236 + */
  1237 + closeResult() {
  1238 + clearInterval(this.timer);
  1239 + this.setData({
  1240 + num: 3,
  1241 + showResult: false,
  1242 + showMask: false,
  1243 + hiddenCanvas: false,
  1244 + start: false,
  1245 + });
  1246 + },
  1247 +
  1248 + loadmore() {
  1249 + this.scrollToLower('/api/weshop/marketing/marketingLuckRecord/page', {
  1250 + store_id: app.globalData.setting.stoid,
  1251 + user_id: app.globalData.userInfo.user_id,
  1252 + luck_formid: this.data.options.id,
  1253 + luck_state: 1,
  1254 + });
  1255 + },
  1256 +
  1257 +
  1258 + /**
  1259 + * 请求数据
  1260 + */
  1261 + getData: function (isInit, url, data) {
  1262 + let p = app.request.promiseGet(url, {
  1263 + data: data,
  1264 + isShowLoading: true,
  1265 + })
  1266 + .then(function (res) {
  1267 + if (res.data.code == 0) {
  1268 +
  1269 + self.setData({
  1270 + isLoading: false
  1271 + });
  1272 +
  1273 + if (isInit) {// 第一次加载
  1274 + self.setData({
  1275 + list: res.data.data
  1276 + });
  1277 + } else {
  1278 + self.setData({
  1279 + 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData)
  1280 + });
  1281 + };
  1282 +
  1283 + if ((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) {
  1284 + self.setData({
  1285 + noMore: true
  1286 + });
  1287 + };
  1288 +
  1289 + } else {
  1290 + self.setData({
  1291 + 'list.pageData': []
  1292 + });
  1293 + };
  1294 +
  1295 + });
  1296 +
  1297 + return p;
  1298 + },
  1299 +
  1300 +
  1301 + /**
  1302 + * 上拉加载
  1303 + */
  1304 + scrollToLower(url, requestData) {
  1305 + // 数据总量
  1306 + let total = this.data.list.total;
  1307 + // 单页最大数据量
  1308 + let pageSize = this.data.list.pageSize;
  1309 + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’
  1310 + if ((total != 0) && (total <= pageSize)) {
  1311 + this.setData({
  1312 + noMore: true
  1313 + });
  1314 + };
  1315 +
  1316 + if (!this.data.isLoading && !this.data.noMore) {
  1317 + this.setData({
  1318 + isLoading: true,
  1319 + pageNum: this.data.pageNum + 1
  1320 + });
  1321 + requestData.page = this.data.pageNum;
  1322 + this.getData(false, url, requestData);
  1323 + };
  1324 + },
  1325 +
  1326 +
  1327 + goto(e) {
  1328 + let url = '';
  1329 + let type = e.currentTarget.dataset.type;
  1330 + let ordersn = null;
  1331 + let buyreceive_id = null;
  1332 + if (e.currentTarget.dataset.ordersn) {
  1333 + ordersn = e.currentTarget.dataset.ordersn;
  1334 + };
  1335 + if (e.currentTarget.dataset.buyreceiveid) {
  1336 + buyreceive_id = e.currentTarget.dataset.buyreceiveid;
  1337 + };
  1338 + switch (type) {
  1339 + case 1: {
  1340 + url = '/packageD/pages/user/integral/integral';
  1341 + break;
  1342 + };
  1343 + case 2: {
  1344 + url = '/packageE/pages/user/grow_value/grow_value';
  1345 + break;
  1346 + };
  1347 + case 3: {
  1348 + url = '/packageD/pages/user/coupons/coupons';
  1349 + break;
  1350 + };
  1351 + case 4: {
  1352 + url = '/pages/user/my_service/i_service';
  1353 + break;
  1354 + };
  1355 + case 6: {
  1356 + url = `/pages/giftpack/giftpacklist/giftpacklist?isBuy=0&orderSn=${ordersn}&lbId=${buyreceive_id}`;
  1357 + break;
  1358 + };
  1359 + };
  1360 + app.goto(url);
1136 }, 1361 },
1137 -  
1138 - showPopup() {  
1139 - this.setData({  
1140 - list: null,  
1141 - pageNum: 1,  
1142 - noMore: false,  
1143 - });  
1144 - this.getData(true, '/api/weshop/marketing/marketingLuckRecord/page', {  
1145 - store_id: app.globalData.setting.stoid,  
1146 - user_id: app.globalData.userInfo.user_id,  
1147 - luck_formid: this.data.options.id,  
1148 - luck_state: 1,  
1149 - }).then(function(res) {  
1150 - self.setData({  
1151 - showPopup: true,  
1152 - showMask: true,  
1153 - hiddenCanvas: true,  
1154 - });  
1155 - });  
1156 -  
1157 - // this.setData({  
1158 - // showPopup: true,  
1159 - // showMask: true,  
1160 - // hiddenCanvas: true,  
1161 - // 'list.pageData': this.data.record,  
1162 - // // record: self.data.list.pageData,  
1163 - // });  
1164 -  
1165 - },  
1166 -  
1167 - closePopup() {  
1168 - this.setData({  
1169 - showPopup: false,  
1170 - showMask: false,  
1171 - hiddenCanvas: false,  
1172 - });  
1173 - },  
1174 -  
1175 - /**  
1176 - * 关闭中奖结果  
1177 - */  
1178 - closeResult() {  
1179 - clearInterval(this.timer);  
1180 - this.setData({  
1181 - num: 3,  
1182 - showResult: false,  
1183 - showMask: false,  
1184 - hiddenCanvas: false,  
1185 - start: false,  
1186 - });  
1187 - },  
1188 -  
1189 - loadmore() {  
1190 - this.scrollToLower('/api/weshop/marketing/marketingLuckRecord/page', {  
1191 - store_id: app.globalData.setting.stoid,  
1192 - user_id: app.globalData.userInfo.user_id,  
1193 - luck_formid: this.data.options.id,  
1194 - luck_state: 1,  
1195 - });  
1196 - },  
1197 -  
1198 -  
1199 - /**  
1200 - * 请求数据  
1201 - */  
1202 - getData: function(isInit, url, data) {  
1203 - let p = app.request.promiseGet(url, {  
1204 - data: data,  
1205 - isShowLoading: true,  
1206 - })  
1207 - .then(function(res) {  
1208 - if(res.data.code == 0) {  
1209 -  
1210 - self.setData({  
1211 - isLoading: false  
1212 - });  
1213 -  
1214 - if(isInit) {// 第一次加载  
1215 - self.setData({  
1216 - list: res.data.data  
1217 - });  
1218 - } else {  
1219 - self.setData({  
1220 - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData)  
1221 - });  
1222 - };  
1223 -  
1224 - if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) {  
1225 - self.setData({  
1226 - noMore: true  
1227 - });  
1228 - };  
1229 -  
1230 - } else {  
1231 - self.setData({  
1232 - 'list.pageData': []  
1233 - });  
1234 - };  
1235 -  
1236 - });  
1237 -  
1238 - return p;  
1239 - },  
1240 -  
1241 -  
1242 - /**  
1243 - * 上拉加载  
1244 - */  
1245 - scrollToLower(url, requestData) {  
1246 - // 数据总量  
1247 - let total = this.data.list.total;  
1248 - // 单页最大数据量  
1249 - let pageSize = this.data.list.pageSize;  
1250 - // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’  
1251 - if((total != 0)&&(total <= pageSize)) {  
1252 - this.setData({  
1253 - noMore: true  
1254 - });  
1255 - };  
1256 -  
1257 - if(!this.data.isLoading && !this.data.noMore) {  
1258 - this.setData({  
1259 - isLoading: true,  
1260 - pageNum: this.data.pageNum + 1  
1261 - });  
1262 - requestData.page = this.data.pageNum;  
1263 - this.getData(false, url, requestData);  
1264 - };  
1265 - },  
1266 -  
1267 -  
1268 - goto(e) {  
1269 - let url = '';  
1270 - let type = e.currentTarget.dataset.type;  
1271 - let ordersn = null;  
1272 - let buyreceive_id = null;  
1273 - if(e.currentTarget.dataset.ordersn) {  
1274 - ordersn = e.currentTarget.dataset.ordersn;  
1275 - };  
1276 - if(e.currentTarget.dataset.buyreceiveid) {  
1277 - buyreceive_id = e.currentTarget.dataset.buyreceiveid;  
1278 - };  
1279 - switch(type) {  
1280 - case 1: {  
1281 - url = '/packageD/pages/user/integral/integral';  
1282 - break;  
1283 - };  
1284 - case 2: {  
1285 - url = '/packageE/pages/user/grow_value/grow_value';  
1286 - break;  
1287 - };  
1288 - case 3: {  
1289 - url = '/packageD/pages/user/coupons/coupons';  
1290 - break;  
1291 - };  
1292 - case 4: {  
1293 - url = '/pages/user/my_service/i_service';  
1294 - break;  
1295 - };  
1296 - case 6: {  
1297 - url = `/pages/giftpack/giftpacklist/giftpacklist?isBuy=0&orderSn=${ordersn}&lbId=${buyreceive_id}`;  
1298 - break;  
1299 - };  
1300 - };  
1301 - app.goto(url);  
1302 - },  
1303 -  
1304 - showQr(e) {  
1305 - let id = null;  
1306 - let store_id = app.globalData.setting.stoid;  
1307 - if(e && e.currentTarget.dataset.id) {  
1308 - id = e.currentTarget.dataset.id;  
1309 - } else {  
1310 - id = this.data.wow.record_id;  
1311 - };  
1312 - let url = `/api/weshop/marketing/marketingLuckList/updateGoodsVerifyCode/${store_id}/${id}`;  
1313 - // console.log('good_id', id, url);  
1314 - app.request.put(url, {  
1315 - success: function(res) {  
1316 - if(res.data.code == 0) {  
1317 - let data = res.data.data;  
1318 - let barcode = self.selectComponent("#qrcode");  
1319 - barcode.open({val: data});  
1320 - self.setData({  
1321 - hiddenCanvas: true,  
1322 - showPopup: false,  
1323 - });  
1324 - } else {  
1325 - wx.showToast({  
1326 - title: res.data.msg,  
1327 - icon: 'none',  
1328 - });  
1329 - };  
1330 - },  
1331 -  
1332 - });  
1333 - },  
1334 -  
1335 - closeQr() {  
1336 - this.setData({  
1337 - hiddenCanvas: false,  
1338 - showMask: false,  
1339 - });  
1340 - },  
1341 -  
1342 - clickReceive() {  
1343 - this.setData({  
1344 - showResult: false,  
1345 - });  
1346 - this.showQr();  
1347 - },  
1348 -  
1349 -  
1350 -  
1351 - showPoster() {  
1352 -  
1353 - console.log('已经生成图片!!!!!!', self.data.imgPath);  
1354 - // console.log(Promise.resolve(this.onImgOK));  
1355 - wx.showLoading({  
1356 - title: '生成海报中',  
1357 - });  
1358 - var timer;  
1359 - if(this.data.isImgOk && this.data.getMiniCode) {  
1360 - wx.hideLoading();  
1361 - self.setData({  
1362 - myimg: self.data.imgPath,  
1363 - hiddenCanvas: true,  
1364 - showMask: true,  
1365 - showPoster: true,  
1366 - });  
1367 - } else {  
1368 - timer = setInterval(function() {  
1369 - if(self.data.isImgOk && self.data.getMiniCode) {  
1370 - clearInterval(timer);  
1371 - wx.hideLoading();  
1372 - self.setData({  
1373 - myimg: self.data.imgPath,  
1374 - hiddenCanvas: true,  
1375 - showMask: true,  
1376 - showPoster: true,  
1377 - });  
1378 - };  
1379 - }, 500);  
1380 - };  
1381 - },  
1382 -  
1383 - closePoster() {  
1384 - this.setData({  
1385 - showMask: false,  
1386 - showPoster: false,  
1387 - hiddenCanvas: false,  
1388 - });  
1389 - },  
1390 -  
1391 -  
1392 -  
1393 - onImgOK(e) {  
1394 - console.log('图片绘制成功', e.detail.path);  
1395 - // this.setData({  
1396 - // imgPath: e.detail.path,  
1397 - // });  
1398 - if(e&&e.detail.path) {  
1399 - this.setData({  
1400 - isImgOk: true,  
1401 - imgPath: e.detail.path,  
1402 - });  
1403 - };  
1404 -  
1405 - },  
1406 -  
1407 -  
1408 - 1362 +
  1363 + showQr(e) {
  1364 + let id = null;
  1365 + let store_id = app.globalData.setting.stoid;
  1366 + let goods_pickup_id = ''
  1367 + let off = false //是否需要携带登记的门店id
  1368 +
  1369 + if (e && e.currentTarget.dataset.id) {
  1370 + id = e.currentTarget.dataset.id;
  1371 + if (e.verify_pickup_id) {
  1372 + goods_pickup_id = e.verify_pickup_id;
  1373 + off = true
  1374 + }
  1375 + } else {
  1376 + id = this.data.wow.record_id;
  1377 + goods_pickup_id = this.data.wow.goods_pickup_id;
  1378 + off = true
  1379 + };
  1380 + let url = `/api/weshop/marketing/marketingLuckList/updateGoodsVerifyCode/${store_id}/${id}`;
  1381 +
  1382 + //判断是否需要登记门店,才可以核销商品
  1383 + if (this.data.luckInfo.is_store == 1 && goods_pickup_id && off) {
  1384 + url += `/${goods_pickup_id}`
  1385 + }
  1386 +
  1387 + // console.log('good_id', id, url);
  1388 + app.request.put(url, {
  1389 + success: function (res) {
  1390 + if (res.data.code == 0) {
  1391 + let data = res.data.data;
  1392 + let barcode = self.selectComponent("#qrcode");
  1393 + barcode.open({ val: data });
  1394 + self.setData({
  1395 + hiddenCanvas: true,
  1396 + showPopup: false,
  1397 + });
  1398 + } else {
  1399 + wx.showToast({
  1400 + title: res.data.msg,
  1401 + icon: 'none',
  1402 + });
  1403 + };
  1404 + },
  1405 +
  1406 + });
  1407 + },
  1408 +
  1409 + closeQr() {
  1410 + this.setData({
  1411 + hiddenCanvas: false,
  1412 + showMask: false,
  1413 + });
  1414 + },
  1415 +
  1416 + clickReceive() {
  1417 + this.setData({
  1418 + showResult: false,
  1419 + });
  1420 + this.showQr();
  1421 + },
  1422 +
  1423 +
  1424 +
  1425 + showPoster() {
  1426 +
  1427 + console.log('已经生成图片!!!!!!', self.data.imgPath);
  1428 + // console.log(Promise.resolve(this.onImgOK));
  1429 + wx.showLoading({
  1430 + title: '生成海报中',
  1431 + });
  1432 + var timer;
  1433 + if (this.data.isImgOk && this.data.getMiniCode) {
  1434 + wx.hideLoading();
  1435 + self.setData({
  1436 + myimg: self.data.imgPath,
  1437 + hiddenCanvas: true,
  1438 + showMask: true,
  1439 + showPoster: true,
  1440 + });
  1441 + } else {
  1442 + timer = setInterval(function () {
  1443 + if (self.data.isImgOk && self.data.getMiniCode) {
  1444 + clearInterval(timer);
  1445 + wx.hideLoading();
  1446 + self.setData({
  1447 + myimg: self.data.imgPath,
  1448 + hiddenCanvas: true,
  1449 + showMask: true,
  1450 + showPoster: true,
  1451 + });
  1452 + };
  1453 + }, 500);
  1454 + };
  1455 + },
  1456 +
  1457 + closePoster() {
  1458 + this.setData({
  1459 + showMask: false,
  1460 + showPoster: false,
  1461 + hiddenCanvas: false,
  1462 + });
  1463 + },
  1464 + //门店退出回调
  1465 + closeback(){
  1466 + console.log('门店关闭回调');
  1467 + this.setData({
  1468 + store: 0,
  1469 + showPopup: false,
  1470 + showMask: false,
  1471 + hiddenCanvas: false,
  1472 + })
  1473 + },
  1474 +
  1475 +
  1476 + onImgOK(e) {
  1477 + console.log('图片绘制成功', e.detail.path);
  1478 + // this.setData({
  1479 + // imgPath: e.detail.path,
  1480 + // });
  1481 + if (e && e.detail.path) {
  1482 + this.setData({
  1483 + isImgOk: true,
  1484 + imgPath: e.detail.path,
  1485 + });
  1486 + };
  1487 +
  1488 + },
  1489 +
  1490 +
  1491 +
1409 }) 1492 })
1410 \ No newline at end of file 1493 \ No newline at end of file
packageB/pages/luckactivity/luckinfo/luckinfo.json
@@ -2,7 +2,8 @@ @@ -2,7 +2,8 @@
2 "usingComponents": { 2 "usingComponents": {
3 "lucky-wheel":"/packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index", 3 "lucky-wheel":"/packageB/miniprogram_npm/mini-luck-draw/lucky-wheel/index",
4 "qrcode": "/components/my-qrcode/my-qrcode", 4 "qrcode": "/components/my-qrcode/my-qrcode",
5 - "nodata": "/components/nodata/nodata", 5 + "nodata": "/components/nodata/nodata",
  6 + "store_popup":"/components/store_popup/store_popup",
6 "painter": "/packageB/components/painter/painter" 7 "painter": "/packageB/components/painter/painter"
7 }, 8 },
8 "enablePullDownRefresh": false, 9 "enablePullDownRefresh": false,
packageB/pages/luckactivity/luckinfo/luckinfo.wxml
@@ -143,9 +143,9 @@ @@ -143,9 +143,9 @@
143 <view class="fs26 xc-black3">价值:<text class="rmb">{{item.luck_goods_price}}</text></view> 143 <view class="fs26 xc-black3">价值:<text class="rmb">{{item.luck_goods_price}}</text></view>
144 <view class="flex ai_c {{item.luck_type == 5 ? 'jc_sb':'jc_fe'}} fs26 xc-black3 "> 144 <view class="flex ai_c {{item.luck_type == 5 ? 'jc_sb':'jc_fe'}} fs26 xc-black3 ">
145 <!-- <view style="visibility: {{item.luck_type == 5 ? 'visible':'hidden'}};">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> --> 145 <!-- <view style="visibility: {{item.luck_type == 5 ? 'visible':'hidden'}};">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> -->
146 - <!-- <view style="">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> --> 146 + <!-- <view style="">兑换状态:{{item.state == 0 ? '未兑换':'已兑换'}}</view> -->
147 <view class="fs24 c-a" wx:if="{{item.luck_type == 5}}">兑换截止时间:{{filter.show_default(item.changeDate, '不限')}}</view> 147 <view class="fs24 c-a" wx:if="{{item.luck_type == 5}}">兑换截止时间:{{filter.show_default(item.changeDate, '不限')}}</view>
148 - <view class="btn" bindtap="{{item.luck_type == 5 ? (item.state == 0 ? 'showQr':'showQr'):'goto'}}" data-type="{{item.luck_type}}" data-id="{{item.id}}" data-ordersn="{{item.order_sn}}" data-buyreceiveid="{{item.buyreceive_id}}">{{item.luck_type == 5 ? (item.state == 1 ? '已兑换':'兑换'):'查看'}}</view> 148 + <view class="btn" bindtap="{{item.luck_type == 5 ? (item.state == 0 ? 'select_product2':'select_product2'):'goto'}}" data-verify_pickup_id="{{item.verify_pickup_id}}" data-type="{{item.luck_type}}" data-id="{{item.id}}" data-ordersn="{{item.order_sn}}" data-buyreceiveid="{{item.buyreceive_id}}">{{item.luck_type == 5 ? (item.state == 1 ? '已兑换':'兑换'):'查看'}}</view>
149 </view> 149 </view>
150 </view> 150 </view>
151 </view> 151 </view>
@@ -179,7 +179,7 @@ @@ -179,7 +179,7 @@
179 </view> 179 </view>
180 180
181 <view class="pdt40" wx:if="{{currentLbtype == 5}}"> 181 <view class="pdt40" wx:if="{{currentLbtype == 5}}">
182 - <view class="btn btn2" bindtap="clickReceive">立即兑换</view> 182 + <view class="btn btn2" bindtap="select_product">立即兑换</view>
183 </view> 183 </view>
184 184
185 185
@@ -201,5 +201,7 @@ @@ -201,5 +201,7 @@
201 201
202 <qrcode id="qrcode" bind:close="closeQr"></qrcode> 202 <qrcode id="qrcode" bind:close="closeQr"></qrcode>
203 203
  204 +<!-- 门店选择弹窗 -->
  205 +<store_popup store="{{store}}" bind:closeback="closeback" bind:callback="callback" ></store_popup>
204 206
205 <painter style="position: absolute;left: -9999rpx;" palette="{{imgDraw}}" bind:imgOK="onImgOK"/> 207 <painter style="position: absolute;left: -9999rpx;" palette="{{imgDraw}}" bind:imgOK="onImgOK"/>
206 \ No newline at end of file 208 \ No newline at end of file