Browse Source

fix 加价分享 bug 修复

ylong 6 months ago
parent
commit
556727f1f6

+ 21 - 14
App.vue

@@ -1,4 +1,5 @@
 <script>
+import { eventBus } from '@/utils/event-bus'
 export default {
 	globalData: {
 		// 胶囊距上距离
@@ -23,12 +24,16 @@ export default {
 		windowHeight: 0,
 		// 常规子页面可操作区域高度
 		pageContentHeight: 0,
+
+		// 是否是冷启动
+		isColdLaunch: false,
 	},
 	onLaunch(options) {
-		console.log(options, "onLaunch系统信息");
+		this.globalData.isColdLaunch = true;
+		console.log('冷启动onLaunch:',this.globalData.isColdLaunch)
 		let params = {};
 		if (options.query) {
-			// #ifdef MP-WEIXIN
+			//微信小程序的场景值解析
 			if (options.query.scene) {
 				// 对 scene 进行解码
 				const decodeScene = decodeURIComponent(options.query.scene);
@@ -41,21 +46,21 @@ export default {
 
 				let keys = Object.keys(params)
 				if (keys.length > 0) {
-					this.slientLogin(params);
-					if (params.inviteCode) {
-						uni.setStorageSync('inviteCode', params.inviteCode)
+					console.log(params, "params");
+					// 如果链接参数中有一个名为 upsellCode 的参数
+					if (params.upsellCode) {
+						uni.setStorageSync('upsellCode', params.upsellCode)
 					}
+					this.slientLogin(params);
 				} else {
 					this.slientLogin();
 				}
-			}
-			// #endif
-
-			// 如果链接参数中有一个名为 inviteCode 的参数
-			this.slientLogin(options.query);
-			// 如果链接参数中有一个名为 upsellCode 的参数
-			if (options.query.upsellCode) {
-				uni.setStorageSync('upsellCode', options.query.upsellCode)
+			} else {
+				this.slientLogin(options.query);
+				// 如果链接参数中有一个名为 upsellCode 的参数
+				if (options.query.upsellCode) {
+					uni.setStorageSync('upsellCode', options.query.upsellCode)
+				}
 			}
 		} else {
 			this.slientLogin()
@@ -79,9 +84,11 @@ export default {
 						.post("/user/miniLogin", data)
 						.then((response) => {
 							if (response.code == 200) {
-								console.log(response.data, data, "登录成功");
+								eventBus.emit('loginSuccess', { response: response.data, params: data })
+								this.globalData.isColdLaunch = false;
 								uni.setStorageSync("loginSuccess", response.data);
 								uni.setStorageSync("token", response.data.token);
+								console.log("登录成功返回参数", response.data, data);
 							}
 						});
 				},

+ 1 - 0
api/auth.js

@@ -7,6 +7,7 @@ export const silentLogin = () => {
                 let data = uni.getStorageSync("loginType") || {};
                 data.code = loginRes.code;
                 data.plat = platform === 'mp-alipay' ? 2 : 1
+                data.upsellCode = uni.getStorageSync("upsellCode") || ''
                 console.log("登录参数2", data);
 
                 uni.$u.http

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

@@ -1,5 +1,5 @@
 <template>
-    <u-popup v-model="showPopup" @close="closePopup" @open="openPopup" mode="center" border-radius="20" width="100%" class="first-order-free-popup">
+    <u-popup v-model="showPopup" @close="closePopup" @open="openPopup" mode="center" border-radius="20" width="100%" class="first-order-free-popup" background-color="transparent">
         <view class="popup-content">
             <image 
                 class="gift-image" 

+ 181 - 182
pages/home/components/upsell-share.vue

@@ -1,217 +1,216 @@
 <template>
-  <custom-popup
-    v-model="showPopup"
-    mode="center"
-    border-radius="24"
-    width="540rpx"
-    :bg-color="'transparent'"
-  >
-    <view class="share-container">
-      <!-- 标题 -->
-      <view class="title-text">
-        <view>好友邀您助力</view>
-        <view>提升卖书收入</view>
-      </view>
-
-      <!-- 活动规则按钮 -->
-      <view class="rules-button-container">
-        <u-button
-          class="rules-button"
-          :custom-style="rulesButtonStyle"
-          @click="viewRules"
-          >查看活动规则</u-button
-        >
-      </view>
-
-      <!-- 用户信息区域 -->
-      <view class="user-info">
-        <view class="avatar-container">
-          <u-avatar :src="avatarUrl" size="140"></u-avatar>
+    <custom-popup v-model="showPopup" mode="center" border-radius="24" width="540rpx" :bg-color="'transparent'">
+        <view class="share-container">
+            <!-- 标题 -->
+            <view class="title-text">
+                <view>好友邀您助力</view>
+                <view>提升卖书收入</view>
+            </view>
+
+            <!-- 活动规则按钮 -->
+            <view class="rules-button-container">
+                <u-button class="rules-button" :custom-style="rulesButtonStyle" @click="viewRules">查看活动规则</u-button>
+            </view>
+
+            <!-- 用户信息区域 -->
+            <view class="user-info">
+                <view class="avatar-container">
+                    <u-avatar :src="avatarUrl" size="140"></u-avatar>
+                </view>
+                <view class="username">{{ username }}</view>
+            </view>
+
+            <!-- 助力按钮 -->
+            <button class="help-button" @click="inviteClickHelp" v-if="inviteDone == 1">
+                点击助力
+            </button>
+
+            <button class="help-button" @click="close" v-if="inviteDone == 0">
+                助力成功
+            </button>
+
+            <!-- 关闭按钮 -->
+            <view class="close-button" @click="close">
+                <image src="/static/img/activity/close2.png" mode="widthFix"></image>
+            </view>
         </view>
-        <view class="username">{{ username }}</view>
-      </view>
-
-      <!-- 助力按钮 -->
-      <button class="help-button" @click="inviteClickHelp" v-if="inviteDone == 1">
-        点击助力
-      </button>
-
-      <button class="help-button" @click="close" v-if="inviteDone == 0">
-        助力成功
-      </button>
-
-      <!-- 关闭按钮 -->
-      <view class="close-button" @click="close">
-        <image src="/static/img/activity/close2.png" mode="widthFix"></image>
-      </view>
-    </view>
-  </custom-popup>
+    </custom-popup>
 </template>
 
 <script>
 import customPopup from "../../../components/custom-popup.vue";
 
 export default {
-  components: {
-    customPopup,
-  },
-  data() {
-    return {
-      showPopup: false,
-      avatarUrl: "", // 用户头像URL
-      username: "", // 用户名,带星号
-      // 自定义按钮样式
-      rulesButtonStyle: {
-        backgroundColor: "#39c248",
-        color: "#FFFFFF",
-        fontSize: "28rpx",
-        width: "280rpx",
-        height: "80rpx",
-        borderRadius: "40rpx",
-      },
-      // 邀请可以助力 0-否(完成不能再助力) 1-是
-      inviteDone: 1,
-      upsellCode: "",
-    };
-  },
-  methods: {
-    open(upsellCode) {
-      this.showPopup = true;
-      this.upsellCode = upsellCode;
-      this.getInviteHelpQuery(upsellCode);
+    components: {
+        customPopup,
     },
-    //获取分享的邀请人信息 /token/order/inviteHelpQuery
-    getInviteHelpQuery(upsellCode) {
-      upsellCode = upsellCode || uni.getStorageInfoSync("upsellCode");
-      uni.$u.http
-        .post(`/token/order/inviteHelpQuery?upsellCode=${upsellCode}`)
-        .then((res) => {
-          console.log(res, 'res')
-          if (res.code == 200) {
-            this.avatarUrl = res.data.imgPath;
-            this.username = res.data.nickName;
-            this.inviteDone = res.data.inviteDone;
-          }else {
-            uni.$u.toast(res.msg);
-          }
-        });
+    data() {
+        return {
+            showPopup: false,
+            avatarUrl: "", // 用户头像URL
+            username: "", // 用户名,带星号
+            // 自定义按钮样式
+            rulesButtonStyle: {
+                backgroundColor: "#39c248",
+                color: "#FFFFFF",
+                fontSize: "28rpx",
+                width: "280rpx",
+                height: "80rpx",
+                borderRadius: "40rpx",
+            },
+            // 邀请可以助力 0-否(完成不能再助力) 1-是
+            inviteDone: 1,
+            upsellCode: "",
+        };
     },
-
-    close() {
-      this.showPopup = false;
-    },
-    viewRules() {
-      // 打开活动规则弹窗
-      this.$emit("view-rules");
-    },
-
-    //调用助力接口 /api/token/order/inviteClickHelp
-    inviteClickHelp() {
-      let upsellCode = this.upsellCode || uni.getStorageInfoSync("upsellCode");
-      uni.$u.http
-        .post(`/token/order/inviteClickHelp?upsellCode=${upsellCode}`)
-        .then((res) => {
-          if (res.code == 200) {
-            this.close();
-            this.inviteDone = 0;
-            uni.$u.toast("助力成功");
-          } else {
-            uni.$u.toast(res.msg);
-          }
-        });
+    methods: {
+        open(upsellCode) {
+            this.showPopup = true;
+            this.upsellCode = upsellCode;
+            this.getInviteHelpQuery(upsellCode);
+        },
+        //获取分享的邀请人信息 /token/order/inviteHelpQuery
+        getInviteHelpQuery(upsellCode) {
+            uni.$u.http
+                .post(`/token/order/inviteHelpQuery?upsellCode=${upsellCode}`)
+                .then((res) => {
+                    console.log(res, 'res')
+                    if (res.code == 200) {
+                        this.avatarUrl = res.data.imgPath;
+                        this.username = res.data.nickName;
+                        this.inviteDone = res.data.inviteDone;
+                    } else {
+                        this.username = res.msg;
+                        uni.showToast({
+                            icon: "none",
+                            title: res.msg,
+                        });
+                    }
+                });
+        },
+
+        close() {
+            this.showPopup = false;
+            uni.removeStorageSync("upsellCode");
+        },
+        viewRules() {
+            // 打开活动规则弹窗
+            this.$emit("view-rules");
+        },
+
+        //调用助力接口 /api/token/order/inviteClickHelp
+        inviteClickHelp() {
+            let upsellCode = this.upsellCode || uni.getStorageInfoSync("upsellCode");
+            uni.$u.http
+                .post(`/token/order/inviteClickHelp?upsellCode=${upsellCode}`)
+                .then((res) => {
+                    if (res.code == 200) {
+                        this.close();
+                        this.inviteDone = 0;
+                        uni.showToast({
+                            icon: "none",
+                            title: "助力成功",
+                        });
+                        this.$emit("inviteSuccess");
+                    } else {
+                        uni.showToast({
+                            icon: "none",
+                            title: res.msg || "助力失败",
+                        });
+                    }
+                });
+        },
     },
-  },
 };
 </script>
 
 <style lang="scss" scoped>
 .share-container {
-  position: relative;
-  padding: 40rpx;
-  border-radius: 24rpx;
-  text-align: center;
-  background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg.png")
-    no-repeat center center;
-  background-size: 100% 100%;
+    position: relative;
+    padding: 40rpx;
+    border-radius: 24rpx;
+    text-align: center;
+    background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg.png") no-repeat center center;
+    background-size: 100% 100%;
 }
 
 .title-text view {
-  font-size: 50rpx;
-  font-weight: bold;
-  color: #000;
+    font-size: 50rpx;
+    font-weight: bold;
+    color: #000;
 }
 
 .rules-button-container {
-  display: flex;
-  justify-content: center;
-  margin: 20rpx 0 40rpx;
-
-  .rules-button {
-    position: relative;
-
-    &::before,
-    &::after {
-      content: "";
-      position: absolute;
-      top: 50%;
-      width: 80rpx;
-      height: 2rpx;
-      background-color: #39c248;
+    display: flex;
+    justify-content: center;
+    margin: 20rpx 0 40rpx;
+
+    .rules-button {
+        position: relative;
+
+        &::before,
+        &::after {
+            content: "";
+            position: absolute;
+            top: 50%;
+            width: 80rpx;
+            height: 2rpx;
+            background-color: #39c248;
+        }
+
+        &::before {
+            left: -90rpx;
+        }
+
+        &::after {
+            right: -90rpx;
+        }
     }
+}
 
-    &::before {
-      left: -90rpx;
+.user-info {
+    .avatar-container {
+        margin: 0 auto 20rpx;
+        width: 140rpx;
+        height: 140rpx;
+        border-radius: 50%;
+        overflow: hidden;
     }
 
-    &::after {
-      right: -90rpx;
+    .username {
+        font-size: 28rpx;
+        color: #333;
+        background: #39c248;
+        padding: 6rpx 20rpx;
+        border-radius: 30rpx;
+        color: #fff;
+        display: inline-block;
+        position: relative;
+        top: -50rpx;
     }
-  }
-}
-
-.user-info {
-  .avatar-container {
-    margin: 0 auto 20rpx;
-    width: 140rpx;
-    height: 140rpx;
-    border-radius: 50%;
-    overflow: hidden;
-  }
-
-  .username {
-    font-size: 28rpx;
-    color: #333;
-    background: #39c248;
-    padding: 6rpx 20rpx;
-    border-radius: 30rpx;
-    color: #fff;
-    display: inline-block;
-    position: relative;
-    top: -50rpx;
-  }
 }
 
 .help-button {
-  height: 90rpx;
-  background: linear-gradient(to bottom, #47d46c, #24ad3c);
-  font-size: 32rpx;
-  color: #ffffff;
-  border-radius: 10rpx;
-  line-height: 90rpx;
-  width: 100%;
-  margin-top: 20rpx;
-  border: none;
+    height: 90rpx;
+    background: linear-gradient(to bottom, #47d46c, #24ad3c);
+    font-size: 32rpx;
+    color: #ffffff;
+    border-radius: 10rpx;
+    line-height: 90rpx;
+    width: 100%;
+    margin-top: 20rpx;
+    border: none;
 }
 
 .close-button {
-  position: absolute;
-  bottom: -120rpx;
-  left: 50%;
-  transform: translateX(-50%);
-
-  image {
-    width: 70rpx;
-    height: 70rpx;
-  }
+    position: absolute;
+    bottom: -120rpx;
+    left: 50%;
+    transform: translateX(-50%);
+
+    image {
+        width: 70rpx;
+        height: 70rpx;
+    }
 }
 </style>

+ 89 - 142
pages/home/index.vue

@@ -1,27 +1,12 @@
 <template>
-    <view
-        class="container"
-        :style="{ background: containerBg }"
-        :class="bookList.length ? 'book-list' : 'no-list'"
-    >
-        <u-navbar
-            :is-back="false"
-            :border-bottom="false"
-            :background="{ background: navbarBackground }"
-        >
+    <view class="container" :style="{ background: containerBg }" :class="bookList.length ? 'book-list' : 'no-list'">
+        <u-navbar :is-back="false" :border-bottom="false" :background="{ background: navbarBackground }">
             <text class="nav-title">卖书给书嗨</text>
         </u-navbar>
 
         <not-scanned v-if="!bookList.length"></not-scanned>
-        <scan-book-list
-            v-else
-            @updateBooks="updateBooksList"
-            @deleted="handleDeleteBook"
-            :bookList="bookList"
-            ref="scanBookList"
-            @upsell="handleUpsell"
-            @refresh="getLastOrder"
-        ></scan-book-list>
+        <scan-book-list v-else @updateBooks="updateBooksList" @deleted="handleDeleteBook" :bookList="bookList"
+            ref="scanBookList" @upsell="handleUpsell" @refresh="getLastOrder"></scan-book-list>
         <!-- 底部固定按钮 -->
         <view class="bottom-fixed">
             <view class="btn-wrap mb-20">
@@ -35,71 +20,40 @@
                 </button>
             </view>
 
-            <view
-                class="flex-a flex-j-b pad-20"
-                style="padding-top: 0"
-                v-if="bookList.length"
-            >
+            <view class="flex-a flex-j-b pad-20" style="padding-top: 0" v-if="bookList.length">
                 <view class="left-info" style="min-width: 194px">
                     <view class="flex-a common-text">
                         <text class="color-red">{{ orderInfo.totalNum }}</text>
                         件 预估回收价
-                        <text class="color-red"
-                            >¥{{ orderInfo.totalRecycleMoney || 0 }}</text
-                        >
+                        <text class="color-red">¥{{ orderInfo.totalRecycleMoney || 0 }}</text>
                     </view>
-                    <text class="common-text tip"
-                        >*旧书预估价格满{{ orderInfo.minOrderMoney }}元起收</text
-                    >
+                    <text class="common-text tip">*旧书预估价格满{{ orderInfo.minOrderMoney }}元起收</text>
                 </view>
 
-                <button
-                    class="scan-btn next-btn"
-                    @click="handleValidate"
-                    :disabled="isDisabled"
-                >
+                <button class="scan-btn next-btn" @click="handleValidate" :disabled="isDisabled">
                     下一步
                 </button>
             </view>
 
-            <service-info
-                v-if="bookList.length"
-                :serviceList="serviceList"
-                :firstOrder="orderInfo.firstOrder"
-            ></service-info>
+            <service-info v-if="bookList.length" :serviceList="serviceList"
+                :firstOrder="orderInfo.firstOrder"></service-info>
         </view>
 
-        <InputIsbn
-            ref="isbnPopup"
-            @submit="(isbn) => checkBookISBN(isbn, 'input')"
-        />
+        <InputIsbn ref="isbnPopup" @submit="(isbn) => checkBookISBN(isbn, 'input')" />
         <!-- 套装书说明弹窗 -->
-        <CommonDialog
-            ref="setBookDialog"
-            title="套装书说明"
-            :showCancel="false"
-            @confirm="handleSetBookConfirm"
-        >
-            <text
-                >套装书(ISBN码相同的系列书箱)只需扫描其中一册,扫码价即套装价。打包时请把所有单册统在一起或放在一个袋子里寄出。</text
-            >
+        <CommonDialog ref="setBookDialog" title="套装书说明" :showCancel="false" @confirm="handleSetBookConfirm">
+            <text>套装书(ISBN码相同的系列书箱)只需扫描其中一册,扫码价即套装价。打包时请把所有单册统在一起或放在一个袋子里寄出。</text>
         </CommonDialog>
 
         <!-- 暂不回收弹窗 -->
-        <CommonDialog
-            ref="notAcceptDialog"
-            title="暂不回收"
-            :showCancel="false"
-        >
+        <CommonDialog ref="notAcceptDialog" title="暂不回收" :showCancel="false">
             <text>这本书暂时不回收,请您过段时间再来试试~</text>
         </CommonDialog>
 
         <!-- 暂无信息弹窗 -->
         <CommonDialog ref="noInfoDialog" title="暂无信息" :showCancel="false">
-            <text
-                >抱歉,没有该书的信息,书嗨会定期补充图书信息,请您过段时间再来试试~</text
-            >
+            <text>抱歉,没有该书的信息,书嗨会定期补充图书信息,请您过段时间再来试试~</text>
         </CommonDialog>
 
         <!-- 扫累了弹窗 -->
@@ -108,29 +62,17 @@
         </CommonDialog>
 
         <!-- 该书超出最大回收本数  maxAcceptDialog-->
-        <CommonDialog
-            ref="maxAcceptDialog"
-            title="温馨提示"
-            :showCancel="false"
-        >
+        <CommonDialog ref="maxAcceptDialog" title="温馨提示" :showCancel="false">
             <text>该书超出最大回收本数</text>
         </CommonDialog>
 
         <!-- 单个订单最多40本书  orderMaxNumDialog-->
-        <CommonDialog
-            ref="orderMaxNumDialog"
-            title="温馨提示"
-            :showCancel="false"
-        >
+        <CommonDialog ref="orderMaxNumDialog" title="温馨提示" :showCancel="false">
             <text>单个订单最多40本书</text>
         </CommonDialog>
 
         <!-- 删除活动书籍弹窗 -->
-        <common-dialog
-            ref="deleteDialog"
-            title="温馨提示"
-            @confirm="confirmDelete"
-        >
+        <common-dialog ref="deleteDialog" title="温馨提示" @confirm="confirmDelete">
             <text>{{
                 deleteBook.upsellMoney
                     ? "此书为限时加价收图书,删除后再次添加将失去加价收资格,确定删除吗?"
@@ -140,45 +82,25 @@
 
         <!-- 此订单还有未加价的图书,提交订单后将失去加价资格,确定提交吗? -->
         <common-dialog ref="noUpsellDialog" title="温馨提示" @confirm="onNext">
-            <text
-                >此订单还有未加价的图书,提交订单后将失去加价资格,确定提交吗?</text
-            >
+            <text>此订单还有未加价的图书,提交订单后将失去加价资格,确定提交吗?</text>
         </common-dialog>
 
         <!-- 温馨提示弹窗 -->
-        <KindReminder
-            ref="kindReminder"
-            @start="handleStartSelling"
-            @viewRules="handleViewRules"
-        />
-
-        <view
-            class="customer-service"
-            :style="{
-                left: servicePosition.left + 'px',
-                right: servicePosition.right + 'px',
-                bottom: servicePosition.bottom + 'px',
-            }"
-            @touchstart="touchStart"
-            @touchmove="touchMove"
-            @touchend="touchEnd"
-        >
+        <KindReminder ref="kindReminder" @start="handleStartSelling" @viewRules="handleViewRules" />
+
+        <view class="customer-service" :style="{
+            left: servicePosition.left + 'px',
+            right: servicePosition.right + 'px',
+            bottom: servicePosition.bottom + 'px',
+        }" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
             <!-- #ifdef MP-ALIPAY -->
             <button class="service-btn" @click="navigateToCustomerService">
-                <image
-                    src="/static/img/kf.png"
-                    mode="widthFix"
-                    style="width: 126rpx; height: 140rpx"
-                ></image>
+                <image src="/static/img/kf.png" mode="widthFix" style="width: 126rpx; height: 140rpx"></image>
             </button>
             <!-- #endif -->
             <!-- #ifndef MP-ALIPAY -->
             <button class="service-btn" open-type="contact">
-                <image
-                    src="/static/img/kf.png"
-                    mode="widthFix"
-                    style="width: 126rpx; height: 140rpx"
-                ></image>
+                <image src="/static/img/kf.png" mode="widthFix" style="width: 126rpx; height: 140rpx"></image>
             </button>
             <!-- #endif -->
         </view>
@@ -213,6 +135,8 @@ 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";
+import { eventBus } from "@/utils/event-bus";
+
 const app = getApp();
 
 export default {
@@ -278,18 +202,14 @@ export default {
             return this.bookList.length > 0 ? "300rpx" : "110rpx";
         },
         totalBooks() {
-            return this.bookList.reduce(
-                (sum, book) => sum + (book.num || 1),
-                0
-            );
+            return this.bookList.reduce((sum, book) => sum + (book.num || 1), 0);
         },
         totalPrice() {
             return this.bookList
                 .reduce(
                     (sum, book) =>
-                        sum +
-                            book.recyclePrice * (book.num || 1) +
-                            book.currUpsellMoney || 0,
+                        sum + book.recyclePrice * (book.num || 1) + book.currUpsellMoney ||
+                        0,
                     0
                 )
                 .toFixed(2);
@@ -313,8 +233,7 @@ export default {
             return {
                 title: "书嗨",
                 path: "/pages/home/index?upsellCode=" + upsellCode,
-                imageUrl:
-                    "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
+                imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
                 desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
             };
         } else {
@@ -334,8 +253,7 @@ export default {
             return {
                 title: "书嗨",
                 path: "/pages/home/index?upsellCode=" + upsellCode,
-                imageUrl:
-                    "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
+                imageUrl: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/share.jpg",
                 desc: "书嗨,专注于书籍交易的平台,提供新书和二手书的买卖服务",
             };
         } else {
@@ -353,20 +271,57 @@ export default {
                 this.screenHeight = res.windowHeight;
             },
         });
-        setTimeout(() => {
-            let loginSuccess = uni.getStorageSync("loginSuccess");
-            let upsellCode = app.globalData.upsellCode;
 
-            if (loginSuccess && upsellCode) {
-                console.log(loginSuccess, "登录成功loginSuccess");
-                this.$refs.shareRef?.open(upsellCode);
-                uni.removeStorageSync("loginSuccess");
+        eventBus.on("loginSuccess", (data) => {
+            console.log(data, "登录成功loginSuccess");
+            this.loginSuccess(data);
+            app.globalData.isColdLaunch = false;
+        });
+    },
+    //针对多次扫码的热启动场景,需要判断是否是冷启动
+    onLoad(options) {
+        console.log(options, app.globalData.isColdLaunch, "onLoad");
+        if (app.globalData.isColdLaunch) return
+
+        if (options.scene) {
+            let params = {};
+            // 对 scene 进行解码
+            const decodeScene = decodeURIComponent(options.scene);
+            // 拆分参数
+            const paramPairs = decodeScene.split('&');
+            paramPairs.forEach((pair) => {
+                const [key, value] = pair.split('=');
+                params[key] = value;
+            });
+
+            if (params.upsellCode) {
+                this.$refs.shareRef?.open(params.upsellCode);
                 this.getLastOrder();
             }
-        }, 1000);
+        } else if (options.upsellCode) {
+            this.$refs.shareRef?.open(options.upsellCode);
+        } else {
+            this.getLastOrder();
+        }
+    },
+
+    //卸载loginSuccess事件
+    onUnload() {
+        uni.removeStorageSync("upsellCode");
+        eventBus.off("loginSuccess");
     },
 
     methods: {
+        // 登录成功之后
+        loginSuccess() {
+            let upsellCode = uni.getStorageSync("upsellCode");
+            console.log(upsellCode, "登录成功之后助力的 code值:", upsellCode);
+            if (upsellCode) {
+                this.$refs.shareRef?.open(upsellCode);
+            }
+            this.getLastOrder();
+        },
+
         //删除书籍
         handleDeleteBook(book) {
             this.deleteBook = book;
@@ -375,7 +330,7 @@ export default {
         //支付宝小程序的客服
         navigateToCustomerService() {
             uni.navigateTo({
-                url: '/pages-mine/pages/customer-service'
+                url: "/pages-mine/pages/customer-service",
             });
         },
 
@@ -423,8 +378,7 @@ export default {
                 typeof this.servicePosition.bottom === "string" &&
                 this.servicePosition.bottom.includes("%")
             ) {
-                const percentage =
-                    parseFloat(this.servicePosition.bottom) / 100;
+                const percentage = parseFloat(this.servicePosition.bottom) / 100;
                 this.initialBottom = this.screenHeight * percentage;
             } else {
                 this.initialBottom = parseFloat(this.servicePosition.bottom);
@@ -652,9 +606,9 @@ export default {
 
                     this.bookList = res.data?.orderDetailList
                         ? res.data.orderDetailList.map((v) => {
-                              v.orderId = res.data.orderId;
-                              return v;
-                          })
+                            v.orderId = res.data.orderId;
+                            return v;
+                        })
                         : [];
                     this.serviceList = res.data.serviceList || [];
                 }
@@ -674,14 +628,6 @@ export default {
             uni.setStorageSync("kindReminderShown", true);
         },
     },
-
-    onShow() {
-        // 获取上一个订单
-        setTimeout(() => {
-            let token = uni.getStorageSync("token");
-            token && this.getLastOrder();
-        }, 300);
-    },
 };
 </script>
 
@@ -726,9 +672,9 @@ export default {
         font-size: 34rpx;
         color: #ffffff;
         padding-left: 40rpx;
-		/* #ifdef MP-ALIPAY */
-		padding-left: 70rpx;
-		/* #endif */
+        /* #ifdef MP-ALIPAY */
+        padding-left: 70rpx;
+        /* #endif */
     }
 }
 
@@ -747,6 +693,7 @@ export default {
     color: #ff0000;
     margin: 0 10rpx;
 }
+
 .color-green {
     color: #276f1e;
 }

+ 22 - 0
utils/event-bus.js

@@ -0,0 +1,22 @@
+export const eventBus = {
+    events: {},
+
+    // 注册事件监听
+    on(eventName, callback) {
+        this.events[eventName] = callback;
+    },
+
+    // 触发事件
+    emit(eventName, data) {
+        if (typeof this.events[eventName] === 'function') {
+            this.events[eventName](data);
+        }
+    },
+
+    // 移除事件监听
+    off(eventName, callback) {
+        if (this.events[eventName] === callback) {
+            delete this.events[eventName];
+        }
+    }
+};

+ 7 - 1
uview-ui/components/u-popup/u-popup.vue

@@ -193,6 +193,11 @@ export default {
 		duration: {
 			type: [String, Number],
 			default: 250
+		},
+		// 背景颜色
+		backgroundColor: {
+			type: String,
+			default: '#ffffff'
 		}
 	},
 	data() {
@@ -253,6 +258,7 @@ export default {
 			style.height = this.height ? this.getUnitValue(this.height) : 'auto';
 			style.zIndex = this.uZindex;
 			style.marginTop = `-${this.$u.addUnit(this.negativeTop)}`;
+			style.backgroundColor = this.backgroundColor;
 			if (this.borderRadius) {
 				style.borderRadius = `${this.borderRadius}rpx`;
 				// 不加可能圆角无效
@@ -413,7 +419,7 @@ export default {
 	display: block;
 	/* #endif */
 	position: relative;
-	background-color: transparent;
+	background-color: #ffffff;
 }
 
 .u-drawer-content-visible.u-drawer-center {