const app = getApp() Page({ data: { datatype: '', chose: '', addressList: [], indicatorDots: true, autoplay: true, interval: 5000, duration: 2000, loaddisplay: true, userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo') }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function(options) { if (JSON.stringify(options) != "{}") { this.setData({ datatype: options.type, chose: 'chose' }) } var that = this wx.request({ url: app.globalData.url + '/getWXUserAddress', method: 'get', data: { xu_openid: app.globalData.openid }, success: function(res) { that.setData({ addressList: res.data, loaddisplay: 'none' }) }, fail() { app.timeOut() } }) let _this = this; _this.setData({ navH: app.globalData.navHeight }) }, getUserInfo: function(e) { app.globalData.userInfo = e.detail.userInfo this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) }, // hrefCl: function(e) { // wx.navigateTo({ // url: '/pages/consultant/consultant' // }) // }, // hrefPm: function(e) { // wx.navigateTo({ // url: '/pages/promotion/promotion' // }) // }, // hrefEq: function(e) { // wx.navigateTo({ // url: '/pages/equipment/equipment' // }) // }, radioChange: function(e) { var that = this wx.request({ url: app.globalData.url + '/updateWXUserDefAddress', method: 'get', data: { id: e.detail.value }, success: function(res) { wx.showToast({ title: '设置成功!', icon: 'none', duration: 1000 }) wx.request({ url: app.globalData.url + '/getWXUserAddress', method: 'get', data: { xu_openid: app.globalData.openid }, success: function(res) { that.setData({ addressList: res.data }) } }) } }) }, hrefCreateAddress: function() { if (this.data.chose == "chose") { wx.navigateTo({ url: '/pages/mine/myaddress/createaddress/createaddress?type=chose' }); } else { wx.navigateTo({ url: '/pages/mine/myaddress/createaddress/createaddress' }); } }, hrefCreateedit: function(e) { wx.navigateTo({ url: '/pages/mine/myaddress/createaddress/createaddress?datatype=update&id=' + e.currentTarget.dataset.id + '&consignee=' + e.currentTarget.dataset.consignee + '&city=' + e.currentTarget.dataset.city + '&county=' + e.currentTarget .dataset.county + '&phone=' + e.currentTarget.dataset.phone + '&address=' + e.currentTarget.dataset.address }); }, hrefCreatedel: function(e) { var that = this wx.request({ url: app.globalData.url + '/deleteWXUserDefAddress', method: 'get', data: { id: e.currentTarget.dataset.id }, success: function(res) { wx.showToast({ title: '删除成功!', icon: 'none', duration: 1000 }) wx.request({ url: app.globalData.url + '/getWXUserAddress', method: 'get', data: { xu_openid: app.globalData.openid }, success: function(res) { that.setData({ addressList: res.data }) }, fail() { app.timeOut() } }) }, fail() { app.timeOut() } }) }, chose: function(e) { var pages = getCurrentPages(); var currPage = pages[pages.length - 1]; var prevPage = pages[pages.length - 2]; prevPage.setData({ xa_consignee: e.currentTarget.dataset.consignee, xa_city: e.currentTarget.dataset.city, xa_county: e.currentTarget.dataset.county, xa_address: e.currentTarget.dataset.address, xa_phone: e.currentTarget.dataset.phone, }) wx.navigateBack({ delta: 1 }) } })