Przeglądaj źródła

团餐申请报名接口。

付晓文。 1 miesiąc temu
rodzic
commit
569d465380

+ 38 - 5
pages/merchantDish/apply/index.vue

@@ -38,13 +38,46 @@ export default {
 			}
 		};
 	},
+	onShow() {
+		this.fetchApplyStatus();
+	},
 	methods: {
+		// 进入页面时拉取最新审核状态,避免本地缓存停留在「审核中」
+		fetchApplyStatus() {
+			this.$http.post('/groupmeal/gmMerchantApplicationRecord/isApply', {}).then((res) => {
+				if (res.data.code !== 200 || !res.data.result) return;
+				const apiStatus = res.data.result.status;
+				let localStatus = 0;
+				if (apiStatus == 0) localStatus = 3;
+				else if (apiStatus == 1) localStatus = 1;
+				else if (apiStatus == 2) localStatus = 2;
+				this.status = localStatus;
+				uni.setStorageSync('merchantDish_applyStatus', localStatus);
+			});
+		},
 		onSubmit() {
-			// 假数据:模拟报名成功进入审核
-			this.status = 3;
-			uni.setStorageSync('merchantDish_applyStatus', 3);
-			this.modalText.content = '报名成功,请等待平台审核';
-			this.$refs.myModal.onOpen();
+			this.$http.post('/groupmeal/gmMerchantApplicationRecord/apply', {}).then((res) => {
+				if (res.data.code === 200) {
+					const apiStatus = res.data.result.status;
+					let content = '';
+					// 本地约定:0未报名 1已通过 2驳回 3审核中(接口:0审核中 1通过 2驳回)
+					let localStatus = 0;
+					if (apiStatus == 0) {
+						content = '报名成功,请等待平台审核';
+						localStatus = 3;
+					} else if (apiStatus == 1) {
+						content = '审核通过,快去上传套餐商品开展活动吧';
+						localStatus = 1;
+					} else if (apiStatus == 2) {
+						content = '很抱歉,您没有通过平台审核,如有疑问请联系平台客服。';
+						localStatus = 2;
+					}
+					this.status = localStatus;
+					uni.setStorageSync('merchantDish_applyStatus', localStatus);
+					this.modalText.content = content;
+					this.$refs.myModal.onOpen();
+				}
+			});
 		},
 		onConfirm() {
 			if (this.status == 1) {

+ 17 - 3
pages/merchantDish/dish/form.vue

@@ -314,15 +314,29 @@ export default {
 	methods: {
 		initGroupMealFlag() {
 			// 未报名/审核中/驳回:商品归属只显示「门店」;审核通过(1) 才显示「团餐」
-			let applyStatus = 0;
 			const cache = uni.getStorageSync('merchantDish_applyStatus');
 			if (cache !== '' && cache !== undefined && cache !== null) {
-				applyStatus = Number(cache);
+				this.groupMealOpened = Number(cache) === 1;
 			}
-			this.groupMealOpened = applyStatus === 1;
 			if (!this.groupMealOpened && this.form.belong === 'group' && !this.isEdit) {
 				this.form.belong = 'store';
 			}
+			this.$http.post('/groupmeal/gmMerchantApplicationRecord/isApply', {}).then((res) => {
+				if (res.data.code !== 200) return;
+				const result = res.data.result;
+				let localStatus = 0;
+				if (result) {
+					const apiStatus = result.status;
+					if (apiStatus == 0) localStatus = 3;
+					else if (apiStatus == 1) localStatus = 1;
+					else if (apiStatus == 2) localStatus = 2;
+				}
+				uni.setStorageSync('merchantDish_applyStatus', localStatus);
+				this.groupMealOpened = localStatus === 1;
+				if (!this.groupMealOpened && this.form.belong === 'group' && !this.isEdit) {
+					this.form.belong = 'store';
+				}
+			});
 		},
 		loadEdit() {
 			const list = uni.getStorageSync(DISH_KEY) || createMockDishes();

+ 21 - 2
pages/merchantDish/dish/list.vue

@@ -195,14 +195,33 @@ export default {
 	},
 	onShow() {
 		this.loadList();
-		const apply = uni.getStorageSync('merchantDish_applyStatus');
-		if (apply !== '' && apply !== undefined && apply !== null) this.applyStatus = Number(apply);
+		this.fetchApplyStatus();
 	},
 	methods: {
 		noop() {},
 		goBack() {
 			uni.navigateBack({ delta: 1 });
 		},
+		// 从接口同步报名状态(本地:0未报名 1已通过 2驳回 3审核中;接口:0审核中 1通过 2驳回)
+		fetchApplyStatus() {
+			const cache = uni.getStorageSync('merchantDish_applyStatus');
+			if (cache !== '' && cache !== undefined && cache !== null) {
+				this.applyStatus = Number(cache);
+			}
+			this.$http.post('/groupmeal/gmMerchantApplicationRecord/isApply', {}).then((res) => {
+				if (res.data.code !== 200) return;
+				const result = res.data.result;
+				let localStatus = 0;
+				if (result) {
+					const apiStatus = result.status;
+					if (apiStatus == 0) localStatus = 3;
+					else if (apiStatus == 1) localStatus = 1;
+					else if (apiStatus == 2) localStatus = 2;
+				}
+				this.applyStatus = localStatus;
+				uni.setStorageSync('merchantDish_applyStatus', localStatus);
+			});
+		},
 		loadList() {
 			const cache = uni.getStorageSync(DISH_KEY);
 			if (cache && cache.length) {