123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- huHaoList: [
- {
- id: 1,
- name: '王源',
- tag: '家',
- phone: '32018545245104',
- address: '徐州市丰县***楼102室',
- deleted: 0
- },
- {
- id: 2,
- name: '王长江',
- tag: '父母家',
- phone: '32018545245104',
- address: '徐州市泗县***楼502室',
- deleted: 0
- },
- {
- id: 3,
- name: '李明',
- tag: '公司',
- phone: '32018545245105',
- address: '徐州市云龙区***路88号',
- deleted: 0
- },
- {
- id: 4,
- name: '张伟',
- tag: '',
- phone: '32018545245106',
- address: '徐州市鼓楼区***街道45号',
- deleted: 0
- }
- ],
- showUnbindModal: false,
- currentHuHao: null
- },
- onLoad: function(options) {
- this.filterHuHaoList();
- },
- // 过滤户号列表,只显示deleted=0的数据
- filterHuHaoList: function() {
- const filteredList = this.data.huHaoList.filter(item => item.deleted === 0);
- this.setData({
- huHaoList: filteredList
- });
- },
- // 点击解除绑定按钮
- unbindHuHao: function(e) {
- const id = e.currentTarget.dataset.id;
- const huHao = this.data.huHaoList.find(item => item.id === id);
-
- this.setData({
- showUnbindModal: true,
- currentHuHao: huHao
- });
- },
- // 取消解绑
- cancelUnbind: function() {
- this.setData({
- showUnbindModal: false,
- currentHuHao: null
- });
- },
- // 确认解绑
- confirmUnbind: function() {
- const id = this.data.currentHuHao.id;
-
- // 这里应该调用后端接口,将deleted设为1
- // 模拟接口调用成功后的处理
- const updatedList = this.data.huHaoList.map(item => {
- if (item.id === id) {
- return {...item, deleted: 1};
- }
- return item;
- });
-
- this.setData({
- huHaoList: updatedList,
- showUnbindModal: false,
- currentHuHao: null
- });
-
- // 刷新页面数据
- this.filterHuHaoList();
-
- wx.showToast({
- title: '解绑成功',
- icon: 'success',
- duration: 2000
- });
- },
- // 跳转到绑定新户号页面
- goToBindNewHuHao: function() {
- wx.navigateTo({
- url: '/pages/huhaobangding/huhaobangding'
- });
- },
- /**
- * 返回上一页
- */
- goBack: function() {
- wx.navigateBack();
- },
- })
|