| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import { FunCode } from "../../../constants/enum/funcode"
- import { sendMsgToMQ } from "../../../services/api/common/index"
- import { getErrorMsg, isEncrypted, loginid, protoHeader } from "../../../services/utils"
- import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index"
- import { encryptBody } from "../../../utils/websocket/crypto"
- import CryptoJS from 'crypto-js';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 旧密码
- oldpwd: '',
- /// 新密码
- newpwd: '',
- /// 确认新密码
- confirmpwd: ''
- },
- /**
- * 返回上层视图
- */
- backToParent() {
- /// 返回上层视图
- wx.navigateBack()
- },
- /**
- * 修改密码
- */
- doModifyPwd() {
- /// 合规性校验
- if (!this.check()) { return }
- /// showModel
- showModel(() => {
- /// showLoading
- showLoading(() => {
- const OldPwd = loginid()+this.data.oldpwd
- const NewPwd = loginid()+this.data.newpwd
- /// 参数信息
- const info = JSON.stringify({
- Header: protoHeader(FunCode.ModifyPwdReq),
- ModifyPwdType: 1,
- ModifyPwdID: loginid(),
- OldPwd: CryptoJS.SHA256(OldPwd).toString(),
- NewPwd: CryptoJS.SHA256(NewPwd).toString()
- })
- /// 发送请求
- sendMsgToMQ({
- data: {
- isEncrypted: isEncrypted(),
- funCodeReq: FunCode.ModifyPwdReq,
- funCodeRsp: FunCode.ModifyPwdRsp,
- data: encryptBody(info)
- },
- success: (res) => {
- /// 请求失败
- if (res.code ! = 0) {
- hideLoading(() => {}, res.msg)
- return
- }
- /// 解析对象
- const data = JSON.parse(res.data.data)
- if (data.RetCode != 0) {
- hideLoading(() => {}, getErrorMsg(data.RetCode))
- return
- }
- hideLoading(()=> {
- /// 系统登出响应
- this.onLoginOut()
- }, '修改成功', 'success')
- },
- fail: (emsg) => {
- hideLoading(() => {}, emsg)
- }
- })
- }, '修改中')
- }, '提示', '确定要修改密码吗?')
- },
- /**
- * 系统登出响应
- */
- onLoginOut() {
- /// loding....
- showLoading(()=>{
- /// 登出
- setTimeout(function () {
- hideLoading(()=>{
- // on confirm
- wx.reLaunch({ url: '/pages/login/index' })
- }, '登出成功', 'success')
- }, 3000)
- }, '登出中....')
- },
- check(): boolean {
- /// 请输入原密码!
- if (this.data.oldpwd === '') {
- showToast('请输入原密码!')
- return false
- }
- /// 请输入新密码!
- if (this.data.newpwd === '') {
- showToast('请输入新密码!')
- return false
- }
- /// 请输入原密码!
- if (this.data.confirmpwd === '') {
- showToast('请再次确认新密码!')
- return false
- }
- /// 两次输入的密码不一样!
- if (this.data.confirmpwd != this.data.newpwd) {
- showToast('两次输入的密码不一样!')
- return false
- }
- return true
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|