price-reduction-popup.vue 7.0 KB

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