123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- // pages/pwdSet/index.js
- const util = require('../../utils/util.js');
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- oldPassword:'',
- newPassword:'',
- confirmPassword:'',
- userInfo:{
- password:''
- },
- message:{}
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- changePassword(){
- var that = this
- console.log("66666")
- console.log(that.data)
- // that.data.userInfo = app.globalData.userInfo
- // console.log("88888")
- // console.log(that.data.userInfo)
- // if(that.data.userInfo.password != that.data.oldPassword){
- // wx.showToast({
- // title: "旧密码输入错误!",
- // icon: "none"
- // });
- // return
- // }
- // if(util.isNullOrEmpty(that.data.newPassword)){
- // wx.showToast({
- // title: "新密码不允许为空!",
- // icon: "none"
- // });
- // return
- // }
- // if(that.data.newPassword != that.data.confirmPassword){
- // wx.showToast({
- // title: "两次输入密码不一致!",
- // icon: "none"
- // });
- // return
- // }
- util.request(util.api.changePassword, {oldPassword:that.data.oldPassword,newPassword:that.data.newPassword,confirmPassword:that.data.confirmPassword}, "POST", true, true,app.globalData.token).then((res)=>{
- console.log("444")
- console.log(res)
- console.log("333")
- that.data.message = res.message
- if (res.code == 200) {
- if(res.result === "密码重置成功!"){
- wx.showToast({
- title: "密码重置成功!",
- icon: "none"
- });
- setTimeout(()=>{
- wx.navigateBack({
- delta: 1,
- })
- },500)
- }
- }
- if(res.code == 500){
- if(that.data.message === "旧密码输入错误!"){
- wx.showToast({
- title: "旧密码输入错误!",
- icon: "none"
- });
- return
- }
- if(that.data.message === "新密码不允许为空!"){
- wx.showToast({
- title: "新密码不允许为空!",
- icon: "none"
- });
- return
- }
- if(that.data.message === "两次输入密码不一致!"){
- wx.showToast({
- title: "两次输入密码不一致!",
- icon: "none"
- });
- return
- }
- }
- }).catch((res) => {})
- },
- inputedit: function (e) {
- let _this = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- _this.data[name] = value;
- _this.setData({
- [name]: _this.data[name]
- });
- },
- })
|