123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- var businessT = require('../../../../../tool/business-tool.js')
- var sysT = require('../../../../../tool/sys-tool.js')
- var key = require('../../../../../constant/key.js')
- var url = require('../../../../../constant/url.js')
- var M = require('../../../../../tool/md5.js')
- import Net from '../../../../../tool/net.js'
- var net = new Net()
- var app = getApp()
- Page({
- data: {
- ui: [{ t: '原密码', p: '请输入原密码' }, { t: '新密码', p: '请设置新密码' }, { t: '确认密码', p: '请确认新密码' }]
- },
- inputAction(e) {
- if (e.currentTarget.dataset.index == 0) {
- this.setData({
- oldPwd: e.detail.value
- })
- } else if (e.currentTarget.dataset.index == 1) {
- this.setData({
- newPwd: e.detail.value
- })
- } else {
- this.setData({
- surePwd: e.detail.value
- })
- }
- if (this.data.oldPwd && this.data.newPwd && this.data.surePwd) {
- this.setData({
- canSave: true
- })
- } else {
- this.setData({
- canSave: false
- })
- }
- },
- btnAction() {
- var prePassword = M.md5(this.data.oldPwd)
- var password = M.md5(this.data.newPwd)
- if (swan.getStorageSync(key.StorageKey.userCode) != prePassword) {
- swan.showToast({
- title: '原密码不正确',
- icon: 'none',
- mask: true
- });
- return
- }
- if (this.data.newPwd != this.data.surePwd) {
- swan.showToast({
- title: '新密码和确认密码不一致',
- icon: 'none',
- mask: true
- });
- return
- }
- if (this.data.newPwd.length <6|| this.data.surePwd.length <6) {
- swan.showToast({
- title: '请输入6位以上的新密码',
- icon: 'none',
- mask: true
- });
- return
- }
- swan.showLoading({
- title: '请稍后...',
- mask: true,
- });
- net.connectNeedLogin({
- url: url.app_host + url.changePwd,
- data: { prePassword, password },
- success: (err, res) => {
- swan.setStorageSync(key.StorageKey.userCode,password)
- swan.hideLoading();
- swan.showToast({
- title: '修改成功',
- icon: 'none',
- mask: true
- });
- swan.navigateBack();
- },
- fail: (err, res) => {
- swan.hideLoading();
- console.log(err)
- businessT.showFailTips(err)
- }
- }, false)
- },
- onLoad: function () {
- // 监听页面加载的生命周期函数
- },
- onReady: function () {
- // 监听页面初次渲染完成的生命周期函数
- },
- onShow: function () {
- // 监听页面显示的生命周期函数
- },
- onHide: function () {
- // 监听页面隐藏的生命周期函数
- },
- onUnload: function () {
- // 监听页面卸载的生命周期函数
- },
- onPullDownRefresh: function () {
- // 监听用户下拉动作
- },
- onReachBottom: function () {
- // 页面上拉触底事件的处理函数
- },
- onShareAppMessage: function () {
- // 用户点击右上角转发
- }
- });
|