price-reduction-popup.vue 7.1 KB

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