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

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