补齐店务端改密导出员工订单
This commit is contained in:
@@ -1,12 +1,48 @@
|
||||
const userApi = require('../../api/user')
|
||||
|
||||
function clearSessionAndGoLogin() {
|
||||
const app = getApp()
|
||||
if (app && typeof app.clearSession === 'function') {
|
||||
app.clearSession()
|
||||
}
|
||||
wx.reLaunch({ url: '/pages/login/index' })
|
||||
}
|
||||
|
||||
Page({
|
||||
data: { form: { oldPassword: '', newPassword: '', confirmPassword: '' } },
|
||||
data: {
|
||||
form: { oldPassword: '', newPassword: '', confirmPassword: '' },
|
||||
saving: false
|
||||
},
|
||||
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
|
||||
save() {
|
||||
async save() {
|
||||
if (this.data.saving) {
|
||||
return
|
||||
}
|
||||
if (!this.data.form.oldPassword) {
|
||||
wx.showToast({ title: '请填写原密码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!this.data.form.newPassword || !this.data.form.confirmPassword) {
|
||||
wx.showToast({ title: '请填写新密码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.form.newPassword !== this.data.form.confirmPassword) {
|
||||
wx.showToast({ title: '两次密码不一致', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.showToast({ title: '已提交' })
|
||||
this.setData({ saving: true })
|
||||
try {
|
||||
await userApi.updatePassword({
|
||||
oldPassword: this.data.form.oldPassword,
|
||||
password: this.data.form.newPassword
|
||||
})
|
||||
wx.showToast({ title: '密码已修改', icon: 'success' })
|
||||
setTimeout(clearSessionAndGoLogin, 600)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '密码修改失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ saving: false })
|
||||
}
|
||||
},
|
||||
back() { wx.navigateBack() }
|
||||
})
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
<view class="field"><text class="field-label">新密码</text><input password value="{{form.newPassword}}" data-field="newPassword" bindinput="onInput" /></view>
|
||||
<view class="field"><text class="field-label">确认密码</text><input password value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" /></view>
|
||||
</view>
|
||||
<view class="fixed-bottom"><button class="primary-btn" bindtap="save">保存密码</button></view>
|
||||
<view class="fixed-bottom"><button class="primary-btn" loading="{{saving}}" disabled="{{saving}}" bindtap="save">保存密码</button></view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user