app.js
2.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
//app.js
import md5 from 'utils/md5.js';
App({
post: function(url, data) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'https://insurance.w.broteam.cn/';
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function(res) {
resolve(res)
wx.hideLoading()
wx.hideNavigationBarLoading()
},
fail: function(e) {
reject('');
wx.hideLoading()
wx.hideNavigationBarLoading()
wx.showModal({
title: '',
content: res.data.msg,
showCancel: false
})
}
})
});
return promise;
console.log(promise)
},
formCollect(id) {
let url = 'sign/formid'
let params = {
formid: id,
openid: wx.getStorageSync('openId')
}
this.post(url, params).then((res) => {
console.log(res)
}).catch((errMsg) => {
})
},
nowDate() {
let date = new Date();
let month = date.getMonth() + 1;
let day = date.getDate();
return date.getFullYear() + '-' + (month > 9 ? month : ('0' + month)) + '-' + (day > 9 ? day : ('0' + day));
},
initDate(a) {
let date1 = new Date();
let time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();
let date2 = new Date(date1);
date2.setDate(date1.getDate() + a);
let time2 = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
return time2;
},
// 数组移除指定元素
arryRemove(arr, item) {
return arr.filter(function(ele) {
return ele != item;
})
},
strTime(strtime) {
let str = 'bronet' + strtime + 'beijing'
return md5(md5(str))
},
onLaunch() {
var that=this
wx.login({
success: (res) => {
let url = 'pubilc/sign';
let params = {
code: res.code,
status: ''
}
that.post(url, params).then((res) => {
console.log(res)
// console.log('start', res.data.data.UserType, res.data.data.checkstatus, res.data.data.PublishId)
}).catch((errMsg) => {
console.log(errMsg)
})
}
});
},
globalData: {
userInfo: null,
OpenId: '', //用户openid
UserId: '', //用户userid
UserType: '', //用户类型(2为普通会员,3为顾问,4为推广)
checkstatus: '', //分享参数(0为无分享参数,1为保单分享,2为注册分享,3为文章分享)
UserStatus: '', //用户状态(1初次登录需要授权操作,2多次登录不需要授权)
PublishId: '', //如果是保单分享返回保单id
NewsId: '', //如果是文章分享返回文章id
temp_UserType: '',
user_index: '',
}
})