hsy il y a 2 semaines
Parent
commit
ffe9658cec
1 fichiers modifiés avec 39 ajouts et 4 suppressions
  1. 39 4
      src/views/promotion/goods.vue

+ 39 - 4
src/views/promotion/goods.vue

@@ -117,9 +117,25 @@ const preCheck = async () => {
   );
   return data;
 };
+const jsSdkConfig = async () => {
+  const { data } = await request.post(
+    "archivesService/member/promotionGoods/getJssdk",
+    {
+      url: location.href,
+      promotionGoodsId: route.query.promotionGoodsId,
+    }
+  );
+  return data;
+};
+const wxConfig = async () => {
+  const { data } = await jsSdkConfig();
+  window["wx"]?.config?.(data.config);
+  window["wx"]?.error((res) => {
+    console.log(res);
+  });
+};
 
 const getWeChatAuth = async () => {
-
   const { appId, errMsg, paymentSettingId } = await preCheck();
   if (errMsg) {
     return showToast(errMsg);
@@ -134,14 +150,33 @@ const getWeChatAuth = async () => {
     return;
   }
 };
+const getOpenId = async () => {
+  const { code } = route.query;
+  const paymentSettingId = localStorage.getItem("paymentSettingId");
+  if (!code) {
+    return;
+  }
+  const { data } = await request.get(
+    `archivesService/member/promotionGoods/getOpenId`,
+    {
+      params: {
+        code,
+        paymentSettingId,
+      },
+    }
+  );
+
+};
 const init = async () => {
   const { code } = route.query;
   const paymentSettingId = localStorage.getItem("paymentSettingId");
   if (!code || !paymentSettingId) {
-    getWeChatAuth()
+    return getWeChatAuth();
   }
-}
-onMounted(() => init())
+  getOpenId()
+  wxConfig();
+};
+onMounted(() => init());
 </script>
 
 <style lang="scss" scoped></style>