GoodsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 pb-30" @scrolltolower="loadMore" scroll-y="true">
  15. <view class="div" v-if="goods_list">
  16. <view class="div main-content" v-if="goods_list.length">
  17. <view v-for="item in goods_list" :key="item.goods_commonid" class="div mt-5 inviter-item">
  18. <view class="div goods-info">
  19. <view class="div p-img" :style="'width:'+windowWidth+'px;height:'+windowWidth+'px'">
  20. <image mode="aspectFit" class="img" :src="item.goods_image"/>
  21. </view>
  22. <view class="div p-info">
  23. <view class="div name">{{item.goods_name}}</view>
  24. <view class="div price">¥{{item.goods_price}}</view>
  25. </view>
  26. </view>
  27. <view class="inviter-info">
  28. <view class="info-item">
  29. <view class="left">已分销</view>
  30. <view class="right">{{item.inviter_total_quantity}}件</view>
  31. </view>
  32. <view class="info-item">
  33. <view class="left">总金额</view>
  34. <view class="right">¥{{item.inviter_total_amount}}</view>
  35. </view>
  36. <view class="info-item">
  37. <view class="left">总佣金</view>
  38. <view class="right">{{item.inviter_amount}}</view>
  39. </view>
  40. </view>
  41. <view class="inviter-btn">
  42. <view class="common-btn" @click="onEdit(item.goods_commonid)">修改</view>
  43. </view>
  44. </view>
  45. </view>
  46. <empty-record v-else></empty-record>
  47. </view>
  48. </scroll-view>
  49. <view class='common-add-btn-wrapper'><view class="div common-btn common-add-btn" @click="goAdd">新增</view></view>
  50. </view>
  51. </view>
  52. </seller-base>
  53. </template>
  54. <script>
  55. import {getFontSize} from '@/util/common'
  56. import TitleHeader from '../../TitleHeader'
  57. import { urlencode } from '@/util/common'
  58. import SellerBase from '../SellerBase'
  59. import { getInviterGoodsList } from '../../../api/sellerInviter'
  60. import EmptyRecord from '../../EmptyRecord'
  61. import flexLine from '../../flexLine'
  62. export default {
  63. name: 'GoodsList',
  64. computed:{
  65. fontSize(){
  66. return getFontSize()
  67. },
  68. windowWidth: function () {
  69. const res = uni.getSystemInfoSync()
  70. var width=res.windowWidth
  71. var size=getFontSize()
  72. return (width-3*.6*size)/3
  73. },
  74. },
  75. data(){
  76. return {
  77. navHeight: 0,
  78. params: { 'page': 0, 'per_page': 10 },
  79. loading: false, // 是否加载更多
  80. isMore: true, // 是否有更多
  81. // 分销商品列表
  82. goods_list: false
  83. }
  84. },
  85. components:{
  86. TitleHeader,
  87. SellerBase,
  88. flexLine,
  89. EmptyRecord
  90. },
  91. onShow: function () {
  92. this.reload()
  93. },
  94. mounted(){
  95. // #ifdef MP-WEIXIN
  96. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  97. // #endif
  98. },
  99. methods:{
  100. goBack(){uni.navigateBack({delta:1})},
  101. goAdd () {
  102. uni.navigateTo({url:'/pages/seller/inviter/GoodsForm'+'?'+urlencode({ action: 'add' })})
  103. },
  104. onEdit (goods_commonid) {
  105. uni.navigateTo({url:'/pages/seller/inviter/GoodsForm'+'?'+urlencode({ goods_commonid: goods_commonid })})
  106. },
  107. loadMore () {
  108. this.loading = true
  109. this.params.page = ++this.params.page
  110. if (this.isMore) {
  111. this.loading = false
  112. this.getGoodsList(true)
  113. }
  114. },
  115. reload () {
  116. // 重新加载数据
  117. this.params.page = 0
  118. this.isMore = true
  119. this.goods_list = []
  120. this.loadMore()
  121. },
  122. getGoodsList () {
  123. getInviterGoodsList(this.params).then(res => {
  124. if (this.goods_list) {
  125. this.goods_list = this.goods_list.concat(res.result.goods_list)
  126. } else {
  127. this.goods_list = res.result.goods_list
  128. }
  129. if (res.result.hasmore) {
  130. this.isMore = true
  131. } else {
  132. this.isMore = false
  133. }
  134. }).catch(function (error) {
  135. uni.showToast({icon:'none',title: error.message})
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. .scroll-view-wrapper{display: flex;flex-direction: column;}
  143. .scroll-view{flex:1}
  144. .inviter-item{padding: 1rem $pageSpace .5rem;background-color: #fff;border-radius: .5rem;}
  145. .goods-info{display: flex;box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.06);}
  146. .goods-info .p-img{border-radius: .5rem;overflow: hidden;}
  147. .goods-info .p-info{margin-left:.4rem;width: 45%;}
  148. .goods-info .p-info .name{color: #333;font-size: .7rem; line-height: .8rem;height: 1.6rem;margin-top: .4rem;overflow: hidden;display: -webkit-box; -webkit-box-orient: vertical;-webkit-line-clamp: 2;padding: 0 .3rem;box-sizing: border-box;}
  149. .goods-info .p-info .price{color:red;line-height:1rem;font-size:0.7rem;padding-top: 1rem;}
  150. .inviter-info{padding: .5rem 0;}
  151. .inviter-info .info-item{border-bottom: 1px dashed #DBDADF;display: flex;padding: .5rem 0;color: #666;font-size: .8rem;}
  152. .inviter-info .info-item .right{margin-left: auto;}
  153. .inviter-btn {display: flex;justify-content: flex-end;}
  154. .inviter-btn .common-btn{border: 1px solid #333;border-radius: 1rem;padding: .2rem 1.3rem;}
  155. </style>