marketRankList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  4. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  5. @refresherrestore="onRestore">
  6. <view class="filter-date-box">
  7. <u-icon name="arrow-left" color="#999999" size="48" @click="previousMonth()"></u-icon>
  8. <text class="filter-date">{{year}}年{{month}}月</text>
  9. <u-icon name="arrow-right" color="#999999" size="48" @click="nextMonth()"></u-icon>
  10. </view>
  11. <view class="rank-box">当月销售额:¥{{saleCount}}</view>
  12. <u-card :show-head="false" :show-foot="false" :border="false" padding="0px" margin="0px" borderRadius="0" v-for="(item, index) in tableList"
  13. :key="index" class="card-box">
  14. <view class="card-content" slot="body">
  15. <view class="info-sort">
  16. <u-image :src="index == 0 ? iconPath1 : (index == 1 ? iconPath2 : iconPath3)" mode="aspectFit" width="24px"
  17. height="24px" v-if="index < 3"></u-image>
  18. <text v-else>{{index + 1}}</text>
  19. </view>
  20. <view class="info-img">
  21. <u-avatar :src="item.url" size="80"></u-avatar>
  22. </view>
  23. <view class="info-text">{{item.name}}</view>
  24. <view class="info-money">¥{{item.amount}}</view>
  25. </view>
  26. </u-card>
  27. <u-divider v-if="isOver" bg-color="transparent" style="padding-top: 10px;">没有更多了</u-divider>
  28. </scroll-view>
  29. <u-top-tips ref="uTips"></u-top-tips>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. mapGetters
  35. } from 'vuex'
  36. const NET = require('@/utils/request')
  37. const API = require('@/config/api')
  38. export default {
  39. computed: {
  40. ...mapGetters([
  41. 'mainColor'
  42. ])
  43. },
  44. data() {
  45. return {
  46. iconPath1: API.getServerImg + 'jinpai.png',
  47. iconPath2: API.getServerImg + 'yinpai.png',
  48. iconPath3: API.getServerImg + 'tongpai.png',
  49. year: '',
  50. month: '',
  51. saleCount: '',
  52. triggered: false,
  53. isOver: false,
  54. pageIndex: 1,
  55. tableList: [],
  56. }
  57. },
  58. onLoad() {
  59. this.year = new Date().getFullYear()
  60. this.month = new Date().getMonth() + 1
  61. this.getTableList()
  62. },
  63. onReady() {},
  64. methods: {
  65. // 上一个月
  66. previousMonth() {
  67. if (this.month == 1) {
  68. this.year--
  69. this.month = 12
  70. } else {
  71. this.month--
  72. }
  73. this.onRefresh()
  74. },
  75. // 下一个月
  76. nextMonth() {
  77. if (this.month == 12) {
  78. this.year++
  79. this.month = 1
  80. } else {
  81. this.month++
  82. }
  83. this.onRefresh()
  84. },
  85. // 下拉刷新
  86. onRefresh() {
  87. this.triggered = true
  88. this.isOver = false
  89. this.pageIndex = 1
  90. this.tableList = []
  91. this.getTableList()
  92. },
  93. // 重置下拉刷新状态
  94. onRestore() {
  95. this.triggered = 'restore'
  96. this.triggered = false
  97. },
  98. // 懒加载
  99. handleLoadMore() {
  100. if (!this.isOver) {
  101. this.pageIndex++
  102. this.getTableList()
  103. }
  104. },
  105. // 获取列表数据
  106. getTableList() {
  107. NET.request(API.getSaleSortList, {
  108. date: this.year + '-' + this.month,
  109. page: this.pageIndex,
  110. size: 10,
  111. }, 'POST').then(res => {
  112. this.triggered = false
  113. this.tableList = this.tableList.concat(res.data.row)
  114. this.isOver = res.data.row.length != 10
  115. }).catch(error => {
  116. this.triggered = false
  117. this.$refs.uTips.show({
  118. title: error.message,
  119. type: 'warning',
  120. })
  121. })
  122. NET.request(API.getSaleSortInfo, {
  123. date: this.year + '-' + this.month
  124. }, 'POST').then(res => {
  125. this.saleCount = res.data.amount
  126. }).catch(error => {
  127. this.$refs.uTips.show({
  128. title: error.message,
  129. type: 'warning',
  130. })
  131. })
  132. }
  133. },
  134. }
  135. </script>
  136. <style>
  137. page {
  138. width: 100%;
  139. height: 100%;
  140. background-color: #f7f7f7;
  141. }
  142. </style>
  143. <style lang="scss" scoped>
  144. @import "@/static/css/themes.scss";
  145. .content {
  146. width: 100%;
  147. float: left;
  148. .filter-date-box {
  149. height: 48px;
  150. display: flex;
  151. justify-content: space-between;
  152. align-items: center;
  153. padding: 10px 15px 0 15px;
  154. background-color: #ffffff;
  155. .filter-date {
  156. text-align: center;
  157. font-size: 16px;
  158. font-weight: bold;
  159. line-height: 28px;
  160. flex: 1;
  161. }
  162. }
  163. .rank-box {
  164. padding: 0 15px;
  165. color: $mainColor;
  166. text-align: center;
  167. line-height: 28px;
  168. background-color: #ffffff;
  169. }
  170. .scroll-box {
  171. width: 100%;
  172. height: 100vh;
  173. .card-box {
  174. .card-content {
  175. padding: 5px 15px;
  176. display: flex;
  177. align-items: center;
  178. .info-sort {
  179. width: 34px;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. }
  184. .info-img {
  185. width: 50px;
  186. height: 50px;
  187. margin-right: 5px;
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. }
  192. .info-text {
  193. line-height: 20px;
  194. font-size: 12px;
  195. color: $mainColor;
  196. flex: 1;
  197. }
  198. .info-money {
  199. line-height: 20px;
  200. font-size: 12px;
  201. color: $mainColor;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. </style>