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.
hunjianghu/杨盼成/pages/select-address/index.js

58 lines
1.1 KiB

//index.js
const api = require('../../utils/request.js')
//获取应用实例
var app = getApp()
Page({
data: {
addressList: []
},
selectTap: function(e) {
var id = e.currentTarget.dataset.id;
api.fetchRequest('/user/shipping-address/update', {
token: wx.getStorageSync('token'),
id: id,
isDefault: 'true'
}).then(function(res) {
wx.navigateBack({})
})
},
addAddess: function() {
wx.navigateTo({
url: "/pages/address-add/index"
})
},
editAddess: function(e) {
wx.navigateTo({
url: "/pages/address-add/index?id=" + e.currentTarget.dataset.id
})
},
onLoad: function() {
console.log('onLoad')
},
onShow: function() {
this.initShippingAddress();
},
initShippingAddress: function() {
var that = this;
api.fetchRequest('/user/shipping-address/list', {
token: wx.getStorageSync('token')
}).then(function(res) {
if (res.data.code == 0) {
that.setData({
addressList: res.data.data
});
} else if (res.data.code == 700) {
that.setData({
addressList: null
});
}
})
}
})