CostList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="消费记录" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="scroll-view div" style="position:relative">
  14. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div mt-5" @scrolltolower="loadMore" scroll-y="true">
  15. <view class="div item mb-5" v-for="item in costList" :key="item.cost_id">
  16. <view class="div info">
  17. <view class="p content">{{item.storecost_remark}}<text class="em ml-5">({{storecost_state(item.storecost_state)}})</text></view>
  18. <view class="p time">{{ $moment.unix(item.storecost_time).format('YYYY-MM-DD h:mm:ss') }}</view>
  19. </view>
  20. <view class="div price">{{item.storecost_price}}</view>
  21. </view>
  22. </scroll-view>
  23. </view>
  24. </view>
  25. </seller-base>
  26. </template>
  27. <script>
  28. import {getFontSize} from '@/util/common'
  29. import TitleHeader from '../../TitleHeader'
  30. import SellerBase from '../SellerBase'
  31. import EmptyRecord from '../../EmptyRecord'
  32. import { getSellerCostList } from '../../../api/seller'
  33. export default {
  34. name: 'CostList',
  35. components:{
  36. TitleHeader,
  37. SellerBase,
  38. EmptyRecord
  39. },
  40. data(){
  41. return {
  42. navHeight: 0,
  43. params: { 'page': 0, 'per_page': 10 },
  44. loading: false, // 是否加载更多
  45. isMore: true, // 是否有更多
  46. costList: false // 记录列表
  47. }
  48. },
  49. computed:{
  50. fontSize(){
  51. return getFontSize()
  52. },
  53. storecost_state () {
  54. return function (state) {
  55. if (state === 0) {
  56. return '未结算'
  57. } else {
  58. return '已结算'
  59. }
  60. }
  61. }
  62. },
  63. created () {
  64. this.loadMore()
  65. },
  66. mounted(){
  67. // #ifdef MP-WEIXIN
  68. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  69. // #endif
  70. },
  71. methods:{
  72. goBack(){uni.navigateBack({delta:1})},
  73. getCostList (ispush) {
  74. uni.showLoading({ title: '加载中' })
  75. let params = this.params
  76. getSellerCostList(params).then(res => {
  77. uni.hideLoading()
  78. if (ispush && this.costList) {
  79. this.costList = this.costList.concat(res.result.cost_list)
  80. } else {
  81. this.costList = res.result.cost_list
  82. }
  83. if (res.result.hasmore) {
  84. this.isMore = true
  85. } else {
  86. this.isMore = false
  87. }
  88. }).catch(error=>{
  89. uni.hideLoading()
  90. uni.showToast({icon:'none',title: error.message})
  91. })
  92. },
  93. loadMore () {
  94. this.loading = true
  95. this.params.page = ++this.params.page
  96. if (this.isMore) {
  97. this.loading = false
  98. this.getCostList(true)
  99. }
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .scroll-view-wrapper{display: flex;flex-direction: column;}
  106. .scroll-view{flex:1}
  107. .item{padding:.5rem;background:#fff;height:3rem;}
  108. .item .info{float:left;width:80%;}
  109. .item .info .p{line-height:1.5rem;font-size:$subFontSize;}
  110. .item .info .content .em{}
  111. .item .price{float:left;width:20%;line-height:3rem;text-align:right;color:red;font-weight:bold;}
  112. </style>