upsell-book.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <custom-popup
  3. v-model="showPopup"
  4. mode="center"
  5. border-radius="24"
  6. width="650rpx"
  7. :bg-color="'transparent'"
  8. >
  9. <view class="popup-container">
  10. <!-- 顶部黄色手掌图标和标题 -->
  11. <view class="header">
  12. <!-- <image src="/static/img/activity/hand.png" class="hand-icon"></image> -->
  13. <view class="title-text">你真的太幸运了</view>
  14. <view class="title-text">恭喜你获得限时加价权益</view>
  15. </view>
  16. <!-- 绿色价格信息区域 -->
  17. <view class="price-section">
  18. <view class="price-row">
  19. <text class="price-label">此书预估书款</text>
  20. <text class="price-value">¥ {{ bookInfo.recyclePrice || 0 }}</text>
  21. </view>
  22. <view class="price-row">
  23. <text class="price-label">助力成功提升至</text>
  24. <text class="price-value increased"
  25. >¥ {{ bookInfo.upsellMoney || 0 }}</text
  26. >
  27. <image
  28. class="up-icon"
  29. src="/static/img/activity/up2.png"
  30. mode="widthFix"
  31. ></image>
  32. </view>
  33. <view class="small-text"
  34. >实际金额以最终审核书款为准,活动时间{{
  35. formatDate(bookInfo.startTime)
  36. }}至{{ formatDate(bookInfo.endTime) }}</view
  37. >
  38. </view>
  39. <!-- 分享助力区域 -->
  40. <view class="share-section">
  41. <view class="share-text">分享{{ inviteUsers.length }}位好友助力</view>
  42. <view class="add-button">
  43. <block v-for="(item, index) in inviteUsers" :key="index">
  44. <view class="add-item" v-if="item.imgPath">
  45. <image
  46. class="hand-icon"
  47. :src="item.imgPath"
  48. mode="widthFix"
  49. ></image>
  50. <view class="add-text">{{ formatName(item.nickName) }}</view>
  51. </view>
  52. <image
  53. v-else
  54. class="hand-icon"
  55. src="/static/img/activity/invite.png"
  56. mode="widthFix"
  57. ></image>
  58. </block>
  59. </view>
  60. </view>
  61. <!-- 分享按钮 -->
  62. <view class="action-buttons">
  63. <button class="share-button" @click="shareAction" open-type="share">
  64. 立即分享
  65. </button>
  66. <button class="scan-button" @click="scanAction">扫码助力</button>
  67. </view>
  68. <!-- 关闭按钮 -->
  69. <view class="close-button" @click="closePopup">
  70. <image src="/static/img/activity/close2.png" mode="widthFix"></image>
  71. </view>
  72. </view>
  73. </custom-popup>
  74. </template>
  75. <script>
  76. import customPopup from "../../../components/custom-popup.vue";
  77. export default {
  78. components: {
  79. customPopup,
  80. },
  81. data() {
  82. return {
  83. showPopup: false,
  84. bookInfo: {},
  85. inviteUsers: [],
  86. };
  87. },
  88. methods: {
  89. open(data) {
  90. this.showPopup = true;
  91. this.getIsbnInfo(data.isbn, data.orderId);
  92. },
  93. //获取信息
  94. getIsbnInfo(isbn, orderId) {
  95. uni.$u.http
  96. .get(`/token/order/clickUpsellInvite?isbn=${isbn}&orderId=${orderId}`)
  97. .then((res) => {
  98. if (res.code == 200) {
  99. this.bookInfo = res.data;
  100. let needInviteNum = res.data.needInviteNum;
  101. let inviteUsers = res.data.inviteUsers || [];
  102. let length = inviteUsers.length;
  103. for (let index = 0; index < needInviteNum - length; index++) {
  104. inviteUsers.push({
  105. nickName: "",
  106. imgPath: "",
  107. });
  108. }
  109. this.inviteUsers = inviteUsers;
  110. }
  111. });
  112. },
  113. // 转换时间的方法,将年月日时分秒转换成 3/25 格式
  114. formatDate(dateString) {
  115. if (!dateString) return "";
  116. const date = new Date(dateString);
  117. const month = date.getMonth() + 1; // 月份从0开始,需要+1
  118. const day = date.getDate();
  119. return `${month}/${day}`;
  120. },
  121. //格式化 name,长度大于 3,只保留第一个和最后一个字,中间最多使用三个 *代替
  122. // 长度小于 3,只保留第一个字
  123. formatName(name) {
  124. if (!name) return "";
  125. if (name.length > 2) {
  126. return name.slice(0, 1) + "*" + name.slice(-1);
  127. } else {
  128. return name.slice(0, 1) + "*";
  129. }
  130. },
  131. closePopup() {
  132. this.showPopup = false;
  133. },
  134. shareAction() {
  135. this.$emit("share");
  136. },
  137. scanAction() {
  138. this.showPopup = false;
  139. this.$emit("scan", this.bookInfo);
  140. },
  141. },
  142. };
  143. </script>
  144. <style lang="scss" scoped>
  145. .popup-container {
  146. position: relative;
  147. padding: 30rpx;
  148. box-sizing: border-box;
  149. padding-bottom: 50rpx;
  150. background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg2.png")
  151. no-repeat center center;
  152. background-size: 100% 100%;
  153. }
  154. .header {
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. padding: 20rpx 0 10rpx;
  159. padding-top: 160rpx;
  160. .title-text {
  161. font-size: 38rpx;
  162. font-weight: bold;
  163. color: #000;
  164. margin-bottom: 10rpx;
  165. }
  166. .subtitle-text {
  167. font-size: 32rpx;
  168. color: #000;
  169. }
  170. .hand-icon {
  171. width: 140rpx;
  172. height: 140rpx;
  173. position: relative;
  174. top: -30rpx;
  175. }
  176. }
  177. .price-section {
  178. background-color: #39c248;
  179. border-radius: 16rpx;
  180. padding: 20rpx 30rpx;
  181. margin: 20rpx 0;
  182. .price-row {
  183. display: flex;
  184. align-items: center;
  185. .price-label {
  186. color: #ffffff;
  187. font-size: 30rpx;
  188. }
  189. .price-value {
  190. color: #ffeb3b;
  191. font-size: 30rpx;
  192. font-weight: bold;
  193. margin-left: 10rpx;
  194. }
  195. .increased {
  196. font-size: 42rpx;
  197. }
  198. .up-icon {
  199. width: 30rpx;
  200. height: 30rpx;
  201. margin-left: 5rpx;
  202. }
  203. }
  204. .small-text {
  205. color: #ffffff;
  206. font-size: 22rpx;
  207. margin-top: 10rpx;
  208. }
  209. }
  210. .share-section {
  211. background-color: #e8f8e8;
  212. border-radius: 16rpx;
  213. padding: 30rpx;
  214. margin: 20rpx 0;
  215. .share-text {
  216. color: #39c248;
  217. font-size: 32rpx;
  218. text-align: center;
  219. margin-bottom: 30rpx;
  220. }
  221. .add-button {
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. gap: 10rpx;
  226. .hand-icon {
  227. width: 100rpx;
  228. height: 100rpx;
  229. }
  230. }
  231. .add-item {
  232. position: relative;
  233. .add-text {
  234. position: absolute;
  235. bottom: 2rpx;
  236. left: 5rpx;
  237. font-size: 24rpx;
  238. background: #39c248;
  239. text-align: center;
  240. color: #fff;
  241. padding: 0 10rpx;
  242. border-radius: 20rpx;
  243. display: inline-block;
  244. width: 94rpx;
  245. }
  246. }
  247. }
  248. .action-buttons {
  249. margin-top: 30rpx;
  250. .share-button {
  251. height: 90rpx;
  252. background: linear-gradient(to bottom, #47d46c, #24ad3c) !important;
  253. margin-bottom: 24rpx;
  254. font-size: 32rpx;
  255. color: #ffffff;
  256. border-radius: 10rpx;
  257. line-height: 90rpx;
  258. }
  259. .scan-button {
  260. height: 90rpx;
  261. font-size: 32rpx;
  262. color: #39c248;
  263. border: 1rpx solid #39c248;
  264. background-color: transparent;
  265. border-radius: 10rpx;
  266. line-height: 90rpx;
  267. }
  268. button + button {
  269. margin-left: 0;
  270. }
  271. }
  272. .close-button {
  273. position: absolute;
  274. bottom: -120rpx;
  275. left: 50%;
  276. transform: translateX(-50%);
  277. image {
  278. width: 70rpx;
  279. height: 70rpx;
  280. }
  281. }
  282. </style>