645 lines
31 KiB
JavaScript
645 lines
31 KiB
JavaScript
/**
|
|
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const userApi = require('../../api/user')
|
|
/**
|
|
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const navigation = require('../../utils/navigation')
|
|
/**
|
|
* Purpose: format supports index.js by holding or executing the format page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const format = require('../../utils/format')
|
|
const { getTempRecord, clearTempRecord, setTempRecord } = require('../../utils/storage')
|
|
|
|
/**
|
|
* Purpose: CHANGE_SCENE_OPTIONS supports index.js by holding or executing the change scene options page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const CHANGE_SCENE_OPTIONS = ['MANUAL_RECHARGE', 'MANUAL_INCREASE', 'MANUAL_DEDUCT']
|
|
/**
|
|
* Purpose: VIP_LEVEL_OPTIONS supports index.js by holding or executing the vip level options page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const VIP_LEVEL_OPTIONS = ['普通', '青铜', '白银', '黄金']
|
|
|
|
Page({
|
|
/**
|
|
* Purpose: data supports index.js by holding or executing the data page or API role.
|
|
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
data: {
|
|
/**
|
|
* Purpose: user supports index.js by holding or executing the user page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
user: null,
|
|
/**
|
|
* Purpose: asset supports index.js by holding or executing the asset page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
asset: null,
|
|
/**
|
|
* Purpose: balanceHistory supports index.js by holding or executing the balance history page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
balanceHistory: [],
|
|
/**
|
|
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene index page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
changeSceneIndex: 0,
|
|
/**
|
|
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
vipLevelIndex: 0,
|
|
/**
|
|
* Purpose: balanceForm supports index.js by holding or executing the balance form page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
balanceForm: {
|
|
/**
|
|
* Purpose: amount supports index.js by holding or executing the amount page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
amount: '',
|
|
/**
|
|
* Purpose: externalOrderNo supports index.js by holding or executing the external order no page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
externalOrderNo: '',
|
|
/**
|
|
* Purpose: remark supports index.js by holding or executing the remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
remark: ''
|
|
},
|
|
/**
|
|
* Purpose: vipRemark supports index.js by holding or executing the vip remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
vipRemark: ''
|
|
},
|
|
|
|
/**
|
|
* Purpose: onLoad supports index.js by holding or executing the on load page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
onLoad(options) {
|
|
const cached = getTempRecord('currentUser', null)
|
|
if (cached && (!options || !options.id || String(cached.id) === String(options.id))) {
|
|
this.setUser(cached)
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
onShow() {
|
|
if (!navigation.ensureLogin('进入用户详情')) {
|
|
return
|
|
}
|
|
this.loadAssetData()
|
|
},
|
|
|
|
/**
|
|
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
onUnload() {
|
|
clearTempRecord('currentUser')
|
|
},
|
|
|
|
async loadAssetData() {
|
|
if (!this.data.user) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
const [asset, balanceHistory] = await Promise.all([
|
|
userApi.getUserAsset(this.data.user.id).catch(() => null),
|
|
userApi.getUserBalanceHistory(this.data.user.id).catch(() => [])
|
|
])
|
|
|
|
this.setData({
|
|
asset,
|
|
/**
|
|
* Purpose: balanceHistory supports index.js by holding or executing the balance history page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
balanceHistory: (Array.isArray(balanceHistory) ? balanceHistory : []).map(item => ({
|
|
...item,
|
|
/**
|
|
* Purpose: displayChangeTime supports index.js by holding or executing the display change time page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
displayChangeTime: format.formatDateTime(item.changeTime),
|
|
/**
|
|
* Purpose: amountBadgeClass supports index.js by holding or executing the amount badge class page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
amountBadgeClass: Number(item.amount) >= 0 ? 'success-badge' : 'danger-badge'
|
|
}))
|
|
})
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '用户资产数据加载失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleEdit supports index.js by holding or executing the handle edit page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleEdit() {
|
|
setTempRecord('currentUser', this.data.user)
|
|
navigation.navigate('/pages/user-form/index', {
|
|
/**
|
|
* Purpose: mode supports index.js by holding or executing the mode page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
mode: 'edit',
|
|
/**
|
|
* Purpose: id supports index.js by holding or executing the id page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
id: this.data.user.id
|
|
}).catch(() => undefined)
|
|
},
|
|
|
|
/**
|
|
* Purpose: handlePermissionAssign supports index.js by holding or executing the handle permission assign page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handlePermissionAssign() {
|
|
setTempRecord('currentUser', this.data.user)
|
|
navigation.navigate('/pages/permission-form/index', {
|
|
/**
|
|
* Purpose: mode supports index.js by holding or executing the mode page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
mode: 'assign',
|
|
/**
|
|
* Purpose: userId supports index.js by holding or executing the user id page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
userId: this.data.user.id
|
|
}).catch(() => undefined)
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleBalanceInput supports index.js by holding or executing the handle balance input page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleBalanceInput(event) {
|
|
const field = event.currentTarget.dataset.field
|
|
this.setData({
|
|
[`balanceForm.${field}`]: event.detail.value
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleVipRemarkInput supports index.js by holding or executing the handle vip remark input page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleVipRemarkInput(event) {
|
|
this.setData({
|
|
/**
|
|
* Purpose: vipRemark supports index.js by holding or executing the vip remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
vipRemark: event.detail.value
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleSceneChange supports index.js by holding or executing the handle scene change page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleSceneChange(event) {
|
|
this.setData({
|
|
/**
|
|
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene index page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
changeSceneIndex: Number(event.detail.value)
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleVipLevelChange supports index.js by holding or executing the handle vip level change page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleVipLevelChange(event) {
|
|
this.setData({
|
|
/**
|
|
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level index page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
vipLevelIndex: Number(event.detail.value)
|
|
})
|
|
},
|
|
|
|
async handleBalanceChange() {
|
|
try {
|
|
await userApi.changeUserBalance(this.data.user.id, {
|
|
/**
|
|
* Purpose: amount supports index.js by holding or executing the amount page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
amount: Number(this.data.balanceForm.amount),
|
|
/**
|
|
* Purpose: changeScene supports index.js by holding or executing the change scene page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
changeScene: CHANGE_SCENE_OPTIONS[this.data.changeSceneIndex],
|
|
/**
|
|
* Purpose: externalOrderNo supports index.js by holding or executing the external order no page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
externalOrderNo: this.data.balanceForm.externalOrderNo || undefined,
|
|
/**
|
|
* Purpose: remark supports index.js by holding or executing the remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
remark: this.data.balanceForm.remark || undefined
|
|
})
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '余额已调整',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
this.setData({
|
|
/**
|
|
* Purpose: balanceForm supports index.js by holding or executing the balance form page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
balanceForm: {
|
|
/**
|
|
* Purpose: amount supports index.js by holding or executing the amount page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
amount: '',
|
|
/**
|
|
* Purpose: externalOrderNo supports index.js by holding or executing the external order no page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
externalOrderNo: '',
|
|
/**
|
|
* Purpose: remark supports index.js by holding or executing the remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
remark: ''
|
|
}
|
|
})
|
|
this.loadAssetData()
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '余额调整失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
async handleVipOverride() {
|
|
try {
|
|
await userApi.overrideUserVip(this.data.user.id, {
|
|
/**
|
|
* Purpose: vipLevel supports index.js by holding or executing the vip level page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
vipLevel: VIP_LEVEL_OPTIONS[this.data.vipLevelIndex],
|
|
/**
|
|
* Purpose: remark supports index.js by holding or executing the remark page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
remark: this.data.vipRemark || undefined
|
|
})
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: 'VIP 等级已更新',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
this.loadAssetData()
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || 'VIP 更新失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
async handleVipRecalculate() {
|
|
try {
|
|
await userApi.recalculateUserVip(this.data.user.id)
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '已恢复自动判级',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
this.loadAssetData()
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || 'VIP 重算失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
async handleResetPassword() {
|
|
try {
|
|
await userApi.resetPassword(this.data.user.id)
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '密码已重置',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '密码重置失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleUserAction supports index.js by holding or executing the handle user action page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleUserAction(event) {
|
|
const action = event.currentTarget.dataset.action
|
|
if (action === 'disable') {
|
|
this.updateUserStatus(this.data.user.status === 0 ? 1 : 0)
|
|
return
|
|
}
|
|
if (action === 'delete') {
|
|
this.confirmDelete()
|
|
return
|
|
}
|
|
if (action === 'unbind') {
|
|
this.confirmUnbind()
|
|
}
|
|
},
|
|
|
|
async updateUserStatus(status) {
|
|
try {
|
|
await userApi.updateUserStatus(this.data.user.id, status)
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '用户状态已更新',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
const user = {
|
|
...this.data.user,
|
|
status
|
|
}
|
|
this.setUser(user)
|
|
setTempRecord('currentUser', user)
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '状态更新失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Purpose: confirmDelete supports index.js by holding or executing the confirm delete page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
confirmDelete() {
|
|
wx.showModal({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '确认删除',
|
|
/**
|
|
* Purpose: content supports index.js by holding or executing the content page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
content: '删除后该账号将不再出现在前端可见列表中,确认继续吗?',
|
|
/**
|
|
* Purpose: success supports index.js by holding or executing the success page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
success: async result => {
|
|
if (!result.confirm) {
|
|
return
|
|
}
|
|
try {
|
|
await userApi.deleteUser(this.data.user.id)
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '用户已删除',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
navigation.goBack('/pages/users/index')
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '删除失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: confirmUnbind supports index.js by holding or executing the confirm unbind page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
confirmUnbind() {
|
|
wx.showModal({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '确认解绑',
|
|
/**
|
|
* Purpose: content supports index.js by holding or executing the content page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
content: '解绑后,该用户将无法登录当前店铺,确认继续吗?',
|
|
/**
|
|
* Purpose: success supports index.js by holding or executing the success page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
success: async result => {
|
|
if (!result.confirm) {
|
|
return
|
|
}
|
|
try {
|
|
await userApi.unbindUser(this.data.user.id)
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: '已解除当前店铺绑定',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
} catch (error) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: error.message || '解绑失败',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: setUser supports index.js by holding or executing the set user page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
setUser(user) {
|
|
this.setData({
|
|
/**
|
|
* Purpose: user supports index.js by holding or executing the user page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
user: user ? {
|
|
...user,
|
|
/**
|
|
* Purpose: displayTypeText supports index.js by holding or executing the display type text page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
displayTypeText: format.getUserTypeText(user.type),
|
|
/**
|
|
* Purpose: displayShopName supports index.js by holding or executing the display shop name page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
displayShopName: format.buildShopName(user),
|
|
/**
|
|
* Purpose: displayStatusText supports index.js by holding or executing the display status text page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
displayStatusText: format.getUserStatusText(user.status),
|
|
/**
|
|
* Purpose: displayCreateTime supports index.js by holding or executing the display create time page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
displayCreateTime: format.formatDateTime(user.createTime)
|
|
} : null
|
|
})
|
|
}
|
|
})
|