hsy 2 dní pred
rodič
commit
01b2065391

+ 0 - 2
index.html

@@ -10,8 +10,6 @@
   <title></title>
 
   <script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
-  <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.1.js"></script>
-
   <script>
     window.process = {};
 

+ 0 - 1
public/index.html

@@ -11,7 +11,6 @@
   <!-- <link rel="icon" href="/favicon.ico" /> -->
 
   <script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
-  <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.1.js"></script>
 
   <style>
     body {

+ 1 - 17
src/router/index.ts

@@ -25,7 +25,7 @@ Object.keys(modules).forEach((key) => {
 console.log(routes);
 
 const router = createRouter({
-  history: createWebHistory(),
+  history: createWebHistory('/'),
   routes,
   scrollBehavior(to, from, savedPosition) {
     return new Promise((resolve) => {
@@ -44,7 +44,6 @@ const router = createRouter({
 
 router.beforeEach((to: ToRouteType, _from, next) => {
   NProgress.start();
-  to.meta?.needService && appendCustomService();
   if (to.meta?.title) {
     document.title = to.meta?.title;
   }
@@ -65,19 +64,4 @@ router.afterEach((to) => {
   NProgress.done();
 });
 
-const appendCustomService = () => {
-  const el = document.querySelector("#customService");
-  const a = document.createElement("a");
-  a.id = "customService";
-  a.href = "https://work.weixin.qq.com/kfid/kfca0513e081f5317d9";
-  a.style.position = "fixed";
-  a.style.bottom = "20%";
-  a.style.right = "20px";
-  a.innerHTML = `<svg t="1697164746002" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5127" width="48" height="48"><path d="M513 514m-425 0a425 425 0 1 0 850 0 425 425 0 1 0-850 0Z" fill="#DCEDFF" p-id="5128"></path><path d="M799.76 435.68q-4.23-13.43-9.74-26.48a297.57 297.57 0 0 0-548 0q-5.52 13.08-9.75 26.52a72.29 72.29 0 0 0-56.06 70.44v45.67a72.27 72.27 0 0 0 72.27 72.27 29 29 0 0 0 29-29v-140a21.21 21.21 0 0 0-12.69-19.42 266.8 266.8 0 0 1 502.58 0.07 21.21 21.21 0 0 0-12.54 19.35v140a29 29 0 0 0 29 29A72.27 72.27 0 0 0 856 551.83v-45.67a72.28 72.28 0 0 0-56.24-70.48z" fill="#88C4FF" p-id="5129"></path><path d="M516 297.94c-101.22 0-187 66.15-216.43 157.54v139.68c29.51 91.4 115.25 157.53 216.43 157.53h203.35a12.87 12.87 0 0 0 12.9-12.8l-43.48-66.72a226.43 226.43 0 0 0 43.62-77.71V455.24C702.85 364 617.17 297.94 516 297.94z" fill="#468EF7" p-id="5130"></path></svg>`;
-  if (el) {
-    el.remove();
-  } else {
-    document.body.appendChild(a);
-  }
-};
 export default router;

+ 0 - 25
src/views/promotion/components/PaymentDialog.vue

@@ -126,36 +126,11 @@ const handleGetCode = async () => {
   // 这里添加获取验证码的逻辑
   showToast("验证码已发送");
 };
-const preCheck = async () => {
-  const { data } = await request.get(
-    `/archivesService/member/promotionGoods/preData`,
-    {
-      params: {
-        promotionGoodsId: route.query.promotionGoodsId,
-      },
-    }
-  );
-  return data;
-};
-
 const handleConfirm = async () => {
   if (!phone.value || !verificationCode.value) {
     showToast("请填写完整信息");
     return;
   }
-  const { appId, errMsg, paymentSettingId } = await preCheck();
-  if (errMsg) {
-    return showToast(errMsg);
-  }
-  if (appId) {
-    //缓存信息
-    localStorage.setItem("paymentSettingId", paymentSettingId);
-    //跳转微信授权
-
-    const redirectUri = encodeURIComponent(location.href);
-    location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
-    return;
-  }
 
   // props.onConfirm?.();
 };

+ 82 - 45
src/views/promotion/goods.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="min-h-screen w-full ">
+  <div class="min-h-screen w-full">
     <div class="relative overflow-hidden py-4 pb-10 bg-[#fdedc5]">
       <img
         src="https://oss.hhmdtech.com/merchant/RmW4frEmQRr99JJ4RJ5hwdZR8FYDhTe8PKn6inRBijRJMRcA.png"
@@ -8,36 +8,36 @@
       />
       <div class="relative">
         <div class="h-full w-full overflow-hidden px-4">
-            <div
-              class="flex h-full w-full rounded bg-[#ffc72f] transition-all duration-150"
-            >
-              <div class="flex-1 p-4">
-                <div
-                  class="mb-2 max-w-[8em] truncate whitespace-nowrap text-2xl"
-                >
-                  {{ goodsDetail.memberCardName }}
-                </div>
-                <div v-if="goodsDetail?.originPrice" class="text-gray-500 line-through">
-                  <span>¥</span>
-                  <span>
-                    {{ parseFloat((goodsDetail?.originPrice / 100).toFixed(2)) }}
-                  </span>
-                  <span>/{{ goodsDetail.memberCard?.lifespan }}天</span>
-                </div>
-                <div :class="goodsDetail?.originPrice ? 'pb-3' : 'py-3'">
-                  <span>¥</span>
-                  <span class="text-2xl">
-                    {{ parseFloat((goodsDetail.memberCard?.price / 100).toFixed(2)) }}
-                  </span>
-                  <span>/{{ goodsDetail.memberCard?.lifespan }}天</span>
-                </div>
-                <div class="text-base text-gray-500">{{ goodsDetail.title }}</div>
+          <div
+            class="flex h-full w-full rounded bg-[#ffc72f] transition-all duration-150"
+          >
+            <div class="flex-1 p-4">
+              <div class="mb-2 max-w-[8em] truncate whitespace-nowrap text-2xl">
+                {{ goodsDetail.memberCardName }}
               </div>
-              <img
-                src="@/assets/icon-vip.png"
-                class="m-4 h-12 w-12"
-              />
+              <div
+                v-if="goodsDetail?.originPrice"
+                class="text-gray-500 line-through"
+              >
+                <span>¥</span>
+                <span>
+                  {{ parseFloat((goodsDetail?.originPrice / 100).toFixed(2)) }}
+                </span>
+                <span>/{{ goodsDetail.memberCard?.lifespan }}天</span>
+              </div>
+              <div :class="goodsDetail?.originPrice ? 'pb-3' : 'py-3'">
+                <span>¥</span>
+                <span class="text-2xl">
+                  {{
+                    parseFloat((goodsDetail.memberCard?.price / 100).toFixed(2))
+                  }}
+                </span>
+                <span>/{{ goodsDetail.memberCard?.lifespan }}天</span>
+              </div>
+              <div class="text-base text-gray-500">{{ goodsDetail.title }}</div>
             </div>
+            <img src="@/assets/icon-vip.png" class="m-4 h-12 w-12" />
+          </div>
         </div>
       </div>
     </div>
@@ -47,16 +47,18 @@
       </div>
     </div>
 
-    <div class="z-[2000] fixed bottom-6 left-0 flex w-full items-center justify-center">
+    <div
+      class="z-[2000] fixed bottom-6 left-0 flex w-full items-center justify-center"
+    >
       <div
-        class=" flex w-10/12 items-center justify-center overflow-hidden rounded-xl bg-[#2c2c2c]">
+        class="flex w-10/12 items-center justify-center overflow-hidden rounded-xl bg-[#2c2c2c]"
+      >
         <button
           class="flex-1 whitespace-nowrap border-0 bg-[#2c2c2c] p-4 text-sm text-[#e59223] after:hidden"
-          @click="buy">
-
+          @click="buy"
+        >
           <span class="text-base">立即购买</span>
         </button>
-
       </div>
     </div>
     <PaymentDialog
@@ -70,13 +72,13 @@
 <script setup>
 import { ref, reactive, onMounted, computed, watch } from "vue";
 
-import PaymentDialog from './components/PaymentDialog.vue'
+import PaymentDialog from "./components/PaymentDialog.vue";
 import { useRoute, useRouter } from "vue-router";
 
 import { request } from "@/utils";
 
 const [route, router] = [useRoute(), useRouter()];
-const goodsDetail = ref({})
+const goodsDetail = ref({});
 const getGoodsDetail = async () => {
   const { data } = await request.get(
     `archivesService/member/promotionGoods/detail`,
@@ -86,23 +88,58 @@ const getGoodsDetail = async () => {
       },
     }
   );
-  goodsDetail.value = data.detail
+  goodsDetail.value = data.detail;
 };
 getGoodsDetail();
 
-
-const showDialog = ref(false)
+const showDialog = ref(false);
 
 const handleClose = () => {
-  showDialog.value = false
-}
+  showDialog.value = false;
+};
 
 const handleConfirm = () => {
-  console.log('Payment confirmed')
-  showDialog.value = false
-}
+  console.log("Payment confirmed");
+  showDialog.value = false;
+};
 const buy = () => {
-  showDialog.value = true
+  showDialog.value = true;
+};
+
+const preCheck = async () => {
+  const { data } = await request.get(
+    `/archivesService/member/promotionGoods/preData`,
+    {
+      params: {
+        promotionGoodsId: route.query.promotionGoodsId,
+      },
+    }
+  );
+  return data;
+};
+
+const getWeChatAuth = async () => {
+
+  const { appId, errMsg, paymentSettingId } = await preCheck();
+  if (errMsg) {
+    return showToast(errMsg);
+  }
+  if (appId) {
+    //缓存信息
+    localStorage.setItem("paymentSettingId", paymentSettingId);
+    //跳转微信授权
+
+    const redirectUri = encodeURIComponent(location.href);
+    location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
+    return;
+  }
+};
+const init = async () => {
+  const { code } = route.query;
+  const paymentSettingId = localStorage.getItem("paymentSettingId");
+  if (!code && !paymentSettingId) {
+    getWeChatAuth()
+  }
 }
 </script>