price-reduction-popup.vue 6.7 KB

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