ソースを参照

fix: 修复学习本收藏bug

huangziyang 3 日 前
コミット
f8a89f21e7

+ 0 - 1
components/Container/Container.vue

@@ -236,7 +236,6 @@ defineExpose({
       v-if="$slots.footer"
       class="bottom-button"
       :style="{
-        width: `${safeArea.width}px`,
         background: bottomBgColor,
         borderTop: bottomBorder ? '1px solid #eee' : 'none',
       }"

+ 19 - 5
components/CustomerService/CustomerService.vue

@@ -1,13 +1,27 @@
-<script setup></script>
+<script setup>
+import { ref } from "vue";
+const x = ref(0);
+const y = ref(0);
+
+const onClick = () => {
+  console.log(111);
+};
+</script>
 <template>
-  <button open-type="contact" session-from class="contact">
-    <image class="contact-img"></image>
-  </button>
+  <movable-area style="width: 112rpx">
+    <movable-view
+      :x="x"
+      :y="y"
+      direction="all"
+      @change="onChange"
+      class="contact"
+      ><image class="contact-img" @click="onClick"></image
+    ></movable-view>
+  </movable-area>
 </template>
 
 <style lang="scss" scoped>
 @import "@/uni.scss";
-
 .contact {
   color: $uni-primary;
   font-size: 28rpx;

+ 6 - 6
pages.json

@@ -205,12 +205,12 @@
         "selectedIconPath": "static/icons/home_select.png",
         "text": "首页"
       },
-      // {
-      //   "pagePath": "pages/learn/index",
-      //   "iconPath": "static/icons/learn.png",
-      //   "selectedIconPath": "static/icons/learn_select.png",
-      //   "text": "学习本"
-      // },
+      {
+        "pagePath": "pages/learn/index",
+        "iconPath": "static/icons/learn.png",
+        "selectedIconPath": "static/icons/learn_select.png",
+        "text": "学习本"
+      },
       {
         "pagePath": "pages/challenge/index",
         "iconPath": "static/icons/challenge.png",

+ 2 - 2
pages/challenge/index.vue

@@ -32,8 +32,6 @@ onShow(async () => {
   const res = await request(
     "api/question_bank/question_reception/challenge_registration_log/detail"
   );
-  if (res.data) return;
-  isPay.value = false;
   request(
     "api/question_bank/question_reception/recharge_package/list",
     {
@@ -43,6 +41,8 @@ onShow(async () => {
   ).then(async (res) => {
     p.value = res.data.data[0].id;
   });
+  if (res.data) return;
+  isPay.value = false;
 });
 
 const toRule = () => {

+ 29 - 7
pages/challenge/registration.vue

@@ -13,8 +13,8 @@ const instance = getCurrentInstance();
 const context = ref("");
 const permissions = ref(false);
 const formData = ref({
-  contact_name: "",
-  contact_information: "",
+  contact_name: "ces",
+  contact_information: "13526483571",
   pharmacist_type: 0,
 });
 const loading = ref(false);
@@ -87,6 +87,8 @@ const onSubmit = async () => {
     });
   }
 
+  console.log(permissions.value);
+
   if (!permissions.value) {
     show.value = true;
     return;
@@ -95,6 +97,10 @@ const onSubmit = async () => {
   uni.login({
     provider: instance.proxy.$mpPlatform.substring(3),
     success: async ({ code }) => {
+      if (!code) {
+        loading.value = false;
+        return;
+      }
       const order = await request(
         "api/question_bank/question_reception/challenge_registration_log/add",
         {
@@ -102,6 +108,10 @@ const onSubmit = async () => {
           ...formData.value,
         }
       );
+      if (order.code !== "success") {
+        loading.value = false;
+        return;
+      }
       const e = await request(
         "api/question_bank/question_reception/orders/wechat_pay",
         {
@@ -110,7 +120,10 @@ const onSubmit = async () => {
           app_id: ext.extAppid,
         }
       );
-
+      if (e.code !== "success") {
+        loading.value = false;
+        return;
+      }
       uni.requestPayment({
         provider: "wxpay",
         timeStamp: e.data.timeStamp, //时间戳
@@ -134,8 +147,15 @@ const onSubmit = async () => {
         },
       });
     },
+    fail() {
+      loading.value = false;
+    },
   });
 };
+
+const onChange = (e) => {
+  permissions.value = !!e.detail.value[0];
+};
 </script>
 <template>
   <Container
@@ -190,10 +210,12 @@ const onSubmit = async () => {
       </view>
     </view>
     <div class="permissions">
-      <label>
-        <checkbox class="checkbox" :value="permissions" />
-        阅读并确认
-      </label>
+      <checkbox-group @change="onChange">
+        <label>
+          <checkbox class="checkbox" :value="1" />
+          阅读并确认
+        </label>
+      </checkbox-group>
       <span
         class="text-primary"
         @click="

+ 13 - 0
pages/contant/index.vue

@@ -0,0 +1,13 @@
+<script setup>
+import Container from '../../components/Container/Container.vue';
+</script>
+
+<template>
+  <Container title="客服">
+    <template #bg>
+      <image src="https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/bHbLzGDSB07Gc0tqCVCI3NLUx4sbUU4KHKSolvBq.png" mode="scaleToFill" class="bg" />
+    </template>
+  </Container>
+</template>
+
+<style lang="scss" ></style>

+ 14 - 0
pages/index/index.vue

@@ -95,12 +95,16 @@
       <!-- #endif -->
     </view>
   </Container>
+  <view class="service">
+    <CustomerService>联系客服</CustomerService>
+  </view>
 </template>
 
 <script setup>
 import { ref, onMounted, computed, onBeforeUnmount } from "vue";
 
 import Container from "../../components/Container/Container.vue";
+import CustomerService from '../../components/CustomerService/CustomerService.vue';
 import { router, getRoute } from "../../utils/router";
 import { request } from "../../utils/request";
 import { arrayToTree } from "../../utils";
@@ -169,6 +173,7 @@ const goto_notice_list = (link_url) => {
 };
 onMounted(async () => {
   const params = getRoute().params
+  console.log(params);
   if (params.share_uid) {
     uni.setStorageSync("share_uid", params.share_uid);
   }
@@ -247,6 +252,15 @@ onMounted(async () => {
 
 <style scoped lang="scss">
 @import "@/uni.scss";
+.service {
+	position: absolute;
+	bottom: 20%;
+	right: 5%;
+	color: $uni-primary;
+	font-size: 28rpx;
+	margin-bottom: 40rpx;
+	text-align: right;
+}
 .img_small {
   width: 112rpx;
   height: 112rpx;

+ 1 - 1
pages/learn/favorite.vue

@@ -69,7 +69,7 @@ const onStar = (item) =>
         : "api/question_bank/question_reception/topic/cancel_favorite",
       {
         id: item.id,
-        chapter_id: getRoute().params.id,
+        chapter_id: item.chapter_id,
         user_exercise_paper_id: user_exercise_paper_id.value,
       }
     ).then(() => {

+ 1 - 0
pages/learn/index.vue

@@ -5,6 +5,7 @@
     :scrollStyle="{
       padding: 0,
     }"
+    :showBack="false"
     headerColor="#fff"
   >
     <div class="top">

+ 31 - 5
pages/recharge/index.vue

@@ -87,7 +87,9 @@
           </template>
         </uni-data-checkbox>
       </view>
-      <button class="open-btn" @click="onSubmit">立即开通</button>
+      <button class="open-btn" @click="onSubmit">
+        立即开通
+      </button>
     </template>
     <!-- 客服 -->
     <view class="service">
@@ -111,15 +113,25 @@ const activeCurrent = ref(0);
 const isSelected = ref([0]);
 const data = ref([]);
 
+const paying = ref(false);
+
 const onSubmit = () => {
+  if (paying.value) return;
+  console.log(paying.value);
+  
   if (!isSelected.value[0])
     return uni.showToast({
       icon: "none",
       title: "请阅读并确认",
     });
+  paying.value = true;
   uni.login({
     provider: instance.proxy.$mpPlatform.substring(3),
     success: async ({ code }) => {
+      if (!code) {
+        paying.value = false;
+        return;
+      }
       const package_id = data.value[activeCurrent.value]?.id;
       // 先调用新增订单再支付
       const order = await request(
@@ -128,6 +140,10 @@ const onSubmit = () => {
           package_id,
         }
       );
+      if (order.code !== "success") {
+        paying.value = false;
+        return;
+      }
       const e = await request(
         "api/question_bank/question_reception/orders/wechat_pay",
         {
@@ -137,6 +153,10 @@ const onSubmit = () => {
         }
       );
 
+      if (e.code !== "success") {
+        paying.value = false;
+        return;
+      }
       uni.requestPayment({
         provider: "wxpay",
         timeStamp: e.data.timeStamp, //时间戳
@@ -144,14 +164,20 @@ const onSubmit = () => {
         package: e.data.package, //prepay_id
         signType: e.data.signType, //签名算法MD5
         paySign: e.data.paySign, //签名,
-        success(res) {
-          router.redirectTo('/pages/success/paysuccess')
+        success: (res) => {
+          router.redirectTo("/pages/success/paysuccess");
+        },
+        fail: (err) => {
+          router.redirectTo("/pages/success/error");
         },
-        fail(err) {
-          router.redirectTo('/pages/success/error')
+        complete() {
+          paying.value = false;
         },
       });
     },
+    fail() {
+      paying.value = false;
+    },
   });
 };
 

+ 40 - 0
pages/success/error.vue

@@ -15,19 +15,59 @@
     <view class="button-group">
       <view type="default" class="btn" @click="back">返回首页</view>
     </view>
+    <view class="qr-code">
+      <span>是遇到问题了吧</span>
+      <span>可联系客服进行反馈</span>
+      <div class="card">
+        <img :src="src" show-menu-by-longpress class="img" alt="">
+        <span>可长按识别二维码</span>
+      </div>
+    </view>
   </Container>
 </template>
 
 <script setup>
 import Container from "../../components/Container/Container.vue";
+import { ref } from "vue";
 import { router } from "../../utils/router";
 const onBack = () => new Promise((resolve) => resolve("/pages/user/index"));
 const back = () => {
   router.switchTab("/pages/user/index");
 };
+const src = ref("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/XTYZzM0uKjmKGV2cXN3QC5R1icHXmQDo10mUNZ6T.png");
+
 </script>
 
 <style scoped lang="scss">
+.qr-code {
+  width: 100%;
+  height: 100%;
+  margin-top: 20px;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  color: $error;
+  gap: 12rpx;
+  .card {
+    margin:10rpx auto 0;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    padding: 80rpx;
+    background-color: #fff;
+    gap: 40rpx;
+    border-radius: 40rpx;
+    width: calc(100% - 64rpx);
+    box-sizing: border-box;
+    color: #333;
+
+    .img {
+      width: 181px;
+      height: 181px;
+    }
+  }
+}
 .success-icon {
   width: 180rpx;
   height: 180rpx;

+ 44 - 1
pages/success/paysuccess.vue

@@ -2,8 +2,11 @@
   <Container
     class="body-content"
     title="支付成功"
-    bgColor="#F8F8F8"
+    bgColor="#f7f7f7"
     :onBack="onBack"
+    :scrollStyle="{
+      padding: 0
+    }"
   >
     <view class="info-area">
       <image
@@ -15,19 +18,59 @@
     <view class="button-group">
       <view type="default" class="btn" @click="back">返回首页</view>
     </view>
+    <view class="qr-code">
+      <span>恭喜你成为VIP</span>
+      <span>这是您的专属老师</span>
+      <div class="card">
+        <img :src="src" show-menu-by-longpress class="img" alt="">
+        <span>可长按识别二维码</span>
+      </div>
+    </view>
   </Container>
 </template>
 
 <script setup>
 import Container from "../../components/Container/Container.vue";
 import { router } from "../../utils/router";
+import { ref } from "vue";
 const onBack = () => new Promise((resolve) => resolve("/pages/user/index"));
 const back = () => {
   router.switchTab("/pages/user/index");
 };
+const src = ref("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/XTYZzM0uKjmKGV2cXN3QC5R1icHXmQDo10mUNZ6T.png");
 </script>
 
 <style scoped lang="scss">
+@import "@/uni.scss";
+.qr-code {
+  width: 100%;
+  height: 100%;
+  margin-top: 20px;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  color: $success;
+  gap: 12rpx;
+  .card {
+    margin:10rpx auto 0;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    padding: 80rpx;
+    background-color: #fff;
+    gap: 40rpx;
+    border-radius: 40rpx;
+    width: calc(100% - 64rpx);
+    box-sizing: border-box;
+    color: #333;
+
+    .img {
+      width: 181px;
+      height: 181px;
+    }
+  }
+}
 
 .success-icon {
   width: 180rpx;

+ 1 - 1
pages/user/share.vue

@@ -79,7 +79,7 @@ onShow(() => {
           css="width: 686rpx; height: 888rpx; position: relative;"
         >
           <l-painter-image
-            src="https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/12nSpSIh19rrhQBm0q3jvmT6dgXeN77q4el6cdXX.png"
+            src="https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/Y0X9bMID0ApIBc7GBHtGkSKhB175uB66ghYjMs4z.png"
             css="width: 686rpx; height: 888rpx; position: absolute;top: 0;"
           />
           <l-painter-image

+ 7 - 0
utils/request.js

@@ -66,6 +66,13 @@ export const request = (url, data = {}, method = "GET") => {
             },
           });
           reject("请登录");
+          return;
+        }
+        if (res.data.code !== "success") {
+          uni.showToast({
+            title: res.data.msg,
+            icon: "none",
+          });
         }
         // 返回结果
         resolve(res.data);