Kaynağa Gözat

fix 修改分享

ylong 9 ay önce
ebeveyn
işleme
838f8a1543

+ 1 - 1
pages-home/components/BookItem.vue

@@ -16,7 +16,7 @@
                             <text class="tzs tag-text" v-if="book.suit == 1">套装书</text>
                             <text class="kmdb tag-text" v-if="book.maxNum > 1">可卖多本</text>
                         </view>
-                        <text class="has-upsell" v-if="book.currUpsellMoney">加价 {{ book.currUpsellMoney }} 元
+                        <text class="has-upsell" v-if="book.currUpsellMoney">限时加价 {{ book.currUpsellMoney }} 元
                             <image
                                 src="/static/img/activity/up3.png"
                                 mode="aspectFill"

+ 8 - 17
pages-home/pages/book-order.vue

@@ -80,9 +80,9 @@
             </view>
             <view class="order-summary">
                 <view class="total">
-                    共<text class="price">{{ totalBooks }}</text
+                    共<text class="price">{{ totalNum }}</text
                     >件 预估回收价
-                    <text class="price">¥{{ totalPrice }}</text>
+                    <text class="price">¥{{ totalRecycleMoney }}</text>
                     <u-icon name="question-circle-fill" color="#333333" size="36" @click="showRules"></u-icon>
                 </view>
                 <u-button type="primary" @click="submitOrder" :custom-style="{ margin: 0 }">提交订单</u-button>
@@ -141,16 +141,10 @@ export default {
                 expressDelivery: "",
                 remark: "",
             },
+            totalNum: 0,
+            totalRecycleMoney: 0,
         };
     },
-    computed: {
-        totalBooks() {
-            return this.books.reduce((sum, book) => sum + (book.num || 1), 0);
-        },
-        totalPrice() {
-            return this.books.reduce((sum, book) => sum + book.recycleMoney + book.currUpsellMoney||0, 0).toFixed(2);
-        },
-    },
     methods: {
         showRules() {
             uni.navigateTo({
@@ -186,13 +180,7 @@ export default {
                 url: `/pages-mine/pages/address/list?id=${this.defaultAddr.id}&isSelect=1`,
             });
         },
-
-        calculateTotal() {
-            this.totalBooks = this.books.reduce((sum, book) => sum + book.quantity, 0);
-            this.totalPrice = this.books
-                .reduce((sum, book) => sum + book.quantity * parseFloat(book.price), 0)
-                .toFixed(2);
-        },
+        
         submitOrder() {
             if (!this.submitData.addressId) {
                 this.$u.toast("请选择取货地址");
@@ -263,6 +251,9 @@ export default {
                 this.expressList = res.data.expressTypes.map((v) => ({
                     name: v,
                 }));
+
+                this.totalRecycleMoney = res.data.totalRecycleMoney;
+                this.totalNum = res.data.totalNum;
             });
         },
         goToAgreement() {

+ 3 - 3
pages-mine/components/detail-book-item.vue

@@ -14,7 +14,7 @@
                         <view class="book-price">预估价: ¥{{ book.expectMoney }}</view>
                         
                         <view class="has-upsell" v-if="book.upsellFinalMoney">
-                            加价 {{ book.upsellFinalMoney }} 元
+                            限时加价 {{ book.upsellFinalMoney }} 元
                             <image
                                 src="/static/img/activity/up3.png"
                                 mode="aspectFill"
@@ -23,7 +23,7 @@
                         </view>
 
                         <view class="has-upsell" v-if="!book.upsellFinalMoney && book.upsellExpectMoney">
-                            加价 {{ book.upsellExpectMoney }} 元
+                            限时加价 {{ book.upsellExpectMoney }} 元
                             <image
                                 src="/static/img/activity/up3.png"
                                 mode="aspectFill"
@@ -32,7 +32,7 @@
                         </view>
 
                         <view class="has-upsell" v-if="!book.upsellFinalMoney && book.currUpsellMoney">
-                            加价 {{ book.currUpsellMoney }} 元
+                            限时加价 {{ book.currUpsellMoney }} 元
                             <image
                                 src="/static/img/activity/up3.png"
                                 mode="aspectFill"

+ 1 - 1
pages-mine/pages/order-detail.vue

@@ -23,7 +23,7 @@
                 </view>
                 
                 <view class="flex-a flex-j-b" v-if="orderInfo.upsellFinalMoney || orderInfo.upsellExpectMoney">
-                    <text class="common-text-2 font-26">已加价金额:</text>
+                    <text class="common-text-2 font-26">限时加价:</text>
                     <text class="common-text-2 font-26">¥{{ orderInfo.upsellFinalMoney || orderInfo.upsellExpectMoney }}</text>
                 </view>
                 <view class="flex-a flex-j-b">

+ 11 - 6
pages/home/components/BookItem.vue

@@ -68,7 +68,7 @@
             <view class="book-price"
               >回收价
               <text style="font-weight: 600; color: #db0702; margin-left: 8rpx">
-                ¥{{ recycleMoney }}</text
+                ¥{{ book.recycleMoney }}</text
               ></view
             >
             <button
@@ -147,12 +147,17 @@ export default {
           changeNum,
         })
         .then((res) => {
-          if (res.data == 1) {
-            this.$emit("quantity-change", this.book);
-            let { upsellMoney, canInvite } = this.book;
-            if (upsellMoney && canInvite == 1 && changeNum == 1) {
-              this.handleUpsell();
+          if (res.code == 200) {
+            if (res.data == 1) {
+              this.$emit("quantity-change", this.book);
+              let { upsellMoney, upsellNum, maxUpsellNum, num } = this.book;
+              let bool = upsellMoney && maxUpsellNum >= num && changeNum == 1 && maxUpsellNum > upsellNum
+              if (bool) {
+                this.handleUpsell();    
+              }
             }
+          } else {
+            uni.$u.toast(res.msg);
           }
         });
     },

+ 69 - 39
pages/home/components/ScanBookList.vue

@@ -1,38 +1,42 @@
 <template>
-  <scroll-view
-    scroll-y
-    refresher-enabled
-    :refresher-triggered="isRefreshing"
-    @refresherrefresh="onRefresh"
-    class="book-scroll"
-  >
-    <view class="scan-book-list">
-      <!-- 顶部提示 -->
-      <view class="tip-text">
-        套装书(相同ISBN相同的系列书籍)只需扫描其中一本,扫描价即套装价;需用户将整个套装全部寄出,缺册不予回收。
-      </view>
+  <view class="wrapper">
+    <scroll-view
+      scroll-y
+      @scroll="onScroll"
+      :refresher-enabled="isAtTop"
+      :refresher-triggered="isRefreshing"
+      @refresherrefresh="onRefresh"
+      @scrolltoupper="scrollToUpper"
+      upper-threshold="5"
+      class="book-scroll"
+    >
+      <view class="scan-book-list">
+        <!-- 顶部提示 -->
+        <view class="tip-text">
+          套装书(相同ISBN相同的系列书籍)只需扫描其中一本,扫描价即套装价;需用户将整个套装全部寄出,缺册不予回收。
+        </view>
 
-      <!-- 书籍列表 -->
-
-      <view class="book-list">
-        <BookItem
-          v-for="book in bookList"
-          :key="book.isbn"
-          :book="book"
-          @delete="handleDeleteBook"
-          @quantity-change="handleQuantityChange"
-          @upsell="handleUpsell"
-        />
-      </view>
+        <!-- 书籍列表 -->
+        <view class="book-list">
+          <BookItem
+            v-for="book in bookList"
+            :key="book.isbn"
+            :book="book"
+            @delete="handleDeleteBook"
+            @quantity-change="handleQuantityChange"
+            @upsell="handleUpsell"
+          />
+        </view>
 
-      <view class="link-wrap flex-a">
-        <text class="link-btn flex-1" @click="goToScannedBooks"
-          >扫过的书 ></text
-        >
-        <text class="link-btn flex-1" @click="goToRules">卖书规则 ></text>
+        <view class="link-wrap flex-a">
+          <text class="link-btn flex-1" @click="goToScannedBooks"
+            >扫过的书 ></text
+          >
+          <text class="link-btn flex-1" @click="goToRules">卖书规则 ></text>
+        </view>
       </view>
-    </view>
-  </scroll-view>
+    </scroll-view>
+  </view>
 </template>
 
 <script>
@@ -52,6 +56,8 @@ export default {
     return {
       books: [],
       isRefreshing: false,
+      isAtTop: true, // 是否在顶部,默认为true
+      scrollTop: 0,
     };
   },
   watch: {
@@ -64,24 +70,42 @@ export default {
     },
   },
   methods: {
+    // 滚动事件
+    onScroll(e) {
+      // 记录滚动位置
+      this.scrollTop = e.detail.scrollTop;
+
+      // 只有在最顶部时才能触发下拉刷新
+      this.isAtTop = this.scrollTop < 5;
+    },
+
+    // 滚动到顶部事件
+    scrollToUpper() {
+      this.isAtTop = true;
+    },
+
     // 下拉刷新
     onRefresh() {
       this.isRefreshing = true;
+
       // 触发父组件的刷新事件
       this.$emit("refresh");
 
-      // 模拟刷新完成后关闭刷新状态
+      // 模拟刷新完成
       setTimeout(() => {
         this.isRefreshing = false;
       }, 600);
     },
+
     // 加价
     handleUpsell(book) {
       this.$emit("upsell", book);
     },
+
     handleDeleteBook(book) {
       this.$emit("deleted", book);
     },
+
     handleQuantityChange(data) {
       const book = this.books.find((book) => book.isbn === data.isbn);
       if (book) {
@@ -89,14 +113,17 @@ export default {
       }
       this.$emit("updateBooks", this.books, book);
     },
+
     onNext() {
       this.$emit("next");
     },
+
     goToScannedBooks() {
       uni.navigateTo({
         url: "/pages-home/pages/scaned-book",
       });
     },
+
     goToRules() {
       uni.navigateTo({
         url: "/pages-mine/pages/rules-for-sellbooks",
@@ -107,12 +134,20 @@ export default {
 </script>
 
 <style lang="scss">
+.wrapper {
+  height: 100%;
+  width: 100%;
+  position: relative;
+}
+
+.book-scroll {
+  height: calc(100vh - 240px);
+}
+
 .scan-book-list {
   padding: 20rpx;
   display: flex;
   flex-direction: column;
-  height: 100%;
-  min-height: calc(100vh - 240px);
 
   .tip-text {
     font-family: Source Han Sans CN;
@@ -122,11 +157,6 @@ export default {
     line-height: 36rpx;
   }
 
-  .book-scroll {
-    flex: 1;
-    height: 0;
-  }
-
   .link-wrap {
     gap: 20rpx;
     box-sizing: border-box;

+ 1 - 1
pages/home/components/upsell-rules.vue

@@ -1,5 +1,5 @@
 <template>
-  <custom-popup v-model="showPopup" mode="center" border-radius="24" width="650rpx" :bg-color="'transparent'">
+  <custom-popup v-model="showPopup" mode="center" border-radius="24" width="650rpx" :bg-color="'transparent'" :z-index="11000">
     <view class="rules-container">
       <!-- 标题 -->
       <view class="title-section">

+ 15 - 5
pages/home/index.vue

@@ -42,8 +42,8 @@
       >
         <view class="left-info" style="min-width: 194px">
           <view class="flex-a common-text">
-            共<text class="color-red">{{ totalBooks }}</text
-            >件 预估回收价 <text class="color-red">¥{{ totalPrice || 0 }}</text>
+            共<text class="color-red">{{ orderInfo.totalNum }}</text
+            >件 预估回收价 <text class="color-red">¥{{ orderInfo.totalRecycleMoney || 0 }}</text>
           </view>
           <text class="common-text tip"
             >*旧书预估价格满 {{ orderInfo.minOrderMoney }} 元起收</text
@@ -148,12 +148,14 @@
 
     <!-- 图书加价弹窗 -->
     <UpsellBook ref="upsellRef" @scan="handleScanCode" />
-    <!-- 加价规则弹窗 -->
-    <UpsellRules ref="upsellRulesRef" />
+
     <!-- 加价分享弹窗 -->
     <UpsellShare ref="shareRef" @viewRules="handleViewSellRules" />
     <!-- 加价二维码弹窗 -->
     <UpsellQrcode ref="upsellQrcodeRef" />
+
+    <!-- 加价规则弹窗 -->
+    <UpsellRules ref="upsellRulesRef" />
   </view>
 </template>
 
@@ -260,6 +262,8 @@ export default {
   onShareAppMessage() {
     let upsellCode = uni.getStorageSync("upsellCodeShare");
     console.log(upsellCode, "分享");
+    // 调用分享接口
+    uni.$u.http.get("/token/order/goToShare?upsellCode=" + upsellCode);
     return {
       title: "书嗨",
       path: "/pages/home/index?upsellCode=" + upsellCode,
@@ -270,6 +274,8 @@ export default {
   // 分享到朋友圈
   onShareTimeline() {
     let upsellCode = uni.getStorageSync("upsellCodeShare");
+    // 调用分享接口
+    uni.$u.http.get("/token/order/goToShare?upsellCode=" + upsellCode);
     return {
       title: "书嗨",
       path: "/pages/home/index?upsellCode=" + upsellCode,
@@ -499,7 +505,8 @@ export default {
 
     updateBooksList(data, book) {
       this.bookList = data;
-      book.upsellMoney && this.getLastOrder();
+      // book.upsellMoney && this.getLastOrder();
+      this.getLastOrder()
     },
 
     toggleCollapse(step) {
@@ -538,6 +545,9 @@ export default {
           } else if (code == 2) {
             let item = this.bookList.find((v) => v.isbn === isbn);
             item.num = item.num + 1;
+            if (res.data.canInvite == 1) {
+              this.$refs.upsellRef.open(res.data);
+            }
           } else {
             this.handleBookCode(res.data.code);
           }