index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <template>
  2. <!-- pages/shopOrder/index.wxml -->
  3. <view class="container">
  4. <van-tabs :active="active" class="custom_tabs" line-width="20" line-height="2" :swipe-threshold="6" :border="false" @click="onClickTab">
  5. <van-tab title="全部" :name="-1"></van-tab>
  6. <van-tab title="未支付" :name="0"></van-tab>
  7. <van-tab title="待发货" :name="1"></van-tab>
  8. <van-tab title="待自提" :name="2"></van-tab>
  9. <van-tab title="已完成" :name="3"></van-tab>
  10. </van-tabs>
  11. <view class="orderList">
  12. <!--
  13. <view class="order" v-for="(order,order.id) in (orderList)" :key="order.id">
  14. <view class="user_info">
  15. <image class="thumb" :src="order.user.thumb"></image>
  16. <view class="nickname">{{ order.user.nickname }}</view>
  17. </view>
  18. <view class="order_t">
  19. <view class="order_t_l">
  20. <view :class="order.fare_type == 1 ? 'order_type ziti' : 'order_type waimai'">{{ order.fare_type == 1 ? '自提' : '外卖' }}</view>
  21. <view class="order_time">{{ order.created_at }}</view>
  22. </view>
  23. <view class="order_status">{{ order.statusTitle }}</view>
  24. </view>
  25. <view class="order_goods" v-for="(order_goods,order_goods.id) in (order.order_good)" :key="order_goods.id">
  26. <view class="order_goods_l">
  27. <image class="goods_thumb" :src="imgUrl + order_goods.good_thumb"></image>
  28. <view class="goods_info">
  29. <view class="goods_title">{{ order_goods.good_title }}</view>
  30. <view class="goods_labels" v-if="order_goods.good_specs">
  31. <view class="label">{{ order_goods.good_specs.title }}</view>
  32. </view>
  33. <view class="goods_num">x{{ order_goods.nums }}</view>
  34. </view>
  35. </view>
  36. <view class="order_goods_r">
  37. <view class="goods_price">
  38. <text class="cash_tag">¥</text>
  39. <text class="cash_num">{{ order_goods.add_good_rule_id ? order_goods.add_price : order_goods.price }}</text>
  40. </view>
  41. <view class="goods_vip_price" v-if="!order_goods.add_good_rule_id">
  42. <text class="cash_tag">¥</text>
  43. <text class="cash_num">{{ order_goods.member_price }}</text>
  44. <text class="vip_tag">会员价</text>
  45. </view>
  46. <view class="goods_def_price" v-if="order_goods.add_good_rule_id">
  47. 原价
  48. <text class="price">¥20.00</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="order_address" v-if="order.address">
  53. <view class="icon_wrap">
  54. <image class="icon_address" src="/static/statics/img/address.png"></image>
  55. </view>
  56. <view class="order_user_info">
  57. <view class="address">{{ order.address }}</view>
  58. <view class="address">
  59. <text class="info">{{ order.person }}</text>
  60. <text class="info">{{ order.phone }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="yunfei" v-if="order.delivery_fee != 0">
  65. <view class="f-l">配送费</view>
  66. <view class="f-r price">¥{{ order.delivery_fee }}</view>
  67. </view>
  68. <view class="order_pay">
  69. <view class="order_pay_l">
  70. <view class="heji">
  71. <text class="sum">共{{ order.goods_total_nums }}件商品</text>
  72. <text class="sum_txt">合计</text>
  73. </view>
  74. <view class="heji_price">
  75. <view class="price">¥{{ order.pay_price }}</view>
  76. </view>
  77. </view>
  78. <view class="order_pay_r">
  79. <view
  80. :class="order.fare_type == 1 ? 'btn_pay ziti' : 'btn_pay waimai'"
  81. v-if="order.order_status == 1 && order.pay_status == 1 && order.ship_status == 0"
  82. :data-order="order"
  83. @tap="toHandle"
  84. >
  85. {{ order.fare_type == 1 ? '自提' : '发货' }}
  86. </view>
  87. <view class="btn_pay cancle" v-if="order.ship_status == 0 && order.order_status == 1" :data-order="order" @tap="cancleOrder">取消订单</view>
  88. </view>
  89. </view>
  90. </view>
  91. -->
  92. </view>
  93. </view>
  94. <!-- loading -->
  95. <!-- <van-overlay show="{{ loading }}" z-index="100">
  96. <van-loading custom-class="custom_loading" />
  97. </van-overlay> -->
  98. </template>
  99. <script>
  100. // pages/shopOrder/index.js
  101. let myPro = require('../../../utils/wxRequest.js');
  102. let util = require('../../../utils/util.js');
  103. export default {
  104. data() {
  105. return {
  106. imgUrl: getApp().globalData.imgUrl,
  107. active: null,
  108. // null全部 0未支付 1待发货 2待自提 3已完成
  109. orderList: [],
  110. page: 1,
  111. size: 10,
  112. finished: false,
  113. // 全局loading
  114. loading: false,
  115. order: {
  116. id: '',
  117. user: {
  118. thumb: '',
  119. nickname: ''
  120. },
  121. fare_type: 0,
  122. created_at: '',
  123. statusTitle: '',
  124. order_good: [],
  125. address: '',
  126. person: '',
  127. phone: '',
  128. delivery_fee: 0,
  129. goods_total_nums: '',
  130. pay_price: '',
  131. order_status: 0,
  132. pay_status: 0,
  133. ship_status: 0
  134. },
  135. order_goods: {
  136. id: '',
  137. good_thumb: '',
  138. good_title: '',
  139. good_specs: {
  140. title: ''
  141. },
  142. nums: '',
  143. add_good_rule_id: false,
  144. add_price: '',
  145. price: '',
  146. member_price: ''
  147. }
  148. };
  149. }
  150. /**
  151. * 生命周期函数--监听页面加载
  152. */,
  153. onLoad: function (options) {
  154. var that = this;
  155. if (options.status != null) {
  156. that.setData({
  157. active: parseInt(options.status)
  158. });
  159. }
  160. that.getOrderList();
  161. },
  162. /**
  163. * 生命周期函数--监听页面初次渲染完成
  164. */
  165. onReady: function () {},
  166. /**
  167. * 生命周期函数--监听页面显示
  168. */
  169. onShow: function () {
  170. let that = this;
  171. },
  172. /**
  173. * 生命周期函数--监听页面隐藏
  174. */
  175. onHide: function () {},
  176. /**
  177. * 生命周期函数--监听页面卸载
  178. */
  179. onUnload: function () {},
  180. /**
  181. * 页面相关事件处理函数--监听用户下拉动作
  182. */
  183. onPullDownRefresh: function () {},
  184. /**
  185. * 页面上拉触底事件的处理函数
  186. */
  187. onReachBottom: function () {
  188. // console.log('上拉触底事件')
  189. let that = this;
  190. if (!that.finished) {
  191. that.getOrderList();
  192. }
  193. },
  194. methods: {
  195. // 获取商家订单列表
  196. getOrderList() {
  197. let that = this;
  198. let params = {
  199. page: that.page,
  200. size: that.size
  201. };
  202. if (that.active != -1) {
  203. params.status = that.active;
  204. }
  205. myPro
  206. .wxRequest('store/order/list', 'GET', params)
  207. .then((res) => {
  208. let tempList = res.result;
  209. let list = that.orderList; // 无数据
  210. if (tempList.length == 0) {
  211. uni.showToast({
  212. title: '暂无更多数据',
  213. icon: 'none'
  214. });
  215. that.setData({
  216. finished: true
  217. });
  218. } else {
  219. // 有数据
  220. for (let i in tempList) {
  221. // 订单状态
  222. if (tempList[i].order_status == 0) {
  223. tempList[i].statusTitle = '已关闭';
  224. } else if (tempList[i].order_status == 2) {
  225. tempList[i].statusTitle = '已完成';
  226. } else if (tempList[i].order_status == 1) {
  227. // 正常订单
  228. if (tempList[i].pay_status == 0) {
  229. tempList[i].statusTitle = '待支付';
  230. } else if (tempList[i].pay_status == 1) {
  231. if (tempList[i].ship_status == 0) {
  232. // fare_type 0邮寄 1自提
  233. if (tempList[i].fare_type == 0) {
  234. tempList[i].statusTitle = '待发货';
  235. } else if (tempList[i].fare_type == 1) {
  236. tempList[i].statusTitle = '待自提';
  237. }
  238. }
  239. } else if (tempList[i].pay_status == 2) {
  240. // fare_type 0邮寄 1自提
  241. if (tempList[i].fare_type == 0) {
  242. tempList[i].statusTitle = '已发货';
  243. } else if (tempList[i].fare_type == 1) {
  244. tempList[i].statusTitle = '已自提';
  245. }
  246. }
  247. } // 订单的商品总数
  248. let order_goods = tempList[i].order_good;
  249. let nums = 0;
  250. for (let j in order_goods) {
  251. nums = nums + parseInt(order_goods[j].nums);
  252. }
  253. tempList[i].goods_total_nums = nums; // 商品总数,也应该接口返回(现在没有,就先自己总)
  254. }
  255. list = list.concat(tempList); // 计算总价 (不计算了,直接拿pay_price,这里还有优惠券)
  256. // for(let i in list){
  257. // list[i].totalPrice = parseFloat(list[i].price) + parseFloat(list[i].delivery_fee);
  258. // list[i].totalMemberPrice = parseFloat(list[i].member_price) + parseFloat(list[i].delivery_fee)
  259. // };
  260. that.setData({
  261. orderList: list,
  262. page: that.page + 1
  263. });
  264. }
  265. })
  266. .catch((err) => {
  267. // that.setData({
  268. // loading: false
  269. // });
  270. console.log('报错信息', err);
  271. uni.showToast({
  272. title: err,
  273. icon: 'none'
  274. });
  275. });
  276. },
  277. // 切换列表
  278. onClickTab(event) {
  279. // console.log('event=====',event);
  280. let that = this;
  281. that.setData({
  282. active: event.detail.name,
  283. page: 1,
  284. orderList: []
  285. });
  286. that.getOrderList();
  287. },
  288. // 处理订单(发货)
  289. toHandle(event) {
  290. let that = this; // console.log(event)
  291. let order = event.currentTarget.dataset.order;
  292. let params = {
  293. order_id: order.id
  294. };
  295. myPro
  296. .wxRequest('store/order/ship', 'POST', params)
  297. .then((res) => {
  298. uni.showToast({
  299. title: res.msg,
  300. icon: 'none'
  301. });
  302. that.setData({
  303. page: 1,
  304. orderList: [],
  305. finished: false
  306. });
  307. that.getOrderList();
  308. })
  309. .catch((err) => {
  310. console.log('报错信息', err);
  311. uni.showToast({
  312. title: err,
  313. icon: 'none'
  314. });
  315. });
  316. },
  317. // 处理订单(取消)
  318. cancleOrder(event) {
  319. let that = this;
  320. let order = event.currentTarget.dataset.order;
  321. let params = {
  322. order_id: order.id
  323. };
  324. myPro
  325. .wxRequest('store/tx/cancelOrder', 'POST', params)
  326. .then((res) => {
  327. uni.showToast({
  328. title: res.msg,
  329. icon: 'none'
  330. });
  331. that.setData({
  332. page: 1,
  333. orderList: [],
  334. finished: false
  335. });
  336. that.getOrderList();
  337. })
  338. .catch((err) => {
  339. console.log('报错信息', err);
  340. uni.showToast({
  341. title: err,
  342. icon: 'none'
  343. });
  344. });
  345. }
  346. }
  347. };
  348. </script>
  349. <style>
  350. /* pages/shopOrder/index.wxss */
  351. /* tab */
  352. .van-tabs__scroll--line {
  353. height: auto !important;
  354. }
  355. .van-tabs {
  356. border-bottom: 1rpx solid rgba(243, 244, 249, 1);
  357. }
  358. .van-tabs__line {
  359. width: 40rpx !important;
  360. height: 4rpx;
  361. background: rgba(211, 68, 68, 1);
  362. border-radius: 2rpx !important;
  363. }
  364. .van-tab,
  365. .van-tab .van-ellipsis {
  366. padding: 0 !important;
  367. font-size: 30rpx;
  368. color: rgba(0, 0, 0, 1);
  369. }
  370. .van-tab--active,
  371. .van-tab--active .van-ellipsis {
  372. color: rgba(211, 68, 68, 1);
  373. }
  374. /* 订单列表 */
  375. .orderList {
  376. padding: 90rpx 30rpx 0;
  377. }
  378. .orderList .order {
  379. margin-top: 30rpx;
  380. background: rgba(255, 255, 255, 1);
  381. box-shadow: 0rpx 0rpx 21rpx 0rpx rgba(0, 0, 0, 0.09);
  382. border-radius: 10rpx;
  383. padding: 0 30rpx;
  384. }
  385. .orderList .order:last-child {
  386. margin-bottom: 30rpx;
  387. }
  388. .order .order_t {
  389. display: flex;
  390. align-items: center;
  391. justify-content: space-between;
  392. height: 90rpx;
  393. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  394. }
  395. .order .order_t_l {
  396. display: flex;
  397. align-items: center;
  398. }
  399. .order .order_type {
  400. width: 75rpx;
  401. height: 31rpx;
  402. border-radius: 5rpx;
  403. font-size: 24rpx;
  404. color: rgba(255, 255, 255, 1);
  405. text-align: center;
  406. line-height: 31rpx;
  407. background: #295c56;
  408. }
  409. /* .order .order_type.ziti{
  410. background:rgba(85,141,255,1);
  411. }
  412. .order .order_type.waimai{
  413. background:rgba(213,76,67,1);
  414. } */
  415. .order .order_time {
  416. font-size: 26rpx;
  417. color: rgba(0, 0, 0, 0.45);
  418. padding-left: 20rpx;
  419. }
  420. .order .order_status {
  421. font-size: 30rpx;
  422. color: rgba(255, 109, 29, 1);
  423. }
  424. .order .order_goods {
  425. padding: 30rpx 0;
  426. display: flex;
  427. justify-content: space-between;
  428. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  429. }
  430. .order .order_goods_l {
  431. display: flex;
  432. }
  433. .order .goods_thumb {
  434. width: 127rpx;
  435. height: 127rpx;
  436. border-radius: 10rpx;
  437. overflow: hidden;
  438. }
  439. .order .goods_info {
  440. display: flex;
  441. flex-direction: column;
  442. justify-content: space-between;
  443. padding-left: 18rpx;
  444. }
  445. .order .goods_title {
  446. font-size: 32rpx;
  447. color: rgba(0, 0, 0, 1);
  448. }
  449. .order .goods_num {
  450. font-size: 28rpx;
  451. color: rgba(0, 0, 0, 0.54);
  452. }
  453. .order .order_goods_r {
  454. color: rgba(211, 68, 68, 1);
  455. }
  456. .order .cash_tag {
  457. font-size: 26rpx;
  458. }
  459. .order .cash_num {
  460. font-size: 42rpx;
  461. padding-left: 10rpx;
  462. }
  463. .order .goods_vip_price .cash_num {
  464. font-size: 26rpx;
  465. padding-left: 0;
  466. }
  467. .order .order_address {
  468. padding: 30rpx 0;
  469. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  470. display: flex;
  471. align-items: center;
  472. }
  473. .order .icon_wrap {
  474. width: 29rpx;
  475. height: 35rpx;
  476. }
  477. .order .icon_address {
  478. width: 29rpx;
  479. height: 35rpx;
  480. }
  481. .order .address {
  482. padding-left: 15rpx;
  483. font-size: 30rpx;
  484. color: rgba(0, 0, 0, 1);
  485. }
  486. .order .order_pay {
  487. padding: 30rpx 0;
  488. font-size: 26rpx;
  489. display: flex;
  490. justify-content: space-between;
  491. }
  492. .order .order_pay_l {
  493. display: flex;
  494. }
  495. .order .order_pay .heji {
  496. color: rgba(0, 0, 0, 1);
  497. }
  498. .order .sum_txt {
  499. padding-left: 10rpx;
  500. }
  501. .order .order_pay .heji_price {
  502. color: rgba(211, 68, 68, 1);
  503. display: flex;
  504. flex-direction: column;
  505. padding-left: 10rpx;
  506. }
  507. .order .btn_pay {
  508. width: 179rpx;
  509. height: 59rpx;
  510. border-radius: 30rpx;
  511. font-size: 32rpx;
  512. color: rgba(255, 255, 255, 1);
  513. text-align: center;
  514. line-height: 59rpx;
  515. }
  516. .order .btn_pay.ziti {
  517. background: rgba(100, 200, 133, 1);
  518. }
  519. .order .btn_pay.waimai {
  520. background: rgba(100, 150, 252, 1);
  521. }
  522. /* 会员价 */
  523. .vip_tag {
  524. width: 57rpx;
  525. height: 20rpx;
  526. line-height: 20rpx;
  527. background: rgba(213, 76, 67, 1);
  528. color: #fff;
  529. font-size: 16rpx;
  530. text-align: center;
  531. display: inline-block;
  532. margin-left: 12rpx;
  533. position: relative;
  534. }
  535. .vip_tag::before {
  536. content: '';
  537. position: absolute;
  538. left: -6rpx;
  539. top: 0;
  540. width: 0;
  541. height: 0;
  542. border-left: 6rpx solid transparent;
  543. border-right: 6rpx solid transparent;
  544. border-top: 6rpx solid rgba(213, 76, 67, 1);
  545. display: block;
  546. }
  547. /* 运费 */
  548. .yunfei {
  549. display: flex;
  550. justify-content: space-between;
  551. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  552. padding: 30rpx 0;
  553. font-size: 26rpx;
  554. }
  555. .yunfei .price {
  556. color: rgba(211, 68, 68, 1);
  557. }
  558. /* 顾客信息 */
  559. .address .info {
  560. padding-left: 10rpx;
  561. }
  562. .address .info:first-child {
  563. padding-left: 0;
  564. }
  565. .user_info {
  566. display: flex;
  567. align-items: center;
  568. padding: 30rpx 0 10rpx;
  569. border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
  570. }
  571. .user_info .thumb {
  572. width: 100rpx;
  573. height: 100rpx;
  574. border-radius: 50%;
  575. }
  576. .user_info .nickname {
  577. padding-left: 30rpx;
  578. white-space: nowrap;
  579. text-overflow: ellipsis;
  580. overflow: hidden;
  581. }
  582. /* 固定tab的位置 */
  583. .custom_tabs {
  584. width: 100%;
  585. position: fixed;
  586. top: 0;
  587. left: 0;
  588. z-index: 1;
  589. }
  590. /* 规格名 */
  591. .goods_labels {
  592. display: flex;
  593. flex-wrap: wrap;
  594. font-size: 24rpx;
  595. color: rgba(8, 8, 8, 0.54);
  596. width: 320rpx;
  597. }
  598. .goods_labels .label {
  599. padding: 6rpx;
  600. background: #f6f6f6;
  601. margin: 10rpx 14rpx 0 0;
  602. }
  603. /* 商品原价 */
  604. .order .goods_def_price {
  605. font-size: 26rpx;
  606. color: rgba(8, 8, 8, 0.54);
  607. }
  608. .order .goods_def_price .price {
  609. text-decoration: line-through;
  610. }
  611. /* 取消订单 */
  612. .order .btn_pay.cancle {
  613. background: rgba(0, 0, 0, 0.4);
  614. margin-top: 10rpx;
  615. }
  616. </style>