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.

order.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <!-- 订单列表2 -->
  2. <template>
  3. <filter>
  4. <empty-view v-if="!data.login" mode="permission" content="请先登录再查看订单" btnTxt="立即登录"
  5. @btnClick="$util.navTo('/login/login')">
  6. </empty-view>
  7. <view class="list-wrapper" v-else>
  8. <view class="top-content">
  9. <view class="top-menu">
  10. <view :class="item == state.tabActive ? 'tab active' : 'tab'" v-for="item in state.flowPathTabList"
  11. :key="item" @click="flowPathTabHandle(item)">
  12. <view class="border"></view>{{ item }}
  13. </view>
  14. </view>
  15. <order-tabbar ref="tabbarRef" :tabs="data.tabsList" v-model:curIndex="data.tabIndex"
  16. v-if="data.tabsList.length > 0" @index="test"></order-tabbar>
  17. </view>
  18. <order-list-item v-if="state.tabActive=='小程序'" ref="mescrollItem" :index="data.tabIndex"
  19. :refresh="data.refresh">
  20. </order-list-item>
  21. <view v-else>
  22. <!-- 搜索框 -->
  23. <view class="as-layout-horizontal as-gravity-center-start search-layout">
  24. <view class="search-box">
  25. <image :src="`${$imgUrl}service/icon-search.png`" class="icon" mode="aspectFill"></image>
  26. <input class="search" placeholder="请输入车牌号" @input="onKeyInput" />
  27. </view>
  28. <view class="search-btn" @click="doSearch">搜索</view>
  29. </view>
  30. <!-- 数据为空 -->
  31. <empty-view :mode="config.emptyHint.mode" :content="config.emptyHint.hint"
  32. v-if="state.appOrdersList.length === 0" />
  33. <block v-for="(item,index) in state.appOrdersList" :key="index">
  34. <view :class="item.orderStatus == OrderStatus.已取消 ? 'item finished' : 'item'"
  35. @click.stop="gotoOrderDetails(item,2)">
  36. <view class="head">
  37. <view class="name">
  38. <image :src="`${$imgUrl}order/icon-star-green.png`" class="icon" mode="aspectFill">
  39. </image>
  40. <text class="title">{{item.productName ?item.productName: ''}}</text>
  41. </view>
  42. <view class="status text-orange" v-if="item.orderStatus == OrderStatus.已取消">已取消</view>
  43. <view class="status text-green" v-else
  44. :class="{'text-orange':item.orderStep == OrderStatus.已完成 || item.orderStep == OrderStatus.已结束
  45. || item.orderStep == OrderStatus['换货-设备已回收'] || item.orderStep == OrderStatus.退款成功 || item.orderStep == OrderStatus.退货成功}">
  46. {{getOrderStatusName(item.orderStep)}}
  47. </view>
  48. </view>
  49. <view class="detail">
  50. <view class="orders">
  51. <view class="order-text">
  52. <text class="type">新办单号:</text>
  53. <text class="value">{{item.orderId}}</text>
  54. </view>
  55. <view class="order-text odd">
  56. <text class="type">业务类型:</text>
  57. <text class="value">{{getOrderTypeName(item.orderType)}}</text>
  58. </view>
  59. <view class="order-text">
  60. <text class="type">订单车牌号:</text>
  61. <text class="value">{{item.vehiclePlate}}</text>
  62. </view>
  63. <view class="order-text odd">
  64. <text class="type">订单车牌颜色:</text>
  65. <text class="value">{{getVehiclePlateColor(item.vehiclePlateColor)}}</text>
  66. </view>
  67. </view>
  68. <view class="money"><text class="cny">¥</text>
  69. <text class="amount" v-if="item.amount">{{item.amount / 100}}</text>
  70. <text class="amount" v-else>0.00</text>
  71. </view>
  72. </view>
  73. <!-- 待激活 -->
  74. <view class="btns" v-if="item.orderStep == OrderStatus.待激活 && item.cardId && item.obuId">
  75. <view class="btn btn-primary" @click.stop="gotoActiveOrder(item)">去激活</view>
  76. </view>
  77. <!-- 已完成 -->
  78. <view class="btns" v-else-if="item.orderStep == OrderStatus.已完成">
  79. <view class="btn btn-normal" v-if="item.isStaff==1 && item.isProduct==1">
  80. 已评价
  81. </view>
  82. <view class='evaluation' v-else>
  83. <view class="btn btn-primary" @click.stop="gotoEvaluateSalesman(item)">去评价</view>
  84. </view>
  85. </view>
  86. </view>
  87. </block>
  88. <uni-load-more :status="params.status" iconType="snow" :icon-size="16" :content-text="config.contentTxt"
  89. v-if="state.appOrdersList.length > 0" />
  90. </view>
  91. </view>
  92. </filter>
  93. </template>
  94. <script setup lang="ts">
  95. import orderTabbar from "./components/order-tabbar.vue";
  96. import orderListItem from "./components/order-list-item";
  97. import useOrderList from "@/composables/order/useOrderList";
  98. import filter from '@/components/filter/filter.vue';
  99. import { onLoad, onReachBottom, onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  100. import useOrderListItem from "@/composables/order/useOrderListItem";
  101. import useOrderSkip from "@/composables/order/useOrderSkip";
  102. import {
  103. getOrderStatusName,
  104. msg,
  105. getOrderTypeName,
  106. hasLogin, timesDiff
  107. } from "@/utils/utils";
  108. import {
  109. vehiclePlateColor
  110. } from "@/datas/vehiclePlateColor";
  111. import { getItem, StorageKeys, setItem } from "@/utils/storage";
  112. import { PageData } from "@/datas/enum";
  113. import {
  114. OrderStatus
  115. } from "@/datas/enum";
  116. import {
  117. reactive, watch, ref
  118. } from "vue";
  119. import { request } from "@/utils/network/request.js";
  120. import { appPage } from "@/utils/network/api";
  121. import { stringToJson } from "@/utils/network/encryption";
  122. import { log } from "console";
  123. const tools = require("../../static/etcUtil/tools.js");
  124. const state = reactive({
  125. tabActive: "小程序",
  126. flowPathTabList: ["小程序", "线下网点"],
  127. appOrdersList: [],
  128. index: 0
  129. })
  130. const {
  131. data,
  132. tabbarRef
  133. } = useOrderList();
  134. //办理订单按钮跳转业务逻辑
  135. const {
  136. gotoActiveOrder,
  137. gotoOrderDetails,
  138. gotoEvaluateSalesman
  139. } = useOrderSkip();
  140. //请求参数
  141. const params = reactive({
  142. pageNum: PageData.NUM,
  143. pageSize: PageData.SIZE,
  144. total: 0,
  145. status: 'more',
  146. reload: false,
  147. })
  148. function test(index) {
  149. console.log("test", index, data.tabIndex)
  150. state.index = index
  151. if (state.tabActive == '小程序') {
  152. changeTab(state.tabActive)
  153. } else {
  154. console.log("apppppppp",)
  155. getList()
  156. }
  157. }
  158. const props = defineProps({
  159. index: {
  160. type: Number,
  161. default() {
  162. return 0
  163. }
  164. },
  165. refresh: { //是否刷新列表
  166. type: Boolean,
  167. default: true
  168. }
  169. })
  170. const { changeTab, config, refreshList } = useOrderListItem(props);
  171. onLoad((option) => {
  172. // 一进来就调一遍
  173. changeTab(state.tabActive)
  174. })
  175. let searchKeyWords = '';
  176. //获取车牌颜色文字
  177. const getVehiclePlateColor = (id : number) => {
  178. const colors = vehiclePlateColor.filter(item => item.id == id);
  179. return colors[0].color
  180. }
  181. const flowPathTabHandle = (tab) => {
  182. console.log("tab", tab)
  183. state.tabActive = tab;
  184. if (state.tabActive == '小程序') {
  185. changeTab(state.tabActive)
  186. } else {
  187. console.log("apppppppp",)
  188. getList()
  189. }
  190. };
  191. //搜索
  192. const doSearch = () => {
  193. // #ifdef MP-WEIXIN
  194. if (!searchKeyWords) {
  195. msg('请输入需要搜索的车牌号!');
  196. return;
  197. }
  198. getList();
  199. // #endif
  200. // #ifdef MP-ALIPAY
  201. tools.showLoadingAlert("加载中");
  202. getList();
  203. tools.hideLoadingAlert();
  204. // #endif
  205. }
  206. //订单车牌号输入
  207. const onKeyInput = (event) => {
  208. searchKeyWords = event.target.value;
  209. if (searchKeyWords == '') {
  210. getList();
  211. }
  212. }
  213. const getList = async () => {
  214. if (!hasLogin()) {
  215. uni.stopPullDownRefresh();
  216. return;
  217. }
  218. const options = {
  219. type: 2,
  220. data: {
  221. "opId": getItem(StorageKeys.OpenId),
  222. "vehiclePlate": searchKeyWords,
  223. "tabIndex": state.index + '',
  224. "pageNo": params.pageNum,
  225. "pageSize": params.pageSize,
  226. },
  227. method: 'POST',
  228. showLoading: true
  229. }
  230. request(appPage, options).then((res) => {
  231. uni.hideLoading()
  232. var data = stringToJson(res.bizContent);
  233. console.log("state.appOrdersList", data)
  234. params.total = data.totalCount;
  235. if (params.pageNum === 1) {
  236. state.appOrdersList = [];
  237. }
  238. if (params.total > 0) {
  239. const curList = data.data || [];
  240. state.appOrdersList = params.reload ? curList : state.appOrdersList.concat(curList);
  241. params.reload = false;
  242. }
  243. if (params.total === state.appOrdersList.length) {
  244. params.reload = false;
  245. params.status = 'noMore';
  246. }
  247. if (params.pageNum === 1) {
  248. uni.stopPullDownRefresh();
  249. }
  250. // 订单发货后未激活 30天 以后 结束订单功能 insertTime >30 算出来距离今天是负数 updateTime<30(结束订单)
  251. for (var k = 0; k < state.appOrdersList.length; k++) {
  252. if (state.appOrdersList[k]['insertTime']) {
  253. if (timesDiff(state.appOrdersList[k]['insertTime'].replace("T", " ")).days > 30) {
  254. state.appOrdersList[k]['finishOrder'] = true //可以结束
  255. } else {
  256. state.appOrdersList[k]['finishOrder'] = false //不可以结束
  257. }
  258. }
  259. if (state.appOrdersList[k]['updateTime']) {
  260. if (timesDiff(state.appOrdersList[k]['updateTime'].replace("T", " ")).days <= 30) {
  261. state.appOrdersList[k]['isUseAgain'] = true //可以再次使用
  262. } else {
  263. state.appOrdersList[k]['isUseAgain'] = false //不可以再次使用
  264. }
  265. }
  266. }
  267. uni.$emit("refreshOrder");
  268. console.log("data.refresh===============", props.refresh, state.appOrdersList)
  269. })
  270. .catch((err) => {
  271. console.log(err);
  272. });
  273. }
  274. onReachBottom(() => {
  275. loadMore();
  276. });
  277. /* 加载更多 */
  278. const loadMore = () => {
  279. if (params.total > state.appOrdersList.length) {
  280. params.status = 'loading';
  281. params.pageNum++;
  282. getList();
  283. } else {
  284. params.status = 'noMore';
  285. }
  286. }
  287. onPullDownRefresh(() => {
  288. if (hasLogin()) {
  289. getList();
  290. }
  291. });
  292. </script>
  293. <style lang="scss">
  294. page {
  295. background: #eef7f7;
  296. }
  297. :deep(.u-mode-center-box) {
  298. border-radius: 20rpx;
  299. }
  300. </style>
  301. <style lang="scss" scoped>
  302. .top-content {
  303. position: fixed;
  304. left: 0;
  305. z-index: 99999;
  306. background-color: white;
  307. }
  308. .top-menu {
  309. display: flex;
  310. justify-content: space-around;
  311. }
  312. .top-menu .tab {
  313. font-size: 28rpx;
  314. padding: 30rpx 30rpx;
  315. color: #666666;
  316. position: relative;
  317. }
  318. .top-menu .active .border {
  319. position: absolute;
  320. width: 70%;
  321. height: 16rpx;
  322. background: #00b38b;
  323. opacity: 0.3;
  324. bottom: 28rpx;
  325. z-index: -99;
  326. left: 15%;
  327. border-radius: 6rpx;
  328. }
  329. .top-menu .active {
  330. font-weight: bold;
  331. font-size: 32rpx;
  332. color: #0d0f26;
  333. }
  334. .top-menu .active::before {
  335. width: 100%;
  336. height: 16rpx;
  337. background: #00b38b;
  338. opacity: 0.3;
  339. }
  340. .search-layout {
  341. padding-top: 180rpx;
  342. .search-box {
  343. margin: 30rpx 30rpx 0rpx 30rpx;
  344. height: 80rpx;
  345. background: #FFFFFF;
  346. border: 1px solid #DCDCDC;
  347. border-radius: 40rpx;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. box-sizing: border-box;
  352. flex: 1;
  353. }
  354. .search-box .icon {
  355. width: 48rpx;
  356. height: 48rpx;
  357. margin: 0 20rpx;
  358. }
  359. .search-box .search {
  360. flex: 1;
  361. margin-right: 20rpx;
  362. height: 100%;
  363. padding: 0 10rpx;
  364. font-size: 28rpx;
  365. color: #00b38b;
  366. }
  367. .search-btn {
  368. color: white;
  369. background-color: #00B38B;
  370. width: 140rpx;
  371. height: 75rpx;
  372. line-height: 75rpx;
  373. font-size: 32rpx;
  374. border-radius: 40rpx;
  375. text-align: center;
  376. margin-right: 30rpx;
  377. margin-top: 30rpx;
  378. }
  379. }
  380. .item .head {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. padding: 20rpx 28rpx;
  385. border-bottom: 1px solid #dcdcdc;
  386. }
  387. .item .head {
  388. .head-row {
  389. display: flex;
  390. width: 100%;
  391. justify-content: space-between;
  392. align-items: center;
  393. }
  394. .name {}
  395. .name>text {
  396. font-size: 26rpx;
  397. font-family: Noto Sans S Chinese;
  398. font-weight: 400;
  399. color: #999999;
  400. line-height: 36rpx;
  401. }
  402. }
  403. .item .head .icon {
  404. width: 48rpx;
  405. height: 48rpx;
  406. }
  407. .item .head .name {
  408. display: flex;
  409. align-items: center;
  410. }
  411. .text-green {
  412. font-size: 26rpx;
  413. color: #00b38b;
  414. }
  415. .text-orange {
  416. font-size: 26rpx;
  417. color: #ff8000;
  418. }
  419. .text-black {
  420. font-size: 28rpx;
  421. color: #333;
  422. font-weight: 500;
  423. }
  424. .title {
  425. font-size: 30rpx;
  426. color: #333;
  427. }
  428. .tag-green {
  429. font-size: 22rpx;
  430. height: 40rpx;
  431. line-height: 40rpx;
  432. padding: 0 12rpx;
  433. border-radius: 6rpx;
  434. background: #d9f4ee;
  435. color: #00b38b;
  436. }
  437. .tag-grey {
  438. font-size: 22rpx;
  439. height: 40rpx;
  440. line-height: 40rpx;
  441. padding: 0 12rpx;
  442. border-radius: 6rpx;
  443. background: #e8e8e8;
  444. color: #666;
  445. }
  446. .detail {
  447. display: flex;
  448. justify-content: space-between;
  449. align-items: center;
  450. padding: 30rpx 32rpx;
  451. }
  452. .detail .type {
  453. font-size: 26rpx;
  454. color: #999;
  455. }
  456. .detail .value {
  457. font-size: 26rpx;
  458. color: #333;
  459. }
  460. .finished .detail .value {
  461. color: #999;
  462. }
  463. .detail .odd {
  464. margin: 20rpx 0;
  465. }
  466. .cny {
  467. font-size: 26rpx;
  468. color: #333;
  469. }
  470. .finished .cny {
  471. color: #999;
  472. }
  473. .amount {
  474. font-size: 40rpx;
  475. font-weight: bold;
  476. }
  477. .bottom .amount {
  478. color: #ff8000;
  479. }
  480. .finished .amount {
  481. color: #999;
  482. }
  483. .btns {
  484. position: relative;
  485. display: flex;
  486. align-items: center;
  487. justify-content: flex-end;
  488. border-top: 1px solid #dcdcdc;
  489. margin: 0 30rpx;
  490. padding: 20rpx 0;
  491. }
  492. .bottom {
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. border-top: 1px solid #dcdcdc;
  497. margin: 0 30rpx;
  498. padding: 20rpx 0;
  499. }
  500. .btn {
  501. height: 60rpx;
  502. line-height: 58rpx;
  503. border-radius: 30rpx;
  504. padding: 0 24rpx;
  505. font-size: 23rpx;
  506. box-sizing: border-box;
  507. margin-right: 12rpx;
  508. }
  509. .btns .btn:last-child {
  510. margin: 0;
  511. }
  512. .btns .state {
  513. position: absolute;
  514. left: 0;
  515. font-size: 26rpx;
  516. font-family: Noto Sans S Chinese;
  517. font-weight: 400;
  518. color: #999999;
  519. line-height: 58rpx;
  520. text {
  521. font-size: 26rpx;
  522. font-family: Noto Sans S Chinese;
  523. font-weight: 400;
  524. color: #00B38B;
  525. line-height: 58rpx;
  526. }
  527. }
  528. .btn-primary {
  529. border: 1px solid #00b38b;
  530. color: #00b38b;
  531. }
  532. .btn-disable {
  533. border: 1px solid #999;
  534. color: #999;
  535. }
  536. .btn-normal {
  537. border: 1px solid #dcdcdc;
  538. color: #333;
  539. }
  540. .evaluation {
  541. display: flex;
  542. }
  543. .finished .detail .value {
  544. color: #999;
  545. }
  546. .detail .odd {
  547. margin: 20rpx 0;
  548. }
  549. .cny {
  550. font-size: 26rpx;
  551. color: #333;
  552. }
  553. .finished .cny {
  554. color: #999;
  555. }
  556. .item {
  557. background: #ffffff;
  558. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  559. border-radius: 20rpx;
  560. box-sizing: border-box;
  561. display: flex;
  562. flex-direction: column;
  563. margin: 30rpx 30rpx 0rpx;
  564. }
  565. .bg-white .item {
  566. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  567. }
  568. .item .head {
  569. display: flex;
  570. justify-content: space-between;
  571. align-items: center;
  572. padding: 20rpx 28rpx;
  573. border-bottom: 1px solid #dcdcdc;
  574. }
  575. .item .head {
  576. .head-row {
  577. display: flex;
  578. width: 100%;
  579. justify-content: space-between;
  580. align-items: center;
  581. }
  582. .name {}
  583. .name>text {
  584. font-size: 26rpx;
  585. font-family: Noto Sans S Chinese;
  586. font-weight: 400;
  587. color: #999999;
  588. line-height: 36rpx;
  589. }
  590. }
  591. .item .head .icon {
  592. width: 48rpx;
  593. height: 48rpx;
  594. }
  595. .item .head .name {
  596. display: flex;
  597. align-items: center;
  598. }
  599. </style>