You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
7.4 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <template>
  2. <view class="coupon-list">
  3. <view v-for="(item,index) in couponData" style="padding:20rpx;" :key="index">
  4. <view>
  5. <view class="card">
  6. <view class="card-left">
  7. <view class="">
  8. {{switchType(item.stockType)}}
  9. </view>
  10. </view>
  11. <view class="card-center">
  12. <view class="card-center-top"></view>
  13. <view class="card-center-bottom"></view>
  14. </view>
  15. <view class="card-right">
  16. <view class="card-content">
  17. <view class="card-info">{{item.stockName}}</view>
  18. <view class="card-type">可用于
  19. <text class="card-type-text">专业喂养</text>
  20. <text class="card-type-text">专业遛狗</text>
  21. <!-- <text class="card-type-text">{{ item.goodsName }}</text> -->
  22. </view>
  23. <view class="card-time">有效期至: {{item.availableEndTime.slice(0, 16)}}</view>
  24. </view>
  25. <!-- <view style="width: 22%;">
  26. <u-button @click="receiveCoupon(item.id)" shape="circle" size="mini" color="#ffaa48" text="立即领取"></u-button>
  27. </view> -->
  28. <view style="width: 132rpx;height: 52rpx;background-color: #FFAA48; display: flex;align-items: center;justify-content: center;border-radius: 56rpx;">
  29. <text @click="receiveCoupon(item.id)" style="font-size: 24rpx; font-weight: 500; color: #FFFFFF;">立即领取</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="card-bottom">
  34. <view class="card-bottom-text">
  35. 优惠券不可兑换现金
  36. </view>
  37. <view class="card-bottom-text" @click="showRulePopup(item)">
  38. 查看详细规则>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 优惠券详细规则弹窗 -->
  44. <uni-popup ref="rulePopup" type="center">
  45. <view class="rule-popup">
  46. <view class="rule-popup-title">优惠券详细规则</view>
  47. <view class="rule-popup-content">
  48. <view class="rule-item">
  49. <view class="rule-label">名称</view>
  50. <view class="rule-value">{{currentCoupon.stockName}}</view>
  51. </view>
  52. <view class="rule-item">
  53. <view class="rule-label">折扣</view>
  54. <view class="rule-value">{{getDiscountText(currentCoupon)}}</view>
  55. </view>
  56. <view class="rule-item">
  57. <view class="rule-label">使用规则</view>
  58. <view class="rule-value">可用于专业喂养和专业遛狗服务</view>
  59. </view>
  60. <view class="rule-item">
  61. <view class="rule-label">有效日期</view>
  62. <view class="rule-value">{{currentCoupon.availableEndTime ? currentCoupon.availableEndTime.slice(0, 16) : ''}}</view>
  63. </view>
  64. <view class="rule-item">
  65. <view class="rule-label">特别说明</view>
  66. <view class="rule-value">单笔订单仅限使用1张优惠券优惠券仅限用户本人使用不可赠送不可提现不得找零</view>
  67. </view>
  68. </view>
  69. <view class="rule-popup-close" @click="closeRulePopup">关闭</view>
  70. </view>
  71. </uni-popup>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. getCouponList,
  77. receiveCoupon,
  78. } from "@/api/system/user"
  79. export default {
  80. data() {
  81. return {
  82. couponData: [],
  83. currentCoupon: {}, // 当前选中的优惠券
  84. }
  85. },
  86. onLoad() {
  87. // this.openIdStr = this.$globalData.openIdStr;
  88. this.getCouponListAuth()
  89. },
  90. methods: {
  91. getCouponListAuth() {
  92. getCouponList().then(res => {
  93. if (res.code == 200) {
  94. this.couponData = res.data
  95. console.log("this.couponData", this.couponData)
  96. } else {
  97. this.$modal.showToast('获取优惠券失败')
  98. }
  99. })
  100. },
  101. switchType(type) {
  102. if (type == 'PNORMAL') {
  103. return '满减券'
  104. }
  105. if (type == 'PDISCOUNT') {
  106. return '折扣券'
  107. }
  108. if (type == 'PTRAIL') {
  109. return '体验券'
  110. }
  111. return '优惠券'
  112. },
  113. receiveCoupon (id) {
  114. let data = {
  115. stockId: id
  116. }
  117. receiveCoupon(data).then(res => {
  118. console.log("this.receiveCoupon", res)
  119. if (res.code == 200) {
  120. this.$modal.showToast('优惠券领取成功')
  121. } else {
  122. this.$modal.showToast('领取优惠券失败')
  123. }
  124. })
  125. },
  126. // 显示优惠券规则弹窗
  127. showRulePopup(item) {
  128. this.currentCoupon = item || {};
  129. this.$refs.rulePopup.open();
  130. },
  131. // 关闭优惠券规则弹窗
  132. closeRulePopup() {
  133. this.$refs.rulePopup.close();
  134. },
  135. // 获取优惠券折扣文本
  136. getDiscountText(coupon) {
  137. if (!coupon || !coupon.stockType) return '';
  138. if (coupon.stockType === 'PNORMAL') {
  139. return '满100可减10元';
  140. } else if (coupon.stockType === 'PDISCOUNT') {
  141. return '打8折';
  142. } else if (coupon.stockType === 'PTRAIL') {
  143. return '免费体验一次';
  144. }
  145. return '';
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .coupon-list {
  152. /* 优惠券规则弹窗样式 */
  153. .rule-popup {
  154. width: 600rpx;
  155. background-color: #FFFFFF;
  156. border-radius: 16rpx;
  157. overflow: hidden;
  158. }
  159. .rule-popup-title {
  160. height: 100rpx;
  161. line-height: 100rpx;
  162. text-align: center;
  163. font-size: 32rpx;
  164. font-weight: 600;
  165. color: #FFFFFF;
  166. background-color: #FFAA48;
  167. }
  168. .rule-popup-content {
  169. padding: 30rpx;
  170. }
  171. .rule-item {
  172. display: flex;
  173. margin-bottom: 20rpx;
  174. }
  175. .rule-label {
  176. width: 140rpx;
  177. font-size: 28rpx;
  178. color: #666666;
  179. flex-shrink: 0;
  180. }
  181. .rule-value {
  182. flex: 1;
  183. font-size: 28rpx;
  184. color: #333333;
  185. line-height: 40rpx;
  186. }
  187. .rule-popup-close {
  188. height: 90rpx;
  189. line-height: 90rpx;
  190. text-align: center;
  191. font-size: 30rpx;
  192. color: #FFAA48;
  193. border-top: 1px solid #EEEEEE;
  194. }
  195. .card {
  196. display: flex;
  197. align-items: center;
  198. width: 100%;
  199. padding: 10px 0;
  200. background: #fff;
  201. border-radius: 8px 8px 0 0;
  202. }
  203. .card-bottom {
  204. display: flex;
  205. background-color: #FFF1E0;
  206. height: 50rpx;
  207. align-items: center;
  208. justify-content: space-between;
  209. padding: 0 20rpx 0 20rpx;
  210. border-radius: 0 0 8px 8px;
  211. .card-bottom-text {
  212. color: #AAAAAA;
  213. font-size: 24rpx;
  214. font-weight: 400;
  215. }
  216. }
  217. .card-left {
  218. width: 88px;
  219. text-align: center;
  220. color: #FF530A;
  221. font-size: 28rpx;
  222. font-weight: 900;
  223. }
  224. .card-center {
  225. display: flex;
  226. flex-direction: column;
  227. // align-items: center;
  228. .card-center-top {
  229. width: 40rpx;
  230. height: 20rpx;
  231. border-radius: 0 0 20rpx 20rpx;
  232. background-color: #F5F5F7;
  233. line-height: 20rpx;
  234. // border-bottom: 1px solid #FDA714;
  235. // border-left: 1px solid #FDA714;
  236. // border-right: 1px solid #FDA714;
  237. margin-top: -22rpx;
  238. margin-bottom: 20rpx;
  239. margin-left: -19rpx;
  240. }
  241. .card-center-bottom {
  242. border-right: 1px dashed #AAAAAA;
  243. width: 1px;
  244. height: 120rpx;
  245. }
  246. }
  247. .card-right {
  248. padding: 0px 12px;
  249. display: flex;
  250. flex: 1;
  251. /* flex-direction: column; */
  252. justify-content: space-between;
  253. align-items: center;
  254. height: 60px;
  255. .card-content {
  256. width: 77%;
  257. }
  258. .card-icon {
  259. position: relative;
  260. right: -10px;
  261. top: -10px;
  262. }
  263. }
  264. .card-info {
  265. margin: 0;
  266. font-size: 28rpx;
  267. line-height: 28rpx;
  268. color: #333333;
  269. font-weight: 500;
  270. }
  271. .card-type {
  272. font-size: 24rpx;
  273. font-weight: 400;
  274. line-height: 24rpx;
  275. font-weight: 400;
  276. color: #AAAAAA;
  277. margin-top: 10rpx;
  278. .card-type-text {
  279. color: #FFAA48;
  280. font-size: 24rpx;
  281. font-weight: 400;
  282. line-height: 24rpx;
  283. border: #FFAA48 1px solid;
  284. border-radius: 7rpx;
  285. margin-left: 8rpx;
  286. }
  287. }
  288. .card-time {
  289. font-size: 24rpx;
  290. font-weight: 400;
  291. line-height: 24rpx;
  292. font-weight: 400;
  293. color: #AAAAAA;
  294. margin-top: 10rpx;
  295. }
  296. }
  297. </style>