金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
9.2 KiB

  1. <template>
  2. <view id="order-search">
  3. <view class="search-box">
  4. <view class="input-box">
  5. <i class="iconfont icon-sousuo " type="search" size="20"></i>
  6. <input type="text" :value="text" @input="sureSearch" confirm-type="search" bindconfirm="searchKeywords" />
  7. <!-- #ifdef MP-WEIXIN -->
  8. <icon type="clear" size="20" class="clear" :hidden="clear" @tap="clearF"></icon>
  9. <!-- #endif -->
  10. </view>
  11. <view class="text" @tap="searchKeywords">
  12. 搜索
  13. </view>
  14. </view>
  15. <view class="tab-panel">
  16. <view class="tab-content">
  17. <view class="order-box">
  18. <view v-for="(item, idx) in dataList" :key="idx">
  19. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[idx]" :key="index" @tap="jump">
  20. <view class="item-top">
  21. <view class="indent mx-1px-bottom">
  22. <view class="order-num">
  23. <span>{{order.from}}</span> | 订单编号{{order.order_no}}
  24. </view>
  25. <view class="order-type">
  26. {{typeList[order.status]}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="item-middle">
  31. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index" >
  32. <image :src="good.item_meta.image"></image>
  33. <view class="text">
  34. <view class="names">
  35. {{good.item_name}}
  36. </view>
  37. <view class="model">
  38. {{good.item_meta.specs_text}}
  39. </view>
  40. </view>
  41. <view class="money-box">
  42. <view>
  43. {{good.quantity}}
  44. </view>
  45. <view>
  46. {{good.total_yuan}}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="item-bottom">
  52. <view class="all-money">
  53. {{order.count}}, 共计 {{order.total_yuan}}
  54. </view>
  55. <view class="button-box" v-if="order.status === 1" :data-no="order.order_no" @tap.stop="pay">
  56. 立即付款
  57. </view>
  58. <view class="button-box" v-if="order.status === 3" :data-no="order.order_no" @tap.stop="submit">
  59. 确认收货
  60. </view>
  61. <view class="button-box" v-if="order.status === 6" :data-no="order.order_no" @tap.stop="deleteF">
  62. 删除订单
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!--<view class="loadingbox" :hidden="!tabList[0].show">
  68. {{showText}}
  69. </view>-->
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  77. export default {
  78. data() {
  79. return {
  80. dataList: [],
  81. text: '',
  82. clear: true,
  83. meta: '',
  84. typeList: {
  85. 0: '临时订单',
  86. 1: '待付款',
  87. 2: '付款成功',
  88. 3: '已发货',
  89. 4: '已完成',
  90. 5: '已完成',
  91. 6: '已取消',
  92. 7: '已退款',
  93. 8: '已作废',
  94. 9: '已删除',
  95. 31: '部分已发货'
  96. }
  97. };
  98. },
  99. onReachBottom() {
  100. // debugger
  101. var hasMore = this.meta.pagination.total_pages > this.meta.pagination.current_page;
  102. if (hasMore) {
  103. var page = this.meta.pagination.current_page + 1;
  104. this.orderList(this.text, page);
  105. } else {
  106. wx.showToast({
  107. image: '../../../static/error.png',
  108. title: '再拉也没有啦'
  109. });
  110. }
  111. },
  112. methods: {
  113. sureSearch(e) {
  114. this.setData({
  115. text: e.detail.value,
  116. clear: e.detail.value <= 0
  117. });
  118. },
  119. clearF() {
  120. this.setData({
  121. text: '',
  122. clear: true
  123. });
  124. },
  125. // 搜索
  126. searchKeywords() {
  127. var keyword = this.text;
  128. if (!keyword || !keyword.length) return;
  129. this.orderList(keyword);
  130. },
  131. jump(e) {
  132. wx.navigateTo({
  133. url: '/pages/order/detail/detail?no=' + e.currentTarget.dataset.no
  134. });
  135. },
  136. pay(e) {
  137. var order_no = e.currentTarget.dataset.no;
  138. wx.navigateTo({
  139. url: '/pages/store/payment/payment?order_no=' + order_no
  140. });
  141. },
  142. deleteF(e) {
  143. wx.showModal({
  144. title: '',
  145. content: '是否删除该订单',
  146. success: res => {
  147. if (res.confirm) {
  148. this.deleteOrder(e.currentTarget.dataset.no);
  149. }
  150. }
  151. });
  152. },
  153. submit(e) {
  154. wx.showModal({
  155. title: '',
  156. content: '是否确认收货',
  157. success: res => {
  158. if (res.confirm) {
  159. this.receiveOrder(e.currentTarget.dataset.no);
  160. }
  161. }
  162. });
  163. },
  164. // 确认收货
  165. receiveOrder(orderNo) {
  166. var token = this.$cookieStorage.get('user_token');
  167. this.$http.post({
  168. api: 'api/shopping/order/received',
  169. header: {
  170. Authorization: token
  171. },
  172. data: {
  173. order_no: orderNo
  174. }
  175. }).then(res => {
  176. if (res.statusCode == 200) {
  177. res = res.data;
  178. wx.showModal({
  179. title: '',
  180. content: res.message,
  181. showCancel: false,
  182. success: res => {
  183. if (res.confirm) {
  184. this.orderList(0, this.activeIndex);
  185. }
  186. }
  187. });
  188. } else {
  189. wx.showModal({
  190. title: '',
  191. content: '取消订单失败, 请检查您的网络状态',
  192. showCancel: false
  193. });
  194. }
  195. }).catch(rej => {
  196. wx.showModal({
  197. title: '',
  198. content: '取消订单失败, 请检查您的网络状态',
  199. showCancel: false
  200. });
  201. });
  202. },
  203. // 删除订单
  204. deleteOrder(orderNo) {
  205. var token = this.$cookieStorage.get('user_token');
  206. this.$http.post({
  207. api: 'api/shopping/order/delete',
  208. header: {
  209. Authorization: token
  210. },
  211. data: {
  212. 'order_no': orderNo
  213. }
  214. }).then(res => {
  215. if (res.statusCode == 200) {
  216. wx.showToast({
  217. title: res.data.message
  218. });
  219. this.orderList(0, this.activeIndex);
  220. } else {
  221. wx.showModal({
  222. title: '',
  223. content: '删除订单失败, 请检查您的网络状态',
  224. showCancel: false
  225. });
  226. }
  227. }).catch(rej => {
  228. wx.showModal({
  229. title: '',
  230. content: '删除订单失败, 请检查您的网络状态',
  231. showCancel: false
  232. });
  233. });
  234. },
  235. // 获取订单列表
  236. orderList(status, page = 1) {
  237. console.log(status);
  238. var token = this.$cookieStorage.get('user_token');
  239. var params = {
  240. criteria: status,
  241. page: page
  242. };
  243. wx.showLoading({
  244. title: '加载中',
  245. mask: true
  246. });
  247. this.$http.get({
  248. api: 'api/order/list',
  249. header: {
  250. Authorization: token
  251. },
  252. data: params
  253. }).then(res => {
  254. if (res.statusCode == 200) {
  255. res = res.data;
  256. if (res.data.length) {
  257. this.setData({
  258. [`dataList.${page - 1}`]: res.data,
  259. meta: res.meta
  260. });
  261. } else {
  262. wx.showToast({
  263. image: '../../../static/error.png',
  264. title: '没有查询到'
  265. });
  266. }
  267. } else {
  268. wx.showModal({
  269. title: '',
  270. content: '请求失败',
  271. showCancel: false
  272. });
  273. }
  274. wx.hideLoading();
  275. }).catch(rej => {
  276. wx.showToast({
  277. title: "请求失败",
  278. image: '../../../static/error.png'
  279. });
  280. wx.hideLoading();
  281. });
  282. },
  283. setData: function (obj) {
  284. let that = this;
  285. let keys = [];
  286. let val, data;
  287. Object.keys(obj).forEach(function (key) {
  288. keys = key.split('.');
  289. val = obj[key];
  290. data = that.$data;
  291. keys.forEach(function (key2, index) {
  292. if (index + 1 == keys.length) {
  293. that.$set(data, key2, val);
  294. } else {
  295. if (!data[key2]) {
  296. that.$set(data, key2, {});
  297. }
  298. }
  299. data = data[key2];
  300. });
  301. });
  302. }
  303. },
  304. computed: {},
  305. watch: {}
  306. };
  307. </script>
  308. <style rel="stylesheet/less" lang="less">
  309. @import "search";
  310. </style>