ChainList.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 pb-30" style="position:relative">
  14. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  15. <view class="div chain" v-if="chain_list && chain_list.length">
  16. <view class="div" v-for="item in chain_list" :key="item.chain_id" @click="onEdit(item.chain_id)">
  17. <flex-line :is-link="true" :show-border="true"><text class="span line-name">{{item.chain_addressname}}</text></flex-line>
  18. </view>
  19. </view>
  20. <empty-record v-else-if="chain_list && !chain_list.length"></empty-record>
  21. </scroll-view>
  22. <view class='common-add-btn-wrapper'><view class="div common-btn common-add-btn" @click="goAdd">新增</view></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 { urlencode } from '@/util/common'
  31. import SellerBase from '../SellerBase'
  32. import EmptyRecord from '../../EmptyRecord'
  33. import { getChainList } from '../../../api/sellerChain'
  34. import flexLine from '../../flexLine'
  35. export default {
  36. name: 'Chain',
  37. components:{
  38. TitleHeader,
  39. SellerBase,
  40. EmptyRecord,
  41. flexLine
  42. },
  43. computed:{
  44. fontSize(){
  45. return getFontSize()
  46. },
  47. },
  48. data(){
  49. return {
  50. navHeight: 0,
  51. // 配送员列表
  52. chain_list: false,
  53. params: { 'page': 0, 'per_page': 10 },
  54. loading: false, // 是否加载更多
  55. isMore: true // 是否有更多
  56. }
  57. },
  58. onShow: function () {
  59. this.reload()
  60. },
  61. mounted(){
  62. // #ifdef MP-WEIXIN
  63. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  64. // #endif
  65. },
  66. methods:{
  67. goBack(){uni.navigateBack({delta:1})},
  68. goAdd () {
  69. uni.navigateTo({url:'/pages/seller/chain/ChainForm'+'?'+urlencode({ action: 'add' })})
  70. },
  71. onEdit (chain_id) {
  72. uni.navigateTo({url:'/pages/seller/chain/ChainForm'+'?'+urlencode({ chain_id: chain_id })})
  73. },
  74. getChainList (ispush) {
  75. uni.showLoading({ title: '加载中' })
  76. getChainList({}, this.params).then(res => {
  77. if (ispush && this.chain_list) {
  78. this.chain_list = this.chain_list.concat(res.result.chain_list)
  79. } else {
  80. this.chain_list = res.result.chain_list
  81. }
  82. if (res.result.hasmore) {
  83. this.isMore = true
  84. } else {
  85. this.isMore = false
  86. }
  87. this.loading = false
  88. uni.hideLoading()
  89. }).catch(function (error) {
  90. this.loading = false
  91. uni.showToast({icon:'none',title: error.message})
  92. uni.hideLoading()
  93. })
  94. },
  95. loadMore () {
  96. if (this.loading) {
  97. return
  98. }
  99. this.loading = true
  100. this.params.page = ++this.params.page
  101. if (this.isMore) {
  102. this.getChainList(true)
  103. }
  104. },
  105. reload () {
  106. // 重新加载数据
  107. this.params.page = 0
  108. this.isMore = true
  109. this.loading = false
  110. this.chain_list = []
  111. this.loadMore()
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .common-header{
  118. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  119. }
  120. .scroll-view-wrapper{display: flex;flex-direction: column;}
  121. .scroll-view{flex:1}
  122. .chain{background: #fff;padding: 0 $pageSpace}
  123. .chain .li{line-height:1rem;padding:.5rem 1rem;background:#fff;font-size:$subFontSize}
  124. .chain .i{float:right}
  125. </style>