shish 2 months ago
parent
commit
b9d0d781a1
2 changed files with 35 additions and 2 deletions
  1. 5 0
      ghsApp/src/api/purchase/index.js
  2. 30 2
      ghsApp/src/pagesOrder/showOrder.vue

+ 5 - 0
ghsApp/src/api/purchase/index.js

@@ -55,6 +55,11 @@ export const checkSeatRemin = data => {
 	return https.get("/purchase-order/check-seat-update", data);
 };
 
+/** 按 xhCg 主键获取采购单 salt(分享跳转用,无需登录) */
+export const getCgSalt = data => {
+	return https.get("/purchase/get-cg-salt", data);
+};
+
 
 /** *
  * 采购列表

+ 30 - 2
ghsApp/src/pagesOrder/showOrder.vue

@@ -11,6 +11,7 @@
 </template>
 <script>
 import { getWeixinId } from "@/api/invite/index"
+import { getCgSalt } from "@/api/purchase/index"
 export default {
     name: "showCgOrder",
 	data() {
@@ -18,7 +19,8 @@ export default {
 			getAppIdList:{},
 			showButton:false,
 			purchaseId:0,
-			cgSalt:''
+			cgSalt:'',
+			loadingSalt:false
 		};
 	},
 	onLoad() {
@@ -39,7 +41,33 @@ export default {
 		},
 		showCgOrder() {
 			const purchaseId = this.purchaseId || 0
-			const salt = this.cgSalt || ''
+			if (!purchaseId) {
+				this.$msg('订单信息无效')
+				return false
+			}
+			if (this.cgSalt) {
+				this.navigateToPurDetails(purchaseId, this.cgSalt)
+				return
+			}
+			if (this.loadingSalt) {
+				this.$msg('订单无效呢,请重新分享')
+				return false
+			}
+			this.loadingSalt = true
+			getCgSalt({ id: purchaseId }).then(res => {
+				if (res.code == 1 && res.data && res.data.salt) {
+					this.cgSalt = res.data.salt
+					this.navigateToPurDetails(purchaseId, this.cgSalt)
+				} else {
+					this.$msg(res.msg || '订单信息无效')
+				}
+			}).catch(() => {
+				this.$msg('订单信息无效')
+			}).finally(() => {
+				this.loadingSalt = false
+			})
+		},
+		navigateToPurDetails(purchaseId, salt) {
 			if (!purchaseId || !salt) {
 				this.$msg('订单信息无效')
 				return false