index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box">
  3. <Nav :leftShow='false' :customNav='true' bgckgroundBox='#fff'>
  4. <template>
  5. <view slot="custom" class="text-align-center fw-600 fs-36">
  6. 我的订单
  7. </view>
  8. </template>
  9. </Nav>
  10. <view class="nav-box box-border-box bgc-f display-flex">
  11. <view class="nav-item" :class="type == item.id?'fs-36 fw-600':'fs-34 fw-400'" v-for="(item,i) in navList"
  12. :key="i" @click="selectType(item.id)">
  13. {{item.name}}
  14. <view v-if="type == item.id" class="nav-item-x"></view>
  15. </view>
  16. </view>
  17. <scroll-view class="nav-type-box bgc-f p-12-24 box-border-box" :scroll-x="true">
  18. <view class="nav-type-item text-align-center fs-28" v-for="(item,index) in navTypeData"
  19. @click="navTypeClick(item.key)"
  20. :class="navTypeKey== item.key?'bgc-E4F3FD fw-600 fc-41ABF5':'bgc-F4F5F7 fw-400 fc-3'">
  21. {{item.name}}
  22. </view>
  23. </scroll-view>
  24. <view v-if="list.length == 0" class="scroll-view-css">
  25. <EnBlank :customSrc='true'>
  26. <template v-slot:blankImg>
  27. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  28. </template>
  29. </EnBlank>
  30. </view>
  31. <scroll-view v-else :scroll-y="true" class="scroll-view-css" @scrolltolower="scrolltolower">
  32. <view class="list-box">
  33. <view class="list-item bgc-f b-rad-20 mb-32 p-24 box-border-box" v-for="(item,index) in list"
  34. @click="goToInfo(item)">
  35. <view class="align-items-center flex-justify-space mb-24">
  36. <view class="align-items-center">
  37. <image v-if="item.site_logo" class="shops-img" :src="item.site_logo" mode="aspectFit">
  38. </image>
  39. <image v-else class="shops-img" src="@/static/img/logo/logo.png" mode=""></image>
  40. <view v-if="item.site_name" class="fs-32 fc-3 fw-600 shops-name text-overflow-ellipsis-one">
  41. {{item.site_name}}
  42. </view>
  43. <view v-else class="fs-32 fc-3 fw-600 shops-name text-overflow-ellipsis-one">
  44. 君子校园
  45. </view>
  46. <!-- <image class="icons" src="@/static/img/toRight.png" mode=""></image> -->
  47. </view>
  48. <view class="fc-41ABF5 fs-28">
  49. {{item.order_status_str}}
  50. </view>
  51. </view>
  52. <view class="align-items-center flex-justify-space mb-24">
  53. <view class="goods-box" v-if="type == 1 || type == 2 || type == 5">
  54. <view class="" v-if="item.item.length == 1">
  55. <view class="align-items-center" v-for="(itemGoods,indexGoods) in item.item">
  56. <image class="goods-img flex-shrink0" :src="itemGoods.goods_img" mode="">
  57. </image>
  58. <view class="fs-28 fc-6 text-overflow-ellipsis">
  59. {{itemGoods.goods_name}}
  60. </view>
  61. </view>
  62. </view>
  63. <view class="align-items-center goods-two" v-else>
  64. <view class="flex-direction" v-for="(itemGoods,indexGoods) in item.item">
  65. <image class="goods-img flex-shrink0" :src="itemGoods.goods_img" mode="">
  66. </image>
  67. <view
  68. class="fs-28 fc-6 text-overflow-ellipsis-one goods-two-name text-align-center">
  69. {{itemGoods.goods_name}}
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="goods-box" v-else>
  75. <view class="align-items-center">
  76. <image class="goods-img flex-shrink0" :src="item.goods_img" mode="">
  77. </image>
  78. <view class="fs-28 fc-6 text-overflow-ellipsis">
  79. {{item.goods_name}}
  80. </view>
  81. </view>
  82. </view>
  83. <view class="goods-num text-align-center">
  84. 共 {{item.goods_number}} 件
  85. </view>
  86. </view>
  87. <view class="align-items-center flex-justify-space mb-24">
  88. <view class="fs-24 fc-9">
  89. 下单时间:{{item.created_at}}
  90. </view>
  91. <view class="fs-28 fc-9">
  92. {{item.order_status == 1?'需付':'实付'}} <text
  93. class="fs-32 fc-3 fw-600">¥{{item.pay_money}}</text>
  94. </view>
  95. </view>
  96. <view class="align-items-center flex-justify-end">
  97. <view class="item-but but-class-two fs-28 mr-18"
  98. v-if="type == 1 && item.order_status == 7 && item.is_comment == 0">
  99. 评价
  100. </view>
  101. <view class="item-but but-class-two fs-28 mr-18" @click.stop="cancel(item)"
  102. v-if="type == 5 && item.order_status == 2">
  103. <!-- 干洗 -->
  104. 取消订单
  105. </view>
  106. <view class="item-but but-class-two fs-28 mr-18" @click.stop="expressCancel(item)"
  107. v-if="type == 2 && item.order_status == 2">
  108. <!-- 代取 -->
  109. 取消订单
  110. </view>
  111. <view class="item-but but-class-one fs-28" @click.stop="orderPay(item)"
  112. v-if="item.order_status == 1">
  113. 立即支付
  114. </view>
  115. <view @click.stop="goToUrl('express')" class="item-but but-class-one fs-28"
  116. v-if="type == 2 && item.order_status == 4">
  117. <!-- 代取 -->
  118. 再来一单
  119. </view>
  120. <view @click.stop="goToUrl('group')" class="item-but but-class-one fs-28"
  121. v-if="type == 3 && item.order_status == 2">
  122. <!-- 团购 -->
  123. 再来一单
  124. </view>
  125. <view @click.stop="goToUrl('ticket')" class="item-but but-class-one fs-28"
  126. v-if="type == 4 && item.order_status == 2">
  127. <!-- 票务 -->
  128. 再来一单
  129. </view>
  130. <view class="item-but but-class-one fs-28" v-if="type == 5 && item.order_status == 5">
  131. <!-- 干洗 -->
  132. 再来一单
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </scroll-view>
  138. </view>
  139. </template>
  140. <script>
  141. import tools from '@/service/tools';
  142. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  143. import {
  144. getExpressPay
  145. } from "@/api/express.js"
  146. import {
  147. expressOrderStatus,
  148. expressOrderList,
  149. expressOrderCancel
  150. } from "@/api/expressOrder.js"
  151. import {
  152. orderStatus
  153. } from "@/api/order.js"
  154. import {
  155. groupPay
  156. } from '@/api/groupOrder.js';
  157. import {
  158. groupOrderStatus,
  159. groupOrderList
  160. } from "@/api/groupOrder.js"
  161. import {
  162. ticketPay
  163. } from '@/api/ticket.js';
  164. import {
  165. ticketOrderStatus,
  166. ticketOrderList
  167. } from "@/api/ticketOrder.js"
  168. import {
  169. laundryOrderStatus,
  170. laundryOrderList,
  171. laundryOrderCancel
  172. } from "@/api/laundryOrder.js"
  173. export default {
  174. components: {
  175. EnBlank
  176. },
  177. data() {
  178. return {
  179. type: 1,
  180. navList: [{
  181. name: '外卖',
  182. id: 1
  183. },
  184. {
  185. name: '代取',
  186. id: 2
  187. },
  188. {
  189. name: '团购',
  190. id: 3
  191. },
  192. {
  193. name: '票务',
  194. id: 4
  195. },
  196. {
  197. name: '干洗',
  198. id: 5
  199. },
  200. ],
  201. page: 1,
  202. list: [],
  203. total: 0,
  204. navTypeData: [],
  205. navTypeKey: 0,
  206. isAjax: false
  207. };
  208. },
  209. onShow() {
  210. this.resetList();
  211. },
  212. methods: {
  213. goToUrl(type) {
  214. if (type == 'express') {
  215. uni.navigateTo({
  216. url: '/pages-takeout/replace-take'
  217. })
  218. } else if (type == 'group') {
  219. uni.navigateTo({
  220. url: '/pages-buy/group'
  221. })
  222. } else if (type == 'ticket') {
  223. uni.navigateTo({
  224. url: '/pages-buy/ticket'
  225. })
  226. }
  227. },
  228. goToInfo(item) {
  229. if (this.type === 1) {
  230. uni.navigateTo({
  231. url: `/pages-order/express-info`
  232. })
  233. } else if (this.type === 2) {
  234. uni.navigateTo({
  235. url: `/pages-order/express-info?orderId=` + item.id
  236. })
  237. } else if (this.type === 3) {
  238. uni.navigateTo({
  239. url: `/pages-order/group-info?orderId=` + item.id
  240. })
  241. } else if (this.type === 4) {
  242. uni.navigateTo({
  243. url: `/pages-order/ticket-info?orderId=` + item.id
  244. })
  245. } else if (this.type === 5) {
  246. uni.navigateTo({
  247. url: `/pages-order/laundry-info?orderId=` + item.id
  248. })
  249. }
  250. },
  251. orderPay(item) {
  252. // 立即支付
  253. if (this.type === 1) {
  254. } else if (this.type === 2) {
  255. this.getExpressPay(item.id)
  256. } else if (this.type === 3) {
  257. this.groupPay(item.id)
  258. } else if (this.type === 4) {
  259. this.ticketPay(item.id)
  260. } else if (this.type === 5) {
  261. this.laundryOrderList()
  262. }
  263. },
  264. navTypeClick(key) {
  265. if (this.navTypeKey != key) {
  266. this.navTypeKey = key
  267. this.page = 1
  268. this.list = []
  269. if (this.type === 1) {
  270. } else if (this.type === 2) {
  271. this.expressOrderList()
  272. } else if (this.type === 3) {
  273. this.groupOrderList()
  274. } else if (this.type === 4) {
  275. this.ticketOrderList()
  276. } else if (this.type === 5) {
  277. this.laundryOrderList()
  278. }
  279. }
  280. },
  281. resetList() {
  282. this.page = 1;
  283. this.list = [];
  284. this.getList();
  285. },
  286. selectType(type) {
  287. if (type != this.type) {
  288. this.type = type;
  289. this.navTypeKey = 0
  290. this.resetList();
  291. }
  292. },
  293. expressCancel(item) {
  294. // 代取取消订单
  295. expressOrderCancel({
  296. order_id: item.id
  297. }).then((res) => {
  298. if (res.code == 1) {
  299. tools.success(res.msg)
  300. this.page = 1;
  301. this.list = [];
  302. this.expressOrderList()
  303. } else {
  304. tools.error(res.msg)
  305. }
  306. })
  307. },
  308. cancel(item) {
  309. // 干洗取消订单
  310. laundryOrderCancel({
  311. order_id: item.id
  312. }).then((res) => {
  313. if (res.code == 1) {
  314. tools.success(res.msg)
  315. this.page = 1;
  316. this.list = [];
  317. this.laundryOrderList()
  318. } else {
  319. tools.error(res.msg)
  320. }
  321. })
  322. },
  323. scrolltolower() {
  324. ++this.page
  325. if (this.type === 1) {
  326. } else if (this.type === 2) {
  327. this.expressOrderList()
  328. } else if (this.type === 3) {
  329. this.groupOrderList()
  330. } else if (this.type === 4) {
  331. this.ticketOrderList()
  332. } else if (this.type === 5) {
  333. this.laundryOrderList()
  334. }
  335. // console.log('触底');
  336. },
  337. getList() {
  338. if (this.type === 1) {
  339. this.orderStatus()
  340. } else if (this.type === 2) {
  341. this.expressOrderStatus()
  342. this.expressOrderList()
  343. } else if (this.type === 3) {
  344. this.groupOrderStatus()
  345. this.groupOrderList()
  346. } else if (this.type === 4) {
  347. this.ticketOrderStatus()
  348. this.ticketOrderList()
  349. } else if (this.type === 5) {
  350. this.laundryOrderStatus()
  351. this.laundryOrderList()
  352. }
  353. },
  354. expressOrderStatus() {
  355. // 代取订单状态
  356. expressOrderStatus().then((res) => {
  357. if (res.code == 1) {
  358. this.navTypeData = res.data
  359. }
  360. })
  361. },
  362. orderStatus() {
  363. // 外卖订单状态
  364. orderStatus().then((res) => {
  365. if (res.code == 1) {
  366. this.navTypeData = res.data
  367. }
  368. })
  369. },
  370. groupOrderStatus() {
  371. // 团购订单状态
  372. groupOrderStatus().then((res) => {
  373. if (res.code == 1) {
  374. this.navTypeData = res.data
  375. }
  376. })
  377. },
  378. ticketOrderStatus() {
  379. // 票务订单状态
  380. ticketOrderStatus().then((res) => {
  381. if (res.code == 1) {
  382. this.navTypeData = res.data
  383. }
  384. })
  385. },
  386. laundryOrderStatus() {
  387. // 干洗订单状态
  388. laundryOrderStatus().then((res) => {
  389. if (res.code == 1) {
  390. this.navTypeData = res.data
  391. }
  392. })
  393. },
  394. expressOrderList() {
  395. // 代取订单列表
  396. expressOrderList({
  397. status: this.navTypeKey,
  398. page: this.page
  399. }).then((res) => {
  400. if (res.code == 1) {
  401. if (res.data.items.length > 0) {
  402. this.list.push(...res.data.items)
  403. }
  404. }
  405. })
  406. },
  407. groupOrderList() {
  408. // 团购订单列表
  409. groupOrderList({
  410. status: this.navTypeKey,
  411. page: this.page
  412. }).then((res) => {
  413. if (res.code == 1) {
  414. if (res.data.items.length > 0) {
  415. this.list.push(...res.data.items)
  416. }
  417. }
  418. })
  419. },
  420. ticketOrderList() {
  421. // 票务订单列表
  422. ticketOrderList({
  423. status: this.navTypeKey,
  424. page: this.page
  425. }).then((res) => {
  426. if (res.code == 1) {
  427. if (res.data.items.length > 0) {
  428. this.list.push(...res.data.items)
  429. }
  430. }
  431. })
  432. },
  433. laundryOrderList() {
  434. // 干洗订单列表
  435. laundryOrderList({
  436. status: this.navTypeKey,
  437. page: this.page
  438. }).then((res) => {
  439. if (res.code == 1) {
  440. if (res.data.items.length > 0) {
  441. this.list.push(...res.data.items)
  442. }
  443. }
  444. })
  445. },
  446. getExpressPay(id) {
  447. // 代取支付
  448. getExpressPay({
  449. order_id: id
  450. }).then((ret) => {
  451. if (ret.code === 1) {
  452. uni.requestPayment({
  453. provider: "wxpay", //支付类型-固定值
  454. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  455. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  456. package: ret.data.wx_pay.package, // 固定值
  457. signType: ret.data.wx_pay.signType, //固定值
  458. paySign: ret.data.wx_pay.paySign, //签名
  459. success: (ren) => {
  460. tools.success("支付成功");
  461. this.isAJAX = false;
  462. this.page = 1;
  463. this.list = [];
  464. this.expressOrderList()
  465. },
  466. fail: (err) => {
  467. this.isAJAX = false;
  468. tools.error("支付失败");
  469. },
  470. });
  471. } else {
  472. this.isAJAX = false;
  473. tools.error("支付失败");
  474. }
  475. })
  476. },
  477. groupPay(id) {
  478. // 团购支付
  479. groupPay({
  480. order_id: id
  481. }).then((ret) => {
  482. if (ret.code === 1) {
  483. uni.requestPayment({
  484. provider: "wxpay", //支付类型-固定值
  485. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  486. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  487. package: ret.data.wx_pay.package, // 固定值
  488. signType: ret.data.wx_pay.signType, //固定值
  489. paySign: ret.data.wx_pay.paySign, //签名
  490. success: (ren) => {
  491. tools.success("支付成功");
  492. this.isAJAX = false;
  493. this.page = 1;
  494. this.list = [];
  495. this.groupOrderList()
  496. },
  497. fail: (err) => {
  498. this.isAJAX = false;
  499. tools.error("支付失败");
  500. },
  501. });
  502. } else {
  503. this.isAJAX = false;
  504. tools.error("支付失败");
  505. }
  506. })
  507. },
  508. ticketPay(id) {
  509. // 票务支付
  510. ticketPay({
  511. order_id: id
  512. }).then((ret) => {
  513. if (ret.code === 1) {
  514. uni.requestPayment({
  515. provider: "wxpay", //支付类型-固定值
  516. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  517. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  518. package: ret.data.wx_pay.package, // 固定值
  519. signType: ret.data.wx_pay.signType, //固定值
  520. paySign: ret.data.wx_pay.paySign, //签名
  521. success: (ren) => {
  522. tools.success("支付成功");
  523. this.isAJAX = false;
  524. this.page = 1;
  525. this.list = [];
  526. this.ticketOrderList()
  527. },
  528. fail: (err) => {
  529. this.isAJAX = false;
  530. tools.error("支付失败");
  531. },
  532. });
  533. } else {
  534. this.isAJAX = false;
  535. tools.error("支付失败");
  536. }
  537. })
  538. }
  539. },
  540. }
  541. </script>
  542. <style lang="scss" scoped>
  543. .nav-box {
  544. padding: 26rpx 44rpx;
  545. overflow-x: scroll;
  546. .nav-item {
  547. margin-right: 76rpx;
  548. white-space: nowrap;
  549. position: relative;
  550. .nav-item-x {
  551. position: absolute;
  552. width: 48rpx;
  553. height: 6rpx;
  554. border-radius: 20rpx;
  555. background-color: #41ABF5;
  556. left: 12rpx;
  557. bottom: -10rpx;
  558. }
  559. }
  560. }
  561. .nav-type-box {
  562. width: 100%;
  563. white-space: nowrap;
  564. }
  565. .nav-type-item {
  566. width: 144rpx;
  567. height: 64rpx;
  568. line-height: 64rpx;
  569. margin: 0 24rpx 0 0;
  570. border-radius: 200rpx;
  571. display: inline-block;
  572. }
  573. .nav-type-item:last-child {
  574. margin: 0;
  575. }
  576. .list-box {
  577. padding: 20rpx;
  578. box-sizing: border-box;
  579. }
  580. .shops-img {
  581. width: 48rpx;
  582. height: 48rpx;
  583. margin: 0 8rpx 0 0;
  584. border-radius: 50%;
  585. }
  586. .shops-name {
  587. max-width: 452rpx;
  588. margin: 0 8rpx 0 0;
  589. }
  590. .icons {
  591. width: 32rpx;
  592. height: 32rpx;
  593. }
  594. .goods-box {
  595. max-width: 506rpx;
  596. height: auto;
  597. }
  598. .goods-num {
  599. width: 24rpx;
  600. height: auto;
  601. }
  602. .goods-img {
  603. width: 144rpx;
  604. height: 144rpx;
  605. border-radius: 12rpx;
  606. margin: 0 16rpx 0 0;
  607. }
  608. .goods-two {
  609. overflow-x: scroll;
  610. overflow: auto;
  611. }
  612. .goods-two-name {
  613. width: 144rpx;
  614. }
  615. .item-but {
  616. width: 160rpx;
  617. height: 64rpx;
  618. line-height: 64rpx;
  619. text-align: center;
  620. border-radius: 200rpx;
  621. }
  622. .but-class-one {
  623. background: linear-gradient(225deg, #41ABF5 0%, #5BD8FB 100%);
  624. color: #fff;
  625. }
  626. .but-class-two {
  627. background: #fff;
  628. border: 2rpx solid #CCCCCC;
  629. color: #333;
  630. }
  631. </style>