index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="shop-statistics-container">
  3. <JHeader title="商家统计" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view style="margin-bottom: 20upx;text-align: right;">
  5. <tui-button
  6. type="primary" width="268rpx" height="60rpx" margin="0 20upx 0 0"
  7. style="display: inline-block;border-radius: 30rpx;"
  8. @click="go('/another-tf/another-user/shop-statistics/finance-statistics?type=recharge')"
  9. >
  10. 充值财务数据 →
  11. </tui-button>
  12. <tui-button
  13. type="primary" width="268rpx" height="60rpx" margin="0 20upx 0 0"
  14. style="display: inline-block;border-radius: 30rpx;"
  15. @click="go('/another-tf/another-user/shop-statistics/finance-statistics?type=order')"
  16. >
  17. 订单财务数据 →
  18. </tui-button>
  19. </view>
  20. <view style="padding: 0 24upx;background-color: #ffffff;">
  21. <tui-tabs
  22. style="width: 702upx;padding: 0 0upx 0 0upx;overflow: hidden;" :slider-width="175.5" :padding="24"
  23. item-width="175.5rpx" selected-color="#000000" bold slider-bg-color="#ff0000"
  24. :tabs="[{ name: '今天' }, { name: '昨天' }, { name: '最近7天' }, { name: '最近30天' }]" :current-tab="currentTab"
  25. @change="handleCurrentChange"
  26. ></tui-tabs>
  27. </view>
  28. <view
  29. style="width: 100%;color: #000;padding: 34upx 24upx 44upx;box-sizing: border-box;margin-top: 2upx;margin-bottom: 20upx;background-color: #ffa637;border-radius: 20upx;font-size: 28upx;"
  30. >
  31. <view style="margin-top: 20upx;">
  32. <view style="display: flex;justify-content: space-between;align-items: center;">
  33. <view
  34. style="width: 20%;padding: 40upx 6upx;color: #FFFFFF;text-align: center;border-radius: 24px;background: rgba(255, 255, 255, 0.32);border: 2px solid rgba(255, 255, 255, 0.16);"
  35. >
  36. <view>店铺访问次数 (次)</view>
  37. <view style="font-size: 40upx;font-weight: bold;margin-top: 10upx;">
  38. {{ typeof shopStatisticsData.total === 'number' ? shopStatisticsData.total : '--' }}
  39. </view>
  40. </view>
  41. <view
  42. style="width: 20%;padding: 40upx 6upx;color: #FFFFFF;text-align: center;border-radius: 24px;background: rgba(255, 255, 255, 0.32);border: 2px solid rgba(255, 255, 255, 0.16);"
  43. >
  44. <view>待处理订单 (件)</view>
  45. <view style="font-size: 40upx;font-weight: bold;margin-top: 10upx;">
  46. {{ typeof shopStatisticsData.stayOrders === 'number' ? shopStatisticsData.stayOrders : '--' }}
  47. </view>
  48. </view>
  49. <view
  50. style="width: 20%;padding: 40upx 6upx;color: #FFFFFF;text-align: center;border-radius: 24px;background: rgba(255, 255, 255, 0.32);border: 2px solid rgba(255, 255, 255, 0.16);"
  51. >
  52. <view>售后订单 (件)</view>
  53. <view style="font-size: 40upx;font-weight: bold;margin-top: 10upx;">
  54. {{ typeof shopStatisticsData.stayAfters === 'number' ? shopStatisticsData.stayAfters : '--' }}
  55. </view>
  56. </view>
  57. <view
  58. style="width: 20%;padding: 40upx 6upx;color: #FFFFFF;text-align: center;border-radius: 24px;background: rgba(255, 255, 255, 0.32);border: 2px solid rgba(255, 255, 255, 0.16);"
  59. >
  60. <view>{{ shopStatisticsData.money < 10000 ? '成交金额 (元)' : '成交金额 (万元)' }}</view>
  61. <view style="font-size: 40upx;font-weight: bold;margin-top: 10upx;">
  62. {{ typeof shopStatisticsData.money === 'number' ? shopStatisticsData.money : '--' }}
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view>
  69. <view style="text-align: center;">
  70. <view>用户访问趋势(单位:次数)</view>
  71. <view style="font-size: 28upx;">用户访问数:{{ shopStatisticsData.count }} 次</view>
  72. </view>
  73. <view
  74. v-if="shopStatisticsData.visitWeek.time && shopStatisticsData.visitWeek.time.length"
  75. style="display: flex;justify-content: flex-end;"
  76. >
  77. <tui-charts-line
  78. ref="refAccessTrends" tooltip scrollable :x-axis="shopStatisticsData.visitWeek.time"
  79. :x-axis-line="{ color: '#e3e3e3', itemGap: 135 }" :y-axis-label="{ show: true, size: 24, color: '#333333' }"
  80. :max="Math.max(...shopStatisticsData.visitWeek.total) || 1"
  81. :split-number="(Math.max(...shopStatisticsData.visitWeek.total) / 8) || 1"
  82. ></tui-charts-line>
  83. </view>
  84. <!-- <view
  85. v-if="shopStatisticsData.visitWeek.time && shopStatisticsData.visitWeek.time.length && Math.max(...shopStatisticsData.visitWeek.total)"
  86. style="width: 100%;overflow-x: auto;"
  87. >
  88. <tui-charts-line
  89. ref="refAccessTrends" tooltip scrollable :x-axis="shopStatisticsData.visitWeek.time"
  90. :x-axis-line="{ color: '#e3e3e3', itemGap: 135 }" :y-axis-label="{ show: true, size: 24, color: '#333333' }"
  91. :max="Math.max(...shopStatisticsData.visitWeek.total) || 1"
  92. :split-number="(Math.max(...shopStatisticsData.visitWeek.total) / 8) || 1"
  93. ></tui-charts-line>
  94. </view> -->
  95. </view>
  96. <view style="padding: 20upx;">
  97. <view style="text-align: center;">
  98. <view>订单转换漏斗</view>
  99. <view style="font-size: 28upx;">总转化率:{{ shopStatisticsData.rate }}%</view>
  100. </view>
  101. <view v-if="shopStatisticsData.conversion.names.length">
  102. <tui-table>
  103. <tui-tr>
  104. <tui-td bold :span="8"></tui-td>
  105. <tui-td v-for="(item, index) in shopStatisticsData.conversion.names" :key="index" bold :span="8">
  106. {{ item }}
  107. </tui-td>
  108. </tui-tr>
  109. <tui-tr>
  110. <tui-td bold :span="8">转化率(%)</tui-td>
  111. <tui-td v-for="(item, idx) in shopStatisticsData.conversion.rates" :key="idx" :span="8">{{ item }}</tui-td>
  112. </tui-tr>
  113. </tui-table>
  114. </view>
  115. </view>
  116. <view style="padding: 20upx;">
  117. <tui-list-view v-if="shopStatisticsData.hotSellProducts && shopStatisticsData.hotSellProducts.length" title="">
  118. <tui-list-cell v-for="(item, index) in shopStatisticsData.hotSellProducts" :key="item.id">
  119. <view style="display: flex;justify-content: space-between;flex-wrap: wrap;">
  120. <view>{{ index + 1 }}:{{ item.productName }}</view>
  121. <view style="flex: 1;text-align: right;white-space: nowrap;">{{ `已售 ${item.number} 件` }}</view>
  122. </view>
  123. </tui-list-cell>
  124. </tui-list-view>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. import { getShopStatisticsApi } from '../../../api/anotherTFInterface'
  130. export default {
  131. name: 'ShopStatistics',
  132. components: {},
  133. data() {
  134. return {
  135. currentTab: 3,
  136. shopStatisticsData: {
  137. total: '',
  138. stayOrders: '',
  139. stayAfters: '',
  140. money: '',
  141. visitWeek: { time: [], total: [] },
  142. count: '',
  143. conversion: {
  144. names: [],
  145. rates: []
  146. },
  147. rate: '',
  148. hotSellProducts: []
  149. },
  150. queryInfo: {
  151. condition: 4
  152. }
  153. }
  154. },
  155. onLoad() {
  156. this.getShopStatistics()
  157. },
  158. methods: {
  159. handleCurrentChange(e) {
  160. this.currentTab = e.index
  161. this.queryInfo.condition = this.currentTab + 1
  162. this.getShopStatistics()
  163. },
  164. getShopStatistics() {
  165. uni.showLoading({
  166. title: '加载中'
  167. })
  168. getShopStatisticsApi({
  169. shopId: this.$store.state.auth.identityInfo.shopInfo.shopId,
  170. ...this.queryInfo
  171. })
  172. .then((res) => {
  173. this.shopStatisticsData = res.data
  174. uni.hideLoading()
  175. this.$nextTick(() => {
  176. this.$refs.refAccessTrends && this.$refs.refAccessTrends.draw([ { name: '次数', color: '#5677fc', source: this.shopStatisticsData.visitWeek.total } ])
  177. })
  178. })
  179. .catch(() => {
  180. uni.hideLoading()
  181. })
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="less" scoped>
  187. .shop-statistics-container {
  188. min-height: 100vh;
  189. width: 100%;
  190. background: #f6f6f6;
  191. .tui-tabs-view {
  192. /deep/ .tui-tabs-slider {
  193. margin-left: -24upx;
  194. }
  195. }
  196. }
  197. </style>