Browse Source

登录调试

lilei 3 years ago
parent
commit
7be50f31b0

+ 1 - 1
App.vue

@@ -1,7 +1,7 @@
 <script>
 	export default {
 		globalData: {
-			baseUrl: 'http://192.168.16.156:9110/saas/clz/', // 本地
+			baseUrl: 'http://192.168.16.103:9110/saas/clz/', // 本地
 			// baseUrl: 'http://md.test.zyucgj.com/saas/clz/', // 预发布
 			// baseUrl: 'https://car.zyucgj.com/saas/clz/' // 生产
 		},

+ 34 - 34
api/login.js

@@ -3,59 +3,35 @@ import request from './request';
 // 微信授权登录
 export const wxlogin = params => {
   return request({
-    url: 'login',
+    url: 'auth/wxlogin',
     data: params,
     method: 'post'
-  }).then(res => res.data);
+  })
 };
-
-// 获取图片验证码
-export const getCaptcha = randomCode => {
-  return request({
-    url: `captcha/create/${randomCode}`,
-    method: 'get',
-    responseType: 'text',
-  }).then(res=>res.data);
-}
-
+// 获取openid
 export const code2Session = params => {
   return request({
-    url: 'code2Session',
+    url: 'auth/getOpenId',
     data: params,
     method: 'get'
-  }).then(res => res.data);
+  })
 };
+// 手机登录
 export const login = params => {
   return request({
-    url: `loginVerify`,
-    data: params,
-    method: 'post',
-  }).then(res => res.data);
-};
-export const logout = params => {
-  return request({
-    url: `logout`,
+    url: `auth/loginVerify`,
     data: params,
-    method: 'get'
-  }).then(res => res.data);
-};
-// 验证手机
-export const sendLoginVerifyCode = params => {
-  return request({
-    url: `sendLoginVerifyCode`,
     method: 'post',
-	data:params,
-  }).then(res => res.data);
+  })
 };
 // 验证是否登录过
 export const checkLogin = () => {
   let token = uni.getStorageSync('token')
-  console.log(token,'----------获取token')
   if (token&&token!='') {
     return request({
-      url: `checkLogin`,
+      url: `auth/checkLogin`,
       method: 'get'
-    }).then(res => res.data);
+    })
   } else {
     return new Promise(resolve => {
       resolve({
@@ -65,4 +41,28 @@ export const checkLogin = () => {
     });
   }
 };
+// 退出登录
+export const logout = params => {
+  return request({
+    url: `auth/logout`,
+    data: params,
+    method: 'get'
+  })
+};
+// 获取图片验证码
+export const getCaptcha = randomCode => {
+  return request({
+    url: `auth/captchaCreate/${randomCode}`,
+    method: 'get',
+    responseType: 'text',
+  })
+}
+// 验证手机
+export const sendLoginVerifyCode = params => {
+  return request({
+    url: `auth/sendVerifyCode`,
+    method: 'post',
+	data:params,
+  })
+};
 

+ 3 - 6
api/request.js

@@ -11,17 +11,14 @@ function request(options) {
     };
 	const baseUrl = getApp().globalData.baseUrl
     Object.assign(_obj, options);
-    // _obj.header['X-AUTH-TOKEN'] = uni.getStorageSync('token');
-    // _obj.header['X-HEADER-APPID'] = 'WuyoKG1AcDZzLwxfhOAC+E16SeG3+mDqVYmsa/e5HRE=';
-	
 	const header = {
 			'USER-TERM-TYPE': 'ipad', // 支付时需要用到 与pad一致
 			'App-Type': 2,
-			'Version': '',
-			'authorization':'Bearer clz|eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiIxNTA5MTMzMDAwMCIsImF1dGhfdXNlciI6eyJ1c2VyU24iOiIxMDc1OSIsInVzZXJpZCI6IjEwNzU5IiwidXNlcm5hbWUiOiIxNTA5MTMzMDAwMCIsInVzZXJUeXBlIjoiMiIsIm1lcmNoYW50SWQiOiIxMDA0MCIsIm1lcmNoYW50U24iOiIxMDA0MCIsIm9yZ0lkIjoiMTAwMDAiLCJvcmdTbiI6IjEwMDAwIiwib3JnTmFtZSI6Iui9pumihuS4u-aAu-mDqOmXqOW6lyIsIm9yZ1N0YXR1cyI6IjEiLCJvcmdFeHBpcmVEYXRlIjo0MDcwODgwMDAwMDAwLCJvcmdUaGVtZVR5cGUiOiJjaGVsaW5nemh1Iiwicm9vdE9yZ0lkIjoiMTAwMDAiLCJyb290T3JnU24iOiIxMDAwMCIsInJvb3RPcmdOYW1lIjoi6L2m6aKG5Li7Iiwicm9vdE9yZ0V4cGlyZURhdGUiOjQwNzA4ODAwMDAwMDAsInJvb3RPcmdUaGVtZVR5cGUiOiJjaGVsaW5nemh1Iiwicm9vdE9yZ1N0YXR1cyI6IjEiLCJvcmdUeXBlIjoibHMiLCJzY29wZVR5cGUiOiJhbGwiLCJyb290TWVudU1vdWxkSWQiOiIyIiwib3JnTWVudU1vdWxkSWQiOiIyIiwic3VwZXJBZG1pbiI6IjAiLCJ1c2VyTmFtZUNOIjoi5byg5LiJ5LqaIiwibW9iaWxlIjoiMTUwOTEzMzAwMDAiLCJlbWFpbCI6bnVsbCwic2V4IjoiMSIsInBhc3N3b3JkIjoiZmYwM2NhYjkyMGYyYWM3Yjg3NTI1Y2YzOGEyMjIxOWZlMDI2OWYyNGRmOGIxZWE1ZDU4YWI1OTkiLCJzYWx0IjpudWxsLCJhdXRob3JpdGllcyI6bnVsbCwicGVybUNvZGVzIjpudWxsLCJhY2xNYXAiOm51bGwsImFjY291bnROb25FeHBpcmVkIjp0cnVlLCJhY2NvdW50Tm9uTG9ja2VkIjp0cnVlLCJjcmVkZW50aWFsc05vbkV4cGlyZWQiOnRydWUsImVuYWJsZWQiOnRydWUsImFwcE5hbWUiOm51bGwsImV4dGVuZEluZm8iOm51bGwsImV4dEluZm8iOnt9LCJzb3VyY2VGbGFnIjpudWxsLCJjbGllbnRUeXBlIjpudWxsLCJtdXN0Q2hhbmdlUHdkIjpudWxsLCJleHBlY3RUcnVzdCI6ZmFsc2V9LCJzY29wZSI6WyJhbGwiXSwiZXhwIjoxNjU0NTYzODA1LCJqdGkiOiI0OTM0MGQ5MC0wMTUxLTRiNDgtOTg4YS1iNWI3YWJmN2E1MjciLCJjbGllbnRfaWQiOiJjbGllbnRfcGFzc3dvcmQiLCJzdGF0dXMiOiIyMDAifQ.f05LtCz1-gb5zBCrhW79-MyQpPLoRvBn8Gay99M7Xcw'
+			'Version': '1.0.0',
+			'authorization': uni.getStorageSync('token')
 	}
 	_obj.header = header
-	_obj.header['X-HEADER-APPID'] = 'WuyoKG1AcDZzLwxfhOAC+E16SeG3+mDqVYmsa/e5HRE=';
+	_obj.header['X-HEADER-APPID'] = '!z2Yc.aes|STw5oReFk+wACvW4IGVHZsFe+/MgMT9cp0amuic1gqE=';
 	
     _obj.url = baseUrl + _obj.url;
     _obj.method = _obj.method.toUpperCase();

+ 3 - 2
components/scrollBox.vue

@@ -26,9 +26,10 @@ export default {
 			animationData: {} //动画对象
 		};
 	},
-	components: {},
 	mounted() {
-		this.prizeScroll();
+		if(this.hasLogin){
+			this.prizeScroll();
+		}
 	},
 	methods: {
 		getHeight(Class) {

+ 0 - 1
components/uni-popup/image-txt-popup.vue

@@ -47,7 +47,6 @@
 			  //  6位随机数
 			  this.nowRandomCode = Math.random().toString().slice(-6)
 			  getCaptcha(this.nowRandomCode).then(res => {
-				// console.log(res.data)
 			    //  获取图片路径
 			    _this.captchaBase = 'data:image/png;base64,' + res.data
 			    // 显示图文验证码弹框

+ 24 - 15
pages/index/index.vue

@@ -25,8 +25,8 @@
 							请点击登录/注册
 						</view>
 						<view v-else>
-							<view>王杰</view>
-							<view>宇博极速汽车维修养护中心</view>
+							<view>{{userInfo.userNameCN}}</view>
+							<view>{{userInfo.orgName}}</view>
 						</view>
 					</view>
 				</view>
@@ -40,14 +40,14 @@
 			</view>
 			<!-- 扫描记录 -->
 			<u-cell-group :border="false">
-				<u-cell-item title="扫描记录" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" value="查看全部">
-					<u-icon slot="icon" size="38" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
+				<u-cell-item title="扫描记录" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" :value="hasLogin?'查看全部':''">
+					<u-icon slot="icon" size="38" v-if="hasLogin" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
 				</u-cell-item>
 			</u-cell-group>
 		</view>
 		<!-- 扫描记录 -->
 		<view class="list-box">
-			<u-cell-group :border="false">
+			<u-cell-group :border="false" v-if="hasLogin">
 				<u-cell-item v-for="item in vinList" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :value="item.brandName +' '+item.modelName">
 					<text slot="icon"></text>
 				</u-cell-item>
@@ -57,6 +57,7 @@
 				</view>
 			</u-cell-group>
 			<view class="des" v-if="vinList.length">仅展示最近10条记录,点击“全部”查看更多</view>
+			<view class="des" v-if="!hasLogin">请登录后,查看扫描记录</view>
 		</view>
 	</view>
 </template>
@@ -87,19 +88,27 @@
 			...mapState(['hasLogin']),
 			hasShelf(){
 				return this.$store.state.vuex_storeShelf
+			},
+			userInfo(){
+				return this.$store.state.vuex_userInfo
 			}
 		},
 		onLoad() {
-			this.getStoreShelf()
-			// 获取数据字典
-			this.getListLookUp();
-			// 获取支付,收款方式
-			this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
+			if(this.hasLogin){
+				this.getStoreShelf()
+				// 获取数据字典
+				this.getListLookUp();
+				// 获取支付,收款方式
+				this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
+			}
 		},
 		onShow() {
-			// 获取扫描记录
-			this.getScrollLog()
-			this.getVinLog()
+			if(this.hasLogin){
+				this.$store.state.vuex_userInfo = uni.getStorageSync('userInfo')
+				// 获取扫描记录
+				this.getScrollLog()
+				this.getVinLog()
+			}
 		},
 		methods: {
 			//  获取数据字典
@@ -158,13 +167,13 @@
 			// 去扫描
 			openCamera(){
 				uni.navigateTo({
-					url: "/pages/scan-frame/scan-frame"
+					url: this.hasLogin ? "/pages/scan-frame/scan-frame" : '/pages/login/login'
 				})
 			},
 			// 查看扫描记录
 			toAllRecord(){
 				uni.navigateTo({
-					url: "/pages/vinRecord/vinRecord"
+					url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
 				})
 			},
 			toUser(){

+ 1 - 3
pages/login/login.vue

@@ -21,7 +21,6 @@
 </template>
 
 <script>
-    import service from '../../service.js';
 	import {wxlogin} from '../../api/login.js'
     import {
         mapState,
@@ -97,7 +96,6 @@
 							console.log(res,_this.path, 'login data')
 							if (res.status == '200') {
 								this.toMain(res.data)
-								// _this.$u.vuex('vuex_token',res.data)
 								uni.$emit("getUserInfo")
 								if (_this.path === '/pages/index/index' || _this.lanuch) {
 									uni.reLaunch({
@@ -137,7 +135,7 @@
 				})
 			},
 			toMain(data) {
-			    this.login({token:data});
+			    this.login(data);
 			    uni.reLaunch({
 			        url: '/pages/index/index',
 			    });

+ 5 - 5
pages/login/phoneLogin.vue

@@ -6,10 +6,10 @@
 			</view>
 			<u-form ref="uForm">
 				<u-form-item>
-					<u-input v-model.trim="mobile" placeholder="请输入手机号" type="number" maxlength='11' />
+					<u-input v-model="mobile" placeholder="请输入手机号" type="number" maxlength='11' />
 				</u-form-item>
 				<u-form-item>
-					<u-input placeholder="请输入验证码" maxlength='4' type="number" v-model.trim="code" />
+					<u-input placeholder="请输入验证码" maxlength='4' type="number" v-model="code" />
 					<u-button slot="right" class="yzmBtn" :custom-style="yzmBtn" shape="circle" :hair-line="false" size="mini"
 						@click="checkMobile" :disabled="isDisabled">{{codeText}}</u-button>
 				</u-form-item>
@@ -31,7 +31,6 @@
 </template>
 
 <script>
-	import service from '../../service.js';
 	import {
 		code2Session,
 		login,
@@ -131,7 +130,8 @@
 				obj.mobile = this.mobile
 				obj.random = nowRandomCode
 				obj.code = code
-				obj.openid = this.$store.state.openid
+				obj.openid = this.$store.state.vuex_openid
+				console.log(this.$store.state.vuex_openid)
 				//  发送短信验证码
 				sendLoginVerifyCode(obj).then(res => {
 					console.log(JSON.stringify(res.data))
@@ -168,7 +168,7 @@
 			// 登录
 			bindLogin() {
 				let mobile = this.mobile
-				let openid = this.$store.state.openid
+				let openid = this.$store.state.vuex_openid
 				let code = this.code
 				let random = this.randomCode
 				let data = {

+ 14 - 18
store/index.js

@@ -34,10 +34,8 @@ const store = new Vuex.Store({
          * 是否需要强制登录
          */
         forcedLogin: false,
-        hasLogin: true,
-		openid: "",
+        hasLogin: false,
 		isOpenLocation: false, // 用户是否开启授权开启定位
-		orderStatusList: [], // 服务订单状态数据字典数据
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
 		vuex_carBrandList: lifeData.vuex_carBrandList ? lifeData.vuex_carBrandList : [] ,// 车型品牌数据
@@ -49,25 +47,32 @@ const store = new Vuex.Store({
 		vuex_shelfChoosePart: [], // 数字货架临配选择配件
 		vuex_allLookUp: [],  //  数据字典
 		vuex_paymentTypeList: [], // 支付方式
+		vuex_userInfo: null,
+		vuex_openid: ""
     },
 	getters:{
 		getOpeid(state){
-			return state.openid
+			return state.vuex_openid
 		}
 	},
     mutations: {
-        login(state, userInfo) {
+        login(state, data) {
+			console.log(data)
             state.hasLogin = true;
-			uni.setStorageSync('token', userInfo.token);
-			uni.setStorageSync('userInfo', userInfo.user);
+			uni.setStorageSync('token', data.access_token);
+			uni.setStorageSync('userInfo', data.auth_user);
+			state.vuex_userInfo = data.auth_user
         },
         logout(state) {
             state.hasLogin = false;
 			uni.removeStorageSync('token')
 			uni.removeStorageSync('userInfo')
+			state.vuex_userInfo = null
         },
 		openId(state,id) {
-			state.openid = id
+			console.log(id,'----------')
+			state.vuex_openid = id
+			uni.setStorageSync('openid', id);
 		},
 		$uStore(state, payload) {
 			// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
@@ -92,9 +97,6 @@ const store = new Vuex.Store({
 		isOpenLocation(state,isOpenLocation){
 			state.isOpenLocation = isOpenLocation
 		},
-		orderStatusList(state,orderStatusList){
-			state.orderStatusList = orderStatusList
-		},
     },
 	actions: {
 		wxLogin(context,provider){
@@ -106,8 +108,8 @@ const store = new Vuex.Store({
 				  code2Session({
 					code: result.code
 				  }).then(res => {
+					console.log(res)
 					if (res.status === '200') {
-					  uni.setStorageSync('openid', res.data);
 					  context.commit('openId',res.data)
 					};
 				  });
@@ -164,12 +166,6 @@ const store = new Vuex.Store({
 				}
 			})
 		},
-		// 获取订单状态数据字典
-		getOrderStatusList(context,data) {
-			getLookUpDatas({type:'ORDER_ON_CALL_STATUS'}).then(res =>{
-				context.commit('orderStatusList', res.data || [])
-			})
-		},
 	}
 })