price-reduction-popup.vue 7.4 KB

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