upsell-book.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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" data-share-type="upsell" class="hand-btn">
  53. <image
  54. class="hand-icon"
  55. src="/static/img/activity/invite.png"
  56. mode="widthFix"
  57. ></image>
  58. </button>
  59. </block>
  60. </view>
  61. </view>
  62. <!-- 分享按钮 -->
  63. <view class="action-buttons">
  64. <button class="share-button" data-share-type="upsell" @click="shareAction" open-type="share">
  65. 立即分享
  66. </button>
  67. <button class="scan-button" @click="scanAction">扫码助力</button>
  68. </view>
  69. <!-- 关闭按钮 -->
  70. <view class="close-button" @click="closePopup">
  71. <image src="/static/img/activity/close2.png" mode="widthFix"></image>
  72. </view>
  73. </view>
  74. </custom-popup>
  75. </template>
  76. <script>
  77. import customPopup from "../../../components/custom-popup.vue";
  78. export default {
  79. components: {
  80. customPopup,
  81. },
  82. data() {
  83. return {
  84. showPopup: false,
  85. bookInfo: {},
  86. inviteUsers: [],
  87. };
  88. },
  89. methods: {
  90. open(data) {
  91. this.showPopup = true;
  92. this.getIsbnInfo(data.isbn, data.orderId);
  93. },
  94. //获取信息
  95. getIsbnInfo(isbn, orderId) {
  96. uni.$u.http
  97. .get(`/token/order/clickUpsellInvite?isbn=${isbn}&orderId=${orderId}`)
  98. .then((res) => {
  99. if (res.code == 200) {
  100. this.bookInfo = res.data;
  101. let needInviteNum = res.data.canInvite;
  102. let inviteUsers = res.data.inviteUsers || [];
  103. let length = inviteUsers.length;
  104. for (let index = 0; index < needInviteNum - length; index++) {
  105. inviteUsers.push({
  106. nickName: "",
  107. imgPath: "",
  108. });
  109. }
  110. this.inviteUsers = inviteUsers;
  111. uni.setStorageSync("upsellCodeShare", res.data.upsellCode);
  112. } else {
  113. uni.$u.toast(res.msg);
  114. }
  115. });
  116. },
  117. // 转换时间的方法,将年月日时分秒转换成 3/25 格式
  118. formatDate(dateString) {
  119. if (!dateString) return "";
  120. const date = new Date(dateString);
  121. const month = date.getMonth() + 1; // 月份从0开始,需要+1
  122. const day = date.getDate();
  123. return `${month}/${day}`;
  124. },
  125. //格式化 name,长度大于 3,只保留第一个和最后一个字,中间最多使用三个 *代替
  126. // 长度小于 3,只保留第一个字
  127. formatName(name) {
  128. if (!name) return "";
  129. if (name.length > 2) {
  130. return name.slice(0, 1) + "*" + name.slice(-1);
  131. } else {
  132. return name.slice(0, 1) + "*";
  133. }
  134. },
  135. closePopup() {
  136. this.showPopup = false;
  137. },
  138. shareAction() {
  139. this.$emit("share", this.bookInfo);
  140. },
  141. scanAction() {
  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. .hand-btn{
  235. display: inline-block;
  236. width: 100rpx !important;
  237. height: 110rpx;
  238. background: transparent;
  239. flex: none;
  240. padding: 0;
  241. }
  242. .add-item {
  243. position: relative;
  244. .add-text {
  245. position: absolute;
  246. bottom: 2rpx;
  247. left: 5rpx;
  248. font-size: 24rpx;
  249. background: #39c248;
  250. text-align: center;
  251. color: #fff;
  252. padding: 0 10rpx;
  253. border-radius: 20rpx;
  254. display: inline-block;
  255. width: 94rpx;
  256. }
  257. }
  258. }
  259. .action-buttons {
  260. margin-top: 30rpx;
  261. .share-button {
  262. height: 90rpx;
  263. background: linear-gradient(to bottom, #47d46c, #24ad3c) !important;
  264. margin-bottom: 24rpx;
  265. font-size: 32rpx;
  266. color: #ffffff;
  267. border-radius: 10rpx;
  268. line-height: 90rpx;
  269. }
  270. .scan-button {
  271. height: 90rpx;
  272. font-size: 32rpx;
  273. color: #39c248;
  274. border: 1rpx solid #39c248;
  275. background-color: transparent;
  276. border-radius: 10rpx;
  277. line-height: 90rpx;
  278. }
  279. button + button {
  280. margin-left: 0;
  281. }
  282. }
  283. .close-button {
  284. position: absolute;
  285. bottom: -120rpx;
  286. left: 50%;
  287. transform: translateX(-50%);
  288. image {
  289. width: 70rpx;
  290. height: 70rpx;
  291. }
  292. }
  293. </style>