plus.js
12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
var e = function(e) {
return e && e.__esModule ? e : {
default: e
};
}(require("../../../utils/LoadMore.js")),
t = getApp(),
a = t.request,
o = t.globalData.setting,
os = o,
i = require("../../../utils/util.js"),
ut = i,
s = require("../../../utils/common.js"),
w = require("../../../utils/wxParse/wxParse.js"),
n = new e.default();
var regeneratorRuntime = require('../../../utils/runtime.js');
var api = require('../../../api/api.js');
//wx.downloadFile把线上地址设为本地地址
Page({
/**
* 页面的初始数据
*/
data: {
images: [o.imghost + "/miniapp/images/plus/card_one.jpg", o.imghost + "/miniapp/images/plus/card_two.jpg", o.imghost + "/miniapp/images/plus/card_three.jpg"],
currentId: 0,
url: o.imghost,
screenWidth: 0,
screenheight: 0,
canvasHidden: true,
shareImgPath: null,
is_plusCard: "",//卡的列表
imagePath: "",
is_pulscardname: "",//plus会员的名字
is_card:0,//用于判断是否是续费页和购买页面 0不是puls会员
content:"",//等级卡规则
is_card_rule: "",//等级卡规则判断用
},
swiperChange: function(e) {
var currentId = e.detail.current;
this.setData({
currentId: currentId
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log();
var that = this;
getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, {
success: function (res) {
var user_information=res.data.data;
console.log(res, "会员个人信息");
//判断是是不是会员
if (user_information == null || user_information == ""){
}
//判断是是不是plus会员
if (user_information.card_field == null || user_information.card_fiel == "") {
that.setData({ is_card:1});
}
if (user_information.card_expiredate == null || user_information.card_expiredate == ""){
}
}
});
//获取用户设备信息,屏幕宽度
wx.getSystemInfo({
success: res => {
that.setData({
screenWidth: res.screenWidth
})
}
})
this.getPlusCardType();
this.saveImageToPhotosAlbum();
this.puls_user();
//-----------商家配置信息----- 等级卡规则------------
getApp().request.get("/api/weshop/storeconfig/get/"+ os.stoid, {
success: function (res) {
var is_cardrule=res.data.data.cardrules;
w.wxParse("content", "html", is_cardrule, that, 6);
console.log("等级卡规则8888888888888", is_cardrule);
that.setData({
is_card_rule: is_cardrule
});
}
});
},
//-----Plus会员获取-----------
puls_user: function () {
var th = this;
getApp().request.get("/api/weshop/plus/vip/mem/list", {
data: {
storeId: os.stoid,
userId: getApp().globalData.user_id,
},
success: function (su) {
if (su.data.code == 0) {
var cardname = su.data.data[0].MemCardName;
console.log("卡的名字", cardname);
th.setData({ pulscardname: cardname });
}
}
});
},
//获取卡类
getPlusCardType: function(e) {
var storid = o.stoid;
var th = this;
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
var plusCard = res.data.data;
var arr = [1219, 2089, 3031];
for(var i = 0; i < plusCard.length;i++){
plusCard[i].free=arr[i];
}
th.setData({
is_plusCard: plusCard
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
saveImageToPhotosAlbum: function() {
wx.showLoading({
title: '生成中...',
})
var th = this;
var unit = th.data.screenWidth / 750 * 1.35;
const ctx = wx.createCanvasContext('myCanvas');
//设置画板显示,才能开始绘图
th.setData({
canvasHidden: false
})
ctx.drawImage("../../../images/plus/share/mackground.png", 0, 0, 554 * unit, 930 * unit);
ctx.setFontSize(26 * unit);
ctx.setFillStyle("rgb(0,0,0)");
ctx.fillText("钱巧玲", 155 * unit, 75 * unit, 200 * unit);
var tj_path = "../../../images/userinfo/q_tj.png";
ctx.drawImage(tj_path, 385 * unit, 45 * unit, 90 * unit, 30 * unit);
ctx.setFontSize(18 * unit);
ctx.setFillStyle("rgb(255,255,255)");
ctx.fillText("强烈推荐", 394 * unit, 65 * unit);
ctx.setStrokeStyle("rgb(255,255,255)");
ctx.setLineDash([5 * unit, 5 * unit], 5 * unit);
ctx.beginPath();
ctx.moveTo(0, 125 * unit);
ctx.lineTo(554 * unit, 125 * unit);
ctx.stroke();
var x = 55 * unit,
y = 165 * unit,
w = 444 * unit,
h = 220 * unit,
r = 14 * unit;
ctx.save();
// 开始绘制
ctx.beginPath();
// 因为边缘描边存在锯齿,最好指定使用 transparent 填充
// 这里是使用 fill 还是 stroke都可以,二选一即可
ctx.setFillStyle('rgb(237,188,150)')
// ctx.setStrokeStyle('transparent')
// 左上角
ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
// border-top
ctx.moveTo(x + r, y)
ctx.lineTo(x + w - r, y)
ctx.lineTo(x + w, y + r)
// 右上角
ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
// border-right
ctx.lineTo(x + w, y + h - r)
ctx.lineTo(x + w - r, y + h)
// 右下角
ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5)
// border-bottom
ctx.lineTo(x + r, y + h)
ctx.lineTo(x, y + h - r)
// 左下角
ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI)
// border-left
ctx.lineTo(x, y + r)
ctx.lineTo(x + r, y)
// 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应
ctx.fill()
ctx.clip(); //画了圆 再剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内
ctx.drawImage("../../../images/plus/share/one.jpg", x, y, 444 * unit, 220 * unit); // 推进去图片
ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
ctx.beginPath();
// 卡图片
// ctx.drawImage("../../../images/plus/share/one.jpg", 55 * unit, 165 * unit, 444 * unit, 220 * unit,);
ctx.setFontSize(26 * unit);
ctx.setFillStyle("rgb(237,188,150)");
ctx.fillText("PLUSI会员", 80 * unit, 215 * unit);
ctx.setFontSize(18 * unit);
ctx.setFillStyle("rgb(237,188,150)");
ctx.fillText("开通会员年卡仅199元", 80 * unit, 240 * unit);
ctx.drawImage("../../../images/plus/share/privilege_o.png", 80 * unit, 343 * unit, 20 * unit, 20 * unit);
ctx.setFontSize(14 * unit);
ctx.setFillStyle("rgb(237,188,150)");
ctx.fillText("根据大家购买数据,您成为超级会员预计可省¥3031元", 105 * unit, 360 * unit);
ctx.rect(70 * unit, 425 * unit, 182 * unit, 1 * unit);
ctx.setFillStyle('rgb(218,194,169)');
ctx.fill();
ctx.drawImage("../../../images/plus/share/square.png", 267 * unit, 420 * unit, 13 * unit, 13 * unit);
ctx.beginPath();
ctx.rect(295 * unit, 425 * unit, 182 * unit, 1 * unit);
ctx.setFillStyle('rgb(218,194,169)');
ctx.fill();
ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 470 * unit, 10 * unit, 10 * unit);
ctx.setFontSize(24 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("超级VIP权益", 100 * unit, 475 * unit);
ctx.setFontSize(20 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("超级会员专属权益", 100 * unit, 505 * unit);
ctx.drawImage("../../../images/plus/share/Ancrown.png", 355 * unit, 440 * unit, 65 * unit, 65 * unit);
ctx.rect(85 * unit, 530 * unit, 375 * unit, 1 * unit)
ctx.setFillStyle('rgb(218,194,169)')
ctx.fill();
ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 575 * unit, 10 * unit, 10 * unit);
ctx.setFontSize(24 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("超级VIP标识", 100 * unit, 580 * unit);
ctx.setFontSize(20 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("彰显尊贵身份的象征", 100 * unit, 610 * unit);
ctx.drawImage("../../../images/plus/share/Identification.png", 355 * unit, 548 * unit, 65 * unit, 65 * unit);
ctx.rect(85 * unit, 635 * unit, 375 * unit, 1 * unit);
ctx.setFillStyle('rgb(218,194,169)');
ctx.fill();
ctx.drawImage("../../../images/plus/share/square.png", 80 * unit, 695 * unit, 10 * unit, 10 * unit);
ctx.setFontSize(24 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("超级VIP价格", 100 * unit, 695 * unit);
ctx.setFontSize(20 * unit);
ctx.setFillStyle("rgb(198,165,126)");
ctx.fillText("享受专属会员超低价", 100 * unit, 725 * unit);
ctx.drawImage("../../../images/plus/share/money.png", 355 * unit, 660 * unit, 65 * unit, 65 * unit);
ctx.rect(85 * unit, 750 * unit, 375 * unit, 1 * unit)
ctx.setFillStyle('rgb(218,194,169)')
ctx.fill();
ctx.drawImage("../../../images/userinfo/user_head.jpg", 100 * unit, 780 * unit, 110 * unit, 110 * unit);
ctx.setFontSize(20 * unit);
ctx.setFillStyle("#000");
ctx.fillText("解锁新权益 精彩享不停", 230 * unit, 825 * unit);
ctx.setFontSize(20 * unit);
ctx.setFillStyle("#000");
ctx.fillText("长按识别二维码,立即开通!", 230 * unit, 865 * unit);
//---绘制圆形要放在最后----
ctx.save();
ctx.beginPath();
var h_x = 60 * unit;
var h_y = 24 * unit;
var h_r = 40 * unit;
var cx = h_x + h_r;
var cy = h_y + h_r;
ctx.arc(cx, cy, h_r, 0, Math.PI * 2, false);
ctx.closePath();
ctx.fill();
ctx.clip();
ctx.drawImage("../../../images/userinfo/user_head.jpg", h_x, h_y, h_r * 2, h_r * 2);
ctx.restore();
var x = 345 * unit,
y = 190 * unit,
w = 105 * unit,
h = 30 * unit,
r = 14 * unit;
ctx.save();
// 开始绘制
ctx.beginPath();
// 因为边缘描边存在锯齿,最好指定使用 transparent 填充
// 这里是使用 fill 还是 stroke都可以,二选一即可
ctx.setFillStyle('rgb(237,188,150)')
// ctx.setStrokeStyle('transparent')
// 左上角
ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5)
// border-top
ctx.moveTo(x + r, y)
ctx.lineTo(x + w - r, y)
ctx.lineTo(x + w, y + r)
// 右上角
ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2)
// border-right
ctx.lineTo(x + w, y + h - r)
ctx.lineTo(x + w - r, y + h)
// 右下角
ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5)
// border-bottom
ctx.lineTo(x + r, y + h)
ctx.lineTo(x, y + h - r)
// 左下角
ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI)
// border-left
ctx.lineTo(x, y + r)
ctx.lineTo(x + r, y)
// 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应
ctx.fill()
// ctx.stroke()
ctx.closePath()
// 剪切
ctx.clip();
ctx.setFontSize(18 * unit);
ctx.setFillStyle("#000");
ctx.fillText("立即开通", 362 * unit, 212 * unit);
//绘制图片
ctx.draw(false,
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 750,
height: 930,
destWidth: 1.2 * 750 * 750 / th.data.screenWidth,
destHeight: 1.2 * 1217 * 750 / th.data.screenWidth,
canvasId: 'myCanvas',
success: function(res) {
console.log("sssssssssssssssssssssssss" + res.tempFilePath);
var tempFilePath = res.tempFilePath;
th.setData({
imagePath: tempFilePath,
maskHidden: false,
canvasHidden: true
});
wx.previewImage({
urls: [res.tempFilePath],
})
if (!res.tempFilePath) {
wx.showModal({
title: '提示',
content: '图片绘制中,请稍后重试',
showCancel: false
})
}
wx.hideLoading();
}
}))
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
var goods_list = this.selectComponent("#goods_list"); //组件的id
goods_list.get_list();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
var goods_list = this.selectComponent("#goods_list"); //组件的id
goods_list.get_list();
this.setData({
j: true
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
//开通会员
Opening: function() {
this.setData({
j: true
})
},
//返回会员页面
OpeningClose: function() {
this.setData({
j: false
})
}
})