statisticsMore.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="销售统计"></u-navbar>
  5. <view class="content">
  6. <view class="goods-table">
  7. <view class="table">
  8. <view class="table-title flex justify-between align-center">
  9. <view class="title">
  10. 商品销售排行
  11. </view>
  12. <view class="sort-type flex">
  13. <view :class="[goodsSortType==0?'sort-type-item sort-type-show':'sort-type-item']"
  14. @click="goodsSort(0)">
  15. 销售额
  16. </view>
  17. <view :class="[goodsSortType==1?'sort-type-item sort-type-show':'sort-type-item']"
  18. @click="goodsSort(1)">
  19. 销量
  20. </view>
  21. </view>
  22. </view>
  23. <uni-table :border="false" :stripe="false" emptyText="暂无更多数据">
  24. <!-- 表头行 -->
  25. <uni-tr>
  26. <uni-th align="center" width="52">排名</uni-th>
  27. <uni-th align="center" width="110">上榜商品</uni-th>
  28. <uni-th align="center" width="92">销售额</uni-th>
  29. <uni-th align="center" width="92">销量</uni-th>
  30. </uni-tr>
  31. <!-- 表格数据行 -->
  32. <uni-tr v-for="(item,index) in list2" :key="item.goodsId">
  33. <uni-td v-if="index==0">
  34. <view class="table-td">
  35. <image class="table-img" src="../../static/images/global/first-class.png"
  36. mode="widthFix"></image>
  37. </view>
  38. </uni-td>
  39. <uni-td v-else-if="index==1">
  40. <view class="table-td">
  41. <image class="table-img" src="../../static/images/global/second-class.png"
  42. mode="widthFix"></image>
  43. </view>
  44. </uni-td>
  45. <uni-td v-else-if="index==2">
  46. <view class="table-td">
  47. <image class="table-img" src="../../static/images/global/third-class.png"
  48. mode="widthFix"></image>
  49. </view>
  50. </uni-td>
  51. <uni-td v-else>
  52. <view class="table-td">
  53. {{index+1}}
  54. </view>
  55. </uni-td>
  56. <uni-td>
  57. <view class="table-td table-td-name">{{item.goodsName}}</view>
  58. </uni-td>
  59. <uni-td>
  60. <view class="table-td">¥{{$xy.delMoney(item.salesMoney)}}</view>
  61. </uni-td>
  62. <uni-td>
  63. <view class="table-td">{{item.salesCount}}件</view>
  64. </uni-td>
  65. </uni-tr>
  66. </uni-table>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. goodSumPage
  75. } from "@/api/device/device.js"
  76. export default {
  77. data() {
  78. return {
  79. timeStart: '',
  80. timeEnd: '',
  81. typeColumns: [
  82. ['销售额', '订单笔数']
  83. ],
  84. status: 'loadmore', //加载更多
  85. list1: [], //设备列表
  86. list2: [], //商品列表
  87. deviceSortType: 0,
  88. goodsSortType: 0,
  89. id: null
  90. }
  91. },
  92. onLoad(o) {
  93. this.id = o.id
  94. this.timeStart = o.timeStart
  95. this.timeEnd = o.timeEnd
  96. this.goodsSortType = o.sortType
  97. },
  98. onShow() {
  99. this.getData()
  100. },
  101. methods: {
  102. getData() {
  103. this.getList(this.goodsSortType)
  104. },
  105. goodsSort(type) {
  106. this.goodsSortType = type
  107. this.getList(type)
  108. },
  109. getParams(type) {
  110. let orderByKey = "";
  111. let orderBy = "";
  112. switch (type) {
  113. case '销售额':
  114. orderBy = 'desc';
  115. orderByKey = 'sales_money';
  116. break;
  117. case '销量':
  118. orderBy = 'desc';
  119. orderByKey = 'sales_count';
  120. break;
  121. default:
  122. break;
  123. }
  124. let params = {
  125. type: 'day',
  126. orderByKey: orderByKey,
  127. orderBy: orderBy,
  128. beginDate: this.timeStart,
  129. endDate: this.timeEnd,
  130. deviceId: this.id
  131. }
  132. return params
  133. },
  134. //获取商品排行
  135. getList(e) {
  136. let type = e == 0 ? '销售额' : '销量';
  137. let dataParams = this.getParams(type)
  138. let pageParams = {
  139. page: {
  140. current: 1,
  141. size: 1000
  142. }
  143. }
  144. let params = Object.assign(dataParams, pageParams)
  145. goodSumPage(params).then(res => {
  146. if (res.data) {
  147. this.list2 = res.data.records;
  148. } else {
  149. this.list2 = []
  150. }
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .container {
  158. .content {
  159. .select {
  160. .time-tab {
  161. padding: 0 36rpx;
  162. .time-tab-item {
  163. padding: 0 24rpx;
  164. background-color: #fff;
  165. border: 1rpx solid #e0b4a2;
  166. text-align: center;
  167. line-height: 50rpx;
  168. color: #e0b4a2;
  169. border-radius: 40rpx;
  170. &.time-tab-show {
  171. background-color: #eab09a;
  172. color: #d98a6d;
  173. }
  174. }
  175. }
  176. .time-select {
  177. padding: 24rpx 36rpx;
  178. color: rgb(144, 144, 144);
  179. font-size: 28rpx;
  180. >view:nth-child(2) {
  181. width: 160rpx;
  182. text-align: right;
  183. }
  184. >view:nth-child(3) {
  185. width: 80rpx;
  186. padding: 0 24rpx;
  187. }
  188. }
  189. }
  190. .total {
  191. padding: 12rpx 0;
  192. background-color: #fff;
  193. .total-name {
  194. color: #333;
  195. font-size: 28rpx;
  196. line-height: 50rpx;
  197. }
  198. .total-num {
  199. color: #eab09a;
  200. font-size: 32rpx;
  201. font-weight: bold;
  202. line-height: 50rpx;
  203. }
  204. }
  205. .search {
  206. padding: 24rpx 24rpx;
  207. background-color: #fff;
  208. position: relative;
  209. font-size: 26rpx;
  210. .time-type {
  211. width: 180rpx;
  212. }
  213. .time-select {
  214. width: 340rpx;
  215. line-height: 64rpx;
  216. background-color: #eeeeef;
  217. border-radius: 6rpx;
  218. }
  219. }
  220. .table {
  221. width: 100%;
  222. background-color: #fff;
  223. color: #333;
  224. .table-title {
  225. line-height: 50rpx;
  226. padding: 24rpx;
  227. border-bottom: 1rpx solid #ebeef5;
  228. }
  229. .table-td {
  230. width: 100%;
  231. text-align: center;
  232. &.table-td-name {
  233. width: 270rpx;
  234. white-space: wrap;
  235. }
  236. }
  237. .table-img {
  238. width: 40rpx;
  239. height: 40rpx;
  240. position: relative;
  241. }
  242. .sort-type {
  243. width: 250rpx;
  244. height: 50rpx;
  245. line-height: 48rpx;
  246. text-align: center;
  247. font-weight: normal;
  248. .sort-type-item {
  249. width: 50%;
  250. font-size: 26rpx;
  251. color: #555555;
  252. background-color: #fff;
  253. &.sort-type-item:nth-child(1) {
  254. border-top-left-radius: 6rpx;
  255. border-bottom-left-radius: 6rpx;
  256. border-top: 1rpx solid #CCCCCC;
  257. border-left: 1rpx solid #CCCCCC;
  258. border-bottom: 1rpx solid #CCCCCC;
  259. &.sort-type-show {
  260. color: #fff;
  261. border-top: 1rpx solid #2C6FF3;
  262. border-left: 1rpx solid #2C6FF3;
  263. border-bottom: 1rpx solid #2C6FF3;
  264. background-color: #2C6FF3;
  265. }
  266. }
  267. &.sort-type-item:nth-child(2) {
  268. border-top-right-radius: 6rpx;
  269. border-bottom-right-radius: 6rpx;
  270. border-top: 1rpx solid #CCCCCC;
  271. border-right: 1rpx solid #CCCCCC;
  272. border-bottom: 1rpx solid #CCCCCC;
  273. &.sort-type-show {
  274. color: #fff;
  275. border-top: 1rpx solid #2C6FF3;
  276. border-right: 1rpx solid #2C6FF3;
  277. border-bottom: 1rpx solid #2C6FF3;
  278. background-color: #2C6FF3;
  279. }
  280. }
  281. }
  282. }
  283. /deep/.uni-table-th {
  284. color: #333;
  285. font-weight: normal;
  286. }
  287. /deep/.uni-table-td {
  288. vertical-align: middle;
  289. }
  290. }
  291. .more {
  292. text-align: right;
  293. padding-right: 40rpx;
  294. position: relative;
  295. color: #333;
  296. line-height: 80rpx;
  297. background-color: #fff;
  298. >view {
  299. position: absolute;
  300. right: 12rpx;
  301. top: 50%;
  302. transform: translateY(-50%);
  303. }
  304. }
  305. }
  306. }
  307. </style>