// pages/my/addressList.js import request from '../../utils/request' Page({ /** * 页面的初始数据 */ data: { listInfo: [], selectId: '', flag:0, pageNum: 1, pageSize:10 }, select(e){ console.log(e.currentTarget.dataset.item) if(this.data.flag){ wx.setStorageSync('addressInfo', e.currentTarget.dataset.item); wx.navigateBack({ delta: 1 }) } }, editEvent(e){ wx.navigateTo({ url: '/pages/my/addressAdd?id='+e.currentTarget.dataset.id, }) }, topEvent(e){ const that = this const type = e.currentTarget.dataset.default; console.log('荆防颗粒圣诞节fdsfsd来看',type) const param = { "id": e.currentTarget.dataset.id, // 地址⾃增 Id,必填项 "isDefault": type == 2?1:2 // 是否默认地址,1是 2否,必填项 } console.log('荆防颗粒1111圣诞节来看') request._post('/firefly/account-address/my-address/set/default',param, res=>{ if(res.retCode == 0){ that.getList() } }) }, addEvent(){ wx.navigateTo({ url: '/pages/my/addressAdd', }) }, radioChange(e) { this.setData({ selectId: e.detail.value }) }, delEvent(e){ const param = { id: e.currentTarget.dataset.id } request._post('/firefly/account-address/my-address/delete/one',param, res=>{ if(res.retCode == 0){ this.getList() wx.showToast({ title: '删除成功', icon: 'none', duration:3000 }) } }) }, getList(){ const param = { pageNum: this.data.pageNum, pageSize:this.data.pageSize } request._post('/firefly/account-address/my-address/list',param, res=>{ if(res.retCode == 0){ if(res.body.length>0){ var listdata = this.data.listInfo listdata.push.apply(listdata, res.body) this.setData({ listInfo:listdata, pageNum:++res.pageInfo.pageNum }) }else{ if(this.data.pageNum != 1){ setTimeout(() => { wx.showToast({ title: '没有更多数据', icon: 'none', duration: 2000 }) }, 200); } } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ flag:options.flag }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getList() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getList() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })