|
@@ -0,0 +1,309 @@
|
|
|
+<template>
|
|
|
+ <div class="container">
|
|
|
+ <div class="better-scroll wrapper" ref="wrapper">
|
|
|
+ <ul>
|
|
|
+ <li class="list" v-for="(item, index) in listData" :key="index">
|
|
|
+ <img class="icon" src="./image/able@2x.png" alt="" v-if="false">
|
|
|
+ <img class="icon" src="./image/disable@2x.png" alt="" v-else>
|
|
|
+ <p class="coupon-id">
|
|
|
+ <span>ID:</span>
|
|
|
+ <span>2319283927421</span>
|
|
|
+ </p>
|
|
|
+ </li>
|
|
|
+ <li class="load-status" v-if="listData.length && booFetchData">
|
|
|
+ <p>{{ arrFetchStatus[numFetchStatus] }}</p>
|
|
|
+ </li>
|
|
|
+ <li class="bitmap" v-if="!listData.length && booFetchData">
|
|
|
+ <img src="" alt="">
|
|
|
+ <p>暂无记录</p>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import BScroll from 'better-scroll'
|
|
|
+ import { Toast } from 'vant'
|
|
|
+ import { getOrderList } from '../home/api'
|
|
|
+
|
|
|
+ const PAGESIZE = 20
|
|
|
+ export default {
|
|
|
+ name: 'home',
|
|
|
+ props: {
|
|
|
+ tabindex: {
|
|
|
+ type: Number,
|
|
|
+ default: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ pager: {
|
|
|
+ pagenum: 1,
|
|
|
+ pagesize: PAGESIZE,
|
|
|
+ pagecount: 1
|
|
|
+ },
|
|
|
+ listData: [],
|
|
|
+ scroll: null,
|
|
|
+ numFetchStatus: 0,
|
|
|
+ arrFetchStatus: ['正在加载,请稍后~', '上拉加载更多', '没有更多了', '出错啦'],
|
|
|
+ booFetchData: false,
|
|
|
+ numPositionY: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ if (!this.$route.meta.isUseCache) {
|
|
|
+ this.pager = {
|
|
|
+ pagenum: 1,
|
|
|
+ pagesize: PAGESIZE,
|
|
|
+ pagecount: 1
|
|
|
+ }
|
|
|
+ this.listData = []
|
|
|
+ this.numFetchStatus = 0
|
|
|
+ this.booFetchData = false
|
|
|
+ this.numPositionY = 0
|
|
|
+ this.funFetch()
|
|
|
+ } else {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.scroll) {
|
|
|
+ this.scroll.refresh()
|
|
|
+ this.scroll.scrollTo(0, this.numPositionY)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$route.meta.isUseCache = false
|
|
|
+ },
|
|
|
+ async mounted () {
|
|
|
+ await this.$nextTick()
|
|
|
+ this.$refreshTitle('优惠券')
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ funFetch () {
|
|
|
+ const vm = this
|
|
|
+ getOrderList(vm.pager.pagenum, vm.pager.pagesize).then(response => {
|
|
|
+ if (response.status) {
|
|
|
+ const data = response.data
|
|
|
+ const temp = data.data
|
|
|
+ vm.pager.pagecount = Math.ceil(data.count / PAGESIZE)
|
|
|
+ vm.pager.pagenum++
|
|
|
+ vm.booFetchData = true
|
|
|
+ if (vm.pager.pagecount <= 1) {
|
|
|
+ vm.numFetchStatus = 2
|
|
|
+ } else {
|
|
|
+ vm.numFetchStatus = 1
|
|
|
+ }
|
|
|
+ if (temp.length) {
|
|
|
+ vm.listData = vm.listData.concat(temp)
|
|
|
+ vm.$nextTick(() => {
|
|
|
+ if (!vm.scroll) {
|
|
|
+ vm.scroll = new BScroll(vm.$refs.wrapper, {
|
|
|
+ click: true,
|
|
|
+ pullUpLoad: {
|
|
|
+ threshold: -20
|
|
|
+ },
|
|
|
+ scrollbar: true
|
|
|
+ })
|
|
|
+ vm.scroll.on('pullingUp', () => {
|
|
|
+ if (vm.pager.pagenum > vm.pager.pagecount) {
|
|
|
+ vm.numFetchStatus = 2
|
|
|
+ return
|
|
|
+ }
|
|
|
+ vm.funFetch()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ vm.scroll.refresh()
|
|
|
+ vm.scroll.finishPullUp()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Toast(response.msg)
|
|
|
+ vm.numFetchStatus = 3
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ Toast('出错啦')
|
|
|
+ vm.numFetchStatus = 3
|
|
|
+ })
|
|
|
+ },
|
|
|
+ funJumpDetail (item) {
|
|
|
+ this.$router.push({ path: '/loan/detail/' + item.id })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeDestroy () {
|
|
|
+ if (this.scroll) {
|
|
|
+ this.scroll.destroy()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeRouteLeave (to, from, next) {
|
|
|
+ if (['loanDetail'].includes(to.name)) {
|
|
|
+ from.meta.isUseCache = true
|
|
|
+ }
|
|
|
+ this.numPositionY = this.scroll ? this.scroll.y : 0
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .container {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .wrapper {
|
|
|
+ position: relative;
|
|
|
+ width: 100%;
|
|
|
+ height: 100vh;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ ul {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ width: 100%;
|
|
|
+ padding-bottom: 80px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .list {
|
|
|
+ position: relative;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ width: 329px;
|
|
|
+ height: 114px;
|
|
|
+ margin-top: 26px;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ &.bg-0 {
|
|
|
+ background: linear-gradient(270deg, #E2E2E2 0%, #C7C7C7 100%);
|
|
|
+ }
|
|
|
+
|
|
|
+ &.bg-1 {
|
|
|
+ background: linear-gradient(90deg, #44403B 0%, #93806B 100%);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
+ z-index: 1;
|
|
|
+ display: block;
|
|
|
+ width: 67px;
|
|
|
+ height: 73px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-id {
|
|
|
+ position: absolute;
|
|
|
+ left: 27px;
|
|
|
+ bottom: 11px;
|
|
|
+ z-index: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ span {
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #999;
|
|
|
+
|
|
|
+ &:nth-of-type(2) {
|
|
|
+ margin-left: 13px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .right-wrap {
|
|
|
+ margin-left: 18px;
|
|
|
+
|
|
|
+ p:nth-of-type(1) {
|
|
|
+ line-height: 25px;
|
|
|
+ font-size: 18px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ p:nth-of-type(2) {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end;
|
|
|
+
|
|
|
+ span:nth-of-type(1) {
|
|
|
+ padding-bottom: 5px;
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 15px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ span:nth-of-type(2) {
|
|
|
+ line-height: 33px;
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ span:nth-of-type(3) {
|
|
|
+ padding-bottom: 4px;
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 15px;
|
|
|
+ font-weight: bolder;
|
|
|
+ }
|
|
|
+
|
|
|
+ .col-0 {
|
|
|
+ color: #A7A7A7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .col-1 {
|
|
|
+ color: #D6BDA1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .fail {
|
|
|
+ position: absolute;
|
|
|
+ right: 14px;
|
|
|
+ top: 21px;
|
|
|
+ z-index: 1;
|
|
|
+ display: block;
|
|
|
+ width: 77px;
|
|
|
+ height: 49px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bottom {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ width: 297px;
|
|
|
+ padding: 11px 0 12px;
|
|
|
+
|
|
|
+ span {
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 15px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .load-status {
|
|
|
+ p {
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .bitmap {
|
|
|
+ img {
|
|
|
+ display: block;
|
|
|
+ width: 168px;
|
|
|
+ height: 168px;
|
|
|
+ margin-top: 81px;
|
|
|
+ }
|
|
|
+
|
|
|
+ p {
|
|
|
+ line-height: 22px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ text-align: center;
|
|
|
+ color: #333;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|