123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
- <home-base :show="true"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div">
- <view class="div common-header-wrap">
- <view class="status-holder"></view>
- <view :style="'height:'+navHeight+'px'"></view>
- <view class="common-header-holder"></view>
- <view class="common-header-fixed">
- <title-header />
- <uni-nav-bar title="积分店铺代金券" class="common-header" left-icon="back" @clickLeft="goBack()">
- </uni-nav-bar>
- </view>
- </view>
- <view class="scroll-view div" style="position:relative">
- <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div list-wrap" @scrolltolower="loadMore" scroll-y="true">
- <index-voucher-item class="list-wrap-item" v-for="item in voucherList" :key="item.vouchertemplate_id" :item="item">
- </index-voucher-item>
- </scroll-view>
- <empty-record v-if="voucherList.length === 0"></empty-record>
- </view>
- </view></home-base>
- </template>
- <script>
- import {getFontSize} from '@/util/common'
- import TitleHeader from '../../TitleHeader'
- import HomeBase from '../HomeBase'
- import EmptyRecord from '../../EmptyRecord'
- import IndexVoucherItem from './IndexVoucherItem'
- import { getPointVoucherList } from '../../../api/homePointsgoods'
- export default {
- name: 'index',
- mounted(){
- // #ifdef MP-WEIXIN
- this.navHeight = uni.getMenuButtonBoundingClientRect().top
- // #endif
- },
- computed:{
- fontSize(){
- return getFontSize()
- },
- },
- data(){
- return {
- navHeight: 0,
- params: { 'page': 0, 'per_page': 10 },
- loading: false, // 是否加载更多
- isMore: true, // 是否有更多
- pageTotal: 1, // 总页数
- voucherList: [] // 商品列表
- }
- },
- components:{
- TitleHeader,
- HomeBase,
- EmptyRecord,
- IndexVoucherItem
- },
- created () {
- this.loadMore()
- },
- methods:{
- goBack(){uni.navigateBack({delta:1})},
- getPointVoucherList (ispush) {
- uni.showLoading({ title: '加载中' })
- let params = this.params
- getPointVoucherList(params).then(res => {
- uni.hideLoading()
- if (ispush) {
- this.voucherList = this.voucherList.concat(res.result.voucherlist)
- } else {
- this.voucherList = res.result.voucherlist
- }
- this.pageTotal = res.result.page_total
- if (res.result.hasmore) {
- this.isMore = true
- } else {
- this.isMore = false
- }
- })
- },
- loadMore () {
- this.loading = true
- this.params.page = ++this.params.page
- if (this.isMore && this.params.page <= this.pageTotal) {
- this.loading = false
- this.getPointVoucherList(true)
- }
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .scroll-view-wrapper{display: flex;flex-direction: column;}
- .scroll-view{flex:1}
- .list-wrap {padding:0 15px;box-sizing: border-box;}
- .list-wrap .list-wrap-item {display: inline-block;margin-top: 10px;width:50%;}
- .list-wrap .list-wrap-item:nth-child(2n+2) {text-align: right}
- </style>
|