From d38f3d8c0642d5d58a3baeff5d80abafaa702f9f Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 13 一月 2025 13:43:11 +0800
Subject: [PATCH] ll

---
 h5/pages/waybill/home.vue |   71 +++++++++++++++++++++++++++++++----
 1 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/h5/pages/waybill/home.vue b/h5/pages/waybill/home.vue
index 16478c4..62dae00 100644
--- a/h5/pages/waybill/home.vue
+++ b/h5/pages/waybill/home.vue
@@ -4,7 +4,7 @@
 		<view class="login_wrap">
 			<view class="item">
 				<view class="la">鎵嬫満鍙�</view>
-			  <input v-model="form.phone" maxlength="18" placeholder-class="placeholder9" placeholder="璇疯緭鍏ユ墜鏈哄彿" />
+			  <input v-model="form.phone" type="tel" maxlength="18" placeholder-class="placeholder9" placeholder="璇疯緭鍏ユ墜鏈哄彿" />
 			</view>
 			<view class="item">
 				<view class="la">楠岃瘉鐮�</view>
@@ -13,7 +13,8 @@
 			  	  v-model="form.code"
 			  	  placeholder="璇疯緭鍏ラ獙璇佺爜"
 			  		placeholder-class="placeholder9"
-			  	  type="text"
+						:maxlength="6"
+			  	  type="number"
 			  	/>
 			  	<text class="captcha" v-if="countDown == 0" @click="initCaptcha"
 			  	  >鑾峰彇楠岃瘉鐮�</text
@@ -29,7 +30,7 @@
 </template>
 
 <script>
-	import { sendSms, validPhoneCaptcha } from '@/api'
+	import { sendSms, loginGkUserWithCode, wxAuthorizea, getUserInfo } from '@/api'
 	export default {
 		data() {
 			return {
@@ -37,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)
+						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