binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame^] | 1 | // pages/signxy/signxy.js |
| 2 | Page({ |
| 3 | /** |
| 4 | * 页面的初始数据 |
| 5 | */ |
| 6 | data: { |
| 7 | url: '', |
| 8 | signMsg: '', |
| 9 | disabled: false, |
| 10 | xy: '' |
| 11 | }, |
| 12 | |
| 13 | /** |
| 14 | * 生命周期函数--监听页面加载 |
| 15 | */ |
| 16 | onLoad: function(options) { |
| 17 | var signed = wx.getStorageSync("signed"); |
| 18 | if (wx.$isEmpty(signed) || signed != 'yes') { |
| 19 | this.setData({ |
| 20 | signMsg: '我已阅读并同意该协议', |
| 21 | disabled: false |
| 22 | }) |
| 23 | } else { |
| 24 | this.setData({ |
| 25 | signMsg: '您已签约', |
| 26 | disabled: true |
| 27 | }) |
| 28 | return; |
| 29 | } |
| 30 | // var that = this; |
| 31 | // wx.showLoading("加载中"); |
| 32 | // wx.$doPost('/v1/bxy', {}, function(ok, ret, err) { |
| 33 | // wx.hideLoading(); |
| 34 | |
| 35 | // if (ok) { |
| 36 | // if (ret.data.code == 200) { |
| 37 | |
| 38 | // // var text = ret.data.page; |
| 39 | // // that.setData({ |
| 40 | // // xy: text.replace('/br/g', ' ') |
| 41 | // // }) |
| 42 | // // this.setData({ |
| 43 | // // url: ret.data.data.url |
| 44 | // // }) |
| 45 | // // if (wx.$isEmpty(ret.data.signed) || ret.data.data.signed != 'yes') { |
| 46 | // // } else { |
| 47 | // // } |
| 48 | // } else { |
| 49 | // wx.showModal({ |
| 50 | // title: '错误', |
| 51 | // content: ret.data.msg, |
| 52 | // }) |
| 53 | // } |
| 54 | // } else { |
| 55 | // wx.showModal({ |
| 56 | // title: '错误', |
| 57 | // content: '', |
| 58 | // }) |
| 59 | // } |
| 60 | // }) |
| 61 | }, |
| 62 | |
| 63 | /** |
| 64 | * 生命周期函数--监听页面初次渲染完成 |
| 65 | */ |
| 66 | onReady: function() { |
| 67 | |
| 68 | }, |
| 69 | |
| 70 | /** |
| 71 | * 生命周期函数--监听页面显示 |
| 72 | */ |
| 73 | onShow: function() { |
| 74 | |
| 75 | }, |
| 76 | |
| 77 | /** |
| 78 | * 生命周期函数--监听页面隐藏 |
| 79 | */ |
| 80 | onHide: function() { |
| 81 | |
| 82 | }, |
| 83 | |
| 84 | /** |
| 85 | * 生命周期函数--监听页面卸载 |
| 86 | */ |
| 87 | onUnload: function() { |
| 88 | |
| 89 | }, |
| 90 | |
| 91 | /** |
| 92 | * 页面相关事件处理函数--监听用户下拉动作 |
| 93 | */ |
| 94 | onPullDownRefresh: function() { |
| 95 | |
| 96 | }, |
| 97 | |
| 98 | /** |
| 99 | * 页面上拉触底事件的处理函数 |
| 100 | */ |
| 101 | onReachBottom: function() { |
| 102 | |
| 103 | }, |
| 104 | |
| 105 | /** |
| 106 | * 用户点击右上角分享 |
| 107 | */ |
| 108 | onShareAppMessage: function() { |
| 109 | |
| 110 | }, |
| 111 | |
| 112 | signXY: function() { |
| 113 | |
| 114 | wx.showLoading({ |
| 115 | title: '正在请求', |
| 116 | }) |
| 117 | var param = { |
| 118 | "agree": 'yes' |
| 119 | } |
| 120 | wx.$doPost('/v1/signbxy', param, function(ok, ret, err) { |
| 121 | wx.hideLoading(); |
| 122 | if (ok) { |
| 123 | |
| 124 | if (ret.data.code == 200) { |
| 125 | wx.setStorageSync("signed", ret.data.signed); |
| 126 | wx.redirectTo({ |
| 127 | url: '../index/index', |
| 128 | }) |
| 129 | } else { |
| 130 | wx.showModal({ |
| 131 | title: '错误', |
| 132 | content: ret.data.msg, |
| 133 | }) |
| 134 | } |
| 135 | } else { |
| 136 | |
| 137 | wx.showModal({ |
| 138 | title: '错误', |
| 139 | content: ret.data.status, |
| 140 | }) |
| 141 | } |
| 142 | }) |
| 143 | } |
| 144 | }) |