//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)) }, 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:'' } })