ylong 7 mesiacov pred
rodič
commit
bea76a7275

+ 23 - 6
App.vue

@@ -47,13 +47,30 @@
 				systemInfo.windowHeight -
 				(that.globalData.navBarHeight + that.globalData.menuTop + that.globalData.menuBotton);
 
-			const scene = options.query.scene ? decodeURIComponent(options.query.scene) : "";
-			const inviteCode = scene ? scene.split("=")[1] : "";
-			console.log(inviteCode, "inviteCode");
-			if (inviteCode) {
-				wx.setStorageSync('inviteCode', inviteCode)
+			let params = {};
+			if (options.query.scene) {
+				// 对 scene 进行解码
+				const decodeScene = decodeURIComponent(options.query.scene);
+				// 拆分参数
+				const paramPairs = decodeScene.split('&');
+				paramPairs.forEach((pair) => {
+					const [key, value] = pair.split('=');
+					params[key] = value;
+				});
+			}
+			console.log('解析出的 scene 参数:', params);
+			// 假设链接参数中有一个名为 inviteCode 的参数
+			if (params.inviteCode) {
+				wx.setStorageSync('inviteCode', params.inviteCode)
+				console.log('解析出的 inviteCode 参数:', params.inviteCode);
+				this.slientLogin(params.inviteCode);
+			}
+			// 用于书籍加价的邀请码,关联订单 id 和 isbn
+			if(params.upsellCode){
+				wx.setStorageSync('upsellCode', params.upsellCode)
+				console.log('解析出的 upsellCode 参数:', params.upsellCode);
+				this.slientLogin();
 			}
-			this.slientLogin(inviteCode);
 		},
 		methods: {
 			slientLogin(inviteCode) {

+ 95 - 32
pages/home/components/upsell-book.vue

@@ -18,11 +18,13 @@
       <view class="price-section">
         <view class="price-row">
           <text class="price-label">此书预估书款</text>
-          <text class="price-value">¥ {{ bookInfo.recyclePrice }}</text>
+          <text class="price-value">¥ {{ bookInfo.recyclePrice || 0 }}</text>
         </view>
         <view class="price-row">
           <text class="price-label">助力成功提升至</text>
-          <text class="price-value increased">¥ {{ upselledMoney }}</text>
+          <text class="price-value increased"
+            >¥ {{ bookInfo.upsellMoney || 0 }}</text
+          >
           <image
             class="up-icon"
             src="/static/img/activity/up2.png"
@@ -30,35 +32,42 @@
           ></image>
         </view>
         <view class="small-text"
-          >实际金额以最终审核书款为准,活动时间3/25至4/30</view
+          >实际金额以最终审核书款为准,活动时间{{
+            formatDate(bookInfo.startTime)
+          }}至{{ formatDate(bookInfo.endTime) }}</view
         >
       </view>
 
       <!-- 分享助力区域 -->
       <view class="share-section">
-        <view class="share-text">分享位好友助力</view>
+        <view class="share-text">分享{{ inviteUsers.length }}位好友助力</view>
         <view class="add-button">
-          <image
-            class="hand-icon"
-            src="/static/img/activity/invite.png"
-            mode="widthFix"
-          ></image>
+          <block v-for="(item, index) in inviteUsers" :key="index">
+            <view class="add-item" v-if="item.imgPath">
+              <image
+                class="hand-icon"
+                :src="item.imgPath"
+                mode="widthFix"
+              ></image>
+              <view class="add-text">{{ formatName(item.nickName) }}</view>
+            </view>
+
+            <image
+              v-else
+              class="hand-icon"
+              src="/static/img/activity/invite.png"
+              mode="widthFix"
+            ></image>
+          </block>
         </view>
       </view>
 
       <!-- 分享按钮 -->
       <view class="action-buttons">
-        <button
-          class="share-button"
-          @click="shareAction"
-          open-type="share"
-          >立即分享</button
-        >
-        <button
-          class="scan-button"
-          @click="scanAction"
-          >扫码助力</button
-        >
+        <button class="share-button" @click="shareAction" open-type="share">
+          立即分享
+        </button>
+        <button class="scan-button" @click="scanAction">扫码助力</button>
       </view>
 
       <!-- 关闭按钮 -->
@@ -70,7 +79,7 @@
 </template>
 
 <script>
-import customPopup from '../../../components/custom-popup.vue';
+import customPopup from "../../../components/custom-popup.vue";
 export default {
   components: {
     customPopup,
@@ -79,20 +88,56 @@ export default {
     return {
       showPopup: false,
       bookInfo: {},
+      inviteUsers: [],
     };
   },
-  computed: {
-    upselledMoney() {
-      return (this.bookInfo.recyclePrice + this.bookInfo.upsellMoney).toFixed(
-        2
-      );
-    },
-  },
   methods: {
     open(data) {
-      this.bookInfo = data;
       this.showPopup = true;
+      this.getIsbnInfo(data.isbn, data.orderId);
+    },
+    //获取信息
+    getIsbnInfo(isbn, orderId) {
+      uni.$u.http
+        .get(`/token/order/clickUpsellInvite?isbn=${isbn}&orderId=${orderId}`)
+        .then((res) => {
+          if (res.code == 200) {
+            this.bookInfo = res.data;
+            let needInviteNum = res.data.needInviteNum;
+            let inviteUsers = res.data.inviteUsers || [];
+            let length = inviteUsers.length;
+            for (let index = 0; index < needInviteNum - length; index++) {
+              inviteUsers.push({
+                nickName: "",
+                imgPath: "",
+              });
+            }
+            this.inviteUsers = inviteUsers;
+          }
+        });
+    },
+    // 转换时间的方法,将年月日时分秒转换成 3/25 格式
+    formatDate(dateString) {
+      if (!dateString) return "";
+
+      const date = new Date(dateString);
+      const month = date.getMonth() + 1; // 月份从0开始,需要+1
+      const day = date.getDate();
+
+      return `${month}/${day}`;
     },
+
+    //格式化 name,长度大于 3,只保留第一个和最后一个字,中间最多使用三个 *代替
+    // 长度小于 3,只保留第一个字
+    formatName(name) {
+      if (!name) return "";
+      if (name.length > 2) {
+        return name.slice(0, 1) + "*" + name.slice(-1);
+      } else {
+        return name.slice(0, 1) + "*";
+      }
+    },
+
     closePopup() {
       this.showPopup = false;
     },
@@ -100,7 +145,8 @@ export default {
       this.$emit("share");
     },
     scanAction() {
-      this.$emit("scan");
+      this.showPopup = false;
+      this.$emit("scan", this.bookInfo);
     },
   },
 };
@@ -199,15 +245,32 @@ export default {
 
   .add-button {
     display: flex;
-    flex-direction: column;
     align-items: center;
     justify-content: center;
+    gap: 10rpx;
 
     .hand-icon {
       width: 100rpx;
       height: 100rpx;
     }
   }
+
+  .add-item {
+    position: relative;
+    .add-text {
+      position: absolute;
+      bottom: 2rpx;
+      left: 5rpx;
+      font-size: 24rpx;
+      background: #39c248;
+      text-align: center;
+      color: #fff;
+      padding: 0 10rpx;
+      border-radius: 20rpx;
+      display: inline-block;
+      width: 94rpx;
+    }
+  }
 }
 
 .action-buttons {
@@ -232,7 +295,7 @@ export default {
     border-radius: 10rpx;
     line-height: 90rpx;
   }
-  button+button{
+  button + button {
     margin-left: 0;
   }
 }

+ 129 - 0
pages/home/components/upsell-qrcode.vue

@@ -0,0 +1,129 @@
+<template>
+  <custom-popup
+    v-model="showPopup"
+    mode="center"
+    border-radius="24"
+    width="650rpx"
+    :bg-color="'transparent'"
+  >
+    <view class="popup-container">
+      <!-- 顶部标题 -->
+      <view class="header">
+        <view class="title-text">
+          让好友打开<text class="green">微信</text>扫一扫
+        </view>
+        <view class="subtitle-text">加油!你就要成功了</view>
+      </view>
+
+      <!-- 二维码区域 -->
+      <view class="qrcode-section">
+        <image
+          class="qrcode-img"
+          :src="qrcode"
+          mode="aspectFit"
+        ></image>
+      </view>
+
+      <!-- 关闭按钮 -->
+      <view class="close-button" @click="closePopup">
+        <image src="/static/img/activity/close2.png" mode="widthFix"></image>
+      </view>
+    </view>
+  </custom-popup>
+</template>
+
+<script>
+import customPopup from '../../../components/custom-popup.vue';
+export default {
+  components: {
+    customPopup,
+  },
+  data() {
+    return {
+      showPopup: false,
+      qrcode: '',
+      // 可扩展为自定义图标
+      wechatIcon: false,
+      scanIcon: false,
+      successIcon: false,
+    };
+  },
+  methods: {
+    open(data) {
+      this.showPopup = true;
+      this.getQrcode(data.upsellCode);
+    },
+    //获取二维码
+    getQrcode(upsellCode){
+      uni.$u.http.get(`/token/order/getUpsellQrcode?upsellCode=${upsellCode}`).then(res=>{
+        if(res.code==200){
+          this.qrcode = res.data;
+        }
+      })
+    },
+    closePopup() {
+      this.showPopup = false;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.popup-container {
+  position: relative;
+  padding: 30rpx 30rpx 80rpx 30rpx;
+  box-sizing: border-box;
+  background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/upsellbg.png") no-repeat center center;
+  background-size: 100% 100%;
+  height: 1020rpx;
+}
+
+.header {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding-top: 20rpx;
+  .title-text {
+    font-size: 38rpx;
+    font-weight: bold;
+    color: #222;
+    margin-bottom: 10rpx;
+    .green {
+      color: #39c248;
+    }
+  }
+  .subtitle-text {
+    font-size: 28rpx;
+    color: #666;
+    margin-bottom: 30rpx;
+  }
+}
+
+.qrcode-section {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 400rpx;
+  width: 400rpx;
+  background: #38c249;
+  margin: 30rpx auto;
+  .qrcode-img {
+    width: 300rpx;
+    height: 300rpx;
+    border-radius: 24rpx;
+    background: #fff;
+    border: 8rpx solid #fff;
+  }
+}
+
+.close-button {
+  position: absolute;
+  bottom: -100rpx;
+  left: 50%;
+  transform: translateX(-50%);
+  image {
+    width: 70rpx;
+    height: 70rpx;
+  }
+}
+</style>

+ 11 - 3
pages/home/index.vue

@@ -137,11 +137,13 @@
     <FirstOrderFreePopup ref="firstOrderFreePopup" />
 
     <!-- 图书加价弹窗 -->
-    <UpsellBook ref="upsellRef" />
+    <UpsellBook ref="upsellRef" @scan="handleScanCode" />
     <!-- 加价规则弹窗 -->
     <UpsellRules ref="upsellRulesRef" />
     <!-- 加价分享弹窗 -->
     <UpsellShare ref="shareRef" @viewRules="handleViewSellRules" />
+    <!-- 加价二维码弹窗 -->
+    <UpsellQrcode ref="upsellQrcodeRef" />
   </view>
 </template>
 
@@ -157,6 +159,8 @@ import FirstOrderFreePopup from "./components/FirstOrderFreePopup.vue";
 import UpsellBook from "./components/upsell-book.vue";
 import UpsellRules from "./components/upsell-rules.vue";
 import UpsellShare from "./components/upsell-share.vue";
+import UpsellQrcode from "./components/upsell-qrcode.vue";
+
 export default {
   components: {
     notScanned,
@@ -170,6 +174,7 @@ export default {
     UpsellBook,
     UpsellRules,
     UpsellShare,
+    UpsellQrcode,
   },
   data() {
     return {
@@ -262,10 +267,13 @@ export default {
         this.screenHeight = res.windowHeight;
       },
     });
-
-    this.$refs.shareRef.open();
   },
   methods: {
+    //扫码助力
+    handleScanCode(data = {}) {
+      this.$refs.upsellQrcodeRef.open(data);
+    },
+
     slientLogin() {
       let inviteCode = wx.getStorageSync("inviteCode") || "";
       let token = wx.getStorageSync("token");