order.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view>
  3. <scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="60">
  4. <view class="data-list">
  5. <view v-if="data_list.length > 0" class="data-list padding-horizontal-main padding-top-main">
  6. <view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main oh bg-white spacing-mb">
  7. <view class="base oh br-b padding-bottom-main">
  8. <image class="select-icon va-m margin-right-sm" data-type="node" :data-value="item.id" @tap="selected_event" :src="common_static_url+'select' + (select_ids.indexOf(item.id) != -1 ? '-active' : '') + '-icon.png'" mode="widthFix"></image>
  9. <text class="cr-base va-m">{{item.add_time}}</text>
  10. </view>
  11. <view class="content margin-top">
  12. <navigator :url="'/pages/user-order-detail/user-order-detail?id=' + item.id" hover-class="none">
  13. <block v-for="(fv,fi) in content_list">
  14. <view class="single-text margin-top-xs">
  15. <text class="cr-gray margin-right-xl">{{fv.name}}</text>
  16. <text class="cr-base">{{item[fv.field]}}</text>
  17. <text v-if="(fv.unit || null) != null" class="cr-gray">{{fv.unit}}</text>
  18. </view>
  19. </block>
  20. </navigator>
  21. </view>
  22. <view class="item-operation tr br-t padding-top-main margin-top-main">
  23. <button class="round bg-white br cr-base br" type="default" size="mini" hover-class="none" :data-ids="item.id" data-type="item" @tap="invoice_event">开票</button>
  24. </view>
  25. </view>
  26. <!-- 合并开票 -->
  27. <button v-if="select_ids.length > 0" class="bottom-fixed invoice-merge-submit bg-green cr-white round" type="default" size="mini" hover-class="none" data-type="all" @tap="invoice_event">合并开票</button>
  28. </view>
  29. <view v-else>
  30. <!-- 提示信息 -->
  31. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  32. </view>
  33. <!-- 结尾 -->
  34. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  35. </view>
  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. var common_static_url = app.globalData.get_static_url('common');
  44. export default {
  45. data() {
  46. return {
  47. common_static_url: common_static_url,
  48. data_base: null,
  49. data_list: [],
  50. data_total: 0,
  51. data_page_total: 0,
  52. data_page: 1,
  53. data_list_loding_status: 1,
  54. data_bottom_line_status: false,
  55. params: null,
  56. select_ids: [],
  57. content_list: [
  58. {name: "订单编号", field: "order_no"},
  59. {name: "订单总额", field: "total_price", unit: "元"},
  60. {name: "支付金额", field: "pay_price", unit: "元"},
  61. {name: "订单单价", field: "price", unit: "元"}
  62. ]
  63. };
  64. },
  65. components: {
  66. componentNoData,
  67. componentBottomLine
  68. },
  69. props: {},
  70. onLoad(params) {
  71. this.setData({
  72. params: params
  73. });
  74. },
  75. onShow() {
  76. this.init();
  77. // 分享菜单处理
  78. app.globalData.page_share_handle();
  79. },
  80. // 下拉刷新
  81. onPullDownRefresh() {
  82. this.setData({
  83. data_page: 1
  84. });
  85. this.get_data_list(1);
  86. },
  87. methods: {
  88. init() {
  89. var user = app.globalData.get_user_info(this, 'init');
  90. if (user != false) {
  91. // 用户未绑定用户则转到登录页面
  92. if (app.globalData.user_is_need_login(user)) {
  93. uni.redirectTo({
  94. url: "/pages/login/login?event_callback=init"
  95. });
  96. return false;
  97. } else {
  98. // 获取数据
  99. this.get_data_list();
  100. }
  101. } else {
  102. this.setData({
  103. data_list_loding_status: 0,
  104. data_bottom_line_status: false
  105. });
  106. }
  107. },
  108. // 获取数据
  109. get_data_list(is_mandatory) {
  110. // 分页是否还有数据
  111. if ((is_mandatory || 0) == 0) {
  112. if (this.data_bottom_line_status == true) {
  113. uni.stopPullDownRefresh();
  114. return false;
  115. }
  116. }
  117. // 加载loding
  118. uni.showLoading({
  119. title: '加载中...'
  120. });
  121. this.setData({
  122. data_list_loding_status: 1
  123. });
  124. // 获取数据
  125. uni.request({
  126. url: app.globalData.get_request_url("index", "order", "invoice"),
  127. method: 'POST',
  128. data: {
  129. page: this.data_page
  130. },
  131. dataType: 'json',
  132. success: res => {
  133. uni.hideLoading();
  134. uni.stopPullDownRefresh();
  135. if (res.data.code == 0) {
  136. if (res.data.data.data.length > 0) {
  137. if (this.data_page <= 1) {
  138. var temp_data_list = res.data.data.data;
  139. } else {
  140. var temp_data_list = this.data_list || [];
  141. var temp_data = res.data.data.data;
  142. for (var i in temp_data) {
  143. temp_data_list.push(temp_data[i]);
  144. }
  145. }
  146. this.setData({
  147. data_base: res.data.data.base || null,
  148. data_list: temp_data_list,
  149. data_total: res.data.data.total,
  150. data_page_total: res.data.data.page_total,
  151. data_list_loding_status: 3,
  152. data_page: this.data_page + 1
  153. });
  154. // 是否还有数据
  155. this.setData({
  156. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  157. });
  158. } else {
  159. this.setData({
  160. data_list_loding_status: 0,
  161. data_list: [],
  162. data_bottom_line_status: false
  163. });
  164. }
  165. } else {
  166. this.setData({
  167. data_list_loding_status: 0
  168. });
  169. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  170. app.globalData.showToast(res.data.msg);
  171. }
  172. }
  173. },
  174. fail: () => {
  175. uni.hideLoading();
  176. uni.stopPullDownRefresh();
  177. this.setData({
  178. data_list_loding_status: 2
  179. });
  180. app.globalData.showToast('服务器请求出错');
  181. }
  182. });
  183. },
  184. // 滚动加载
  185. scroll_lower(e) {
  186. this.get_data_list();
  187. },
  188. // 选择
  189. selected_event(e) {
  190. var value = e.currentTarget.dataset.value;
  191. var temp_select_ids = this.select_ids;
  192. var index = temp_select_ids.indexOf(value);
  193. if (index == -1) {
  194. temp_select_ids.push(value);
  195. } else {
  196. temp_select_ids.splice(index, 1);
  197. }
  198. this.setData({
  199. select_ids: temp_select_ids
  200. });
  201. },
  202. // 合并开票
  203. invoice_event(e) {
  204. var type = e.currentTarget.dataset.type || 'all';
  205. var ids = e.currentTarget.dataset.ids || null;
  206. if(type == 'all') {
  207. if (this.select_ids.length <= 0) {
  208. app.globalData.showToast('请先选择数据');
  209. return false;
  210. } else {
  211. ids = this.select_ids.join(',');
  212. }
  213. } else {
  214. if(ids === null) {
  215. app.globalData.showToast('元素参数id有误');
  216. return false;
  217. }
  218. }
  219. uni.navigateTo({
  220. url: '/pages/plugins/invoice/invoice-saveinfo/invoice-saveinfo?ids=' + ids + '&type=order&is_redirect=1'
  221. });
  222. }
  223. }
  224. };
  225. </script>
  226. <style>
  227. @import './order.css';
  228. </style>