From 41d11d9db46ccd44163860f6be6bfd2137aff369 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 07 一月 2025 09:16:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 h5/pages/waybill/home.vue |   66 +++++++++++++++++++++++++++++---
 1 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/h5/pages/waybill/home.vue b/h5/pages/waybill/home.vue
index dc5d12e..b1cead8 100644
--- a/h5/pages/waybill/home.vue
+++ b/h5/pages/waybill/home.vue
@@ -30,7 +30,7 @@
 </template>
 
 <script>
-	import { sendSms, validPhoneCaptcha } from '@/api'
+	import { sendSms, loginGkUserWithCode, wxAuthorizea, getUserInfo } from '@/api'
 	export default {
 		data() {
 			return {
@@ -38,24 +38,76 @@
 					code: '',
 					phone: ''
 				},
-				countDown: 0
+				countDown: 0,
+				
+				code: ''
 			};
+		},
+		onShow() {
+			var that = this
+			let url = 'https://atwl.ahzyssl.com/zhyq_h5/#/pages/waybill/home'
+			let code = ''
+			if (window.location.href.indexOf('code=') !== -1 || this.code) {
+				this.userAuth(3)
+			} else {
+				// let url = window.location.href
+				const appID = 'wx173e6caf5abc718a'
+				let uri = encodeURIComponent(url)
+				let authURL =
+					`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=${uri}&response_type=code&scope=snsapi_base#wechat_redirect`
+				window.location.href = authURL
+			}
 		},
 		methods: {
 			onSubmit() {
 				const { code, phone } = this.form
 				if (!phone) return this.showToast('鎵嬫満鍙蜂笉鑳戒负绌�')
 				if (!code) return this.showToast('楠岃瘉鐮佷笉鑳戒负绌�')
-				validPhoneCaptcha({
-				  phone, code
+				loginGkUserWithCode({
+				  phone, code,openid: this.$store.state.openId, userType: 3
 				}).then(res => {
 				  if (res && res.code == 200) {
-				    uni.navigateTo({
-				      url: "/pages/waybill/list?phone=" + phone
-				    })
+						this.$store.commit('setToken', res.data.token)
+						getUserInfo().then(ress => {
+							this.$store.commit('setWaybillInfo', ress.data)
+							uni.navigateTo({
+								url: '/pages/waybill/list'
+							})
+						})
 				  }
 				})
 			},
+			userAuth(source) {
+				var that = this
+				let url = window.location.href
+				let code = ''
+				if (url.indexOf('code=') !== -1 || this.code) {
+					const query = url.split('?')
+					for (const q of query) {
+						if (q.indexOf('code=') !== -1) {
+							let statusIndex = q.indexOf('&state')
+							code = q.substring(q.indexOf('code=') + 5, statusIndex)
+						}
+					}
+					wxAuthorizea({
+						code: code || this.code,
+						source: source
+					}).then(res => {
+						if (res.code === 200) {
+							that.$store.commit('setOpenId', res.data.openid)
+							if (res.data.token) {
+								that.$store.commit('setToken', res.data.token)
+								getUserInfo().then(ress => {
+									that.$store.commit('setWaybillInfo', ress.data)
+									uni.navigateTo({
+										url: '/pages/waybill/list'
+									})
+								})
+							}
+						}
+					})
+				}
+			},
 			initCaptcha() {
 			  if (!this.form.phone) return uni.showToast({
 			    title: '鎵嬫満鍙蜂笉鑳戒负绌�',

--
Gitblit v1.9.3