mycard.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.orderList.length === 0"></empty>
  11. <view class="ka_box" v-for="(item, index) in tabItem.orderList" :key="index">
  12. <view class="ka_bg">
  13. <image class="ka_bg_img" src="https://tmp01.kktv6.com/img/ka1.png" v-if="item.status == 0 && item._msg !== '已失效'"></image>
  14. <image class="ka_bg_img" src="https://tmp01.kktv6.com/img/ka3.png" v-if="item.status !== 0 || item._msg == '已失效'"></image>
  15. </view>
  16. <view class="ka_item">
  17. <view class="ka_price" :class="{ 'ka_guoqi': item.status !== 0 || item._msg == '已失效' }">{{ item.coupon_price | parseFloatNum }}</view>
  18. <view class="ka_right">
  19. <view class="ka_tit">订单满{{ item.use_min_price | parseFloatNum }}使用</view>
  20. <view class="ka_synopsis">{{ item.coupon_title }}</view>
  21. <view class="ka_synopsis" v-if="item.applicable_type == 0">通用券</view>
  22. <view class="ka_synopsis" v-if="item.applicable_type == 1">商品券</view>
  23. <view class="ka_state" v-if="item.status == 0 && item._msg !== '已失效'">有效期至:{{ item._end_time }}</view>
  24. <view class="ka_state" v-if="item.status == 1">已使用</view>
  25. <view class="ka_state" v-if="item._msg == '已失效'">已过期</view>
  26. </view>
  27. </view>
  28. </view>
  29. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  30. </scroll-view>
  31. </swiper-item>
  32. </swiper>
  33. </view>
  34. </template>
  35. <script>
  36. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  37. import empty from '@/components/empty';
  38. import { mapState } from 'vuex';
  39. import { getCouponsList } from '@/api/coupon.js';
  40. export default {
  41. filters: {
  42. // 去处小数点后的0
  43. parseFloatNum(clock) {
  44. return parseFloat(clock);
  45. }
  46. },
  47. components: {
  48. uniLoadMore,
  49. empty
  50. },
  51. data() {
  52. return {
  53. tabCurrentIndex: 0,
  54. state: '',
  55. showModal: false,
  56. navList: [
  57. {
  58. state: 0,
  59. text: '全部',
  60. loadingType: 'more',
  61. orderList: [],
  62. page: 1, //当前页数
  63. limit: 10 //每次信息条数
  64. },
  65. {
  66. state: 2,
  67. text: '已使用',
  68. loadingType: 'more',
  69. orderList: [],
  70. page: 1, //当前页数
  71. limit: 10 //每次信息条数
  72. },
  73. {
  74. state: 1,
  75. text: '未使用',
  76. loadingType: 'more',
  77. orderList: [],
  78. page: 1, //当前页数
  79. limit: 10 //每次信息条数
  80. },
  81. ]
  82. };
  83. },
  84. onLoad(options) {
  85. this.loadData();
  86. },
  87. computed: {
  88. ...mapState(['userInfo'])
  89. },
  90. methods: {
  91. //获取订单列表
  92. loadData(source) {
  93. let index = this.tabCurrentIndex;
  94. let navItem = this.navList[index];
  95. let state = navItem.state;
  96. if (navItem.loadingType === 'noMore') {
  97. //防止重复加载
  98. return;
  99. }
  100. // 修改当前对象状态为加载中
  101. navItem.loadingType = 'loading';
  102. getCouponsList({}, state ).then(({data}) => {
  103. navItem.orderList = data;
  104. navItem.loadingType = 'noMore';
  105. })
  106. },
  107. //swiper 切换
  108. changeTab(e) {
  109. this.tabCurrentIndex = e.target.current;
  110. this.loadData('tabChange');
  111. },
  112. //顶部tab点击
  113. tabClick(index) {
  114. this.tabCurrentIndex = index;
  115. },
  116. }
  117. };
  118. </script>
  119. <style lang="scss">
  120. page,
  121. .content {
  122. // background: $page-color-base;
  123. height: 100%;
  124. }
  125. .swiper-box {
  126. height: calc(100% - 40px);
  127. padding: 20rpx 30rpx;
  128. }
  129. .list-scroll-content {
  130. height: 100%;
  131. }
  132. .navbar {
  133. display: flex;
  134. height: 40px;
  135. padding: 0 5px;
  136. background: #fff;
  137. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  138. position: relative;
  139. z-index: 10;
  140. .nav-item {
  141. flex: 1;
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. height: 100%;
  146. font-size: 15px;
  147. color: $font-color-dark;
  148. position: relative;
  149. &.current {
  150. color: #FC4E6F ;
  151. &:after {
  152. content: '';
  153. position: absolute;
  154. left: 50%;
  155. bottom: 0;
  156. transform: translateX(-50%);
  157. width: 44px;
  158. height: 0;
  159. border-bottom: 2px solid #FC4E6F ;
  160. }
  161. }
  162. }
  163. }
  164. .ka_box {
  165. position: relative;
  166. height: 240rpx;
  167. margin-bottom: 20rpx;
  168. .ka_bg {
  169. width: 100%;
  170. height: 240rpx;
  171. .ka_bg_img {
  172. width: 100%;
  173. height: 240rpx;
  174. }
  175. }
  176. .ka_item {
  177. position: absolute;
  178. top: 0;
  179. width: 100%;
  180. height: 240rpx;
  181. display: flex;
  182. .ka_guoqi {
  183. text-shadow: 0px 10rpx 5rpx rgba(173, 173, 173, 0.3) !important;
  184. }
  185. .ka_price {
  186. width: 32%;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. height: 240rpx;
  191. font-size: 100rpx;
  192. font-family: SJcuyuan;
  193. font-weight: 400;
  194. color: #FFFFFF;
  195. text-shadow: 0px 10rpx 5rpx rgba(255, 125, 69, 0.3);
  196. &::before {
  197. content: '¥';
  198. font-size: 40rpx;
  199. margin-top: 60rpx;
  200. }
  201. }
  202. .ka_right {
  203. width: 68%;
  204. line-height: 1;
  205. padding: 48rpx 48rpx 0 0;
  206. text-align: right;
  207. .ka_tit {
  208. font-size: 40rpx;
  209. font-family: SJcuyuan;
  210. font-weight: 400;
  211. color: #FFFFFF;
  212. }
  213. .ka_synopsis {
  214. margin-top: 16rpx;
  215. font-size: 24rpx;
  216. font-family: SJcuyuan;
  217. font-weight: 400;
  218. color: #FFFFFF;
  219. }
  220. .ka_state {
  221. margin-top: 30rpx;
  222. font-size: 20rpx;
  223. font-family: SJcuyuan;
  224. font-weight: 400;
  225. color: #FFFFFF;
  226. }
  227. }
  228. }
  229. }
  230. .uni-swiper-item {
  231. height: auto;
  232. }
  233. /* load-more */
  234. .uni-load-more {
  235. display: flex;
  236. flex-direction: row;
  237. height: 80rpx;
  238. align-items: center;
  239. justify-content: center;
  240. }
  241. .uni-load-more__text {
  242. font-size: 28rpx;
  243. color: #999;
  244. }
  245. .uni-load-more__img {
  246. height: 24px;
  247. width: 24px;
  248. margin-right: 10px;
  249. }
  250. .uni-load-more__img > view {
  251. position: absolute;
  252. }
  253. .uni-load-more__img > view view {
  254. width: 6px;
  255. height: 2px;
  256. border-top-left-radius: 1px;
  257. border-bottom-left-radius: 1px;
  258. background: #999;
  259. position: absolute;
  260. opacity: 0.2;
  261. transform-origin: 50%;
  262. animation: load 1.56s ease infinite;
  263. }
  264. .uni-load-more__img > view view:nth-child(1) {
  265. transform: rotate(90deg);
  266. top: 2px;
  267. left: 9px;
  268. }
  269. .uni-load-more__img > view view:nth-child(2) {
  270. transform: rotate(180deg);
  271. top: 11px;
  272. right: 0;
  273. }
  274. .uni-load-more__img > view view:nth-child(3) {
  275. transform: rotate(270deg);
  276. bottom: 2px;
  277. left: 9px;
  278. }
  279. .uni-load-more__img > view view:nth-child(4) {
  280. top: 11px;
  281. left: 0;
  282. }
  283. .load1,
  284. .load2,
  285. .load3 {
  286. height: 24px;
  287. width: 24px;
  288. }
  289. .load2 {
  290. transform: rotate(30deg);
  291. }
  292. .load3 {
  293. transform: rotate(60deg);
  294. }
  295. .load1 view:nth-child(1) {
  296. animation-delay: 0s;
  297. }
  298. .load2 view:nth-child(1) {
  299. animation-delay: 0.13s;
  300. }
  301. .load3 view:nth-child(1) {
  302. animation-delay: 0.26s;
  303. }
  304. .load1 view:nth-child(2) {
  305. animation-delay: 0.39s;
  306. }
  307. .load2 view:nth-child(2) {
  308. animation-delay: 0.52s;
  309. }
  310. .load3 view:nth-child(2) {
  311. animation-delay: 0.65s;
  312. }
  313. .load1 view:nth-child(3) {
  314. animation-delay: 0.78s;
  315. }
  316. .load2 view:nth-child(3) {
  317. animation-delay: 0.91s;
  318. }
  319. .load3 view:nth-child(3) {
  320. animation-delay: 1.04s;
  321. }
  322. .load1 view:nth-child(4) {
  323. animation-delay: 1.17s;
  324. }
  325. .load2 view:nth-child(4) {
  326. animation-delay: 1.3s;
  327. }
  328. .load3 view:nth-child(4) {
  329. animation-delay: 1.43s;
  330. }
  331. @-webkit-keyframes load {
  332. 0% {
  333. opacity: 1;
  334. }
  335. 100% {
  336. opacity: 0.2;
  337. }
  338. }
  339. </style>