GainCoupon.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="container">
  3. <view class="detail flex">
  4. <text>优惠详情</text>
  5. <view class="closeIcon" @click="close">
  6. <u-icon name="close" color="#999" size="20" />
  7. </view>
  8. </view>
  9. <view class="content">
  10. <view v-for="item in list" :key="item.id" class="itemList">
  11. <view class="title"> {{ item.title }}</view>
  12. <view class="text">{{ item.text }} </view>
  13. </view>
  14. </view>
  15. <view class="placeholder"></view>
  16. <view>
  17. <view style="padding: 20rpx">店铺优惠</view>
  18. <view class="coupon-box">
  19. <view class="coupon" v-for="(item, index) in coupons" :key="index">
  20. <view class="coupon-left">
  21. <text class="coupon-text">¥</text>
  22. <text class="coupon-price">5</text>
  23. </view>
  24. <view class="coupon-center">
  25. <view class="coupon-center-user">{{ item.name }}</view>
  26. <view class="coupon-center-type">{{ item.description }}</view>
  27. </view>
  28. <view class="coupon-right">
  29. <view class="claimable" v-show="true" @click="handlerGetCoupon(item, index)">可领取</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. acceptConpons
  39. } from "@/api/client/mine.js"
  40. export default {
  41. props: {
  42. coupons: {
  43. type: Array,
  44. default: [],
  45. },
  46. },
  47. data() {
  48. return {
  49. list: [{
  50. id: 0,
  51. title: '30天低价',
  52. text: '当前商品价格为30天低价,比平时低48%',
  53. },
  54. {
  55. id: 1,
  56. title: '店铺新客立减',
  57. text: '店铺新客购买该商品立减10元%',
  58. },
  59. {
  60. id: 2,
  61. title: '多件优惠',
  62. text: '该商品满2件享9.5折%',
  63. },
  64. ],
  65. };
  66. },
  67. methods: {
  68. close() {
  69. this.$emit('close', false);
  70. },
  71. // 点击领取优惠卷
  72. handlerGetCoupon(item, index) {
  73. console.log('@@@@item', item);
  74. acceptConpons(item.id).then(res => {
  75. console.log('@@@@res',res);
  76. if (res.code === 'OK') {
  77. uni.showToast({
  78. title:'领取成功',
  79. icon:'none'
  80. })
  81. this.close()
  82. }else{
  83. uni.showToast({
  84. title:res.message,
  85. icon:'none'
  86. })
  87. return
  88. }
  89. })
  90. },
  91. },
  92. };
  93. </script>
  94. <style lang="scss" scoped>
  95. .container {
  96. height: 900rpx;
  97. box-sizing: border-box;
  98. .flex {
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. }
  103. .detail {
  104. height: 100rpx;
  105. position: relative;
  106. border-bottom: 1rpx solid #f4f4f4;
  107. .closeIcon {
  108. position: absolute;
  109. top: 40rpx;
  110. right: 30rpx;
  111. }
  112. }
  113. .content {
  114. padding: 10rpx 20rpx;
  115. .itemList {
  116. margin: 20rpx 0;
  117. .title {
  118. font-size: 30rpx;
  119. color: #333;
  120. margin-bottom: 8rpx;
  121. }
  122. .text {
  123. font-size: 24rpx;
  124. color: #999;
  125. }
  126. }
  127. }
  128. .placeholder {
  129. height: 30rpx;
  130. background-color: #f4f4f4;
  131. margin: 0 20rpx;
  132. }
  133. .coupon-box {
  134. height: 400rpx;
  135. overflow-y: auto;
  136. }
  137. .coupon {
  138. height: 150rpx;
  139. margin: 10rpx 20rpx;
  140. background-color: #faeaea;
  141. border: 2rpx solid #eb8f8f;
  142. display: flex;
  143. align-items: center;
  144. .coupon-text {
  145. color: #e53f3f;
  146. font-size: 30rpx;
  147. }
  148. .coupon-left {
  149. flex: 1;
  150. text-align: center;
  151. .coupon-price {
  152. font-size: 60rpx;
  153. color: #ee1310;
  154. }
  155. }
  156. .coupon-center {
  157. flex: 4;
  158. color: #ee1310;
  159. .coupon-center-user {
  160. font-size: 30rpx;
  161. font-weight: 600;
  162. }
  163. .coupon-center-type {
  164. font-size: 28rpx;
  165. margin-top: 10rpx;
  166. }
  167. }
  168. .coupon-right {
  169. flex: 1.5;
  170. .claimable {
  171. width: 110rpx;
  172. height: 55rpx;
  173. background: #f39818;
  174. border-radius: 10rpx;
  175. color: #fff;
  176. font-size: 26rpx;
  177. line-height: 55rpx;
  178. text-align: center;
  179. }
  180. .claimable-content {
  181. width: 160rpx;
  182. height: 80rpx;
  183. background-color: #de2d23;
  184. font-size: 24rpx;
  185. color: #fff;
  186. border-radius: 10rpx;
  187. display: flex;
  188. flex-direction: column;
  189. justify-content: center;
  190. align-items: center;
  191. margin-right: 10rpx;
  192. }
  193. }
  194. }
  195. }
  196. // .coupon {
  197. // height: 300rpx;
  198. // display: flex;
  199. // font-size: 32rpx;
  200. // color: #f2110d;
  201. // border-radius: 10rpx;
  202. // margin-bottom: 25rpx;
  203. // padding: 20rpx 25rpx;
  204. // box-sizing: border-box;
  205. // background-color: #faeaea;
  206. // border: 2rpx solid #eb8b8b;
  207. // .coupon-left {
  208. // width: 10%;
  209. // height: 100%;
  210. // .coupon-left-price {
  211. // font-size: 65rpx;
  212. // }
  213. // }
  214. // .coupon-middle {
  215. // flex-direction: column;
  216. // justify-content: space-between;
  217. // align-items: flex-start;
  218. // width: 60%;
  219. // height: 100%;
  220. // .coupon-middle-user {
  221. // width: 100%;
  222. // font-size: 30rpx;
  223. // font-weight: 600;
  224. // }
  225. // .coupon-middle-type {
  226. // width: 100%;
  227. // font-size: 24rpx;
  228. // font-weight: 600;
  229. // opacity: 0.8;
  230. // }
  231. // }
  232. // .coupon-right {
  233. // flex-direction: column;
  234. // justify-content: space-between;
  235. // align-items: flex-start;
  236. // width: 25%;
  237. // height: 100%;
  238. // .coupon-right-time {
  239. // height: 100%;
  240. // flex-direction: column;
  241. // justify-content: space-between;
  242. // align-items: center;
  243. // .tip {
  244. // font-size: 30rpx;
  245. // font-weight: 600;
  246. // }
  247. // .time {
  248. // font-size: 24rpx;
  249. // font-weight: 600;
  250. // opacity: 0.8;
  251. // }
  252. // }
  253. // .coupon-right-get {
  254. // width: 80%;
  255. // background-color: #e8a87c;
  256. // height: 55rpx;
  257. // text-align: center;
  258. // line-height: 55rpx;
  259. // margin-top: 15rpx;
  260. // }
  261. // }
  262. // }
  263. </style>