price-reduction-popup.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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">¥ {{ currBookPrice }}</text>
  15. </view>
  16. <view class="price-row">
  17. <text class="price-label">助力成功减至</text>
  18. <text class="price-value increased">¥ {{ reducedPrice }}</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" data-share-type="reduce" class="hand-btn">
  40. <image class="invite-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" data-share-type="reduce" @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. name: 'PriceReductionPopup',
  64. components: {
  65. customPopup,
  66. },
  67. data() {
  68. return {
  69. showPopup: false,
  70. bookInfo: {},
  71. inviteUsers: [],
  72. };
  73. },
  74. computed: {
  75. reducedPrice() {
  76. const price = parseFloat(this.bookInfo.price || 0);
  77. const reduceMoney = parseFloat(this.bookInfo.reduceMoney || 0);
  78. const currReduceMoney = parseFloat(this.bookInfo.currReduceMoney || 0);
  79. return (price - reduceMoney - currReduceMoney).toFixed(2);
  80. },
  81. currBookPrice() {
  82. const price = parseFloat(this.bookInfo.price || 0);
  83. const currReduceMoney = parseFloat(this.bookInfo.currReduceMoney || 0);
  84. return (price - currReduceMoney).toFixed(2);
  85. }
  86. },
  87. methods: {
  88. open(data) {
  89. this.showPopup = true;
  90. this.getIsbnInfo(data);
  91. },
  92. //获取信息
  93. getIsbnInfo(data) {
  94. this.$u.api.clickReduceInviteAjax({
  95. isbn: data.isbn,
  96. conditionType: data.conditionType,
  97. }).then((res) => {
  98. if (res.code == 200) {
  99. this.bookInfo = res.data;
  100. let needInviteNum = res.data.canInvite;
  101. let inviteUsers = res.data.inviteUsers || [];
  102. let length = inviteUsers.length;
  103. for (let index = 0; index < needInviteNum - length; index++) {
  104. inviteUsers.push({
  105. nickName: "",
  106. imgPath: "",
  107. });
  108. }
  109. this.inviteUsers = inviteUsers;
  110. console.log(this.inviteUsers, 'inviteUsers');
  111. uni.setStorageSync("reduceCodeShare", res.data.reduceCode);
  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") no-repeat center center;
  154. background-size: 100% 100%;
  155. }
  156. .header {
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. padding: 20rpx 0 10rpx;
  161. padding-top: 160rpx;
  162. .title-text {
  163. font-size: 38rpx;
  164. font-weight: bold;
  165. color: #000;
  166. margin-bottom: 10rpx;
  167. }
  168. .subtitle-text {
  169. font-size: 32rpx;
  170. color: #000;
  171. }
  172. .hand-icon {
  173. width: 140rpx;
  174. height: 140rpx;
  175. position: relative;
  176. top: -30rpx;
  177. }
  178. }
  179. .price-section {
  180. background-color: #39c248;
  181. border-radius: 16rpx;
  182. padding: 20rpx 30rpx;
  183. margin: 20rpx 0;
  184. .price-row {
  185. display: flex;
  186. align-items: center;
  187. .price-label {
  188. color: #ffffff;
  189. font-size: 30rpx;
  190. }
  191. .price-value {
  192. color: #ffeb3b;
  193. font-size: 30rpx;
  194. font-weight: bold;
  195. margin-left: 10rpx;
  196. }
  197. .increased {
  198. font-size: 42rpx;
  199. }
  200. .up-icon {
  201. width: 30rpx;
  202. height: 30rpx;
  203. margin-left: 5rpx;
  204. }
  205. }
  206. .small-text {
  207. color: #ffffff;
  208. font-size: 22rpx;
  209. margin-top: 10rpx;
  210. }
  211. }
  212. .share-section {
  213. background-color: #e8f8e8;
  214. border-radius: 16rpx;
  215. padding: 30rpx;
  216. margin: 20rpx 0;
  217. .share-text {
  218. color: #39c248;
  219. font-size: 32rpx;
  220. text-align: center;
  221. margin-bottom: 30rpx;
  222. }
  223. .add-button {
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. gap: 10rpx;
  228. .hand-icon {
  229. width: 100rpx;
  230. height: 100rpx;
  231. border-radius: 50%;
  232. }
  233. .invite-icon {
  234. width: 100rpx;
  235. height: auto;
  236. border-radius: 0;
  237. }
  238. }
  239. .hand-btn {
  240. display: inline-block;
  241. width: 100rpx !important;
  242. height: 110rpx;
  243. background: transparent;
  244. flex: none;
  245. padding: 0;
  246. overflow: visible;
  247. &::after {
  248. display: none;
  249. }
  250. }
  251. .add-item {
  252. position: relative;
  253. border-radius: 50%;
  254. .add-text {
  255. position: absolute;
  256. bottom: 2rpx;
  257. left: 5rpx;
  258. font-size: 24rpx;
  259. background: #39c248;
  260. text-align: center;
  261. color: #fff;
  262. padding: 0 10rpx;
  263. border-radius: 20rpx;
  264. display: inline-block;
  265. width: 94rpx;
  266. }
  267. }
  268. }
  269. .action-buttons {
  270. margin-top: 30rpx;
  271. .share-button {
  272. height: 90rpx;
  273. background: linear-gradient(to bottom, #47d46c, #24ad3c) !important;
  274. margin-bottom: 24rpx;
  275. font-size: 32rpx;
  276. color: #ffffff;
  277. border-radius: 10rpx;
  278. line-height: 90rpx;
  279. }
  280. .scan-button {
  281. height: 90rpx;
  282. font-size: 32rpx;
  283. color: #39c248;
  284. border: 1rpx solid #39c248;
  285. background-color: transparent;
  286. border-radius: 10rpx;
  287. line-height: 90rpx;
  288. }
  289. button+button {
  290. margin-left: 0;
  291. }
  292. }
  293. .close-button {
  294. position: absolute;
  295. bottom: -120rpx;
  296. left: 50%;
  297. transform: translateX(-50%);
  298. image {
  299. width: 70rpx;
  300. height: 70rpx;
  301. }
  302. }
  303. </style>