|
@@ -6,7 +6,7 @@ Page({
|
|
|
data: {
|
|
|
huHaoList: [],
|
|
|
showUnbindModal: false,
|
|
|
- currentHuHao: null
|
|
|
+ unbindId: null
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
@@ -34,21 +34,12 @@ Page({
|
|
|
let apiReturnData = res.data;
|
|
|
debugger;
|
|
|
_this.setData({
|
|
|
- huHaoList: apiReturnData.data.map(data => {
|
|
|
- return {
|
|
|
- id: data.id,
|
|
|
- name: data.username,
|
|
|
- tag: data.groupName,
|
|
|
- phone: data.usernumber,
|
|
|
- address: data.address,
|
|
|
- deleted: 0
|
|
|
- };
|
|
|
- }),
|
|
|
+ huHaoList: apiReturnData.data,
|
|
|
})
|
|
|
},
|
|
|
fail(error) {
|
|
|
wx.hideLoading()
|
|
|
- utils.simleInfo('登录失败,请稍后再试')
|
|
|
+ utils.simleInfo('获取数据失败,请稍后再试')
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -56,11 +47,10 @@ Page({
|
|
|
// 点击解除绑定按钮
|
|
|
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
|
|
|
+ unbindId: id
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -68,39 +58,83 @@ Page({
|
|
|
cancelUnbind: function () {
|
|
|
this.setData({
|
|
|
showUnbindModal: false,
|
|
|
- currentHuHao: null
|
|
|
+ unbindId: 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;
|
|
|
+ const id = this.data.unbindId;
|
|
|
+ this.accountUnbind(id);
|
|
|
+ },
|
|
|
+ // 解绑方法
|
|
|
+ accountUnbind:function (id) {
|
|
|
+ debugger;
|
|
|
+ const unbindInfo = this.data.huHaoList.filter(item => {
|
|
|
+ return item.id === id;
|
|
|
+ })[0];
|
|
|
+ const otherInfo=this.data.huHaoList.filter(item => {
|
|
|
+ return item.id!= id;
|
|
|
});
|
|
|
-
|
|
|
- this.setData({
|
|
|
- huHaoList: updatedList,
|
|
|
- showUnbindModal: false,
|
|
|
- currentHuHao: null
|
|
|
+ const _this = this;
|
|
|
+ wx.showLoading({
|
|
|
+ title: '获取中...',
|
|
|
+ mask: true,
|
|
|
});
|
|
|
-
|
|
|
- // 刷新页面数据
|
|
|
- this.filterHuHaoList();
|
|
|
-
|
|
|
- wx.showToast({
|
|
|
- title: '解绑成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.interfaceUrls.accountUnbind,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ account: unbindInfo.usernumber,
|
|
|
+ deKey: unbindInfo.dsKey,
|
|
|
+ refresh: false,
|
|
|
+ //为true 时otherDsKeys最好必填节约后端请求时间
|
|
|
+ otherDsKeys: []
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json', // 默认值
|
|
|
+ 'token': app.globalData.userWxInfo.token,
|
|
|
+ // '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ wx.hideLoading();
|
|
|
+ let apiReturnData = res.data;
|
|
|
+ if(apiReturnData.code=='200'){
|
|
|
+ wx.showToast({
|
|
|
+ title: '解绑成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ _this.setData({
|
|
|
+ huHaoList: otherInfo,
|
|
|
+ showUnbindModal: false,
|
|
|
+ currentHuHao: null
|
|
|
+ });
|
|
|
+ if(otherInfo.length==0){
|
|
|
+ app.globalData.currentAccountInfo=[];
|
|
|
+ app.globalData.userWxInfo.currentDsKey="";
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/FirstBangDing/FirstBangDing',
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ app.globalData.currentAccountInfo=otherInfo[0];
|
|
|
+ app.globalData.userWxInfo.currentDsKey=otherInfo[0].deKey;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: apiReturnData.msg,
|
|
|
+ icon: 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail(error) {
|
|
|
+ wx.hideLoading();
|
|
|
+ utils.simleInfo('户号解绑失败,请稍后再试');
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
// 跳转到绑定新户号页面
|
|
|
goToBindNewHuHao: function () {
|
|
|
wx.navigateTo({
|