WIN-2CJ8FMUT9OF\Administrator пре 7 месеци
родитељ
комит
c37f3b3e83
2 измењених фајлова са 40 додато и 18 уклоњено
  1. 6 3
      pages/index/index.vue
  2. 34 15
      pages/login/index.vue

+ 6 - 3
pages/index/index.vue

@@ -41,9 +41,12 @@
 			// if (data) {
 			// 	uni.setStorageSync('shop_id', data.shop_id)
 			// }
-			uni.setStorageSync('shop_id', 111)
-			uni.setStorageSync('table_number', 1)
-			this.login()
+		},
+		onShow() {
+			// console.log('222222222');
+			// uni.setStorageSync('shop_id', 111)
+			// uni.setStorageSync('table_number', 1)
+			// this.login()
 		},
 		mounted() {},
 		methods: {

+ 34 - 15
pages/login/index.vue

@@ -25,14 +25,8 @@
 <script>
 	import tools from "@/service/tools";
 	import {
-		commonRegisterSms
-	} from '@/api/common.js';
-	import {
-		membeRphoneLogin
+		appletLogin
 	} from "@/api/member";
-	import {
-		getAgreement
-	} from "@/api/common.js";
 
 	export default {
 		data() {
@@ -54,11 +48,40 @@
 				agreementData: []
 			};
 		},
+		onShow() {},
 		onLoad(data) {
-			console.log(data);
+			console.log('00000');
+			uni.setStorageSync('shop_id', 111)
+			uni.setStorageSync('table_number', 1)
+			this.firstLogin()
 		},
 		mounted() {},
 		methods: {
+			firstLogin() {
+				tools.showLoading()
+				uni.login({
+					provider: "weixin",
+					success: (loginRes) => {
+						this.appletLogin(loginRes.code);
+					},
+					fail: (loginRes) => {
+						this.isAjax = false;
+						tools.error("获取授权信息失败");
+					},
+				});
+			},
+			appletLogin(code) {
+				appletLogin({
+					'code': code
+				}).then(res => {
+					if (res.code === 1) {
+						uni.setStorageSync('token', res.data.token)
+						uni.setStorageSync('m_id', res.data.m_id)
+						tools.hideLoading()
+						// this.goToUrl()
+					}
+				})
+			},
 			refuse() {
 				// #ifdef MP-WEIXIN
 				// 微信小程序平台
@@ -80,16 +103,12 @@
 				// 	url: "/pages/index/index",
 				// });
 				// return
+				console.log('11111111111111');
 				if (this.isAjax) {
 					return false;
 				}
-				this.isAjax = true;
-				uni.switchTab({
-					url: "/pages/index/index",
-				});
-			},
-			noLogin() {
-				uni.switchTab({
+				this.isAjax = false;
+				uni.reLaunch({
 					url: "/pages/index/index",
 				});
 			}