statistics.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view>
  3. <view class="padding-main">
  4. <!-- 推广客户 -->
  5. <view class="container padding-main border-radius-main bg-white">
  6. <view class="title border-color-main padding-left-lg text-size fw-b">推广客户</view>
  7. <view class="margin-top-lg oh tc">
  8. <block v-for="(item, index) in stats_user_data_list" :key="index">
  9. <view class="item fl padding-main">
  10. <view class="cr-base">{{item.name}}</view>
  11. <view class="single-text margin-top-sm">
  12. <text class="text-size">{{item.value}}</text>
  13. <text class="cr-gray margin-left-sm">人</text>
  14. </view>
  15. </view>
  16. </block>
  17. </view>
  18. </view>
  19. <!-- 返利概况 -->
  20. <view class="container padding-main border-radius-main bg-white spacing-mt">
  21. <view class="title border-color-main padding-left-lg text-size fw-b">返利概况</view>
  22. <view class="margin-top-lg oh tc">
  23. <block v-for="(item, index) in stats_profit_data_list" :key="index">
  24. <view class="item fl padding-main">
  25. <view class="cr-base">{{item.name}}</view>
  26. <view class="single-text margin-top-sm">
  27. <text :class="'fw-b text-size '+item.ent">{{currency_symbol}}{{item.value}}</text>
  28. </view>
  29. </view>
  30. </block>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 结尾 -->
  35. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  36. </view>
  37. </template>
  38. <script>
  39. const app = getApp();
  40. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  41. export default {
  42. data() {
  43. return {
  44. data_list_loding_status: 1,
  45. data_list_loding_msg: '加载中...',
  46. data_bottom_line_status: true,
  47. stats_user_data_list: [
  48. {name: "已推广用户总数", value: 0},
  49. {name: "已消费用户总数", value: 0}
  50. ],
  51. stats_profit_data_list: [
  52. {name: "返佣总额", value: '0.00', ent: "cr-base"},
  53. {name: "待生效", value: '0.00', ent: "cr-yellow"},
  54. {name: "待结算", value: '0.00', ent: "cr-blue"},
  55. {name: "已结算", value: '0.00', ent: "cr-green"}
  56. ],
  57. user_data: null,
  58. profit_data: null,
  59. // 基础配置
  60. currency_symbol: app.globalData.data.currency_symbol
  61. };
  62. },
  63. components: {
  64. componentBottomLine
  65. },
  66. props: {},
  67. onShow() {
  68. // 数据加载
  69. this.init();
  70. // 初始化配置
  71. this.init_config();
  72. // 分享菜单处理
  73. app.globalData.page_share_handle();
  74. },
  75. // 下拉刷新
  76. onPullDownRefresh() {
  77. this.init();
  78. },
  79. methods: {
  80. // 初始化配置
  81. init_config(status) {
  82. if ((status || false) == true) {
  83. this.setData({
  84. currency_symbol: app.globalData.get_config('currency_symbol')
  85. });
  86. } else {
  87. app.globalData.is_config(this, 'init_config');
  88. }
  89. },
  90. // 获取数据
  91. init() {
  92. uni.showLoading({
  93. title: '加载中...'
  94. });
  95. this.setData({
  96. data_list_loding_status: 1
  97. });
  98. uni.request({
  99. url: app.globalData.get_request_url("index", "statistics", "distribution"),
  100. method: 'POST',
  101. data: {},
  102. dataType: 'json',
  103. success: res => {
  104. uni.hideLoading();
  105. uni.stopPullDownRefresh();
  106. if (res.data.code == 0) {
  107. var data = res.data.data;
  108. // 用户统计
  109. var temp_stats_user = this.stats_user_data_list;
  110. temp_stats_user[0]['value'] = data.user_total.user_count || 0;
  111. temp_stats_user[1]['value'] = data.user_total.valid_user_count || 0;
  112. // 收益统计
  113. var temp_stats_profit = this.stats_profit_data_list;
  114. temp_stats_profit[0]['value'] = data.user_profit_total_price || '0.00';
  115. temp_stats_profit[1]['value'] = data.user_profit_stay_price || '0.00';
  116. temp_stats_profit[2]['value'] = data.user_profit_vaild_price || '0.00';
  117. temp_stats_profit[3]['value'] = data.user_profit_already_price || '0.00';
  118. // 数据设置
  119. this.setData({
  120. stats_user_data_list: temp_stats_user,
  121. stats_profit_data_list: temp_stats_profit,
  122. user_data: data.user_chart || null,
  123. profit_data: data.profit_chart || null,
  124. data_list_loding_status: 3,
  125. data_bottom_line_status: true,
  126. data_list_loding_msg: ''
  127. });
  128. } else {
  129. this.setData({
  130. data_list_loding_status: 2,
  131. data_bottom_line_status: false,
  132. data_list_loding_msg: res.data.msg
  133. });
  134. if (app.globalData.is_login_check(res.data, this, 'init')) {
  135. app.globalData.showToast(res.data.msg);
  136. }
  137. }
  138. },
  139. fail: () => {
  140. uni.hideLoading();
  141. uni.stopPullDownRefresh();
  142. this.setData({
  143. data_list_loding_status: 2,
  144. data_bottom_line_status: false,
  145. data_list_loding_msg: '服务器请求出错'
  146. });
  147. app.globalData.showToast('服务器请求出错');
  148. }
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style>
  155. @import './statistics.css';
  156. </style>