upsell-book.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. uni.setStorageSync("upsellCodeShare", res.data.upsellCode);
  111. }else {
  112. uni.$u.toast(res.msg);
  113. }
  114. });
  115. },
  116. // 转换时间的方法,将年月日时分秒转换成 3/25 格式
  117. formatDate(dateString) {
  118. if (!dateString) return "";
  119. const date = new Date(dateString);
  120. const month = date.getMonth() + 1; // 月份从0开始,需要+1
  121. const day = date.getDate();
  122. return `${month}/${day}`;
  123. },
  124. //格式化 name,长度大于 3,只保留第一个和最后一个字,中间最多使用三个 *代替
  125. // 长度小于 3,只保留第一个字
  126. formatName(name) {
  127. if (!name) return "";
  128. if (name.length > 2) {
  129. return name.slice(0, 1) + "*" + name.slice(-1);
  130. } else {
  131. return name.slice(0, 1) + "*";
  132. }
  133. },
  134. closePopup() {
  135. this.showPopup = false;
  136. },
  137. shareAction() {
  138. this.$emit("share", this.bookInfo);
  139. },
  140. scanAction() {
  141. this.showPopup = false;
  142. this.$emit("scan", this.bookInfo);
  143. },
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .popup-container {
  149. position: relative;
  150. padding: 30rpx;
  151. box-sizing: border-box;
  152. padding-bottom: 50rpx;
  153. background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg2.png")
  154. no-repeat center center;
  155. background-size: 100% 100%;
  156. }
  157. .header {
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. padding: 20rpx 0 10rpx;
  162. padding-top: 160rpx;
  163. .title-text {
  164. font-size: 38rpx;
  165. font-weight: bold;
  166. color: #000;
  167. margin-bottom: 10rpx;
  168. }
  169. .subtitle-text {
  170. font-size: 32rpx;
  171. color: #000;
  172. }
  173. .hand-icon {
  174. width: 140rpx;
  175. height: 140rpx;
  176. position: relative;
  177. top: -30rpx;
  178. }
  179. }
  180. .price-section {
  181. background-color: #39c248;
  182. border-radius: 16rpx;
  183. padding: 20rpx 30rpx;
  184. margin: 20rpx 0;
  185. .price-row {
  186. display: flex;
  187. align-items: center;
  188. .price-label {
  189. color: #ffffff;
  190. font-size: 30rpx;
  191. }
  192. .price-value {
  193. color: #ffeb3b;
  194. font-size: 30rpx;
  195. font-weight: bold;
  196. margin-left: 10rpx;
  197. }
  198. .increased {
  199. font-size: 42rpx;
  200. }
  201. .up-icon {
  202. width: 30rpx;
  203. height: 30rpx;
  204. margin-left: 5rpx;
  205. }
  206. }
  207. .small-text {
  208. color: #ffffff;
  209. font-size: 22rpx;
  210. margin-top: 10rpx;
  211. }
  212. }
  213. .share-section {
  214. background-color: #e8f8e8;
  215. border-radius: 16rpx;
  216. padding: 30rpx;
  217. margin: 20rpx 0;
  218. .share-text {
  219. color: #39c248;
  220. font-size: 32rpx;
  221. text-align: center;
  222. margin-bottom: 30rpx;
  223. }
  224. .add-button {
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. gap: 10rpx;
  229. .hand-icon {
  230. width: 100rpx;
  231. height: 100rpx;
  232. }
  233. }
  234. .add-item {
  235. position: relative;
  236. .add-text {
  237. position: absolute;
  238. bottom: 2rpx;
  239. left: 5rpx;
  240. font-size: 24rpx;
  241. background: #39c248;
  242. text-align: center;
  243. color: #fff;
  244. padding: 0 10rpx;
  245. border-radius: 20rpx;
  246. display: inline-block;
  247. width: 94rpx;
  248. }
  249. }
  250. }
  251. .action-buttons {
  252. margin-top: 30rpx;
  253. .share-button {
  254. height: 90rpx;
  255. background: linear-gradient(to bottom, #47d46c, #24ad3c) !important;
  256. margin-bottom: 24rpx;
  257. font-size: 32rpx;
  258. color: #ffffff;
  259. border-radius: 10rpx;
  260. line-height: 90rpx;
  261. }
  262. .scan-button {
  263. height: 90rpx;
  264. font-size: 32rpx;
  265. color: #39c248;
  266. border: 1rpx solid #39c248;
  267. background-color: transparent;
  268. border-radius: 10rpx;
  269. line-height: 90rpx;
  270. }
  271. button + button {
  272. margin-left: 0;
  273. }
  274. }
  275. .close-button {
  276. position: absolute;
  277. bottom: -120rpx;
  278. left: 50%;
  279. transform: translateX(-50%);
  280. image {
  281. width: 70rpx;
  282. height: 70rpx;
  283. }
  284. }
  285. </style>