| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- // pages/address/index.js
- const api = require('../../../api/index.js');
-
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- address:[]
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getaddress()
- },
- getaddress(){
- let data ={
- operationId:''
- }
- api.request(`/sysaddress/selectaddress`, 'post',data,{ isPublic: false })
- .then((data) => {
- console.log(data.data);
- if (data.code==200) {
- this.setData({
- address:data.data
- })
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
- });
- },
- onIconTap(item){
- console.log(item.currentTarget.dataset.item);
-
- if (item.currentTarget.dataset.item=='add') {
- wx.navigateTo({
- url: `/package-order/pages/newaddress/index`,
- })
- }else{
- console.log(item.currentTarget.dataset.item);
- let obj = item.currentTarget.dataset.item
- wx.setStorageSync("editAddress", obj);
- wx.navigateTo({
- url: `/package-order/pages/newaddress/index`,
- })
- }
-
- },
- onDelete(id){
- let _this = this
- // 在页面的 js 文件中
- wx.showModal({
- title: '提示',
- content: '确定要取消工单吗?',
- success (res) {
- if (res.confirm) {
- console.log(id.currentTarget.dataset.id);
- let data ={
- addressId:id.currentTarget.dataset.id
- }
- api.request(`/sysaddress/deleteaddress`, 'post',data,{ isPublic: false })
- .then((data) => {
- console.log(data.data);
- if (data.code==200) {
- wx.showToast({ title: '取消成功', icon: 'none' });
- _this.getaddress()
- }
- })
- .catch((err) => {
- console.error('请求失败:', err);
- });
- } else if (res.cancel) {
- // _this.showInfo('取消操作');
- wx.showToast({ title: '取消操作', icon: 'none' });
- }
- }
- })
- },
- radioChange(e){
- console.log(e.detail.value);
- let data ={
- addressId:e.detail.value,
- isDefault:true
- }
- api.request(`/sysaddress/updateaddress`, 'post',data,{ isPublic: false })
- .then((data) => {
- console.log(data.data);
- if (data.code==200) {
- this.getaddress()
- }
-
- })
- .catch((err) => {
-
- console.error('请求失败:', err);
- });
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getaddress()
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|