[添加转账,提现等新功能]
This commit is contained in:
72
pages/password/password.js
Normal file
72
pages/password/password.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// pages/password/password.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
passSource : '', //设置密码跳转来源favourUrl为转账跳转
|
||||
passType : '', //是否是首次设置密码
|
||||
disabled : false, //设置支付密码
|
||||
password : '', //支付密码
|
||||
confirmation: '' //确认密码
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad (options) {
|
||||
// 检查用户登录状态
|
||||
const Paypass = wx.getStorageSync("hasPaypass")
|
||||
|
||||
this.setData({
|
||||
passType : Paypass,
|
||||
passSource: options.source
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
*/
|
||||
formSubmit(e) {
|
||||
let newoldPassword= e.detail.value.oldPassword,
|
||||
newPassword = e.detail.value.password,
|
||||
newFormSubmit = e.detail.value.confirmation
|
||||
|
||||
let newUrl = '' //定义接口来源名称
|
||||
|
||||
if(this.data.passType == false) newUrl = wx.$api.user.setPassword(newPassword, newFormSubmit)
|
||||
if(this.data.passType == true) newUrl = wx.$api.user.changePassword(newoldPassword, newPassword, newFormSubmit)
|
||||
|
||||
newUrl.then(res=>{
|
||||
// 已设置密码缓存
|
||||
wx.setStorage({
|
||||
key : 'hasPaypass',
|
||||
data : true
|
||||
})
|
||||
|
||||
this.setData({
|
||||
disabled: true
|
||||
})
|
||||
wx.showToast({
|
||||
title: '设置成功',
|
||||
})
|
||||
|
||||
// 只有从转账页面跳转才回到上一页
|
||||
if(this.data.passSource == "favourUrl") {
|
||||
setTimeout(()=>{
|
||||
wx.navigateBack({delta: 1})
|
||||
},2000)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 其他跳转回到用户中心
|
||||
setTimeout(()=>{
|
||||
wx.switchTab({
|
||||
url: '/pages/user/user'
|
||||
})
|
||||
},2000)
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user