金诚优选前端代码
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.

756 lines
26 KiB

  1. <template>
  2. <view id="order-index">
  3. <view class="order-search">
  4. <!-- #ifdef H5 -->
  5. <view class="search-box" @tap="jumpSearch">
  6. <i class="iconfont icon-sousuo"></i>
  7. <p>商品名称商品编号订单编号</p>
  8. </view>
  9. <!-- #endif -->
  10. <!-- #ifdef MP-WEIXIN -->
  11. <view class="search-box" @tap="jumpSearch">
  12. <i class="iconfont icon-sousuo"></i>
  13. <p>商品名称商品编号订单编号</p>
  14. </view>
  15. <!-- #endif -->
  16. <!-- #ifdef APP-PLUS -->
  17. <view class="search-box" @tap="jumpSearch">
  18. <i class="iconfont icon-sousuo"></i>
  19. <p>商品名称商品编号订单编号</p>
  20. </view>
  21. <!-- #endif -->
  22. </view>
  23. <view class="navbar mx-1px-bottom">
  24. <block v-for="(item, index) in tabList" :key="index" >
  25. <view :id="index" class="navbar-item activity" :hidden="activeIndex != index" :style="'color: ' + config.mainColor" @tap="tabClick">
  26. <view class="navbar-title">{{item.title}}</view>
  27. </view>
  28. <view :id="index" :hidden="activeIndex == index" class="navbar-item" @tap="tabClick">
  29. <view class="navbar-title">{{item.title}}</view>
  30. </view>
  31. </block>
  32. <view class="navbar-slider" :style="'width: ' + width + 'px; transform: translateX(' + sliderOffset + 'px); -webkit-transform: translateX(' + sliderOffset + 'px); background: ' + config.mainColor"></view>
  33. <!-- <view class="tab-switch" @tap="tabSwitch">
  34. <i class="iconfont icon-qiehuan"></i>
  35. </view> -->
  36. </view>
  37. <view class="tab-panel">
  38. <view class="tab-content" :hidden="activeIndex != 0">
  39. <view class="order-box">
  40. <view class="order-item__none" v-if="dataList[status[activeIndex]][0][0] == '' && tabList[activeIndex].init">
  41. 暂无数据
  42. </view>
  43. <view v-for="(item,idx) in dataList[status[activeIndex]][0]" :key="idx" >
  44. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[status[activeIndex]][0][idx]" :key="index" @tap="jump">
  45. <view class="item-top">
  46. <view class="indent mx-1px-bottom">
  47. <view class="order-num">
  48. <span>{{order.from}}</span> | 订单编号{{order.order_no}}
  49. </view>
  50. <view class="order-type">
  51. {{typeList[order.status]}}
  52. </view>
  53. </view>
  54. </view>
  55. <view class="item-middle">
  56. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index">
  57. <image :src="good.item_meta.image"></image>
  58. <view class="text">
  59. <view class="names">
  60. {{good.item_name}}
  61. </view>
  62. <view class="model">
  63. {{good.item_meta.specs_text}}
  64. </view>
  65. <view class="order-types" v-if="order.type == 10">
  66. 拼团
  67. </view>
  68. </view>
  69. <view class="money-box">
  70. <view>
  71. {{good.quantity}}
  72. </view>
  73. <view>
  74. {{good.total_yuan}}
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="closeTime mx-1px-bottom" v-if="order.status===1">
  80. <i class="iconfont icon-shijian"></i> <span>剩余付款时间</span>
  81. <countdown :value="order.will_closed_at"></countdown>
  82. </view>
  83. <view class="item-bottom">
  84. <view class="all-money" v-if="order.type == 5">
  85. {{order.count}}, 共计 {{order.redeem_point}} 积分
  86. </view>
  87. <view class="all-money" v-else>
  88. {{order.count}}, 共计 {{order.total_yuan}}
  89. </view>
  90. <view class="button-box" v-if="order.status === 1" :data-no="order.order_no" @tap.stop="pay">
  91. 立即付款
  92. </view>
  93. <view class="button-box" v-if="order.status === 3" :data-no="order.order_no" @tap.stop="submit">
  94. 确认收货
  95. </view>
  96. <view class="button-box" v-if="order.status === 6" :data-no="order.order_no" @tap.stop="deleteF">
  97. 删除订单
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="loadingbox" :hidden="!tabList[0].show">
  103. {{showText}}
  104. </view>
  105. </view>
  106. </view>
  107. <view class="tab-content" :hidden="activeIndex != 1">
  108. <view class="order-box">
  109. <view class="order-item__none" v-if="dataList[status[activeIndex]][1][0] == '' && tabList[activeIndex].init">
  110. 暂无数据
  111. </view>
  112. <view v-for="(item, idx) in dataList[status[activeIndex]][1]" :key="idx" >
  113. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[status[activeIndex]][1][idx]" :key="index" @tap="jump">
  114. <view class="item-top">
  115. <view class="indent mx-1px-bottom">
  116. <view class="order-num">
  117. <span>{{order.from}}</span> | 订单编号{{order.order_no}}
  118. </view>
  119. <view class="order-type">
  120. {{typeList[order.status]}}
  121. </view>
  122. </view>
  123. </view>
  124. <view class="item-middle">
  125. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index" >
  126. <image :src="good.item_meta.image"></image>
  127. <view class="text">
  128. <view class="names">
  129. {{good.item_name}}
  130. </view>
  131. <view class="model">
  132. {{good.item_meta.specs_text}}
  133. </view>
  134. <view class="order-types" v-if="order.type == 10">
  135. 拼团
  136. </view>
  137. </view>
  138. <view class="money-box">
  139. <view>
  140. {{good.quantity}}
  141. </view>
  142. <view>
  143. {{good.total_yuan}}
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. <view class="closeTime mx-1px-bottom" v-if="order.status===1">
  149. <i class="iconfont icon-shijian"></i> <span>剩余付款时间</span><countdown :value="order.will_closed_at"></countdown>
  150. </view>
  151. <view class="item-bottom">
  152. <view class="all-money" v-if="order.type == 5">
  153. {{order.count}}, 共计 {{order.redeem_point}} 积分
  154. </view>
  155. <view class="all-money" v-else>
  156. {{order.count}}, 共计 {{order.total_yuan}}
  157. </view>
  158. <view class="button-box" v-if="order.status === 1" :data-no="order.order_no" @tap.stop="pay">
  159. 立即付款
  160. </view>
  161. <view class="button-box" v-if="order.status === 3" :data-no="order.order_no" @tap.stop="submit">
  162. 确认收货
  163. </view>
  164. <view class="button-box" v-if="order.status === 6" :data-no="order.order_no" @tap.stop="deleteF">
  165. 删除订单
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <view class="loadingbox" :hidden="!tabList[1].show">
  171. {{showText}}
  172. </view>
  173. </view>
  174. </view>
  175. <view class="tab-content" :hidden="activeIndex != 2">
  176. <view class="order-box">
  177. <view class="order-item__none" v-if="dataList[status[activeIndex]][2][0] == '' && tabList[activeIndex].init">
  178. 暂无数据
  179. </view>
  180. <view v-for="(item, idx) in dataList[status[activeIndex]][2]" :key="idx">
  181. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[status[activeIndex]][2][idx]" :key="index" @tap="jump">
  182. <view class="item-top">
  183. <view class="indent mx-1px-bottom">
  184. <view class="order-num">
  185. <span>{{order.from}}</span> | 订单编号{{order.order_no}}
  186. </view>
  187. <view class="order-type">
  188. {{typeList[order.status]}}
  189. </view>
  190. </view>
  191. </view>
  192. <view class="item-middle">
  193. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index" >
  194. <image :src="good.item_meta.image"></image>
  195. <view class="text">
  196. <view class="names">
  197. {{good.item_name}}
  198. </view>
  199. <view class="model">
  200. {{good.item_meta.specs_text}}
  201. </view>
  202. <view class="order-types" v-if="order.type == 10">
  203. 拼团
  204. </view>
  205. </view>
  206. <view class="money-box">
  207. <view>
  208. {{good.quantity}}
  209. </view>
  210. <view>
  211. {{good.total_yuan}}
  212. </view>
  213. </view>
  214. </view>
  215. </view>
  216. <view class="item-bottom">
  217. <view class="all-money" v-if="order.type == 5">
  218. {{order.count}}, 共计 {{order.redeem_point}} 积分
  219. </view>
  220. <view class="all-money" v-else>
  221. {{order.count}}, 共计 {{order.total_yuan}}
  222. </view>
  223. <view class="button-box" v-if="order.status === 1" :data-no="order.order_no" @tap.stop="pay">
  224. 立即付款
  225. </view>
  226. <view class="button-box" v-if="order.status === 3" :data-no="order.order_no" @tap.stop="submit">
  227. 确认收货
  228. </view>
  229. <view class="button-box" v-if="order.status === 6" :data-no="order.order_no" @tap.stop="deleteF">
  230. 删除订单
  231. </view>
  232. </view>
  233. </view>
  234. </view>
  235. <view class="loadingbox" :hidden="!tabList[2].show">
  236. {{showText}}
  237. </view>
  238. </view>
  239. </view>
  240. <view class="tab-content" :hidden="activeIndex != 3">
  241. <view class="order-box">
  242. <view class="order-item__none" v-if="dataList[status[activeIndex]][3][0] == '' && tabList[activeIndex].init">
  243. 暂无数据
  244. </view>
  245. <view v-for="(item, idx) in dataList[status[activeIndex]][3]" :key="idx" >
  246. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[status[activeIndex]][3][idx]" :key="index" @tap="jump">
  247. <view class="item-top">
  248. <view class="indent mx-1px-bottom">
  249. <view class="order-num">
  250. <span>{{order.from}}</span> | 订单编号{{order.order_no}}
  251. </view>
  252. <view class="order-type">
  253. {{typeList[order.status]}}
  254. </view>
  255. </view>
  256. </view>
  257. <view class="item-middle">
  258. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index" >
  259. <image :src="good.item_meta.image"></image>
  260. <view class="text">
  261. <view class="names">
  262. {{good.item_name}}
  263. </view>
  264. <view class="model">
  265. {{good.item_meta.specs_text}}
  266. </view>
  267. <view class="order-types" v-if="order.type == 10">
  268. 拼团
  269. </view>
  270. </view>
  271. <view class="money-box">
  272. <view>
  273. {{good.quantity}}
  274. </view>
  275. <view>
  276. {{good.total_yuan}}
  277. </view>
  278. </view>
  279. </view>
  280. </view>
  281. <view class="item-bottom">
  282. <view class="all-money" v-if="order.type == 5">
  283. {{order.count}}, 共计 {{order.redeem_point}} 积分
  284. </view>
  285. <view class="all-money" v-else>
  286. {{order.count}}, 共计 {{order.total_yuan}}
  287. </view>
  288. <view class="button-box" v-if="order.status === 1" :data-no="order.order_no" @tap.stop="pay">
  289. 立即付款
  290. </view>
  291. <view class="button-box" v-if="order.status === 3" :data-no="order.order_no" @tap.stop="submit">
  292. 确认收货
  293. </view>
  294. <view class="button-box" v-if="order.status === 6" :data-no="order.order_no" @tap.stop="deleteF">
  295. 删除订单
  296. </view>
  297. </view>
  298. </view>
  299. </view>
  300. <view class="loadingbox" :hidden="!tabList[3].show">
  301. {{showText}}
  302. </view>
  303. </view>
  304. </view>
  305. </view>
  306. </view>
  307. </template>
  308. <script>
  309. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  310. import countdown from '@/components/Countdown/Countdown';
  311. export default {
  312. data() {
  313. return {
  314. status: {
  315. 0: 0,
  316. 1: 0,
  317. 2: 0,
  318. 3: 0
  319. },
  320. activeIndex: 0,
  321. sliderOffset: 0,
  322. sliderLeft: 0,
  323. width: 0,
  324. tabList: [{
  325. title: "全部",
  326. init: false,
  327. line: false,
  328. statusNum: {
  329. 0: {
  330. page: 0,
  331. more: true
  332. },
  333. 1: {
  334. page: 0,
  335. more: true
  336. }
  337. },
  338. show: false
  339. }, {
  340. title: "待付款",
  341. init: false,
  342. line: false,
  343. statusNum: {
  344. 0: {
  345. page: 0,
  346. more: true
  347. },
  348. 1: {
  349. page: 0,
  350. more: true
  351. }
  352. },
  353. show: false
  354. }, {
  355. title: "待发货",
  356. init: false,
  357. line: false,
  358. statusNum: {
  359. 0: {
  360. page: 0,
  361. more: true
  362. },
  363. 1: {
  364. page: 0,
  365. more: true
  366. }
  367. },
  368. show: false
  369. }, {
  370. title: "待收货",
  371. init: false,
  372. line: false,
  373. statusNum: {
  374. 0: {
  375. page: 0,
  376. more: true
  377. },
  378. 1: {
  379. page: 0,
  380. more: true
  381. }
  382. },
  383. show: false
  384. }],
  385. dataList: {
  386. 0: {
  387. 0: [],
  388. 1: [],
  389. 2: [],
  390. 3: []
  391. },
  392. 1: {
  393. 0: [],
  394. 1: [],
  395. 2: [],
  396. 3: []
  397. }
  398. },
  399. typeList: {
  400. 0: '临时订单',
  401. 1: '待付款',
  402. 2: '付款成功',
  403. 3: '已发货',
  404. 4: '已完成',
  405. 5: '已完成',
  406. 6: '已取消',
  407. 7: '已退款',
  408. 8: '已作废',
  409. 9: '已删除',
  410. 31: '部分已发货'
  411. },
  412. showText: '正在加载下一页数据',
  413. config: ''
  414. };
  415. },
  416. //注册组件
  417. components: {
  418. countdown
  419. },
  420. onReachBottom(e) {
  421. var status = this.activeIndex;
  422. var statusPage = this.status[status];
  423. var page = this.tabList[status].statusNum[statusPage].page + 1;
  424. var tabList = `tabList[${status}]`;
  425. if (this.tabList[status].statusNum[statusPage].more) {
  426. /* this.setData({
  427. [`${tabList}.show`]: true
  428. }); */
  429. this.tabList[status].show = true
  430. this.orderList(0, status, page);
  431. } else {
  432. wx.showToast({
  433. image: '../../../static/error.png',
  434. title: '再拉也没有啦'
  435. });
  436. }
  437. },
  438. onShow(e) {
  439. wx.showLoading({
  440. title: "加载中",
  441. mask: true
  442. });
  443. wx.getSystemInfo({
  444. success: res => {
  445. this.setData({
  446. width: res.windowWidth / this.tabList.length - 15,
  447. sliderOffset: res.windowWidth / this.tabList.length * this.activeIndex
  448. });
  449. }
  450. });
  451. var tabStatus = this.status[this.activeIndex];
  452. this.orderList(tabStatus, this.activeIndex);
  453. },
  454. onLoad(e) {
  455. // 第三方平台配置颜色
  456. var gbConfig = this.$cookieStorage.get('globalConfig') || '';
  457. this.setData({
  458. config: gbConfig
  459. });
  460. pageLogin(getUrl());
  461. if (e.type) {
  462. this.setData({
  463. activeIndex: e.type
  464. });
  465. }
  466. },
  467. methods: {
  468. jump(e) {
  469. wx.navigateTo({
  470. url: '/pages/order/detail/detail?no=' + e.currentTarget.dataset.no
  471. });
  472. },
  473. jumpSearch() {
  474. wx.navigateTo({
  475. url: '/pages/order/search/search'
  476. });
  477. },
  478. tabClick(e) {
  479. var status = e.currentTarget.id;
  480. this.setData({
  481. sliderOffset: e.currentTarget.offsetLeft,
  482. activeIndex: status
  483. });
  484. if (!this.tabList[status].init) {
  485. wx.showLoading({
  486. title: "加载中",
  487. mask: true
  488. });
  489. this.orderList(0, status);
  490. }
  491. },
  492. tabSwitch() {
  493. var status = this.activeIndex;
  494. var tabList = `tabList[${status}]`;
  495. var tabStatus = this.status[this.activeIndex];
  496. console.log(status);
  497. if (tabStatus == 0) {
  498. // this.setData({
  499. // [`status.${status}`]: 1
  500. // });
  501. //
  502. this.status[status]=1;
  503. } else if (tabStatus == 1) {
  504. // this.setData({
  505. // [`status.${status}`]: 0
  506. // });
  507. this.status[status]=0;
  508. }
  509. console.log(this.tabList[status].line);
  510. if (!this.tabList[status].line) {
  511. wx.showLoading({
  512. title: "加载中",
  513. mask: true
  514. });
  515. this.orderList(1, status);
  516. // this.setData({
  517. // [`status.${status}`]: 1
  518. // });
  519. //
  520. this.status[status]=1;
  521. }
  522. // this.setData({
  523. // [`${tabList}.line`]: true
  524. // });
  525. //
  526. this.tabList[status].line=true;
  527. },
  528. pay(e) {
  529. var order_no = e.currentTarget.dataset.no;
  530. wx.navigateTo({
  531. url: '/pages/store/payment/payment?order_no=' + order_no
  532. });
  533. },
  534. deleteF(e) {
  535. wx.showModal({
  536. title: '',
  537. content: '是否删除该订单',
  538. success: res => {
  539. if (res.confirm) {
  540. this.deleteOrder(e.currentTarget.dataset.no);
  541. }
  542. }
  543. });
  544. },
  545. submit(e) {
  546. wx.showModal({
  547. title: '',
  548. content: '是否确认收货',
  549. success: res => {
  550. if (res.confirm) {
  551. this.receiveOrder(e.currentTarget.dataset.no);
  552. }
  553. }
  554. });
  555. },
  556. // 获取订单列表
  557. orderList(shop = 0, status = 0, page = 1, type = 0) {
  558. var token = this.$cookieStorage.get('user_token');
  559. var params = status ? {
  560. status
  561. } : {};
  562. params.page = page;
  563. params.type = type;
  564. params.channel = shop ? 'shop' : '';
  565. this.$http.get({
  566. api: 'api/order/list',
  567. header: {
  568. Authorization: token
  569. },
  570. data: params
  571. }).then(res => {
  572. if (res.statusCode == 200) {
  573. res = res.data;
  574. if (res.status) {
  575. var pages = res.meta.pagination;
  576. var current_page = pages.current_page;
  577. var total_pages = pages.total_pages;
  578. var tabList = `tabList[${status}]`;
  579. var statusPage = `status[${status}]`;
  580. var dataStatus = this.status[this.activeIndex];
  581. // this.setData({
  582. // [`dataList.${dataStatus}[${status}][${page - 1}]`]: res.data,
  583. // [`${tabList}.init`]: true,
  584. // [`${tabList}.statusNum.${dataStatus}.page`]: current_page,
  585. // [`${tabList}.statusNum.${dataStatus}.more`]: current_page < total_pages,
  586. // [`${tabList}.show`]: false
  587. // });
  588. // this.dataList[dataStatus][status][page - 1]=res.data;
  589. this.$set(this.dataList[dataStatus][status], page -1, res.data);
  590. this.tabList[status].init=true;
  591. this.tabList[status].statusNum[dataStatus].page=current_page;
  592. this.tabList[status].statusNum[dataStatus].more=current_page < total_pages;
  593. this.tabList[status].show=false;
  594. } else {
  595. wx.showToast({
  596. title: res.message,
  597. image: '../../../static/error.png'
  598. });
  599. }
  600. } else {
  601. wx.showModal({
  602. title: '',
  603. content: '请求失败',
  604. showCancel: false
  605. });
  606. }
  607. wx.hideLoading();
  608. }).catch(rej => {
  609. console.log(rej);
  610. wx.showToast({
  611. title: "请求失败",
  612. image: '../../../static/error.png'
  613. });
  614. wx.hideLoading();
  615. });
  616. },
  617. // 确认收货
  618. receiveOrder(orderNo) {
  619. var token = this.$cookieStorage.get('user_token');
  620. this.$http.post({
  621. api: 'api/shopping/order/received',
  622. header: {
  623. Authorization: token
  624. },
  625. data: {
  626. order_no: orderNo
  627. }
  628. }).then(res => {
  629. res = res.data;
  630. wx.showModal({
  631. title: '',
  632. content: res.message || '确认收货成功',
  633. showCancel: false,
  634. success: res => {
  635. if (res.confirm) {
  636. this.orderList(0, this.activeIndex);
  637. }
  638. }
  639. });
  640. }).catch(rej => {
  641. wx.showModal({
  642. title: '',
  643. content: '取消订单失败, 请检查您的网络状态',
  644. showCancel: false
  645. });
  646. });
  647. },
  648. // 删除订单
  649. deleteOrder(orderNo) {
  650. var token = this.$cookieStorage.get('user_token');
  651. this.$http.post({
  652. api: 'api/shopping/order/delete',
  653. header: {
  654. Authorization: token
  655. },
  656. data: {
  657. 'order_no': orderNo
  658. }
  659. }).then(res => {
  660. if (res.statusCode == 200) {
  661. wx.showToast({
  662. title: res.data.message
  663. });
  664. this.orderList(0, this.activeIndex);
  665. } else {
  666. wx.showModal({
  667. title: '',
  668. content: '删除订单失败, 请检查您的网络状态',
  669. showCancel: false
  670. });
  671. }
  672. }).catch(rej => {
  673. wx.showModal({
  674. title: '',
  675. content: '删除订单失败, 请检查您的网络状态',
  676. showCancel: false
  677. });
  678. });
  679. },
  680. setData: function (obj) {
  681. let that = this;
  682. let keys = [];
  683. let val, data;
  684. Object.keys(obj).forEach(function (key) {
  685. keys = key.split('.');
  686. val = obj[key];
  687. data = that.$data;
  688. keys.forEach(function (key2, index) {
  689. if (index + 1 == keys.length) {
  690. that.$set(data, key2, val);
  691. } else {
  692. if (!data[key2]) {
  693. that.$set(data, key2, {});
  694. }
  695. }
  696. data = data[key2];
  697. });
  698. });
  699. }
  700. },
  701. computed: {},
  702. watch: {}
  703. };
  704. </script>
  705. <style rel="stylesheet/less" lang="less">
  706. @import "index";
  707. </style>