纸通宝小程序
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.
 

50 lines
1.3 KiB

// pages/adress/list/index.js
import { getAddressList } from "../../api/ztb"
const event = require('../../../utils/event.js')
Page({
/**
* 页面的初始数据
*/
data: {
type: 0,
adressList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.type){
this.data.type = Number(options.type)
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
wx.showLoading({ title: '加载中', mask: true })
getAddressList().then(res => {
this.setData({ adressList:res.data })
wx.hideLoading()
}).catch((e) => {
wx.hideLoading()
})
},
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' })
}
})