order.vue 9.9 KB

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