couponList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="main">
  3. <view class="body-Discount margin-top-sm">
  4. <view class="collar">
  5. <!-- <view class="title-Discount">
  6. 领券
  7. </view> -->
  8. <view class="couponList">
  9. <view class="couponItem" v-for="(item,index) in list" :key="index">
  10. <view class="couponItem-subject">
  11. <view class="couponItem-subject-left">
  12. <view class="couponItem-subject-price">
  13. <text class="couponItem-subject-icon">{{item.type==1?'¥':''}}</text>
  14. <text class="couponItem-subject-price-min">{{item.type==1?item.money/100:item.discount.substring(0,item.discount.indexOf(".")+2)}}</text>
  15. <view class="couponItem-subject-price-reduce">{{item.name}}</view>
  16. </view>
  17. </view>
  18. <view class="couponItem-subject-right">
  19. <view class="couponItem-subject-right-header">
  20. <span class="couponItem-subject-right-header-icon">{{item.type==1?'满减':'折扣'}}</span>
  21. {{item.title}}
  22. </view>
  23. <button :data-index="index" @click="collectCoupons(item,index)" v-if="item.is_receive==0" class="couponItem-subject-right-btn">领取</button>
  24. <button v-else class="iscouponItem-subject-right-btn">已领取</button>
  25. <view class="closing-date" v-if="item.expire_type == 2">
  26. {{item.start_time}} - {{item.end_time}}
  27. </view>
  28. <view class="" v-else>
  29. 有效期:{{item.effective_days}}天
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <u-empty text="暂无数据" :show="show" mode="order" margin-top="250"></u-empty>
  38. <view class="cu-tabbar-height"></view>
  39. <view class="cu-tabbar-height"></view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. list: [],
  47. pageindex: 1,
  48. show: false
  49. }
  50. },
  51. methods: {
  52. getcoupon: async function() {
  53. let res = await this.$request.post("/api/v1/coupon/couponList", {
  54. page: this.pageindex
  55. })
  56. console.log(res)
  57. if (res.status == 0) {
  58. if (this.pageindex > res.data.last_page) {
  59. uni.showToast({
  60. title: "没有更多了",
  61. icon: "none"
  62. })
  63. } else {
  64. this.list = this.list.concat(res.data.data)
  65. this.list.forEach(item => {
  66. item.start_time = this.$util.formatDate(item.start_time)
  67. item.end_time = this.$util.formatDate(item.end_time)
  68. })
  69. this.pageindex++
  70. }
  71. }
  72. if (this.list.length == 0) {
  73. this.show = true
  74. } else {
  75. this.show = false
  76. }
  77. },
  78. collectCoupons: async function(item, index) {
  79. let res = await this.$request.post("/api/v1/coupon/receiveCoupon", {
  80. coupon_id: item.id
  81. })
  82. console.log(res)
  83. if (res.status == 0) {
  84. uni.showToast({
  85. title: "领取成功"
  86. })
  87. this.list[index].is_receive = 1
  88. this.$forceUpdate()
  89. }
  90. }
  91. },
  92. onLoad() {
  93. },
  94. onShow() {
  95. this.getcoupon()
  96. }
  97. }
  98. </script>
  99. <style>
  100. /* 优惠券样式 */
  101. .discount {
  102. position: relative;
  103. display: inline-block;
  104. margin-right: 5px;
  105. margin-left: 15px;
  106. padding: 0 9px 0 12px;
  107. border-top: 1px solid rgb(11, 115, 186);
  108. border-bottom: 1px solid rgb(11, 115, 186);
  109. height: 16px;
  110. line-height: 16px;
  111. color: rgb(11, 115, 186);
  112. font-size: 10px;
  113. }
  114. .discount::before {
  115. content: "";
  116. left: 0;
  117. width: 7px;
  118. position: absolute;
  119. top: -1px;
  120. height: 18px;
  121. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAkCAMAAACpD3pbAAAAPFBMVEUAAAD////kOTzqaGr+9vb4zc32vL3sdXfnTE/mRUfxmpz87O3yn6HqZ2npXWDlQEP97e33xsf3xsbxl5nHV2NIAAAAAXRSTlMAQObYZgAAAJpJREFUOMvllEsSwiAQRMnjF8g/3v+uKhIrjhHK0l16B4+C7hlALS07qSyS2kVlKnHmCpqdNvwYwTdY6yKGX7AeKtb+jmN3jLuYMMEd5XYBUMZ6cO/BHHhr7ut6wizxHOhvM+kUT5S5I77ZsGWU1kbsExsmiSdMBVc3l9a0tJaDdR+CVcryWtRBFLXYkku1oae955Xnv5Y+j/UKs1MGwyraxf4AAAAASUVORK5CYII=);
  122. background-size: 15px 18px;
  123. background-repeat: no-repeat;
  124. }
  125. .discount::after {
  126. right: 0;
  127. width: 4px;
  128. background-position: -11px 0;
  129. content: "";
  130. position: absolute;
  131. top: -1px;
  132. height: 18px;
  133. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAkCAMAAACpD3pbAAAAPFBMVEUAAAD////kOTzqaGr+9vb4zc32vL3sdXfnTE/mRUfxmpz87O3yn6HqZ2npXWDlQEP97e33xsf3xsbxl5nHV2NIAAAAAXRSTlMAQObYZgAAAJpJREFUOMvllEsSwiAQRMnjF8g/3v+uKhIrjhHK0l16B4+C7hlALS07qSyS2kVlKnHmCpqdNvwYwTdY6yKGX7AeKtb+jmN3jLuYMMEd5XYBUMZ6cO/BHHhr7ut6wizxHOhvM+kUT5S5I77ZsGWU1kbsExsmiSdMBVc3l9a0tJaDdR+CVcryWtRBFLXYkku1oae955Xnv5Y+j/UKs1MGwyraxf4AAAAASUVORK5CYII=);
  134. background-size: 15px 18px;
  135. background-repeat: no-repeat;
  136. }
  137. /* 优惠头部 */
  138. .header-Discount {
  139. position: relative;
  140. height: 46px;
  141. line-height: 46px;
  142. padding-left: 10px;
  143. font-size: 15px;
  144. color: #333;
  145. text-align: center;
  146. font-weight: 700;
  147. }
  148. .body-Discount {
  149. padding: 0 18px;
  150. font-size: 13px;
  151. color: #333;
  152. margin-bottom: 50px;
  153. }
  154. .body-Discount>.collar {
  155. position: relative;
  156. padding-bottom: 9px;
  157. }
  158. .body-Discount>.collar>.title-Discount {
  159. height: 40px;
  160. line-height: 40px;
  161. color: #262626;
  162. font-weight: 700;
  163. }
  164. .body-Discount>.collar .couponList>.couponItem {
  165. color: rgb(11, 115, 186);
  166. margin-bottom: 18px;
  167. padding: 12px 10px;
  168. border-top: 6px solid currentColor;
  169. box-shadow: 0 0 6px 0 rgba(0, 0, 0, .1);
  170. border-radius: 6px;
  171. }
  172. .body-Discount>.collar .couponList>.couponItem>.couponItem-subject {
  173. display: flex;
  174. min-height: 58px;
  175. color: rgb(11, 115, 186);
  176. }
  177. .body-Discount>.collar .couponList>.couponItem>.couponItem-subject>.couponItem-subject-left {
  178. width: 220rpx;
  179. margin-right: 10px;
  180. line-height: 1;
  181. text-align: center;
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: center;
  185. overflow: hidden;
  186. }
  187. .couponItem-subject-price {
  188. overflow: hidden;
  189. text-overflow: ellipsis;
  190. white-space: nowrap;
  191. line-height: 1;
  192. text-align: center;
  193. }
  194. .couponItem-subject-icon {
  195. font-size: 14px;
  196. display: inline-block;
  197. vertical-align: bottom;
  198. margin: 0 4px 3px 0;
  199. }
  200. .couponItem-subject-price-min {
  201. position: relative;
  202. top: 1px;
  203. font-size: 36px;
  204. letter-spacing: 0;
  205. }
  206. .couponItem-subject-price-reduce {
  207. font-size: 14px;
  208. margin-top: 5px;
  209. }
  210. .couponItem-subject-right {
  211. flex: 1;
  212. position: relative;
  213. }
  214. .couponItem-subject-right-header {
  215. height: 36px;
  216. line-height: 18px;
  217. overflow: hidden;
  218. text-overflow: ellipsis;
  219. display: -webkit-box;
  220. -webkit-line-clamp: 1;
  221. -webkit-box-orient: vertical;
  222. font-size: 12px;
  223. color: #666;
  224. }
  225. .couponItem-subject-right-header-icon {
  226. background-color: rgb(11, 115, 186);
  227. color: #fff;
  228. font-size: 12px;
  229. display: inline-block;
  230. padding: 0 6px 0 12px;
  231. height: 14px;
  232. margin-right: 4px;
  233. line-height: 14px;
  234. position: relative;
  235. border-radius: 0 3px 3px 0;
  236. }
  237. .couponItem-subject-right-header-icon::before {
  238. position: absolute;
  239. z-index: 1;
  240. content: "";
  241. width: 0;
  242. top: 0;
  243. left: -7px;
  244. height: 0;
  245. border-top: 7px solid #fff;
  246. border-right: 7px solid transparent;
  247. border-bottom: 7px solid #fff;
  248. border-left: 7px solid #fff;
  249. }
  250. .couponItem-subject-right-header-icon::after {
  251. content: ".";
  252. position: absolute;
  253. color: #fff;
  254. left: 5px;
  255. top: -6px;
  256. font-size: 20px;
  257. }
  258. .couponItem-subject-right-btn {
  259. background-color: rgb(11, 115, 186);
  260. color: #fff;
  261. font-size: 12px;
  262. position: absolute;
  263. right: 0;
  264. bottom: 0;
  265. width: 68px;
  266. height: 20px;
  267. line-height: 20px;
  268. text-align: center;
  269. border-radius: 10px;
  270. box-sizing: border-box;
  271. z-index: 2;
  272. }
  273. .iscouponItem-subject-right-btn {
  274. background-color: #dcdcdc;
  275. color: #fff;
  276. font-size: 12px;
  277. position: absolute;
  278. right: 0;
  279. bottom: 0;
  280. width: 68px;
  281. height: 20px;
  282. line-height: 20px;
  283. text-align: center;
  284. border-radius: 10px;
  285. box-sizing: border-box;
  286. z-index: 2;
  287. }
  288. .desc-style {
  289. padding: 5px 18px 10px 18px;
  290. line-height: 1.3;
  291. position: relative;
  292. font-size: 12px;
  293. max-height: 46px;
  294. overflow: hidden;
  295. color: #666;
  296. background-color: white;
  297. }
  298. .closing-date {
  299. /* padding-right: 68px; */
  300. position: absolute;
  301. left: -18rpx;
  302. bottom: 0;
  303. box-sizing: border-box;
  304. width: 100%;
  305. line-height: 20px;
  306. font-size: 10px;
  307. color: #8c8c8c;
  308. }
  309. </style>