sunChengjie 11 months ago
parent
commit
901c3ff24e
2 changed files with 89 additions and 62 deletions
  1. 11 0
      src/api/index.js
  2. 78 62
      src/pages/components/HomePage.vue

+ 11 - 0
src/api/index.js

@@ -157,5 +157,16 @@ export function getSysUserInfoByUserIdAPI(data) {
 }
 
 
+//获取微信
+export function getWxConfig(data) {
+    return request({
+        url: '/tianzong/weixin/getWxConfig',
+        method: 'post',
+        data: data,
+        emulateJSON: true
+    })
+}
+
+
 
 

+ 78 - 62
src/pages/components/HomePage.vue

@@ -2,7 +2,8 @@
 	<div>
 		<div class="content">
 			<div class="sm">
-				<van-search v-model="value" @search="onSearch" placeholder="点击搜索单号" />
+				<!-- <van-search v-model="value" @search="onSearch" placeholder="点击搜索单号" /> -->
+				<van-search v-model="value" placeholder="点击搜索单号" />
 				<img @click="wxScanCodeA()" src="@/assets/user/u4.png" alt="">
 			</div>
 			<!-- 显示 -->
@@ -50,7 +51,7 @@
 </template>
 
 <script>
-import { appFindYourShipment, appStatistics, getSysUserInfoByUserIdAPI } from '../../api/index'
+import { appFindYourShipment, appStatistics, getSysUserInfoByUserIdAPI, getWxConfig } from '../../api/index'
 import {
 	Toast,
 	Dialog
@@ -84,7 +85,6 @@ export default {
 	},
 	created: function () {
 		this.isLogin();
-		this.getData()
 		this.getUser()
 	},
 	async mounted() {
@@ -300,7 +300,7 @@ export default {
 									let result1 = res.resultStr.split(",");
 									result = result1[result1.length - 1];
 								}
-								this.onSearch(result)
+								// this.onSearch(result)
 							},
 							error: function (res) {
 								console.log(res);
@@ -316,76 +316,92 @@ export default {
 		},
 
 		async wxScanCodeA() {
-			const res = await appFindYourShipment({ expressNo: 'SF202303221917' }, { emulateJSON: true })
-			if (res.msg == 'success') {
-				this.$store.state.shipment = res
-				this.$router.push('ScannerResult')
-			} else {
-				Toast('找不到此单号')
-			}
-			console.log(res, '+++++++++==')
-
-		},
 
+			// let purl = /(Android)/i.test(navigator.userAgent) ? window.location.href.split('#')[0] : encodeURI(window.location.href.split('#')[0]);
+			// let dataForm = {
+			// 	'url': purl
+			// }
+			//alert(url)
+			const res = await getWxConfig({ url: window.location.href.split('#')[0] })
+
+
+
+			var timestamp = res.wxConfig.timestamp;
+			var noncestr = res.wxConfig.nonceStr;
+			var signature = res.wxConfig.signature;
+			var appId = res.wxConfig.appId;
+			wx.config({
+				debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				// debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+				appId: appId, // 必填,公众号的唯一标识
+				timestamp: timestamp, // 必填,生成签名的时间戳
+				nonceStr: noncestr, // 必填,生成签名的随机串
+				signature: signature, // 必填,签名,见附录1
+				jsApiList: [
+					"scanQRCode",
+				] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+			});
+			wx.ready(() => {
+				wx.scanQRCode({
+					needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
+					scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
+					success: (res) => {
+						//alert(res)
+						var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
+						console.log(result, 'result')
+						// if (result.indexOf(",") != -1) {
+						// 	let result1 = res.resultStr.split(",");
+						// 	result = result1[result1.length - 1];
+						// }
+						// this.onSearch(result)
+					},
+					error: function (res) {
+						console.log(res);
+					}
+				});
 
-		//单号搜索
-		onSearch(val) {
-			this.$router.push({
-				path: '/Sysearch',
-				query: {
-					expressNo: val,
-					searchType: "1" //1.搜索全部 2.搜索快件 3.搜索寄件
-				}
-			})
-		},
-		//后端获取数据
-		getData() {
-			Toast.loading({
-				message: '加载中...',
-				forbidClick: true,
-				duration: 0
 			});
+		}
 
-			this.$http.post(this.$store.state.host + "/solic/solicHomePage.do", {
-				mailRoomId: localStorage.getItem('roomId')
-			}, {
-				emulateJSON: true
-			})
-				.then(res => {
-					//发送成功
-					if (res.body.msg == 'success') {
-						console.log(this.expressMap, 'this.expressMap')
-						this.expressMap = res.body.expressMap
-						this.data[0].value = this.expressMap.successNum
-						this.data[1].value = this.expressMap.waitNum
-						this.data[2].value = this.expressMap.problemNum
-						this.mailMap = res.body.mailMap
-						console.log(this.mailMap, '=======================mailMap')
-						console.log(this.expressMap, '=======================expressMap')
-						//this.echart1(this.data)
-					}
-				}, res => {
-					//发送失败
-					Toast("网络错误!")
-				})
-			Toast.clear()
-		},
 
-		echart1(obj) {
-			console.log("图表数据:" + JSON.stringify(obj))
+		// const res = await appFindYourShipment({ expressNo: 'SF202303221917' }, { emulateJSON: true })
+		// if (res.msg == 'success') {
+		// 	this.$store.state.shipment = res
+		// 	this.$router.push('ScannerResult')
+		// } else {
+		// 	Toast('找不到此单号')
+		// }
+		// console.log(res, '+++++++++==')
 
-		},
+	},
 
-		async getUser() {
-			const res = await getSysUserInfoByUserIdAPI({ userId: localStorage.getItem("userId") })
-			this.$store.state.user = res.sysUserInfo
-			console.log(this.$store.state.user, 'this.$state.state.user')
-		}
 
+	//单号搜索
+	onSearch(val) {
+		this.$router.push({
+			path: '/Sysearch',
+			query: {
+				expressNo: val,
+				searchType: "1" //1.搜索全部 2.搜索快件 3.搜索寄件
+			}
+		})
+	},
+
+	echart1(obj) {
+		console.log("图表数据:" + JSON.stringify(obj))
 
 	},
 
+	async getUser() {
+		const res = await getSysUserInfoByUserIdAPI({ userId: localStorage.getItem("userId") })
+		this.$store.state.user = res.sysUserInfo
+		console.log(this.$store.state.user, 'this.$state.state.user')
+	}
+
+
 }
+
+
 </script>
 
 <style scoped lang="less">