upsell-book.vue 7.4 KB

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