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.
57 lines
1.4 KiB
57 lines
1.4 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' })
|
|
}
|
|
})
|