user_fw.js
2.39 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
// pages/user/userfw/userfw.js
var e = getApp(),os = e.globalData.setting;
var utils = require('../../../utils/util.js');
var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
/**
* 页面的初始数据
*/
data: {
qr_code_object:{val:"12121",content:"请将二维码展示给核销员,服务更快捷!"},
fw_list:null,
iurl:os.imghost,
userinfo:null,
GradeId:null,
FormId:null,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var FormId=options.FormId;
var GradeId=options.gradeId;
var userinfo=getApp().globalData.userInfo;
if(userinfo==null){
//界面必须使用warn 做ID,并调用
getApp().my_warnning("会员为空",0,this);
return false;
}
this.setData({GradeId:GradeId,FormId:FormId,userinfo:userinfo});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: async function () {
var th = this;
var fw_list=null;
//--获取列表--
await getApp().request.promiseGet("/api/weshop/users/grade/wechat/sm/page", {
data:{ storeId:os.stoid,FormId:th.data.FormId,GradeId:th.data.GradeId,userId:getApp().globalData.user_id}
}).then(res => {
fw_list = res.data.data.pageData;
})
th.setData({fw_list:fw_list});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/*-- 打开服务项目 --*/
open_fw:function (e) {
var th=this;
var ind=e.currentTarget.dataset.ind;
var item= this.data.fw_list[ind];
//小于0要提示
if(item.ObtainTimes<=0){
getApp().my_warnning("该服务已经使用完",0,th);
return false;
}
var ewm="^"+this.data.userinfo.erpvipid+"|"+item.Id+"|4|TY01|";
var tt=this.format_time(1);
ewm=ewm+tt;
th.data.qr_code_object.val=ewm;
th.data.qr_code_object.is_fw=1;
var qc_com = this.selectComponent("#qc_com"); //组件的id
qc_com.open(th.data.qr_code_object)
},
format_time:function(isFull) {
var d = new Date();
var m = d.getMonth() + 1; if(m<10) m="0"+m;
var dd = d.getDate(); if (dd < 10) dd = "0" + dd;
var fm=[d.getFullYear(),m,dd ].join('-');
if(isFull==1)
fm=fm + ' '+ [d.getHours(), d.getMinutes(), d.getSeconds()].join(':')
return fm;
},
})