ence_push.js
1.3 KB
var app = getApp(); Page({ data: { jscode: '', jsonData: '', isShowtip: false, tip: '', idDisb: true }, formSubmit: function (eve) { var that = this; if(!this.data.idDisb){ return }; that.setData({ idDisb: false }); wx.getUserInfo({ success: function(res){ var data = { appkey: wx.getStorageSync("t_appkey"), wx_code: that.data.jscode, iv: res.iv, jsondata: res.encryptedData, uuid: wx.getStorageSync("t_uuid"), formid: eve.detail.formId }; wx.showNavigationBarLoading(); wx.request({ url: 'https://openapi.xiaoshentui.com/Main/action/Pushmsg/Pushmsg/form_id', data: data, method: 'POST', header: { 'content-type': 'application/json', }, success: function (res) { if (res.data.code == 200) { that.setData({ idDisb: true }); that.setData({ isShowtip: true, tip: '获取成功,快去刷新页面测试推送吧!' }); } else { that.setData({ isShowtip: true, idDisb: true, tip: res.data.message }); } setTimeout(function () { that.setData({ tip: '', isShowtip: false }) }, 1500); wx.hideNavigationBarLoading(); } }); }, fail: function(){ that.setData({ idDisb: true }); } }); }, onShow: function () { this.getJscode(); }, getJscode() { var that = this; wx.login({ success: function (res) { if (res.code) { that.setData({ jscode: res.code }); } else { that.setData({ jscode: '' }); }; } }); } });