orderSC.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <view class="content">
  3. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  4. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  5. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  6. <!-- 空白页 -->
  7. <u-empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></u-empty>
  8. <!-- 订单列表 -->
  9. <view v-for="(item, index) in tabItem.orderList" :key="index"
  10. class="order-item">
  11. <view class="i-top b-b">
  12. <!-- <text class="time">{{ item._add_time }}</text> -->
  13. <!-- <text class="state">{{ item._status._title }}</text> -->
  14. <text v-if="item.status === 4" class="del-btn iconfont icondelete"
  15. @click="deleteOrder(index)"></text>
  16. </view>
  17. <view class="goods-box-single" >
  18. <image class="goods-img" :src="item.class_info.uri" mode="scaleToFill"></image>
  19. <view class="right">
  20. <view class="flex-start">
  21. <text class="title clamp">{{ item.class_info.name }}</text>
  22. </view>
  23. <view class="row flex">
  24. <view class="price-box">
  25. 付款
  26. <text class="price">{{ moneyNum(item.hang_info.price)}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="action-box b-t" >
  32. <button class="action-btn" @click.stop="cancelOrder(item)">取消订单</button>
  33. <button @click.stop="orderPay(item)" class="action-btn recom">立即支付</button>
  34. </view>
  35. </view>
  36. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  37. </scroll-view>
  38. </swiper-item>
  39. </swiper>
  40. </view>
  41. </template>
  42. <script>
  43. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  44. import empty from '@/components/empty';
  45. import uEmpty from '@/uview-ui/components/u-empty/u-empty.vue'
  46. import {
  47. nftOrder,
  48. nftCancel
  49. } from '@/api/order.js';
  50. export default {
  51. components: {
  52. uniLoadMore,
  53. empty,
  54. uEmpty
  55. },
  56. filters: {
  57. moneyNum(value) {
  58. return +value;
  59. },
  60. },
  61. data() {
  62. return {
  63. tabCurrentIndex: 0,
  64. navList: [{
  65. state: 0,
  66. text: '待付款',
  67. loadingType: 'more',
  68. orderList: [],
  69. page: 1, //当前页数
  70. limit: 10 //每次信息条数
  71. }]
  72. };
  73. },
  74. onLoad(options) {
  75. this.loadData();
  76. },
  77. // #ifdef APP-PLUS || H5
  78. onBackPress(e) {
  79. uni.switchTab({
  80. url: '/pages/user/user',
  81. });
  82. return true;
  83. },
  84. // #endif
  85. methods: {
  86. // 转换金额为数字
  87. moneyNum(value) {
  88. return +value;
  89. },
  90. // 确认收货
  91. orderTake(item, index) {
  92. let obj = this;
  93. uni.showModal({
  94. title: '是否确认收货?',
  95. success: () => {
  96. orderTake({
  97. uni: item.order_id
  98. })
  99. .then(e => {
  100. obj.navList[obj.tabCurrentIndex].orderList.splice(index, 1);
  101. uni.showToast({
  102. title: '收货成功'
  103. });
  104. })
  105. .catch(e => {
  106. console.log(e);
  107. });
  108. }
  109. });
  110. },
  111. // 申请退款
  112. orderRefund(e) {
  113. uni.navigateTo({
  114. url: '/pages/order/orderRefund?id=' + e.order_id
  115. });
  116. },
  117. // 订单支付
  118. orderPay(e) {
  119. console.log(e)
  120. uni.navigateTo({
  121. url: '/pages/money/pay?type=1&ordid=' + e.id + '&money=' + e.hang_info.price+'&orderType=2'
  122. });
  123. },
  124. //获取订单列表
  125. loadData(source) {
  126. //这里是将订单挂载到tab列表下
  127. let index = this.tabCurrentIndex;
  128. let navItem = this.navList[index];
  129. let state = navItem.state;
  130. if (source === 'tabChange' && navItem.loaded === true) {
  131. //tab切换只有第一次需要加载数据
  132. return;
  133. }
  134. if (navItem.loadingType === 'loading') {
  135. //防止重复加载
  136. return;
  137. }
  138. if (navItem.loadingType === 'noMore') {
  139. //防止重复加载
  140. return;
  141. }
  142. // 修改当前对象状态为加载中
  143. navItem.loadingType = 'loading';
  144. nftOrder({
  145. status: state,
  146. page: navItem.page,
  147. limit: navItem.limit
  148. })
  149. .then(({
  150. data
  151. }) => {
  152. let arr = data.list.map(e => {
  153. let b = this.orderStateExp(e.status);
  154. e.stateTip = b.stateTip;
  155. e.stateTipColor = b.stateTipColor;
  156. return e;
  157. });
  158. navItem.orderList = navItem.orderList.concat(arr);
  159. // console.log(navItem.orderList);
  160. navItem.page++;
  161. if (navItem.limit == data.length) {
  162. //判断是否还有数据, 有改为 more, 没有改为noMore
  163. navItem.loadingType = 'more';
  164. return;
  165. } else {
  166. //判断是否还有数据, 有改为 more, 没有改为noMore
  167. navItem.loadingType = 'noMore';
  168. }
  169. uni.hideLoading();
  170. this.$set(navItem, 'loaded', true);
  171. })
  172. .catch(e => {
  173. console.log(e);
  174. });
  175. },
  176. //swiper 切换
  177. changeTab(e) {
  178. this.tabCurrentIndex = e.target.current;
  179. this.loadData('tabChange');
  180. },
  181. //顶部tab点击
  182. tabClick(index) {
  183. this.tabCurrentIndex = index;
  184. },
  185. //删除订单
  186. deleteOrder(index) {
  187. uni.showLoading({
  188. title: '请稍后'
  189. });
  190. setTimeout(() => {
  191. this.navList[this.tabCurrentIndex].orderList.splice(index, 1);
  192. uni.hideLoading();
  193. }, 600);
  194. },
  195. //取消订单
  196. cancelOrder(item) {
  197. uni.showModal({
  198. title: '订单取消',
  199. content: '是否取消订单?',
  200. success: e => {
  201. if (e.confirm) {
  202. uni.showLoading({
  203. title: '请稍后'
  204. });
  205. nftCancel({
  206. },item.id)
  207. .then(e => {
  208. uni.showToast({
  209. title: '取消成功',
  210. duration: 2000,
  211. position: 'top'
  212. });
  213. })
  214. .catch(e => {
  215. console.log(e);
  216. });
  217. //取消订单后删除待付款中该项
  218. let list = this.navList[this.tabCurrentIndex].orderList;
  219. let index = list.findIndex(val => val.id === item.id);
  220. index !== -1 && list.splice(index, 1);
  221. uni.hideLoading();
  222. }
  223. }
  224. });
  225. },
  226. //订单状态文字和颜色
  227. orderStateExp(state) {
  228. let stateTip = '',
  229. stateTipColor = '#fa436a';
  230. switch (+state) {
  231. case 0:
  232. stateTip = '待付款';
  233. break;
  234. case 1:
  235. stateTip = '待发货';
  236. break;
  237. case 2:
  238. stateTip = '待收货';
  239. break;
  240. case 3:
  241. stateTip = '待评价';
  242. break;
  243. case 4:
  244. stateTip = '已完成';
  245. stateTipColor = '#5dbc7c';
  246. break;
  247. case 9:
  248. stateTip = '订单已关闭';
  249. stateTipColor = '#909399';
  250. break;
  251. //更多自定义
  252. }
  253. return {
  254. stateTip,
  255. stateTipColor
  256. };
  257. }
  258. }
  259. };
  260. </script>
  261. <style lang="scss">
  262. page,
  263. .content {
  264. background: #111111;
  265. height: 100%;
  266. }
  267. .swiper-box {
  268. height: 100%;
  269. background-color: #111111;
  270. }
  271. .list-scroll-content {
  272. height: 100%;
  273. }
  274. .navbar {
  275. display: flex;
  276. height: 40px;
  277. padding: 0 5px;
  278. background: #111111;
  279. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  280. position: relative;
  281. z-index: 10;
  282. .nav-item {
  283. flex: 1;
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. height: 100%;
  288. font-size: 15px;
  289. color: #fff;
  290. position: relative;
  291. &.current {
  292. color: #5C5EE5;
  293. &:after {
  294. content: '';
  295. position: absolute;
  296. left: 50%;
  297. bottom: 0;
  298. transform: translateX(-50%);
  299. width: 44px;
  300. height: 0;
  301. border-bottom: 2px solid #5C5EE5;
  302. }
  303. }
  304. }
  305. }
  306. .uni-swiper-item {
  307. height: auto;
  308. }
  309. .order-item {
  310. display: flex;
  311. flex-direction: column;
  312. padding-left: 30rpx;
  313. background: #111111;
  314. margin-top: 16rpx;
  315. .i-top {
  316. display: flex;
  317. align-items: center;
  318. height: 80rpx;
  319. padding-right: 30rpx;
  320. font-size: $font-base;
  321. color: $font-color-dark;
  322. position: relative;
  323. .time {
  324. flex: 1;
  325. font-size: 24rpx;
  326. font-weight: 500;
  327. color: #FFFFFF;
  328. }
  329. .state {
  330. color: #5C5EE5;
  331. }
  332. .del-btn {
  333. padding: 10rpx 0 10rpx 36rpx;
  334. font-size: $font-lg;
  335. color: $font-color-light;
  336. position: relative;
  337. &:after {
  338. content: '';
  339. width: 0;
  340. height: 30rpx;
  341. border-left: 1px solid $border-color-dark;
  342. position: absolute;
  343. left: 20rpx;
  344. top: 50%;
  345. transform: translateY(-50%);
  346. }
  347. }
  348. }
  349. /* 多条商品 */
  350. .goods-box {
  351. height: 160rpx;
  352. padding: 20rpx 0;
  353. white-space: nowrap;
  354. .goods-item {
  355. width: 120rpx;
  356. height: 120rpx;
  357. display: inline-block;
  358. margin-right: 24rpx;
  359. }
  360. .goods-img {
  361. display: block;
  362. width: 100%;
  363. height: 100%;
  364. }
  365. }
  366. /* 单条商品 */
  367. .goods-box-single {
  368. background: #0E0E0E;
  369. display: flex;
  370. padding: 20rpx 0;
  371. .goods-img {
  372. display: block;
  373. width: 120rpx;
  374. height: 120rpx;
  375. }
  376. .right {
  377. flex: 1;
  378. display: flex;
  379. flex-direction: column;
  380. padding: 0 30rpx 0 24rpx;
  381. overflow: hidden;
  382. .row {
  383. margin-top: 10rpx;
  384. }
  385. .row_title {
  386. padding: 5rpx 10rpx;
  387. background-color: #dddddd;
  388. border-radius: 10rpx;
  389. font-size: 22rpx;
  390. color: #ffffff;
  391. }
  392. .title {
  393. font-size: $font-base + 2rpx;
  394. color: #fff;
  395. line-height: 1;
  396. width: 80%;
  397. }
  398. .attr-box {
  399. display: flex;
  400. justify-content: flex-end;
  401. font-size: $font-sm + 2rpx;
  402. color: $font-color-light;
  403. }
  404. .price {
  405. display: inline;
  406. font-size: $font-base + 2rpx;
  407. color: #5C5EE5;
  408. &:before {
  409. content: '¥';
  410. font-size: $font-sm;
  411. }
  412. }
  413. }
  414. }
  415. .price-box {
  416. display: flex;
  417. align-items: baseline;
  418. padding: 20rpx 0;
  419. font-size: $font-sm + 2rpx;
  420. color: #fff;
  421. .num {
  422. margin: 0 8rpx;
  423. color: #5C5EE5;
  424. }
  425. .price {
  426. font-size: $font-lg;
  427. color: #5C5EE5;
  428. &:before {
  429. content: '¥';
  430. font-size: $font-sm;
  431. margin: 0 2rpx 0 8rpx;
  432. }
  433. }
  434. }
  435. .action-box {
  436. display: flex;
  437. justify-content: flex-end;
  438. align-items: center;
  439. height: 100rpx;
  440. position: relative;
  441. padding-right: 30rpx;
  442. }
  443. .action-btn {
  444. width: 160rpx;
  445. height: 60rpx;
  446. margin: 0;
  447. margin-left: 24rpx;
  448. padding: 0;
  449. text-align: center;
  450. line-height: 60rpx;
  451. font-size: $font-sm + 2rpx;
  452. color: #fff;
  453. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  454. border-radius: 100px;
  455. &:after {
  456. border-radius: 100px;
  457. }
  458. &.recom {
  459. color: #fff;
  460. &:after {
  461. border-color: $base-color;
  462. }
  463. }
  464. &.evaluate {
  465. color: $color-yellow;
  466. &:after {
  467. border-color: $color-yellow;
  468. }
  469. }
  470. }
  471. }
  472. /* load-more */
  473. .uni-load-more {
  474. display: flex;
  475. flex-direction: row;
  476. height: 80rpx;
  477. align-items: center;
  478. justify-content: center;
  479. }
  480. .uni-load-more__text {
  481. font-size: 28rpx;
  482. color: #999;
  483. }
  484. .uni-load-more__img {
  485. height: 24px;
  486. width: 24px;
  487. margin-right: 10px;
  488. }
  489. .uni-load-more__img>view {
  490. position: absolute;
  491. }
  492. .uni-load-more__img>view view {
  493. width: 6px;
  494. height: 2px;
  495. border-top-left-radius: 1px;
  496. border-bottom-left-radius: 1px;
  497. background: #999;
  498. position: absolute;
  499. opacity: 0.2;
  500. transform-origin: 50%;
  501. animation: load 1.56s ease infinite;
  502. }
  503. .uni-load-more__img>view view:nth-child(1) {
  504. transform: rotate(90deg);
  505. top: 2px;
  506. left: 9px;
  507. }
  508. .uni-load-more__img>view view:nth-child(2) {
  509. transform: rotate(180deg);
  510. top: 11px;
  511. right: 0;
  512. }
  513. .uni-load-more__img>view view:nth-child(3) {
  514. transform: rotate(270deg);
  515. bottom: 2px;
  516. left: 9px;
  517. }
  518. .uni-load-more__img>view view:nth-child(4) {
  519. top: 11px;
  520. left: 0;
  521. }
  522. .load1,
  523. .load2,
  524. .load3 {
  525. height: 24px;
  526. width: 24px;
  527. }
  528. .load2 {
  529. transform: rotate(30deg);
  530. }
  531. .load3 {
  532. transform: rotate(60deg);
  533. }
  534. .load1 view:nth-child(1) {
  535. animation-delay: 0s;
  536. }
  537. .load2 view:nth-child(1) {
  538. animation-delay: 0.13s;
  539. }
  540. .load3 view:nth-child(1) {
  541. animation-delay: 0.26s;
  542. }
  543. .load1 view:nth-child(2) {
  544. animation-delay: 0.39s;
  545. }
  546. .load2 view:nth-child(2) {
  547. animation-delay: 0.52s;
  548. }
  549. .load3 view:nth-child(2) {
  550. animation-delay: 0.65s;
  551. }
  552. .load1 view:nth-child(3) {
  553. animation-delay: 0.78s;
  554. }
  555. .load2 view:nth-child(3) {
  556. animation-delay: 0.91s;
  557. }
  558. .load3 view:nth-child(3) {
  559. animation-delay: 1.04s;
  560. }
  561. .load1 view:nth-child(4) {
  562. animation-delay: 1.17s;
  563. }
  564. .load2 view:nth-child(4) {
  565. animation-delay: 1.3s;
  566. }
  567. .load3 view:nth-child(4) {
  568. animation-delay: 1.43s;
  569. }
  570. @-webkit-keyframes load {
  571. 0% {
  572. opacity: 1;
  573. }
  574. 100% {
  575. opacity: 0.2;
  576. }
  577. }
  578. </style>