Explorar o código

提交逻辑修改

MS-CIAZDCOIXVRW\Administrator %!s(int64=3) %!d(string=hai) anos
pai
achega
0f03e2fa92

+ 1 - 0
pages/authorization/authorization.vue

@@ -33,6 +33,7 @@
 			// console.log(res);
 			if (res.success && res.code == 1) {
 				uni.setStorageSync('wxPhone', res.data)
+				uni.setStorageSync('accredit', true)
 				uni.redirectTo({
 					url:"/pages/index/index"
 				})

+ 53 - 46
pages/index/index.vue

@@ -33,12 +33,21 @@
 
 <script setup>
 	import {
-		ref
+		ref,
+		onMounted
 	} from 'vue'
 	import {
 		myRequest
 	} from "../../util/api.js"
 
+	onMounted(() => {
+		const accredit = uni.getStorageSync('accredit')
+
+		if (accredit) {
+			submit()
+		}
+	})
+
 	const name = ref(uni.getStorageSync('form_name') || '')
 	const phone = ref(uni.getStorageSync('form_phone') || '')
 	const company = ref(uni.getStorageSync('form_company') || '')
@@ -91,7 +100,7 @@
 			})
 			return
 		}
-		
+
 		uni.setStorageSync('form_name', name.value);
 		uni.setStorageSync('form_phone', phone.value);
 		uni.setStorageSync('form_company', company.value);
@@ -100,62 +109,60 @@
 			uni.showModal({
 				title: '提示',
 				content: '本次操作需要获取您的手机号码',
-				success: (res)=> {
+				success: (res) => {
 					if (res.confirm) {
-						
+
 						uni.navigateTo({
-							url:"/pages/authorization/authorization"
+							url: "/pages/authorization/authorization"
 						})
 					} else if (res.cancel) {
-						
+
 					}
 				}
 			});
 		} else {
-			submit()
-		}
-	}
+			uni.showModal({
+				title: '提示',
+				content: '确认提交吗',
+				success: (res) => {
+					if (res.confirm) {
+						submit()
+					} else if (res.cancel) {
 
-	const submit = () => {
-		uni.showModal({
-			title: '提示',
-			content: '确认提交吗',
-			success: async (res) => {
-				if (res.confirm) {
-					const res = await myRequest({
-						url: "/informationReporting/add",
-						method: "post",
-						data: {
-							name: name.value,
-							phone: phone.value,
-							company: company.value,
-							content: content.value,
-							wxPhone: wxPhone.value,
-						}
-					})
-					// console.log(res)
-					if (res.success && res.code == 1) {
-						uni.showToast({
-							title: '提交成功',
-							duration: 3000
-						})
-						content.value = ''
-						uni.setStorageSync('form_content','')
-					} else {
-						uni.showToast({
-							title: res.message,
-							icon: 'error'
-						})
 					}
-				} else if (res.cancel) {
-
 				}
-			}
-		});
+			});
+
+		}
+	}
 
-		// uni.navigateTo({
-		// 	url:"/pages/authorization/authorization"
-		// })
+	const submit = async () => {
+		const res = await myRequest({
+			url: "/informationReporting/add",
+			method: "post",
+			data: {
+				name: name.value,
+				phone: phone.value,
+				company: company.value,
+				content: content.value,
+				wxPhone: wxPhone.value,
+			}
+		})
+		// console.log(res)
+		if (res.success && res.code == 1) {
+			uni.showToast({
+				title: '提交成功',
+				duration: 3000
+			})
+			content.value = ''
+			uni.setStorageSync('form_content', '')
+			uni.setStorageSync('accredit', false)
+		} else {
+			uni.showToast({
+				title: res.message,
+				icon: 'error'
+			})
+		}
 	}
 </script>
 

+ 1 - 0
unpackage/dist/dev/mp-weixin/common/vendor.js

@@ -6747,6 +6747,7 @@ exports.e = e;
 exports.index = index;
 exports.n = n;
 exports.o = o;
+exports.onMounted = onMounted;
 exports.p = p;
 exports.ref = ref;
 exports.resolveComponent = resolveComponent;

+ 1 - 0
unpackage/dist/dev/mp-weixin/pages/authorization/authorization.js

@@ -16,6 +16,7 @@ const _sfc_main = {
         });
         if (res.success && res.code == 1) {
           common_vendor.index.setStorageSync("wxPhone", res.data);
+          common_vendor.index.setStorageSync("accredit", true);
           common_vendor.index.redirectTo({
             url: "/pages/index/index"
           });

+ 40 - 33
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -12,6 +12,12 @@ if (!Math) {
 const _sfc_main = {
   __name: "index",
   setup(__props) {
+    common_vendor.onMounted(() => {
+      const accredit = common_vendor.index.getStorageSync("accredit");
+      if (accredit) {
+        submit();
+      }
+    });
     const name = common_vendor.ref(common_vendor.index.getStorageSync("form_name") || "");
     const phone = common_vendor.ref(common_vendor.index.getStorageSync("form_phone") || "");
     const company = common_vendor.ref(common_vendor.index.getStorageSync("form_company") || "");
@@ -80,43 +86,44 @@ const _sfc_main = {
           }
         });
       } else {
-        submit();
+        common_vendor.index.showModal({
+          title: "提示",
+          content: "确认提交吗",
+          success: (res) => {
+            if (res.confirm) {
+              submit();
+            } else if (res.cancel)
+              ;
+          }
+        });
       }
     };
-    const submit = () => {
-      common_vendor.index.showModal({
-        title: "提示",
-        content: "确认提交吗",
-        success: async (res) => {
-          if (res.confirm) {
-            const res2 = await util_api.myRequest({
-              url: "/informationReporting/add",
-              method: "post",
-              data: {
-                name: name.value,
-                phone: phone.value,
-                company: company.value,
-                content: content.value,
-                wxPhone: wxPhone.value
-              }
-            });
-            if (res2.success && res2.code == 1) {
-              common_vendor.index.showToast({
-                title: "提交成功",
-                duration: 3e3
-              });
-              content.value = "";
-              common_vendor.index.setStorageSync("form_content", "");
-            } else {
-              common_vendor.index.showToast({
-                title: res2.message,
-                icon: "error"
-              });
-            }
-          } else if (res.cancel)
-            ;
+    const submit = async () => {
+      const res = await util_api.myRequest({
+        url: "/informationReporting/add",
+        method: "post",
+        data: {
+          name: name.value,
+          phone: phone.value,
+          company: company.value,
+          content: content.value,
+          wxPhone: wxPhone.value
         }
       });
+      if (res.success && res.code == 1) {
+        common_vendor.index.showToast({
+          title: "提交成功",
+          duration: 3e3
+        });
+        content.value = "";
+        common_vendor.index.setStorageSync("form_content", "");
+        common_vendor.index.setStorageSync("accredit", false);
+      } else {
+        common_vendor.index.showToast({
+          title: res.message,
+          icon: "error"
+        });
+      }
     };
     return (_ctx, _cache) => {
       return {