myorder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view>
  3. <view class="top-tabbar">
  4. <view :class="state_active == 0 ? 'tab-item active' : 'tab-item'" @click="stateFunc(0)">全部订单</view>
  5. <view :class="state_active == 1 ? 'tab-item active' : 'tab-item'" @click="stateFunc(1)">待付款</view>
  6. <view :class="state_active == 2 ? 'tab-item active' : 'tab-item'" @click="stateFunc(2)">待发货</view>
  7. <view :class="state_active == 3 ? 'tab-item active' : 'tab-item'" @click="stateFunc(3)">待收货</view>
  8. <view :class="state_active == 4 ? 'tab-item active' : 'tab-item'" @click="stateFunc(4)">待评价</view>
  9. </view>
  10. <!--列表-->
  11. <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
  12. @scrolltolower="scrolltolowerFunc">
  13. <view :class="topRefresh ? 'top-refresh open' : 'top-refresh'">
  14. <view class="circle" v-for="(circle, n) in 3" :key="n"></view>
  15. </view>
  16. <view class="order-list">
  17. <view class="item" v-for="(item, index) in listData" :key="index">
  18. <view class="order-head d-b-c">
  19. <view>
  20. <text class="state-text">{{ item.order_source_text }}</text>
  21. <text class="shop-name flex-1 fb">订单号:{{ item.order_no }}</text>
  22. </view>
  23. <view class="state">
  24. <text class="red">{{ item.state_text }}</text>
  25. </view>
  26. </view>
  27. <!--多个商品显示-->
  28. <view class="product-list pr" v-if="item.product.length > 1" @click="gotoOrder(item.order_id)">
  29. <scroll-view scroll-x="true">
  30. <view class="list d-s-c pr100">
  31. <view class="cover mr10" v-for="(img, num) in item.product" :key="num">
  32. <image :src="img.image.file_path" mode="aspectFit"></image>
  33. </view>
  34. </view>
  35. </scroll-view>
  36. <view class="total-count">
  37. <view class="left-shadow"></view>
  38. <view class="price f22">
  39. ¥
  40. <text class="f40">{{ item.order_price }}</text>
  41. </view>
  42. <view class="count">共{{ item.product.length }}件</view>
  43. </view>
  44. </view>
  45. <!--一个商品显示-->
  46. <view class="one-product d-s-c" v-else @click="gotoOrder(item.order_id)">
  47. <view class="cover" v-for="(img, num) in item.product" :key="num">
  48. <image :src="img.image.file_path" mode="aspectFit"></image>
  49. </view>
  50. <view class="pro-info flex-1">{{ item.product[0].product_name }}</view>
  51. <view class="total-count">
  52. <view class="left-shadow"></view>
  53. <view class="price f22">
  54. ¥
  55. <text class="f40">{{ item.pay_price }}</text>
  56. </view>
  57. <view class="count">共{{ item.product[0].total_num }}件</view>
  58. </view>
  59. </view>
  60. <view class="order-bts">
  61. <block v-if="item.order_status.value != 20">
  62. <!-- 未支付取消订单 -->
  63. <button @click="cancelOrder(item.order_id)" type="default" v-if="item.pay_status.value == 10">取消</button>
  64. <!-- 已支付取消订单 -->
  65. <block v-if="item.order_status.value != 21">
  66. <block v-if="item.pay_status.value == 20 && item.delivery_status.value == 10">
  67. <button @click="cancelOrder(item.order_id)" type="default">申请取消</button>
  68. </block>
  69. <!-- 订单核销码 -->
  70. <block v-if="item.pay_status.value == 20 && item.delivery_type.value == 20 && item.delivery_status.value == 10">
  71. <button @click="onQRCode(item.order_id)">核销码</button>
  72. </block>
  73. </block>
  74. <text v-else class="count">取消申请中</text>
  75. <!-- 订单付款 -->
  76. <block v-if="item.pay_status.value == 10"><button class="btn-red" @click="onPayOrder(item.order_id)">付款</button></block>
  77. <!-- 确认收货 -->
  78. <block v-if="item.delivery_status.value == 20 && item.receipt_status.value == 10"><button @click="orderReceipt(item.order_id)">确认收货</button></block>
  79. <!-- 订单评价 -->
  80. <button type="default" v-if="item.order_status.value == 30 && item.is_comment == 0" @click="gotoEvaluate(item.order_id)">评价</button>
  81. </block>
  82. <template v-if="item.assemble_status == 10 && item.order_source == 30">
  83. <button class="btn-red" @click="gotoAssembleShare(item.product[0].bill_source_id)">邀请好友拼单</button>
  84. </template>
  85. </view>
  86. </view>
  87. <view class="d-c-c p30" v-if="listData.length == 0 && !loading">
  88. <text class="iconfont icon-wushuju"></text>
  89. <text class="cont">亲,暂无相关记录哦</text>
  90. </view>
  91. <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
  92. </view>
  93. </scroll-view>
  94. <!--支付选择-->
  95. <Popup :show="isPayPopup" msg="支付方式" @hidePopup="hidePopupFunc">
  96. <!--支付方式-->
  97. <view class="buy-checkout">
  98. <view :class="pay_type == 20 ? 'item active border-b-e' : 'item border-b-e'" @click="payTypeFunc(20)">
  99. <view class="d-s-c">
  100. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
  101. <text class="key">微信支付</text>
  102. </view>
  103. <view class="icon-box d-c-c"></view>
  104. </view>
  105. <view v-if="showAlipay" :class="pay_type == 30 ? 'item active border-b-e' : 'item border-b-e'" @click="payTypeFunc(30)">
  106. <view class="d-s-c">
  107. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-zhifubao"></span></view>
  108. <text class="key">支付宝支付</text>
  109. </view>
  110. <view class="icon-box d-c-c"></view>
  111. </view>
  112. <view :class="pay_type == 10 ? 'item active' : 'item'" @click="payTypeFunc(10)">
  113. <view class="d-s-c">
  114. <view class="icon-box d-c-c mr10"><span class="icon iconfont icon-yue"></span></view>
  115. <text class="key">余额支付</text>
  116. </view>
  117. <view class="icon-box d-c-c"></view>
  118. </view>
  119. </view>
  120. <view class="bts"></view>
  121. </Popup>
  122. <!--核销二维码-->
  123. <Popup :show="isCodeImg" type="middle" @hidePopup="hideCodePopupFunc">
  124. <view class="ww100 p20 box-s-b">
  125. <image class="ww100" :src="codeImg" mode="widthFix"></image>
  126. </view>
  127. </Popup>
  128. </view>
  129. </template>
  130. <script>
  131. import Popup from '@/components/uni-popup.vue';
  132. import uniLoadMore from '@/components/uni-load-more.vue';
  133. import {
  134. pay
  135. } from '@/common/pay.js';
  136. export default {
  137. components: {
  138. Popup,
  139. uniLoadMore
  140. },
  141. data() {
  142. return {
  143. /*手机高度*/
  144. phoneHeight: 0,
  145. /*可滚动视图区域高度*/
  146. scrollviewHigh: 0,
  147. /*状态选中*/
  148. state_active: 0,
  149. /*顶部刷新*/
  150. topRefresh: false,
  151. /*数据*/
  152. listData: [],
  153. /*数据类别*/
  154. dataType: 'all',
  155. /*是否显示支付类别弹窗*/
  156. isPayPopup: false,
  157. /*支付方式*/
  158. pay_type: 20,
  159. /*订单id*/
  160. order_id: 0,
  161. /*最后一页码数*/
  162. last_page: 0,
  163. /*当前页面*/
  164. page: 1,
  165. /*每页条数*/
  166. list_rows: 10,
  167. /*有没有等多*/
  168. no_more: false,
  169. /*是否正在加载*/
  170. loading: true,
  171. /*是否显示核销二维码*/
  172. isCodeImg: false,
  173. codeImg: '',
  174. /*是否显示支付宝支付,只有在h5,非微信内打开才显示*/
  175. showAlipay: false
  176. };
  177. },
  178. computed: {
  179. /*加载中状态*/
  180. loadingType() {
  181. if (this.loading) {
  182. return 1;
  183. } else {
  184. if (this.listData.length != 0 && this.no_more) {
  185. return 2;
  186. } else {
  187. return 0;
  188. }
  189. }
  190. }
  191. },
  192. onLoad(e) {
  193. if (typeof e.dataType != 'undefined') {
  194. this.dataType = e.dataType;
  195. }
  196. if (this.dataType == 'payment') {
  197. this.state_active = 1;
  198. } else if (this.dataType == 'received') {
  199. this.state_active = 3;
  200. } else if (this.dataType == 'comment') {
  201. this.state_active = 4;
  202. } else if (this.dataType == 'delivery') {
  203. this.state_active = 2;
  204. }
  205. },
  206. mounted() {
  207. this.init();
  208. /*获取订单列表*/
  209. this.getData();
  210. },
  211. methods: {
  212. /*初始化*/
  213. init() {
  214. let self = this;
  215. uni.getSystemInfo({
  216. success(res) {
  217. self.phoneHeight = res.windowHeight;
  218. // 计算组件的高度
  219. let view = uni.createSelectorQuery().select('.top-tabbar');
  220. view.boundingClientRect(data => {
  221. let h = self.phoneHeight - data.height;
  222. self.scrollviewHigh = h;
  223. }).exec();
  224. }
  225. });
  226. },
  227. /*状态切换*/
  228. stateFunc(e) {
  229. let self = this;
  230. if (self.state_active != e) {
  231. self.page = 1;
  232. self.loading = true;
  233. self.state_active = e;
  234. switch (e) {
  235. case 0:
  236. self.listData = [];
  237. self.dataType = 'all';
  238. break;
  239. case 1:
  240. self.listData = [];
  241. self.dataType = 'payment';
  242. break;
  243. case 2:
  244. self.listData = [];
  245. self.dataType = 'delivery';
  246. break;
  247. case 3:
  248. self.listData = [];
  249. self.dataType = 'received';
  250. break;
  251. case 4:
  252. self.listData = [];
  253. self.dataType = 'comment';
  254. break;
  255. }
  256. self.getData();
  257. }
  258. },
  259. /*可滚动视图区域到底触发*/
  260. scrolltolowerFunc() {
  261. let self = this;
  262. if (self.no_more) {
  263. return;
  264. }
  265. self.page++;
  266. if (self.page <= self.last_page) {
  267. self.getData();
  268. } else {
  269. self.no_more = true;
  270. }
  271. },
  272. /*获取数据*/
  273. getData() {
  274. let self = this;
  275. self.loading = true;
  276. let dataType = self.dataType;
  277. self._get(
  278. 'user.order/lists', {
  279. dataType: dataType,
  280. page: self.page,
  281. list_rows: self.list_rows
  282. },
  283. function(res) {
  284. self.loading = false;
  285. self.listData = self.listData.concat(res.data.list.data);
  286. self.last_page = res.data.list.last_page;
  287. if (res.data.list.last_page <= 1) {
  288. self.no_more = true;
  289. } else {
  290. self.no_more = false;
  291. }
  292. //#ifdef H5
  293. if (!self.isWeixin() && res.data.h5_alipay) {
  294. self.showAlipay = true;
  295. }
  296. //#endif
  297. }
  298. );
  299. },
  300. /*跳转页面*/
  301. gotoOrder(e) {
  302. this.gotoPage('/pages/order/order-detail?order_id=' + e);
  303. },
  304. /*隐藏支付方式*/
  305. hidePopupFunc() {
  306. this.isPayPopup = false;
  307. },
  308. /*去支付*/
  309. payTypeFunc(payType) {
  310. let self = this;
  311. self.isPayPopup = false;
  312. uni.showLoading({
  313. title: '加载中'
  314. });
  315. self._post(
  316. 'user.order/pay', {
  317. payType: payType,
  318. order_id: self.order_id,
  319. pay_source: self.getPlatform()
  320. },
  321. function(res) {
  322. pay(res, self);
  323. }
  324. );
  325. },
  326. /*支付方式选择*/
  327. onPayOrder(orderId) {
  328. let self = this;
  329. self.isPayPopup = true;
  330. self.order_id = orderId;
  331. },
  332. /*确认收货*/
  333. orderReceipt(order_id) {
  334. let self = this;
  335. wx.showModal({
  336. title: '提示',
  337. content: '您确定要收货吗?',
  338. success: function(o) {
  339. if (o.confirm) {
  340. uni.showLoading({
  341. title: '正在处理'
  342. });
  343. self._post(
  344. 'user.order/receipt', {
  345. order_id: order_id
  346. },
  347. function(res) {
  348. uni.hideLoading();
  349. uni.showToast({
  350. title: res.msg,
  351. duration: 2000,
  352. icon: 'success'
  353. });
  354. self.listData = [];
  355. self.getData();
  356. }
  357. );
  358. } else {
  359. uni.showToast({
  360. title: '取消收货',
  361. duration: 1000,
  362. icon: 'none'
  363. });
  364. }
  365. }
  366. });
  367. },
  368. /*取消订单*/
  369. cancelOrder(e) {
  370. let self = this;
  371. let order_id = e;
  372. wx.showModal({
  373. title: '提示',
  374. content: '您确定要取消吗?',
  375. success: function(o) {
  376. if (o.confirm) {
  377. uni.showLoading({
  378. title: '正在处理'
  379. });
  380. self._get(
  381. 'user.order/cancel', {
  382. order_id: order_id
  383. },
  384. function(res) {
  385. uni.hideLoading();
  386. uni.showToast({
  387. title: '操作成功',
  388. duration: 2000,
  389. icon: 'success'
  390. });
  391. self.listData = [];
  392. self.getData();
  393. }
  394. );
  395. }
  396. }
  397. });
  398. },
  399. /*去评论*/
  400. gotoEvaluate(e) {
  401. this.gotoPage('/pages/order/evaluate/evaluate?order_id=' + e);
  402. },
  403. /*核销码*/
  404. onQRCode(e) {
  405. let self = this;
  406. uni.showLoading({
  407. title: '加载中'
  408. });
  409. let order_id = e;
  410. self._get(
  411. 'user.order/qrcode', {
  412. order_id: order_id,
  413. source: self.getPlatform()
  414. },
  415. function(res) {
  416. uni.hideLoading();
  417. self.isCodeImg = true;
  418. self.codeImg = res.data.qrcode;
  419. }
  420. );
  421. },
  422. /*关闭核销二维码*/
  423. hideCodePopupFunc() {
  424. this.isCodeImg = false;
  425. },
  426. /*分享拼团*/
  427. gotoAssembleShare(e) {
  428. let url = '/pages/plus/assemble/fight-group-detail/fight-group-detail?assemble_bill_id=' + e;
  429. this.gotoPage(url);
  430. }
  431. }
  432. };
  433. </script>
  434. <style lang="scss">
  435. page {
  436. background-color: #f2f2f2;
  437. }
  438. .top-tabbar {
  439. height: 96rpx;
  440. }
  441. .order-list .order-head .state-text {
  442. padding: 10rpx 12rpx;
  443. margin-right: 21rpx;
  444. border-radius: 4rpx;
  445. background: #FFE7E4;
  446. font-size: 22rpx;
  447. color: #F6220C;
  448. }
  449. .shop-name {
  450. font-size: 26rpx;
  451. font-family: PingFang SC;
  452. font-weight: 500;
  453. color: #333333;
  454. }
  455. .order-list .item {
  456. margin-bottom: 30rpx;
  457. padding: 30rpx;
  458. background: #ffffff;
  459. }
  460. .order-list .product-list,
  461. .order-list .one-product {
  462. padding: 30rpx 0 27rpx 0;
  463. height: 150rpx;
  464. }
  465. .one-product .pro-info {
  466. padding: 0 21rpx 0 37rpx;
  467. display: -webkit-box;
  468. width: 361rpx;
  469. overflow: hidden;
  470. -webkit-line-clamp: 2;
  471. -webkit-box-orient: vertical;
  472. font-size: 26rpx;
  473. color: #333333;
  474. }
  475. .order-list .cover,
  476. .order-list .cover image {
  477. width: 150rpx;
  478. height: 150rpx;
  479. border-radius: 8rpx;
  480. }
  481. .order-list .total-count {
  482. padding-left: 20rpx;
  483. display: flex;
  484. flex-direction: column;
  485. justify-content: center;
  486. align-items: flex-end;
  487. }
  488. .total-count .count {
  489. padding-top: 16rpx;
  490. color: #999999;
  491. font-size: 22rpx;
  492. }
  493. .product-list .total-count {
  494. position: absolute;
  495. top: 0;
  496. right: 0;
  497. bottom: 0;
  498. background: rgba(255, 255, 255, 0.9);
  499. }
  500. .product-list .total-count .left-shadow {
  501. position: absolute;
  502. top: 0;
  503. bottom: 0;
  504. left: -24rpx;
  505. width: 24rpx;
  506. overflow: hidden;
  507. }
  508. .product-list .total-count .left-shadow::after {
  509. position: absolute;
  510. top: 0;
  511. bottom: 0;
  512. width: 24rpx;
  513. right: -12rpx;
  514. display: block;
  515. content: '';
  516. background-image: radial-gradient(rgba(0, 0, 0, 0.2) 10%, rgba(0, 0, 0, 0.1) 40%, rgba(0, 0, 0, 0) 80%);
  517. }
  518. .order-list .order-bts {
  519. display: flex;
  520. justify-content: flex-end;
  521. align-items: center;
  522. }
  523. .order-list .order-bts button {
  524. margin: 0;
  525. padding: 0 30rpx;
  526. height: 60rpx;
  527. line-height: 60rpx;
  528. margin-left: 20rpx;
  529. font-size: 32rpx;
  530. border: 1px solid #F6220C;
  531. border-radius: 30px;
  532. background: #ffffff;
  533. white-space: nowrap;
  534. color: #F6220C;
  535. font-family: PingFang SC;
  536. }
  537. .order-list .order-bts button::after {
  538. display: none;
  539. }
  540. .order-list .order-bts button.btn-border-red {
  541. border: 1px solid $dominant-color;
  542. font-size: 24rpx;
  543. color: $dominant-color;
  544. }
  545. .order-list .order-bts button.btn-red {
  546. background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
  547. border-radius: 30rpx;
  548. font-size: 32rpx;
  549. font-family: PingFang SC;
  550. color: #ffffff;
  551. border: none;
  552. }
  553. .buy-checkout {
  554. width: 100%;
  555. }
  556. .buy-checkout .item {
  557. min-height: 50rpx;
  558. line-height: 50rpx;
  559. padding: 20rpx;
  560. display: flex;
  561. justify-content: space-between;
  562. font-size: 28rpx;
  563. }
  564. .buy-checkout .iconfont.icon-weixin {
  565. color: #04be01;
  566. font-size: 50rpx;
  567. }
  568. .buy-checkout .iconfont.icon-yue {
  569. color: #f0de7c;
  570. font-size: 50rpx;
  571. }
  572. .buy-checkout .item.active .iconfont.icon-xuanze {
  573. color: #04be01;
  574. }
  575. .item-dianpu {
  576. display: flex;
  577. justify-content: space-between;
  578. align-items: center;
  579. font-size: 24rpx;
  580. line-height: 30rpx;
  581. }
  582. .item-dianpu .icon-jiantou {
  583. font-size: 24rpx;
  584. color: #333333;
  585. }
  586. .item-d-l {
  587. display: flex;
  588. }
  589. .icon-dianpu1 {
  590. margin-right: 20rpx;
  591. color: #333333;
  592. font-size: 32rpx;
  593. }
  594. </style>