profit.vue 9.3 KB

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