team.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view>
  3. <scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="60">
  4. <view v-if="data_list.length > 0" class="data-list padding-horizontal-main padding-top-main">
  5. <view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main oh bg-white spacing-mb">
  6. <view class="base oh br-b padding-bottom-main">
  7. <image class="avatar dis-block fl circle" :src="item.avatar" mode="widthFix" @tap="avatar_event" :data-value="item.avatar"></image>
  8. <text class="cr-base margin-left-sm">{{item.user_name_view || ''}}</text>
  9. <text class="cr-base fr">{{item.add_time_time}}</text>
  10. </view>
  11. <view class="content margin-top">
  12. <block v-for="(fv,fi) in content_list">
  13. <view class="single-text margin-top-xs">
  14. <text class="cr-gray margin-right-xl">{{fv.name}}</text>
  15. <text class="cr-base">{{item[fv.field]}}</text>
  16. <text v-if="(fv.unit || null) != null" class="cr-gray">{{fv.unit}}</text>
  17. </view>
  18. </block>
  19. </view>
  20. <view class="item-operation tr br-t padding-top-main margin-top-main">
  21. <button class="round bg-white br cr-base br" type="default" size="mini" hover-class="none" @tap="user_order_event" :data-value="item.id">用户订单</button>
  22. </view>
  23. </view>
  24. </view>
  25. <view v-else>
  26. <!-- 提示信息 -->
  27. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  28. </view>
  29. <!-- 结尾 -->
  30. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  31. </scroll-view>
  32. </view>
  33. </template>
  34. <script>
  35. const app = getApp();
  36. import componentNoData from "../../../../components/no-data/no-data";
  37. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  38. export default {
  39. data() {
  40. return {
  41. data_list: [],
  42. data_total: 0,
  43. data_page_total: 0,
  44. data_page: 1,
  45. data_list_loding_status: 1,
  46. data_bottom_line_status: false,
  47. params: null,
  48. content_list: [
  49. {name: "消费金额", field: "order_total", unit: "元"},
  50. {name: "下级消费", field: "find_order_total", unit: "元"},
  51. {name: "下级用户", field: "referrer_count"}
  52. ]
  53. };
  54. },
  55. components: {
  56. componentNoData,
  57. componentBottomLine
  58. },
  59. props: {},
  60. onLoad(params) {
  61. this.setData({
  62. params: params
  63. });
  64. this.init();
  65. },
  66. onShow() {
  67. // 分享菜单处理
  68. app.globalData.page_share_handle();
  69. },
  70. // 下拉刷新
  71. onPullDownRefresh() {
  72. this.setData({
  73. data_page: 1
  74. });
  75. this.get_data_list(1);
  76. },
  77. methods: {
  78. init() {
  79. var user = app.globalData.get_user_info(this, 'init');
  80. if (user != false) {
  81. // 用户未绑定用户则转到登录页面
  82. if (app.globalData.user_is_need_login(user)) {
  83. uni.redirectTo({
  84. url: "/pages/login/login?event_callback=init"
  85. });
  86. return false;
  87. } else {
  88. // 获取数据
  89. this.get_data_list();
  90. }
  91. } else {
  92. this.setData({
  93. data_list_loding_status: 0,
  94. data_bottom_line_status: false
  95. });
  96. }
  97. },
  98. // 获取数据
  99. get_data_list(is_mandatory) {
  100. // 分页是否还有数据
  101. if ((is_mandatory || 0) == 0) {
  102. if (this.data_bottom_line_status == true) {
  103. uni.stopPullDownRefresh();
  104. return false;
  105. }
  106. }
  107. // 加载loding
  108. uni.showLoading({
  109. title: '加载中...'
  110. });
  111. this.setData({
  112. data_list_loding_status: 1
  113. });
  114. // 获取数据
  115. uni.request({
  116. url: app.globalData.get_request_url("index", "team", "distribution"),
  117. method: 'POST',
  118. data: {
  119. page: this.data_page
  120. },
  121. dataType: 'json',
  122. success: res => {
  123. uni.hideLoading();
  124. uni.stopPullDownRefresh();
  125. if (res.data.code == 0) {
  126. if (res.data.data.data.length > 0) {
  127. if (this.data_page <= 1) {
  128. var temp_data_list = res.data.data.data;
  129. } else {
  130. var temp_data_list = this.data_list || [];
  131. var temp_data = res.data.data.data;
  132. for (var i in temp_data) {
  133. temp_data_list.push(temp_data[i]);
  134. }
  135. }
  136. this.setData({
  137. data_list: temp_data_list,
  138. data_total: res.data.data.total,
  139. data_page_total: res.data.data.page_total,
  140. data_list_loding_status: 3,
  141. data_page: this.data_page + 1
  142. });
  143. // 是否还有数据
  144. this.setData({
  145. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  146. });
  147. } else {
  148. this.setData({
  149. data_list_loding_status: 0,
  150. data_list: [],
  151. data_bottom_line_status: false
  152. });
  153. }
  154. } else {
  155. this.setData({
  156. data_list_loding_status: 0
  157. });
  158. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  159. app.globalData.showToast(res.data.msg);
  160. }
  161. }
  162. },
  163. fail: () => {
  164. uni.hideLoading();
  165. uni.stopPullDownRefresh();
  166. this.setData({
  167. data_list_loding_status: 2
  168. });
  169. app.globalData.showToast('服务器请求出错');
  170. }
  171. });
  172. },
  173. // 滚动加载
  174. scroll_lower(e) {
  175. this.get_data_list();
  176. },
  177. // 头像查看
  178. avatar_event(e) {
  179. var value = e.currentTarget.dataset.value || null;
  180. if (value != null) {
  181. uni.previewImage({
  182. current: value,
  183. urls: [value]
  184. });
  185. } else {
  186. app.globalData.showToast('头像地址有误');
  187. }
  188. },
  189. // 用户订单事件
  190. user_order_event(e) {
  191. var value = e.currentTarget.dataset.value;
  192. uni.navigateTo({
  193. url: '/pages/plugins/distribution/order/order?uid='+value
  194. })
  195. }
  196. }
  197. };
  198. </script>
  199. <style>
  200. @import './team.css';
  201. </style>