shopOrder.vue 14 KB

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