Browse Source

扫码登录

achao 3 năm trước cách đây
mục cha
commit
0f1c08adb2
2 tập tin đã thay đổi với 23 bổ sung49 xóa
  1. 14 12
      pages/mine/confirm.vue
  2. 9 37
      pages/mine/index.vue

+ 14 - 12
pages/mine/confirm.vue

@@ -11,32 +11,34 @@
 </template>
 
 <script>
+	import {
+		mapState
+	} from 'vuex';
 	export default {
 		data() {
 			return {
-				sessionId: '',
 				token: '',
-				httpUrl: '',
-				username: '',
-				msg: ''
+				msg: '',
+				phone: '',
 			}
 		},
+		computed: {
+			...mapState(['hasLogin', 'userInfo', "firstAuthentication"]),
+		},
 		onLoad(option) {
-			this.sessionId = option.sessionId;
 			this.token = option.token;
-			this.httpUrl = option.httpUrl;
-			this.username = option.username;
 			console.log(option);
 		},
 		methods: {
 			mobileOkPcLogin() {
-				this.$request.baseRequest('post', '/user/mobileOkPcLogin', {
-						sessionId: this.sessionId,
+				this.$request.baseRequest('post', '/login/loginCode', {
+						phone: this.userInfo.phone,
 						token: this.token
 					}).then(res => {
-						let resultData = res.data;
-						_this.msg = resultData.msg;
-						console.log(resultData);
+						console.log(1111111111111111111)
+						console.log(res)
+						this.msg = res.message;
+						console.log(this.msg);
 					})
 					.catch(res => {
 						uni.$u.toast(res.message);

+ 9 - 37
pages/mine/index.vue

@@ -3,7 +3,7 @@
 	<view class="container">
 		<view class='container_content'>
 			<view class="head">
-				<view style='margin-bottom:14px;' class="row flex flex-end">
+				<view style='margin-bottom:14px;' class="row flex flex-end" v-if='hasLogin'>
 					<u--image class='image' :showLoading="true" src="../../static/mine/saoma.png" width="20px"
 						height="20px" @click="scanCode()"></u--image>
 					<u--image @click="goDetailPage('/pages/mine/set')" style='margin-right:0;' class='image'
@@ -226,50 +226,22 @@
 				uni.scanCode({
 					onlyFromCamera: true,
 					success: function(res) {
-						console.log('条码类型:' + res.scanType);
 						console.log('条码内容:' + res.result);
-						_this.sessionId = res.result;
-						uni.getStorage({
-							key: 'info',
-							success: (resStore) => {
-								let infoJson = JSON.parse(resStore.data);
-								console.log(infoJson);
-								_this.token = infoJson.token;
-								_this.httpUrl = infoJson.httpUrl;
-								console.log(_this.token, _this.httpUrl);
-								_this.mobileScanOk();
-							}
-						});
+
+						_this.token = res.result.split('?token=')[1];
+						_this.mobileScanOk();
 					}
 				});
 			},
 			mobileScanOk() {
-				this.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
-					sessionId: this.sessionId,
+				this.$request.baseRequest('get', '/login/loginInfo', {
 					token: this.token
 				}).then(res => {
-					let resultData = res.data;
+					let resultData = res;
 					console.log(resultData);
-					if (resultData.code == 0) {
-
-						let status = resultData.data.status;
-						if (status == 1) { //登录成功
-							this.username = resultData.data.username;
-							uni.navigateTo({
-								url: `./confirm?token=${this.token}&sessionId=${this.sessionId}&httpUrl=${this.httpUrl}&username=${this.username}`
-							});
-						} else {
-							uni.showToast({
-								title: resultData.msg,
-								duration: 2000
-							});
-						}
-					} else {
-						uni.showToast({
-							title: resultData.msg,
-							duration: 2000
-						});
-					}
+					uni.navigateTo({
+						url: `./confirm?token=${this.token}`
+					});
 
 				})
 			},