// pages/login/reg/reg.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { phone:'', psw: '', codeNum: '', userName: '', tjCode:'', imgSrc: '', address:'', detailedaddress:'', radio:true, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (wx.getStorageSync('user')) { app.setUser(wx.getStorageSync('user')) wx.switchTab({ url: '/pages/home/home', }) } this.getImg() }, // 绑定用户名 bindUserName(e) { this.setData({ userName: e.detail.value }) }, // 绑定密码 bindPSW(e) { this.setData({ psw: e.detail.value }) }, // 验证码 bindcodeNum(e) { this.setData({ codeNum: e.detail.value }) }, // 验证码 getImg() { this.setData({ imgSrc: "" }) this.setData({ uuid: "" }) wx.request({ url: `http://39.105.187.20/prod-api/captchaImage`, method: 'GET', header: { "Access-Control-Allow-Headers": 'token' }, dataType: 'json', success: (res, header) => { // console.log(res); if (res.data.code != 200) { wx.showToast({ title: res.data.msg, icon: 'none' }); } else { this.setData({ imgSrc: "data:image/gif;base64," + res.data.img, uuid: res.data.uuid }) // this.imgSrc = "data:image/gif;base64," + res.data.img // this.login.uuid = res.data.uuid // console.log(this.imgSrc); } }, }); }, choseLocation() { wx.chooseLocation({ success: (res) => { // console.log(res) this.setData({ address: res.name, detailedaddress: res.address, locmap: { latitude: res.latitude, longitude: res.longitude }, markers: [{ id: 0, latitude: res.latitude, longitude: res.longitude, iconPath: '/images/ProRep/weizhi.png', width: '50rpx', height: '50rpx' }] }) }, fail: () => { wx.getSetting({ success: (res) => { var statu = res.authSetting; if (!statu['scope.userLocation']) { //未授权 wx.showModal({ title: '授权定位', content: '需要获取您的地理位置,请先设置授权', // cancelColor: 'skyblue', confirmText: "去设置", success: (res) => { if (res.cancel) { //点击取消,默认隐藏弹框 } else { //点击确定 wx.openSetting({ withSubscriptions: true, success: (res) => { this.onLoad() } }) } } }) } } }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })