price-reduction-popup.vue 7.2 KB

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