price-reduction-popup.vue 7.5 KB

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