浏览代码

登录判断是否为初始密码

xiaohaizhao 1 年之前
父节点
当前提交
fa0b504d6e
共有 4 个文件被更改,包括 89 次插入72 次删除
  1. 2 1
      app.js
  2. 15 1
      pages/index/index.js
  3. 71 70
      pages/login/modules/account.js
  4. 1 0
      pages/login/phone.js

+ 2 - 1
app.js

@@ -21,7 +21,7 @@ App({
 				console.log(res)
 			}
 		})
-		
+
 		console.log(this.globalData.http.baseUrl.replace("https", "wss").replace("http", "ws") + '/yos/webSocket/' + wx.getStorageSync('userMsg').token)
 
 		this.globalData.SocketTask.onOpen(function (res) {
@@ -46,5 +46,6 @@ App({
 		getCollectCount: null, // 获取购物车数量
 		socketEstablish: false, //是否已经建立socket
 		SocketTask: '', // Socket方法
+		remindchangepassword_str: ""
 	},
 })

+ 15 - 1
pages/index/index.js

@@ -22,7 +22,21 @@ Page({
 		this.refreshData();
 		this.getCollectCount();
 		this.updateMsgCount();
-		this.getAnnunciate()
+		this.getAnnunciate();
+		if (getApp().globalData.remindchangepassword_str) wx.showModal({
+			title: "提示",
+			content: getApp().globalData.remindchangepassword_str,
+			confirmText: '前往修改',
+			cancelText: "下次再说",
+			success: ({
+				confirm
+			}) => {
+				getApp().globalData.remindchangepassword_str = null;
+				if (confirm) wx.navigateTo({
+					url: '/pages/index/userCenter/changePassword/index',
+				})
+			},
+		})
 	},
 	getAnnunciate() {
 		_Http.basic({

+ 71 - 70
pages/login/modules/account.js

@@ -1,74 +1,75 @@
 const loginMsg = require("./login"),
-    md5 = require("../../../utils/md5"),
-    _Http = getApp().globalData.http;
+	md5 = require("../../../utils/md5"),
+	_Http = getApp().globalData.http;
 
 Component({
-    properties: {},
-    options: {
-        addGlobalClass: true
-    },
-    data: {
-        accountno: "",
-        password: "",
-        inputType: "password", //密码输入框类型
-        memory: true, //记忆
-        focus: false,
-    },
-    lifetimes: {
-        attached: function () {
-            /* 恢复缓存中保存的账号密码 */
-            this.setData({
-                ...wx.getStorageSync('loginMsg')
-            });
-            this.allowOrNot();
-        }
-    },
-    methods: {
-        /* input输入 */
-        inputChange(e) {
-            this.setData({
-                [e.target.dataset.name]: e.detail.value.trim()
-            })
-            this.allowOrNot()
-        },
-        /* 验证是否允许登录 */
-        allowOrNot() {
-            getCurrentPages()[0].setData({
-                disabled: (this.data.accountno.length > 0 && this.data.password.length > 0) ? false : true
-            })
-        },
-        /* 改变密码输入框类型 */
-        changePasswordType() {
-            this.setData({
-                inputType: this.data.inputType == "text" ? 'password' : 'text'
-            })
-        },
-        /* 是否记忆密码 */
-        isMemory() {
-            this.setData({
-                memory: !this.data.memory
-            })
-        },
-        /* 处理登录 */
-        handleLogin() {
-            _Http.login({
-                "accountno": this.data.accountno,
-                "password": md5.hexMD5(this.data.password),
-                "systemclient": "wechatsaletool"
-            }).then(res => {
-                getCurrentPages()[0].setData({
-                    loading: false
-                })
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.msg,
-                    icon: "none"
-                })
-                wx.setStorageSync('loginMsg', {
-                    accountno: this.data.accountno,
-                    password: (this.data.memory) ? this.data.password : ''
-                })
-                loginMsg.loginMsg(res);
-            })
-        }
-    }
+	properties: {},
+	options: {
+		addGlobalClass: true
+	},
+	data: {
+		accountno: "",
+		password: "",
+		inputType: "password", //密码输入框类型
+		memory: true, //记忆
+		focus: false,
+	},
+	lifetimes: {
+		attached: function () {
+			/* 恢复缓存中保存的账号密码 */
+			this.setData({
+				...wx.getStorageSync('loginMsg')
+			});
+			this.allowOrNot();
+		}
+	},
+	methods: {
+		/* input输入 */
+		inputChange(e) {
+			this.setData({
+				[e.target.dataset.name]: e.detail.value.trim()
+			})
+			this.allowOrNot()
+		},
+		/* 验证是否允许登录 */
+		allowOrNot() {
+			getCurrentPages()[0].setData({
+				disabled: (this.data.accountno.length > 0 && this.data.password.length > 0) ? false : true
+			})
+		},
+		/* 改变密码输入框类型 */
+		changePasswordType() {
+			this.setData({
+				inputType: this.data.inputType == "text" ? 'password' : 'text'
+			})
+		},
+		/* 是否记忆密码 */
+		isMemory() {
+			this.setData({
+				memory: !this.data.memory
+			})
+		},
+		/* 处理登录 */
+		handleLogin() {
+			_Http.login({
+				"accountno": this.data.accountno,
+				"password": md5.hexMD5(this.data.password),
+				"systemclient": "wechatsaletool"
+			}).then(res => {
+				getCurrentPages()[0].setData({
+					loading: false
+				})
+				if (res.msg != '成功') return wx.showToast({
+					title: res.msg,
+					icon: "none"
+				})
+				wx.setStorageSync('loginMsg', {
+					accountno: this.data.accountno,
+					password: (this.data.memory) ? this.data.password : ''
+				})
+				loginMsg.loginMsg(res);
+				getApp().globalData.remindchangepassword_str = res.remindchangepassword_str;
+			})
+		}
+	}
 })

+ 1 - 0
pages/login/phone.js

@@ -35,6 +35,7 @@ Page({
                             icon: "none"
                         })
                         loginMsg.loginMsg(res);
+                        getApp().globalData.remindchangepassword_str = res.remindchangepassword_str;
                     })
                 } else {
                     console.log('登录失败!' + res.errMsg)