2025-06-06 15:07:26 +08:00

147 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { areaList } from '../data/index';
import { doNavigateWithUser } from '../../../utils/helper';
import { postUrl } from '../../../utils/util';
import { apiArr } from '../../../api/user';
Page({
/**
* 页面的初始数据
*/
data: {
addressList: [
{
detailArea: '河北省衡水市桃城区中华大街某某小区6号楼5单元 2701',
name: '马玉波',
mobile: '12304565210'
},
{
detailArea: '河北省唐山区桃城区中华大街某某小区6号楼5单元 2701',
name: '聂玲',
mobile: '12304565210'
},
{
detailArea: '河北省石家庄市桃城区中华大街某某小区6号楼5单元 2701',
name: '萧芸芸',
mobile: '12304565210'
},
],
address: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.init();
},
init() {
wx.showLoading({
title: '加载中',
})
postUrl(apiArr.addr, {}, res => {
wx.hideLoading();
console.log('获取地址信息接口', res);
let address = {
...res,
optionAddr: `${areaList.province_list[res.city_id]}${areaList.city_list[res.area_id]}${areaList.county_list[res.business_id]}${res.addr}`
}
if (res.city_id === 0 || res.area_id === 0 || res.business_id === 0) {
address.optionAddr = res.addr
};
this.setData({
address: address
})
})
},
headerAddressClick(event) {
const { name, item } = event.currentTarget.dataset;
// 选择编辑时 携带参数跳转到新页面
console.log('地址按钮触发', event);
console.log('name',name, item);
if(name === 'edit') {
console.log('携带item参数跳转到新页面并且传递btn按钮文案');
wx.setStorage({
key: 'itemData',
data: item,
success: function() {
doNavigateWithUser({ url: `/packages/user/addAress/index?name=${name}` });
},
});
return;
}
if (name === 'select') {
// 缓存新地址,在上一页面读取后及时删除
wx.setStorageSync('newAddress', item);
wx.setStorageSync('isNewAddress', true);
// 关闭当前页 返回上一页
wx.navigateBack({
delta: 1
})
}
if(name === 'delete') {
wx.showModal({
  title: '提示',
  content: '此功能暂未开通!',
  showCancel:false,
})
}
},
headerAddAddressClick() {
console.log('添加新地址');
wx.showModal({
title: '提示',
content: '此功能暂未开通!',
showCancel:false,
});
return;
doNavigateWithUser({ url: `/packages/user/addAress/index` });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})