Browse Source

扫码17:53

sunChengjie 11 months ago
parent
commit
9fcf11be37
3 changed files with 126 additions and 91 deletions
  1. 56 53
      src/App.vue
  2. 38 38
      src/pages/components/HomePage.vue
  3. 32 0
      yarn.lock

+ 56 - 53
src/App.vue

@@ -5,63 +5,66 @@
 </template>
 
 <script>
-	export default {
-		name: 'App',
-		provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。                                             
-			return {
-				reload: this.reload
-			}
-		},
-		data() {
-			return {
-				isRouterAlive: true //控制视图是否显示的变量
-			}
-		},
-		
-		created () {
-		    window.localStorage.setItem('scanUrl',location.href.split('#')[0])
-			this.$http.post(this.$store.state.host + "/weixin/getWxConfig", {
-				url: window.location.href.split('#')[0]
-			}, {
-				emulateJSON: true
+import { getWxConfig } from './api/index'
+export default {
+	name: 'App',
+	provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。                                             
+		return {
+			reload: this.reload
+		}
+	},
+	data() {
+		return {
+			isRouterAlive: true //控制视图是否显示的变量
+		}
+	},
+
+	async created() {
+		window.localStorage.setItem('scanUrl', location.href.split('#')[0])
+		// this.$http.post(this.$store.state.host + "/weixin/getWxConfig", {
+		// 	url: window.location.href.split('#')[0]
+		// }, {
+		// 	emulateJSON: true
+		// })
+
+		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
+		});
+		//  res => {
+		// 	//发送失败
+		// 	Toast("网络错误!")
+		// }
+	},
+	methods: {
+		reload() {
+			this.isRouterAlive = false; //先关闭,
+			this.$nextTick(function () {
+				this.isRouterAlive = true; //再打开
 			})
-				.then(res => {
-					//发送成功
-					var timestamp = res.body.wxConfig.timestamp;
-					var noncestr = res.body.wxConfig.nonceStr;
-					var signature = res.body.wxConfig.signature;
-					var appId = res.body.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
-					});
-				}, res => {
-					//发送失败
-					Toast("网络错误!")
-				})
-		},
-		methods: {
-			reload() {
-				this.isRouterAlive = false; //先关闭,
-				this.$nextTick(function() {
-					this.isRouterAlive = true; //再打开
-				})
-			}
 		}
 	}
+}
 </script>
 
 <style scoped>
-	#app {
-		width: 100%;
-		max-width: 7.5rem;
-		margin: 0 auto;
-	}
+#app {
+	width: 100%;
+	max-width: 7.5rem;
+	margin: 0 auto;
+}
 </style>

+ 38 - 38
src/pages/components/HomePage.vue

@@ -260,72 +260,72 @@ export default {
 	},
 	methods: {//encodeURI(window.location.href.split('#')[0])
 		wxScanCode() {
-			let purl = /(Android)/i.test(navigator.userAgent) ? window.location.href.split('#')[0] : encodeURI(window.location.href.split('#')[0]);
-			let dataForm = {
-				'url': purl
-			}
+
+			// let purl = /(Android)/i.test(navigator.userAgent) ? window.location.href.split('#')[0] : encodeURI(window.location.href.split('#')[0]);
+			// let dataForm = {
+			// 	'url': purl
+			// }
 			//alert(url)
 			wx.scanQRCode({
 				needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
 				scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
 				success: (res) => {
 					//alert(res)
+					console.log(res, '==============')
 					var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
 					if (result.indexOf(",") != -1) {
 						let result1 = res.resultStr.split(",");
 						result = result1[result1.length - 1];
 					}
-					this.onSearch(result)
+					this.wxScanCodeA(result)
 				},
 				error: function (res) {
-					console.log(res);
+					console.log(res, 'error++++++++++');
 				}
 			});
-			
+			console.log('qwe')
 
-		},
 
-		async wxScanCodeA() {
+		},
 
+		async wxScanCodeA(result) {
+			const res = await appFindYourShipment({ expressNo: result }, { emulateJSON: true })
+			if (res.msg == 'success') {
+				this.$store.state.shipment = res
+				this.$router.push('ScannerResult')
+			} else {
+				Toast('找不到此单号')
+			}
+			console.log(res, '+++++++++==')
+		},
 
-		// 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, '+++++++++==')
 
-	},
+		//单号搜索
+		onSearch(val) {
+			this.$router.push({
+				path: '/Sysearch',
+				query: {
+					expressNo: val,
+					searchType: "1" //1.搜索全部 2.搜索快件 3.搜索寄件
+				}
+			})
+		},
 
+		echart1(obj) {
+			console.log("图表数据:" + JSON.stringify(obj))
 
-	//单号搜索
-	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')
+		}
 
-	},
 
-	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">

+ 32 - 0
yarn.lock

@@ -86,6 +86,13 @@
   dependencies:
     regenerator-runtime "^0.14.0"
 
+"@babel/runtime@^7.17.2":
+  version "7.24.1"
+  resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.24.1.tgz#431f9a794d173b53720e69a6464abc6f0e2a5c57"
+  integrity sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ==
+  dependencies:
+    regenerator-runtime "^0.14.0"
+
 "@babel/template@7.0.0-beta.44":
   version "7.0.0-beta.44"
   resolved "https://registry.npmmirror.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f"
@@ -2497,6 +2504,11 @@ copy-descriptor@^0.1.0:
   resolved "https://registry.npmmirror.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
   integrity sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==
 
+copy-text-to-clipboard@^3.0.1:
+  version "3.2.0"
+  resolved "https://registry.npmmirror.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz#0202b2d9bdae30a49a53f898626dcc3b49ad960b"
+  integrity sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q==
+
 copy-webpack-plugin@^4.0.1:
   version "4.6.0"
   resolved "https://registry.npmmirror.com/copy-webpack-plugin/-/copy-webpack-plugin-4.6.0.tgz#e7f40dd8a68477d405dd1b7a854aae324b158bae"
@@ -2516,6 +2528,11 @@ core-js@^2.4.0, core-js@^2.5.0:
   resolved "https://registry.npmmirror.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
   integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==
 
+core-js@^3.11.0:
+  version "3.36.1"
+  resolved "https://registry.npmmirror.com/core-js/-/core-js-3.36.1.tgz#c97a7160ebd00b2de19e62f4bbd3406ab720e578"
+  integrity sha512-BTvUrwxVBezj5SZ3f10ImnX2oRByMxql3EimVqMysepbC9EeMUOpLwdy6Eoili2x6E4kf+ZUB5k/+Jv55alPfA==
+
 core-util-is@1.0.2:
   version "1.0.2"
   resolved "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -6891,6 +6908,11 @@ multicast-dns@^6.0.1:
     dns-packet "^1.3.1"
     thunky "^1.0.2"
 
+mutation-observer@^1.0.3:
+  version "1.0.3"
+  resolved "https://registry.npmmirror.com/mutation-observer/-/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0"
+  integrity sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA==
+
 mute-stream@0.0.7:
   version "0.0.7"
   resolved "https://registry.npmmirror.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
@@ -10471,6 +10493,16 @@ vary@~1.1.2:
   resolved "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
   integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==
 
+vconsole@^3.15.1:
+  version "3.15.1"
+  resolved "https://registry.npmmirror.com/vconsole/-/vconsole-3.15.1.tgz#569a8ab15f353259527bbcf004f02946b4482cff"
+  integrity sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==
+  dependencies:
+    "@babel/runtime" "^7.17.2"
+    copy-text-to-clipboard "^3.0.1"
+    core-js "^3.11.0"
+    mutation-observer "^1.0.3"
+
 vendors@^1.0.0:
   version "1.0.4"
   resolved "https://registry.npmmirror.com/vendors/-/vendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"