couponList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="content">
  3. <view class="top-wrap">
  4. <image src="https://hy.liuniu946.com/app/img/yhq-mbg.png" mode="widthFix" style="width: 750rpx;"></image>
  5. <view class="my-yhq" @click="navTo('/user/page/myCoupon')">
  6. 我的卡券
  7. </view>
  8. </view>
  9. <scroll-view scroll-y="true" :style="{'height': height}" class="scroll-wrap">
  10. <!-- 空白页 -->
  11. <empty v-if="loaded === true && list.length === 0"></empty>
  12. <view class="kq-wrap flex" v-for="item in list" :class="{'qw':item == 9}">
  13. <!-- 普通背景 -->
  14. <image src="https://hy.liuniu946.com/app/img/kq-bg.png" mode="" class="kq-bg" v-if="item != 9"></image>
  15. <!-- 抢完背景 -->
  16. <image src="https://hy.liuniu946.com/app/img/kp-bg-1.png" mode="" class="kq-bg" v-if="item == 9"></image>
  17. <view class="kq-left flex">
  18. <view class="left-val">
  19. {{item.coupon_price}}
  20. </view>
  21. <view class="left-tit" v-if="item.use_min_price*1 > 0">
  22. 满{{item.use_min_price*1}}元使用
  23. </view>
  24. <view class="left-tit" v-else>
  25. 无门槛
  26. </view>
  27. </view>
  28. <view class="kp-center flex">
  29. <view class="center-tit clamp2">
  30. {{item.title}}
  31. </view>
  32. <view class="center-time">
  33. 有效期至2020-0-10 23:59
  34. </view>
  35. </view>
  36. <view class="kp-right flex">
  37. <!-- 在抢 -->
  38. <view class="right-loading flex" v-if="!item.used">
  39. <image src="../../static/icon/kp-loading.png" mode=""></image>
  40. <view class="loading-tit">
  41. 待领取
  42. </view>
  43. <!-- <view class="loading-val">
  44. 88%
  45. </view> -->
  46. </view>
  47. <!-- 已领取 -->
  48. <view class="right-more" v-if="item.used">
  49. <image src="../../static/icon/kp-nomore.png" mode=""></image>
  50. </view>
  51. <!-- 已抢完 -->
  52. <view class="right-nomore" v-if="item == 9">
  53. <image src="../../static/icon/kp-more.png" mode=""></image>
  54. </view>
  55. <view class="right-btn" @click="lq(item)">
  56. {{item.used ?'已领取':'立即领取'}}
  57. </view>
  58. </view>
  59. </view>
  60. <uni-load-more :status="loadingType" v-if="!(list.length == 0 && loaded)">
  61. </uni-load-more>
  62. </scroll-view>
  63. </view>
  64. </template>
  65. <script>
  66. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  67. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  68. import {
  69. getCouponList,
  70. setCoupons
  71. } from '@/api/functionalUnit.js';
  72. import {
  73. spread,
  74. orderData,
  75. userinfo
  76. } from '@/api/user.js';
  77. export default {
  78. data() {
  79. return {
  80. height: '',
  81. loadingType: 'more',
  82. list: [],
  83. loaded: false,
  84. iconColor: 'red',
  85. color: 'red',
  86. page: 1,
  87. limit: 10,
  88. }
  89. },
  90. components: {
  91. empty,
  92. uniLoadMore
  93. },
  94. onLoad() {
  95. let obj = this;
  96. userinfo({})
  97. .then(({
  98. data
  99. }) => {
  100. console.log(data, "123456")
  101. })
  102. this.getCouponList()
  103. },
  104. onShow() {
  105. },
  106. onReachBottom() {
  107. this.getCouponList()
  108. },
  109. onReady() {
  110. var obj = this;
  111. uni.getSystemInfo({
  112. success: resu => {
  113. const query = uni.createSelectorQuery();
  114. query.select('.scroll-wrap').boundingClientRect();
  115. query.exec(function(res) {
  116. obj.height = resu.windowHeight - res[0].top + 'px';
  117. });
  118. console.log(obj.height)
  119. },
  120. fail: res => {}
  121. });
  122. },
  123. methods: {
  124. navTo(url) {
  125. uni.navigateTo({
  126. url,
  127. fail() {
  128. uni.switchTab({
  129. url
  130. })
  131. }
  132. })
  133. },
  134. getCouponList() {
  135. let obj = this
  136. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  137. return
  138. }
  139. obj.loadingType = 'loading'
  140. getCouponList({
  141. page: obj.page,
  142. limit: obj.limit
  143. }).then(res => {
  144. console.log(res)
  145. obj.list = obj.list.concat(res.data)
  146. obj.page++
  147. if (obj.limit == res.data.length) {
  148. obj.loadingType = 'more'
  149. } else {
  150. obj.loadingType = 'noMore'
  151. }
  152. obj.loaded = true
  153. })
  154. },
  155. lq(item) {
  156. if (item.used) {
  157. return
  158. }
  159. setCoupons({
  160. couponId: item.id
  161. }).then(res => {
  162. console.log(res)
  163. uni.showToast({
  164. title: '领取成功',
  165. duration: 2000
  166. });
  167. // let s = this.list.indexOf(item);
  168. // this.list;
  169. item.used = 1
  170. })
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss">
  176. page {
  177. background: #ff4802;
  178. height: auto;
  179. min-height: 100%;
  180. }
  181. .top-wrap {
  182. width: 750rpx;
  183. height: 574rpx;
  184. position: relative;
  185. image {
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. }
  190. .my-yhq {
  191. width: 174rpx;
  192. line-height: 54rpx;
  193. background: #F4DE01;
  194. border-radius: 27rpx 0px 0px 27rpx;
  195. position: absolute;
  196. top: 43rpx;
  197. right: 0;
  198. font-size: 28rpx;
  199. font-weight: bold;
  200. color: #FF4701;
  201. text-align: center;
  202. }
  203. }
  204. .kq-wrap {
  205. width: 663rpx;
  206. height: 176rpx;
  207. margin: 0 auto 20rpx;
  208. position: relative;
  209. // padding: 20rpx;
  210. .kq-bg {
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. width: 663rpx;
  215. height: 176rpx;
  216. }
  217. .kq-left {
  218. width: 180rpx;
  219. height: 176rpx;
  220. position: relative;
  221. // background-color: #bfa;
  222. flex-direction: column;
  223. justify-content: center;
  224. flex-shrink: 0;
  225. color: #FEB100;
  226. .left-val {
  227. font-size: 60rpx;
  228. font-weight: bold;
  229. &::before {
  230. content: '¥';
  231. font-size: 38rpx;
  232. font-weight: bold;
  233. }
  234. }
  235. .left-tit {
  236. font-size: 24rpx;
  237. font-weight: 500;
  238. }
  239. }
  240. .kp-center {
  241. position: relative;
  242. flex-direction: column;
  243. height: 176rpx;
  244. padding: 35rpx 20rpx 35rpx 0;
  245. justify-content: space-between;
  246. align-items: flex-start;
  247. flex-grow: 1;
  248. .center-tit {
  249. font-size: 30rpx;
  250. font-weight: 500;
  251. color: #333333;
  252. }
  253. .center-time {
  254. font-size: 22rpx;
  255. font-weight: 500;
  256. color: #666666;
  257. }
  258. }
  259. .kp-right {
  260. width: 155rpx;
  261. height: 176rpx;
  262. position: relative;
  263. flex-direction: column;
  264. justify-content: center;
  265. flex-shrink: 0;
  266. .right-loading {
  267. width: 105rpx;
  268. height: 105rpx;
  269. position: relative;
  270. flex-direction: column;
  271. justify-content: center;
  272. align-items: center;
  273. image {
  274. width: 105rpx;
  275. height: 105rpx;
  276. position: absolute;
  277. top: 0;
  278. left: 0;
  279. }
  280. .loading-tit {
  281. font-size: 22rpx;
  282. font-weight: 400;
  283. color: #FFFFFF;
  284. }
  285. .loading-val {
  286. font-size: 28rpx;
  287. font-weight: 400;
  288. color: #FFFFFF;
  289. }
  290. }
  291. .right-more,
  292. .right-nomore {
  293. width: 116rpx;
  294. height: 87rpx;
  295. image {
  296. width: 116rpx;
  297. height: 87rpx;
  298. }
  299. }
  300. .right-btn {
  301. width: 122rpx;
  302. height: 31rpx;
  303. background: #FFFFFF;
  304. border-radius: 15rpx;
  305. font-size: 20rpx;
  306. font-weight: 400;
  307. color: #E27A01;
  308. line-height: 31rpx;
  309. text-align: center;
  310. margin-top: 10rpx;
  311. }
  312. }
  313. }
  314. // 抢完样式
  315. .qw {
  316. .kq-left {
  317. color: #CDCBCE;
  318. }
  319. .kp-center {
  320. .center-time {
  321. color: #CDCBCE;
  322. }
  323. .center-tit {
  324. color: #CDCBCE;
  325. }
  326. }
  327. .kp-right {
  328. .right-btn {
  329. background: #B5B5B5;
  330. color: #fff;
  331. }
  332. }
  333. }
  334. .scroll-wrap {
  335. padding-bottom: 20rpx;
  336. width: 663rpx;
  337. margin: auto;
  338. }
  339. </style>