123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // customized/pages/address/address.js
- let app = getApp();
- let host = app.globalData.servsers; // 请求的url
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- addressList: [],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getaddress()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- getaddress() {
- wx.showLoading({
- title: '加载中',
- })
- let that = this;
- wx.request({
- url: host + '/adressapi/adressview',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- user_id: app.globalData.user_id,// 'oovpNwjlsY6xx8ceCebFa1dOLd9E' //app.globalData.user_id,
- },
- success(res) {
- console.log(res, "address")
- that.setData({
- addressList:[...res.data.rows]
- })
- },
- complete(){
- wx.hideLoading()
- }
- })
- },
- addAddress(){
- wx.navigateTo({
- url: '/customized/pages/address/add/add',
- })
- },
- delAddress(e){
- let that = this, id = e.target.dataset.id;
- wx.showModal({
- title: '提示',
- content: '是否确定删除地址?',
- success(res){
- if (res.confirm) {
- console.log('用户点击确定')
- wx.request({
- url: host + '/adressapi/delete',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- method:'get',
- data:{
- id: id
- },
- success(res){
- console.log(res,"删除");
- wx.showToast({
- title: '删除成功!',
- icon:'none'
- })
- that.getaddress()
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- console.log(e.target.dataset.id)
- },
- editAddress(e){
- wx.setStorageSync('address', e.target.dataset.item)
- wx.navigateTo({
- url: '/customized/pages/address/add/add?type=edit',
- })
- },
- selectAddress(e){ // 选中地址
- console.log(e)
- wx.setStorageSync('accountAddress', e.currentTarget.dataset.item)
- wx.navigateBack({
- delta: 1
- })
- // wx.navigateTo({
- // url: '/customized/pages/accounts/accounts?type=selectAddress',
- // })
- }
- })
|