order.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <!-- order -->
  2. <template>
  3. <view class="order" @touchstart="handstart($event)"
  4. @touchend="handend($event)">
  5. <view class="header-warp">
  6. <view class="header-search">
  7. <view class="search">
  8. <input
  9. type="text"
  10. placeholder-style="color:#a3a8a8;font-size:10px;"
  11. placeholder="请输入订单号或手机号"
  12. class="cellphone"
  13. v-model="params.buyPhone"
  14. />
  15. <text class="txt" @tap="orderByNum">搜索</text>
  16. </view>
  17. </view>
  18. <view class="uni-list-cell">
  19. <view class="uni-list-cell-db">
  20. <picker
  21. style="width: 100%; height: 100%;"
  22. @change="bindPickerChange"
  23. :value="index"
  24. :range="shopArray"
  25. range-key="name"
  26. >
  27. <view class="uni-input">{{ shopArray[index].name }}</view>
  28. </picker>
  29. <view class="icon-warp">
  30. <image
  31. src="../../static/images/moreicon.png"
  32. class="iconRight"
  33. ></image>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="btn-time">
  38. <uni-calendar
  39. ref="calendar"
  40. :insert="false"
  41. :range="true"
  42. :startDate="'2020-01-01'"
  43. :endDate="date"
  44. @confirm="confirm"
  45. />
  46. <view class="opentime" @tap="openTime">
  47. <view class="start">{{ startdate ? startdate : date }}</view>
  48. <text class="guo">至</text>
  49. <view class="end">{{ enddate ? enddate : date }}</view>
  50. <text class="sundate">共:{{ sunday }}天</text>
  51. </view>
  52. <view style="width: 19upx;">
  53. <image
  54. src="../../static/images/moreicon.png"
  55. class="iconRight"
  56. ></image>
  57. </view>
  58. </view>
  59. <view class="header-bar">
  60. <view
  61. class="item"
  62. @tap="changeTab(0, flagList[0])"
  63. :class="{ active: isactive === 0,henganimationLeft: direction === 'right', henganimationRight: direction === 'left' }"
  64. >
  65. <view class="ordertype">已付款</view>
  66. <view class="heng"></view>
  67. </view>
  68. <view
  69. class="item"
  70. @tap="changeTab(1, flagList[1])"
  71. :class="{ active: isactive === 1,henganimationLeft: direction === 'right', henganimationRight: direction === 'left' }"
  72. >
  73. <view class="ordertype">已完成</view>
  74. <view class="heng"></view>
  75. </view>
  76. <view
  77. class="item"
  78. @tap="changeTab(2, flagList[2])"
  79. :class="{ active: isactive === 2,henganimationLeft: direction === 'right', henganimationRight: direction === 'left' }"
  80. >
  81. <view class="ordertype">退款</view>
  82. <view class="heng"></view>
  83. </view>
  84. <view class="line"></view>
  85. </view>
  86. </view>
  87. <view style="height: 352upx;"></view>
  88. <view
  89. class="order-content"
  90. v-if="isactive === 0"
  91. :class="{ leaveRightToLeft: isactive === 0 && direction=== 'left', leaveLeftToRight: isactive === 0 && direction ==='right'}"
  92. >
  93. <view
  94. class="order-list"
  95. @tap="todetail(item.ordersNo)"
  96. v-for="(item, index) in orderList"
  97. :key="index"
  98. >
  99. <view class="order-title">
  100. <text class="ordernum"
  101. >订单号:<text class="num">{{ item.ordersNo }}</text></text
  102. >
  103. <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
  104. </view>
  105. <view class="order-detail">
  106. <view class="name">{{ item.shopName }}</view>
  107. <view class="door"
  108. >门店:<text class="message">{{ item.goodsName }}</text></view
  109. >
  110. <view class="num"
  111. >数量:<text class="message">{{ item.num }}</text></view
  112. >
  113. <view class="status"
  114. >状态:<text class="message">{{ item.statusName }}</text></view
  115. >
  116. <view class="playtime"
  117. >游玩时间:<text class="message"
  118. >{{ item.palyTime.substring(0, 11) }}
  119. {{ item.timePart ? item.timePart : '' }}</text
  120. ></view
  121. >
  122. </view>
  123. </view>
  124. </view>
  125. <view
  126. class="order-content"
  127. v-if="isactive === 1"
  128. :class="{ leaveRightToLeft: isactive === 1 && direction=== 'left', leaveLeftToRight: isactive === 1 && direction ==='right'}"
  129. >
  130. <view
  131. class="order-list"
  132. @tap="todetail(item.ordersNo)"
  133. v-for="(item, index) in orderList"
  134. :key="index"
  135. >
  136. <view class="order-title">
  137. <text class="ordernum"
  138. >订单号:<text class="num">{{ item.ordersNo }}</text></text
  139. >
  140. <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
  141. </view>
  142. <view class="order-detail">
  143. <view class="name">{{ item.shopName }}</view>
  144. <view class="door"
  145. >门店:<text class="message">{{ item.goodsName }}</text></view
  146. >
  147. <view class="num"
  148. >数量:<text class="message">{{ item.num }}</text></view
  149. >
  150. <view class="status"
  151. >状态:<text class="message">{{ item.statusName }}</text></view
  152. >
  153. <view class="playtime"
  154. >游玩时间:<text class="message"
  155. >{{ item.palyTime.substring(0, 11) }}
  156. {{ item.timePart ? item.timePart : '' }}</text
  157. ></view
  158. >
  159. </view>
  160. </view>
  161. </view>
  162. <view
  163. class="order-content"
  164. v-if="isactive === 2"
  165. :class="{ leaveRightToLeft: isactive === 2 && direction=== 'left', leaveLeftToRight: isactive === 2 && direction ==='right'}"
  166. >
  167. <view
  168. class="order-list"
  169. @tap="todetail(item.ordersNo)"
  170. v-for="(item, index) in orderList"
  171. :key="index"
  172. >
  173. <view class="order-title">
  174. <text class="ordernum"
  175. >订单号:<text class="num">{{ item.ordersNo }}</text></text
  176. >
  177. <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
  178. </view>
  179. <view class="order-detail">
  180. <view class="name">{{ item.shopName }}</view>
  181. <view class="door"
  182. >门店:<text class="message">{{ item.goodsName }}</text></view
  183. >
  184. <view class="num"
  185. >数量:<text class="message">{{ item.num }}</text></view
  186. >
  187. <view class="status"
  188. >状态:<text class="message">{{ item.statusName }}</text></view
  189. >
  190. <view class="playtime"
  191. >游玩时间:<text class="message"
  192. >{{ item.palyTime.substring(0, 11) }}
  193. {{ item.timePart ? item.timePart : '' }}</text
  194. ></view
  195. >
  196. </view>
  197. </view>
  198. </view>
  199. <tabBar :currentIndex="typeNum" ></tabBar>
  200. <uni-load-more :status="more"> </uni-load-more>
  201. <rf-loading v-if="loading"></rf-loading>
  202. <view style="height: 100upx;"></view>
  203. </view>
  204. </template>
  205. <script>
  206. import moment from '@/common/moment';
  207. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  208. import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
  209. export default {
  210. name: 'order',
  211. components: { uniLoadMore, uniCalendar },
  212. data() {
  213. //这里存放数据
  214. return {
  215. typeNum: 1,
  216. // loading: false,
  217. shopArray: [{ name: '全部', id: '' }],
  218. index: 0,
  219. shopID: 0,
  220. isactive: 0, // tab
  221. flagList: ['pay', 'accomplish', 'refundorder'],
  222. direction: '',
  223. more: 'loading', // more loading noMore
  224. date: moment().format('YYYY-MM-DD'),
  225. yesdate: moment().subtract(1, 'day').format('YYYY-MM-DD'),
  226. dateArr: [],
  227. startdate: '',
  228. enddate: '',
  229. sunday: 1,
  230. orderFlag: 'pay', // pay accomplish refundorder
  231. soleStatus: 1, // 触底状态
  232. orderList: [],
  233. params: {
  234. orderFlag: 'pay', // pay accomplish refundorder
  235. pageNum: 1,
  236. pageSize: 10,
  237. ordersNo: '',
  238. buyPhone: '',
  239. shopId: '',
  240. overTimeArray: [
  241. moment().format('YYYY-MM-DD'),
  242. moment().format('YYYY-MM-DD'),
  243. ],
  244. },
  245. //按下的时间
  246. startTime: 0,
  247. //按下的坐标
  248. startX: 0,
  249. startY: 0,
  250. };
  251. },
  252. // 下拉刷新page.json中要配置
  253. onPullDownRefresh() {
  254. this.startdate = '';
  255. this.enddate = '';
  256. this.sunday = 1;
  257. this.dateArr = [];
  258. this.index = 0
  259. this.params.pageNum = 1;
  260. this.params.buyPhone = '';
  261. this.params.ordersNo = '';
  262. this.params.shopId = '';
  263. this.params.overTimeArray = [
  264. moment().format('YYYY-MM-DD'),
  265. moment().format('YYYY-MM-DD'),
  266. ];
  267. this.orderbynumber = '';
  268. this.getOrderList();
  269. },
  270. // 页面触底加载
  271. onReachBottom() {
  272. if (this.soleStatus === 1) {
  273. if (this.more === 'noMore') {
  274. return;
  275. }
  276. this.loadMoreList();
  277. }
  278. },
  279. onLoad() {
  280. this.getShopList();
  281. this.getOrderList();
  282. },
  283. //方法集合
  284. methods: {
  285. // 手势开始
  286. handstart(event) {
  287. this.startTime = Date.now();
  288. this.startX = event.changedTouches[0].clientX;
  289. this.startY = event.changedTouches[0].clientY;
  290. },
  291. // 手势结束
  292. handend(event) {
  293. const endTime = Date.now();
  294. const endX = event.changedTouches[0].clientX;
  295. const endY = event.changedTouches[0].clientY;
  296. //判断按下的时长
  297. if (endTime - this.startTime > 2000) {
  298. return;
  299. }
  300. this.direction = '';
  301. //先判断用户滑动的距离
  302. if (Math.abs(endX - this.startX) > 50) {
  303. //滑动方向
  304. this.direction = endX - this.startX > 0 ? 'right' : 'left';
  305. this.more = 'loading'
  306. if (this.direction === 'right' && this.isactive === 0) {
  307. this.direction = ''
  308. this.more = 'noMore'
  309. return
  310. }
  311. if (this.direction === 'left' && this.isactive === 2) {
  312. this.direction = ''
  313. this.more = 'noMore'
  314. return
  315. }
  316. if (this.direction === 'right') {
  317. this.isactive--;
  318. if (this.isactive < 0) {
  319. this.isactive = 0
  320. this.more = 'noMore'
  321. return;
  322. }
  323. this.params.orderFlag = this.flagList[this.isactive];
  324. } else if (this.direction === 'left') {
  325. this.isactive++;
  326. if (this.isactive > 2) {
  327. this.isactive = 2;
  328. this.more = 'noMore'
  329. return;
  330. }
  331. this.params.orderFlag = this.flagList[this.isactive];
  332. }
  333. this.getOrderList();
  334. } else {
  335. return;
  336. }
  337. },
  338. // 打开日历
  339. openTime() {
  340. this.startdate = '';
  341. this.enddate = '';
  342. this.sunday = 1;
  343. this.$refs.calendar.open();
  344. },
  345. // 确认时间后
  346. confirm(e) {
  347. this.more = 'loading';
  348. this.startdate = e.range.before;
  349. this.enddate = e.range.after;
  350. if (!this.startdate || !this.enddate) {
  351. this.startdate = e.fulldate;
  352. this.enddate = e.fulldate;
  353. this.sunday = 1;
  354. this.params.overTimeArray = [this.startdate, this.enddate];
  355. this.getOrderList();
  356. return;
  357. }
  358. this.sunday = e.range.data.length;
  359. this.params.overTimeArray = [this.startdate, this.enddate];
  360. this.getOrderList();
  361. },
  362. // 根据订单号或者手机号查询
  363. orderByNum() {
  364. this.more = 'loading';
  365. let num = '';
  366. num = this.params.buyPhone;
  367. const pattern = /^1[345678]\d{9}$/;
  368. if (pattern.test(this.params.buyPhone)) {
  369. this.params.buyPhone = num;
  370. this.params.ordersNo = '';
  371. } else {
  372. this.params.buyPhone = '';
  373. this.params.ordersNo = num;
  374. }
  375. this.getOrderList();
  376. },
  377. // 商铺选择
  378. bindPickerChange(e) {
  379. this.more = 'loading';
  380. this.index = e.detail.value;
  381. this.params.shopId = this.shopArray[this.index].id;
  382. this.getOrderList();
  383. },
  384. // tab
  385. changeTab(type, falg) {
  386. this.direction = '' // 关闭动画
  387. this.more = 'loading';
  388. this.params.pageNum = 1;
  389. this.isactive = type;
  390. console.log(this.isactive);
  391. this.params.orderFlag = falg;
  392. this.getOrderList();
  393. },
  394. // 跳转详情
  395. todetail(num) {
  396. uni.setStorageSync('order', num);
  397. this.$mRouter.push({ route: '/pages/order/orderdetail' });
  398. },
  399. // 获取店铺列表
  400. async getShopList() {
  401. await this.$http.get('/homePage/getShopByMerId').then((res) => {
  402. if (res.data && res.code === 200) {
  403. let newarr = [{ name: '全部', id: '' }];
  404. this.shopArray = newarr.concat(res.data);
  405. }
  406. });
  407. },
  408. // 订单列表
  409. async getOrderList() {
  410. this.soleStatus = 1;
  411. this.orderList = [];
  412. await this.$http
  413. .post('/orders/proList', this.params)
  414. .then(async (res) => {
  415. if (res.data.list.length > 0) {
  416. this.orderList = res.data.list;
  417. if (res.data.nextPage === 0) {
  418. this.more = 'noMore';
  419. }
  420. } else {
  421. this.more = 'noMore';
  422. }
  423. });
  424. uni.stopPullDownRefresh();
  425. },
  426. // 上拉加载
  427. async loadMoreList() {
  428. this.params.pageNum++;
  429. await this.$http
  430. .post('/orders/proList', this.params)
  431. .then(async (res) => {
  432. if (res.data.list.length > 0) {
  433. this.orderList = this.orderList.concat(res.data.list);
  434. if (res.data.nextPage === 0) {
  435. this.more = 'noMore';
  436. }
  437. } else {
  438. this.more = 'noMore';
  439. return;
  440. }
  441. });
  442. },
  443. },
  444. };
  445. </script>
  446. <style lang="scss" scoped>
  447. .order {
  448. background-color: #f4f4f4;
  449. height: 100vh;
  450. .header-warp {
  451. width: 100%;
  452. background-color: #fff;
  453. padding: 15upx 33upx 0;
  454. position: fixed;
  455. .header-search {
  456. display: flex;
  457. align-items: center;
  458. .search {
  459. width: 100%;
  460. display: flex;
  461. align-items: center;
  462. height: 80upx;
  463. margin-left: 20upx;
  464. background-color: #f7f7f7;
  465. border-radius: 10upx;
  466. .cellphone {
  467. flex: 1;
  468. height: 100%;
  469. color: $titleColor;
  470. padding-left: 20upx;
  471. }
  472. .search-holder {
  473. color: #f00;
  474. }
  475. .txt {
  476. height: 72upx;
  477. width: 90upx;
  478. text-align: center;
  479. line-height: 72upx;
  480. color: #a95cff;
  481. font-size: 28upx;
  482. }
  483. }
  484. }
  485. .uni-list-cell {
  486. padding: 0 20upx;
  487. border-bottom: 1px solid #f4f4f4;
  488. .uni-list-cell-db {
  489. height: 80upx;
  490. font-size: 28upx;
  491. display: flex;
  492. justify-content: space-between;
  493. align-items: center;
  494. background-color: #fff;
  495. color: #8f8f8f;
  496. font-size: 30upx;
  497. }
  498. .uni-input {
  499. height: 100%;
  500. line-height: 80upx;
  501. }
  502. .icon-warp {
  503. width: 19upx;
  504. .iconRight {
  505. width: 19upx;
  506. height: 27upx;
  507. }
  508. }
  509. }
  510. .btn-time {
  511. width: 100%;
  512. height: 80upx;
  513. display: flex;
  514. justify-content: center;
  515. align-items: center;
  516. border-bottom: 1px solid #f4f4f4;
  517. padding: 0 20upx;
  518. .opentime {
  519. flex: 1;
  520. display: flex;
  521. align-items: center;
  522. color: #8f8f8f;
  523. .start {
  524. font-size: 30upx;
  525. }
  526. .guo {
  527. padding: 0 45upx;
  528. font-size: 32upx;
  529. }
  530. .end {
  531. font-size: 30upx;
  532. }
  533. .sundate {
  534. font-size: 28upx;
  535. padding-left: 40upx;
  536. }
  537. }
  538. .iconRight {
  539. width: 19upx;
  540. height: 27upx;
  541. }
  542. }
  543. .header-bar {
  544. display: flex;
  545. justify-content: center;
  546. align-items: center;
  547. position: relative;
  548. .item {
  549. position: relative;
  550. width: 33.33%;
  551. height: 99upx;
  552. display: flex;
  553. justify-content: center;
  554. align-items: center;
  555. flex-direction: column;
  556. .ordertype {
  557. position: relative;
  558. font-size: 30upx;
  559. letter-spacing: 3upx;
  560. color: #7a7c7c;
  561. }
  562. .heng {
  563. position: absolute;
  564. display: none;
  565. bottom: 0;
  566. width: 40upx;
  567. height: 6upx;
  568. border-radius: 4upx;
  569. background-color: #a95cff;
  570. }
  571. }
  572. .active .ordertype {
  573. color: #a95cff;
  574. }
  575. .active .heng {
  576. display: block;
  577. }
  578. .henganimationLeft .heng {
  579. transition: all .5s;
  580. animation: hengRightToLeft .5s;
  581. }
  582. .henganimationRight .heng {
  583. transition: all .5s;
  584. animation: hengLeftToRight .5s;
  585. }
  586. @keyframes hengRightToLeft {
  587. from{
  588. transform: translateX(141upx);
  589. }
  590. to{
  591. transform: translateX(0);
  592. }
  593. }
  594. @keyframes hengLeftToRight {
  595. from{
  596. transform: translateX(-141upx);
  597. }
  598. to{
  599. transform: translateX(0);
  600. }
  601. }
  602. }
  603. }
  604. .order-content {
  605. padding: 24upx 32upx 0;
  606. .order-list {
  607. background-color: #fff;
  608. border-radius: 10upx;
  609. padding: 30upx 24upx 33upx;
  610. margin-bottom: 24upx;
  611. .order-title {
  612. border-bottom: 1px solid $bordrColor;
  613. display: flex;
  614. justify-content: space-between;
  615. align-items: center;
  616. padding-bottom: 22upx;
  617. .ordernum {
  618. font-size: 30upx;
  619. color: #232828;
  620. .num {
  621. margin-left: 10upx;
  622. }
  623. }
  624. .ordertime {
  625. color: #a3a8a8;
  626. }
  627. }
  628. .order-detail {
  629. margin-top: 24upx;
  630. .name {
  631. font-size: 34upx;
  632. }
  633. .door,
  634. .num,
  635. .status,
  636. .playtime {
  637. font-size: 26upx;
  638. color: #7a7c7c;
  639. margin-top: 14upx;
  640. }
  641. .message {
  642. margin-left: 10upx;
  643. }
  644. }
  645. }
  646. }
  647. .leaveRightToLeft {
  648. transition: all 0.5s linear;
  649. animation: leaveinRihthToLeft .5s;
  650. z-index: 10;
  651. }
  652. .leaveLeftToRight {
  653. transition: all 0.5s linear;
  654. animation: leaveLeftToRight .5s;
  655. z-index: 10;
  656. }
  657. @keyframes leaveinRihthToLeft {
  658. from {
  659. transform: translateX(768upx);
  660. }
  661. to {
  662. transform: translateX(0);
  663. }
  664. }
  665. @keyframes leaveLeftToRight {
  666. from {
  667. transform: translateX(-768upx);
  668. }
  669. to {
  670. transform: translateX(0);
  671. }
  672. }
  673. }
  674. </style>