Răsfoiți Sursa

feat: 调优

Leo 3 ani în urmă
părinte
comite
6cdec4d09f

+ 10 - 1
src/components/list-item/list-item.vue

@@ -28,7 +28,12 @@
           <text class="list-label">积分</text>
         </view>
         <view class="list-num"
-          ><button class="btn" v-if="btn" @click.stop="handleBtnClick">
+          ><button
+            class="btn"
+            v-if="btn"
+            @click.stop="handleBtnClick"
+            :disabled="disabled"
+          >
             兑换
           </button></view
         >
@@ -62,6 +67,10 @@ export default {
       type: Boolean,
       default: false,
     },
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
   },
   data() {
     return {};

+ 2 - 2
src/pages/activity/detail.vue

@@ -20,9 +20,9 @@
         :src="detail.intro_img"
         mode="widthFix"
       ></image>
-      <view class="desc" v-html="detail.intro" />
+      <view v-else-if="detail.intro" class="desc" v-html="detail.intro" />
     </view>
-    <view class="act-footer">
+    <view class="act-footer" v-if="detail && detail.is_attend === 1">
       <button v-if="detail.status === 0" class="btn btn-gray">未开始</button>
       <button v-else-if="detail.status === 2" class="btn btn-gray">
         活动已结束

+ 17 - 16
src/pages/index/index.vue

@@ -54,8 +54,8 @@
       >
       </list-item>
     </view>
-    <view class="fixed-btns">
-      <!-- <image
+    <!-- <view class="fixed-btns">
+      <image
         class="fixed-btn"
         :src="require('@/assets/icon/icon-btn-service.png')"
         @click="jumpModuleAll('/pages/help/help_contact')"
@@ -65,7 +65,7 @@
         :src="require('@/assets/icon/icon-btn-message.png')"
         @click="jumpModuleAll('/pages/my/messages')"
       ></image>
-       -->
+
       <image
         v-if="showTask"
         class="fixed-btn"
@@ -73,12 +73,13 @@
         @click="jumpModuleAll('/pages/task/index')"
       ></image>
     </view>
+       -->
   </view>
 </template>
 <script>
 import login from "@/lib/utils/login";
 import { homeModules } from "@/lib/api/home";
-import { getSingInfo } from "@/lib/api/task";
+// import { getSingInfo } from "@/lib/api/task";
 import listItem from "@/components/list-item/list-item.vue";
 
 export default {
@@ -94,7 +95,7 @@ export default {
       userInfo: {},
       modules: {},
       tabStyle: "",
-      showTask: false,
+      // showTask: false,
     };
   },
   async onLoad() {
@@ -106,9 +107,9 @@ export default {
       uni.hideLoading();
     });
   },
-  onShow() {
-    this.getSingInfo();
-  },
+  // onShow() {
+  //   // this.getSingInfo();
+  // },
   onShareAppMessage() {
     return {
       title: "云果国潮会员中心",
@@ -187,14 +188,14 @@ export default {
       }
     },
 
-    async getSingInfo() {
-      if (!this.userInfo.session) {
-        this.showTask = true;
-        return Promise.reject();
-      }
-      const data = await getSingInfo(this.userInfo.session);
-      this.showTask = !data.is_current_signin;
-    },
+    // async getSingInfo() {
+    //   if (!this.userInfo.session) {
+    //     this.showTask = true;
+    //     return Promise.reject();
+    //   }
+    //   const data = await getSingInfo(this.userInfo.session);
+    //   this.showTask = !data.is_current_signin;
+    // },
 
     jumpModuleAll(url) {
       if (!url) return;

+ 1 - 1
src/pages/my/my.vue

@@ -14,7 +14,7 @@
             >ID: {{ userInfo.show_id }} <text class="copy">复制</text></text
           >
         </view>
-        <button class="user-btn" @tap="logout">退出登录</button>
+        <!-- <button class="user-btn" @tap="logout">退出登录</button> -->
       </view>
       <view v-else class="user-box">
         <image

+ 15 - 0
src/pages/shop/index.scss

@@ -15,4 +15,19 @@ page {
   box-sizing: border-box;
   left: 0;
   font-size: 28rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  .btn {
+    font-size: 24rpx;
+    background-color: #08c2c3;
+    border-radius: 100px;
+    margin: 0;
+    padding: 0 40rpx;
+    height: 48rpx;
+    line-height: 48rpx;
+    &::after {
+      display: none;
+    }
+  }
 }

+ 27 - 13
src/pages/shop/index.vue

@@ -1,12 +1,23 @@
 <template>
   <view class="shop">
-    <view class="fixtitle">当前积分:{{ userInfo.source || 0 }}</view>
+    <view class="fixtitle">
+      <view>当前积分:{{ userInfo.score || 0 }}</view>
+      <button
+        v-if="!userInfo.phone"
+        class="btn"
+        open-type="getPhoneNumber"
+        @getphonenumber="handlePhoneLogin"
+      >
+        登录
+      </button>
+    </view>
     <view v-if="modules && modules.length" class="base-list">
       <list-item
         v-for="item in modules"
         :key="item.id"
         :item="item"
         :btn="true"
+        :disabled="(userInfo.score || 0) < item.score"
         class="base-list-item"
         @click="handleDetail(item)"
       />
@@ -96,24 +107,26 @@ export default {
       }
     },
 
-    login() {
-      return new Promise((resolve, reject) => {
-        login.wxLogin((userInfo) => {
-          if (userInfo.session) {
-            this.userInfo = userInfo;
-            this.getUserInfo().then(resolve);
-          } else reject();
+    async handlePhoneLogin(e) {
+      if (e.detail.code) {
+        login.setPhoneData({
+          phone_code: e.detail.code,
+          callback: (data) => {
+            this.userInfo = data;
+            this.getUserInfo();
+          },
+          fail: (e) => {
+            console.log(e);
+          },
         });
-      });
+      }
     },
 
     async handleDetail(item) {
-      if (!this.userInfo || !this.userInfo.session) await this.login();
-
       if (item.score > Number(this.userInfo.score)) {
         uni.showToast({
           icon: "none",
-          text: "积分不足",
+          title: "积分不足",
         });
         return;
       }
@@ -139,8 +152,9 @@ export default {
       if (res.errno === 10000) {
         uni.showToast({
           icon: "none",
-          text: "兑换成功",
+          title: "兑换成功",
         });
+        this.getUserInfo();
       }
     },
   },