zouling 1 anno fa
parent
commit
50a801f7bb

+ 2 - 13
package-lock.json

@@ -1,23 +1,17 @@
 {
-  "name": "qs_lyyuyue",
+  "name": "yuanqu_ui",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "dependencies": {
-        "base-64": "^1.0.0",
-        "utf8": "^3.0.0"
+        "base-64": "^1.0.0"
       }
     },
     "node_modules/base-64": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
       "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
-    },
-    "node_modules/utf8": {
-      "version": "3.0.0",
-      "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
-      "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ=="
     }
   },
   "dependencies": {
@@ -25,11 +19,6 @@
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
       "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
-    },
-    "utf8": {
-      "version": "3.0.0",
-      "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
-      "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ=="
     }
   }
 }

+ 1 - 2
package.json

@@ -1,6 +1,5 @@
 {
   "dependencies": {
-    "base-64": "^1.0.0",
-    "utf8": "^3.0.0"
+    "base-64": "^1.0.0"
   }
 }

+ 4 - 2
pages/login.vue

@@ -92,6 +92,7 @@
 </template>
 
 <script>
+	import * as base64 from "base-64"
 	import {getweChatLogin,getInfo,getweChatOpenid,getCodeImg,getCode,sendSmsOnly} from "@/api/login.js"
 	import {getUserProfile} from "@/api/system/user.js"
 	import { getToken } from '@/utils/auth'
@@ -183,7 +184,8 @@
 			  if(that.jzflag){
 			  	var newObj={
 			  		username:that.loginForm.username,
-			  		password:that.loginForm.password,
+			  		password:base64.encode(that.loginForm.password),
+					captchaEnabled:that.captchaEnabled,
 			  	}					  
 			  	uni.setStorageSync('account', JSON.parse(JSON.stringify(newObj)))
 			  }else{
@@ -312,7 +314,7 @@
 		  if(uni.getStorageSync('account')){
 		  	var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('account')))
 		  	this.loginForm.username=newObj.username;
-		  	this.loginForm.password=newObj.password;
+		  	this.loginForm.password=base64.decode(newObj.password);
 		  	this.jzflag=true;
 		  }
 		  

+ 58 - 41
pages/order/info.vue

@@ -9,12 +9,12 @@
 			<uni-forms-item name="phonenumber" label="手机号码">
 			  <uni-easyinput :inputBorder="false" type="number"  v-model="phonenumber" placeholder="请输入手机号码" />
 			</uni-forms-item>
-			<!-- <uni-forms-item name="code" label="验证码">
+			<uni-forms-item name="code" label="验证码">
 			  <uni-easyinput :inputBorder="false" v-model="code" placeholder="请输入验证码" />
 					<view class="line flex0"></view>
 					<view v-if="timefalg" class="code act">{{time}}秒</view>
 					<view v-else @click="getCode" class="code">获取验证码</view>
-			</uni-forms-item> -->
+			</uni-forms-item>
 		</view>
       
       <view class="rbtn" @click="submit">开门</view>
@@ -85,57 +85,74 @@
 				that.$toast("请输入手机号")
 				return
 			}
+			if (!this.code ) {
+				that.$toast("请输入验证码")
+				return
+			}
+			if(this.code!=this.newcode){
+				that.$toast("验证码错误,请重新输入")
+				return
+			}
 			let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
 			if (this.phonenumber && !regphone.test(this.phonenumber)) {
 				that.$toast("请输入正确的手机号")
 				return
 			}
-			
+			that.timefalg=false;
+			that.time=60;
+			clearInterval(that.timer)
 			// this.getDataFn()
 		},
 		// getDetail(data){
 		// 	var s=base64.encode(data)
 		// 	this.$tab.navigateTo('/a/code?id='+s)
 		// },
-		// getCode(){
-		// 	var that=this;
-		// 	if (!this.phonenumber ) {
-		// 		that.$toast("请输入手机号")
-		// 		return
-		// 	}
-		// 	let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
-		// 	if (this.phonenumber && !regphone.test(this.phonenumber)) {
-		// 		that.$toast("请输入正确的手机号")
-		// 		return
-		// 	}
-		// 	sendSmsFn(this.phonenumber).then(res=>{
-		// 		if (res.code == 200) {
-		// 			// 发送验证码
-		// 			that.$toast("发送成功")
-		// 			that.newcode=res.msg
-		// 			that.time=60;
-		// 			that.timefalg=true;
-		// 			that.setTimein()
-		// 		} else {
-		// 			that.$toast(res.msg)
-		// 		}
-		// 		// 判断是不是对等的
-		// 		// that.getCodesend(that.phonenumber)
-		// 	})
-		// },
+		getCode(){
+			var that=this;
+			if (!this.phonenumber ) {
+				that.$toast("请输入手机号")
+				return
+			}
+			let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
+			if (this.phonenumber && !regphone.test(this.phonenumber)) {
+				that.$toast("请输入正确的手机号")
+				return
+			}
+			that.$toast("发送成功")
+			that.newcode='1234'
+			that.time=60;
+			that.timefalg=true;
+			that.setTimein()
+			return
+			
+			sendSmsFn(this.phonenumber).then(res=>{
+				if (res.code == 200) {
+					// 发送验证码
+					that.$toast("发送成功")
+					that.newcode=res.msg
+					that.time=60;
+					that.timefalg=true;
+					that.setTimein()
+				} else {
+					that.$toast(res.msg)
+				}
+				// 判断是不是对等的
+				// that.getCodesend(that.phonenumber)
+			})
+		},
 		// 验证码倒计时
-		// setTimein(){
-		// 	var that=this;
-		// 	clearInterval(that.timer)
-		// 	that.timer=setInterval(()=>{
-		// 		if(that.time<=1){
-		// 			that.timefalg=false;
-		// 			that.time=60;
-		// 			clearInterval(that.timer)
-		// 		}
-		// 		that.time=that.time-1;
-		// 	},1000)
-		// },
+		setTimein(){
+			var that=this;
+			clearInterval(that.timer)
+			that.timer=setInterval(()=>{
+				if(that.time<=1){
+					that.timefalg=false;
+					that.time=60;
+					clearInterval(that.timer)
+				}
+				that.time=that.time-1;
+			},1000)
+		},
 		// getDataFn(){
 		// 	var params={
 		// 		visitPhone:this.phonenumber,

BIN
static/images/tabbar/home.png


BIN
static/images/tabbar/home_.png


BIN
static/images/tabbar/mine.png


BIN
static/images/tabbar/mine_.png


+ 2 - 1
store/getters.js

@@ -4,6 +4,7 @@ const getters = {
   name: state => state.user.name,
   roles: state => state.user.roles,
   permissions: state => state.user.permissions,
-  wgtcode:state => state.user.wgtcode
+  wgtcode:state => state.user.wgtcode,
+  autologin:state => state.user.autologin
 }
 export default getters

+ 30 - 1
store/modules/user.js

@@ -13,7 +13,8 @@ const user = {
     avatar: storage.get(constant.avatar),
     roles: storage.get(constant.roles),
     permissions: storage.get(constant.permissions),
-	wgtcode:storage.get(constant.wgtcode)
+	wgtcode:storage.get(constant.wgtcode),
+	autologin:storage.get(constant.autologin)
   },
 
   mutations: {
@@ -40,6 +41,10 @@ const user = {
 	  state.wgtcode = wgtcode
 	  storage.set(constant.wgtcode, wgtcode)
 	},
+	SET_AUTOLOGIN: (state, autologin) => {
+	  state.autologin = autologin
+	  storage.set(constant.autologin, autologin)
+	},
   },
 
   actions: {
@@ -53,12 +58,36 @@ const user = {
       const password = userInfo.password
       const code = userInfo.code
       const uuid = userInfo.uuid
+	  const strfrom = userInfo.strfrom||""
       return new Promise((resolve, reject) => {
         login(username, password, code, uuid).then(res => {
           setToken(res.token)
           commit('SET_TOKEN', res.token)
+		  commit('SET_AUTOLOGIN',true)
           resolve()
         }).catch(error => {
+			if(error==500&&strfrom=='request'){
+				uni.hideLoading()
+				// 清空数据
+				uni.showModal({
+				  title: '提示',
+				  content: '登录状态已过期,您可以继续留在该页面,或者重新登录?',
+				  cancelText: '取消',
+				  confirmText: '确定',
+				  success: function(res) { 
+				    if (res.confirm) {
+						commit('SET_TOKEN', '')
+						commit('SET_ROLES', [])
+						commit('SET_PERMISSIONS', [])
+						removeToken()
+						storage.clean()
+				      uni.reLaunch({ url: '/pages/login' })
+				    }else{
+						commit('SET_AUTOLOGIN',false)
+					}
+				  }
+				})
+			}
           reject(error)
         })
       })

+ 6 - 5
utils/request.js

@@ -1,3 +1,4 @@
+import * as base64 from "base-64"
 import store from '@/store'
 import config from '@/config'
 import { getToken } from '@/utils/auth'
@@ -12,8 +13,10 @@ var confirmflag = config.confirmflag
 var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('account')))
 var username=newObj.username;
 var password=newObj.password;
-var tenantId=newObj.tenantId;
-var companyName=newObj.companyName;
+if(newObj){
+	password=base64.decode(newObj.password);	
+}
+var captchaEnabled=newObj.captchaEnabled;
 
 const request = config => {
   // 是否需要设置 token
@@ -59,13 +62,11 @@ const request = config => {
 			confirmflag = true;
 			setTimeout(function(){
 				var autologin=store.state.user.autologin;
-				if(username&&password&&tenantId&&companyName&&autologin){
+				if(username&&password&&!captchaEnabled&&autologin){
 					// 自动登录
 					var loginForm={
 						username:username,
 						password:password,
-						tenantId:tenantId,
-						companyName:companyName,
 						strfrom:'request'
 					}
 					store.dispatch('Logines', loginForm).then((res) => {