纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

79 lines
1.6 KiB

// pages/adress/list/index.js
const request = require('../../../utils/request')//导入模块
const event = require('../../../utils/event.js')
Page({
/**
* 页面的初始数据
*/
data: {
type: 0,
adressList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.type){
this.setData({
type: Number(options.type)
})
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getAdressList()
},
lookItem: function (e) {
var item = this.data.adressList[e.currentTarget.dataset.index]
if(this.data.type == 1){
event.emit('EventMessage', { what: 301, obj: item, desc: 'AddressChoose' })
wx.navigateBack({ delta: 1 })
} else {
wx.navigateTo({
url: '/pages/adress/create/index?type=0&shippingAddressId='+ item.shippingAddressId
})
}
},
/**
* 跳转至编辑地址
*/
toEdit: function (e) {
var item = this.data.adressList[e.currentTarget.dataset.index]
wx.navigateTo({
url: '/pages/adress/create/index?type=0&shippingAddressId='+ item.shippingAddressId
})
},
/**
* 跳转至新增地址
*/
toCreate: function () {
wx.navigateTo({
url: '/pages/adress/create/index?type=1'
})
},
/**
* 获取地址列表
*/
getAdressList:function(){
wx.showLoading({
title: '加载中',
mask: true
})
request.get('/recycle-service/get/shipping-address-list').then(res => {
this.setData({
adressList:res.data
})
wx.hideLoading()
}).catch((e) => {
wx.hideLoading()
})
}
})