order.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. onReady () {
  253. // this.roleList = this.$mStore.getters.hasrole.reverse()
  254. let role = uni.getStorageSync('role')
  255. this.roleList = role.reverse()
  256. },
  257. // 下拉刷新page.json中要配置
  258. onPullDownRefresh() {
  259. this.startdate = '';
  260. this.enddate = '';
  261. this.sunday = 1;
  262. this.dateArr = [];
  263. this.index = 0
  264. this.params.pageNum = 1;
  265. this.params.buyPhone = '';
  266. this.params.ordersNo = '';
  267. this.params.shopId = '';
  268. this.params.overTimeArray = [
  269. moment().format('YYYY-MM-DD'),
  270. moment().format('YYYY-MM-DD'),
  271. ];
  272. this.orderbynumber = '';
  273. this.getOrderList();
  274. },
  275. // 页面触底加载
  276. onReachBottom() {
  277. if (this.soleStatus === 1) {
  278. if (this.more === 'noMore') {
  279. return;
  280. }
  281. this.loadMoreList();
  282. }
  283. },
  284. onLoad() {
  285. this.getShopList();
  286. this.getOrderList();
  287. },
  288. //方法集合
  289. methods: {
  290. // 手势开始
  291. handstart(event) {
  292. this.startTime = Date.now();
  293. this.startX = event.changedTouches[0].clientX;
  294. this.startY = event.changedTouches[0].clientY;
  295. },
  296. // 手势结束
  297. handend(event) {
  298. const endTime = Date.now();
  299. const endX = event.changedTouches[0].clientX;
  300. const endY = event.changedTouches[0].clientY;
  301. //判断按下的时长
  302. if (endTime - this.startTime > 2000) {
  303. return;
  304. }
  305. this.direction = '';
  306. //先判断用户滑动的距离
  307. if (Math.abs(endX - this.startX) > 50) {
  308. //滑动方向
  309. this.direction = endX - this.startX > 0 ? 'right' : 'left';
  310. this.more = 'loading'
  311. if (this.direction === 'right' && this.isactive === 0) {
  312. this.direction = ''
  313. this.more = 'noMore'
  314. return
  315. }
  316. if (this.direction === 'left' && this.isactive === 2) {
  317. this.direction = ''
  318. this.more = 'noMore'
  319. return
  320. }
  321. if (this.direction === 'right') {
  322. this.isactive--;
  323. if (this.isactive < 0) {
  324. this.isactive = 0
  325. this.more = 'noMore'
  326. return;
  327. }
  328. this.params.orderFlag = this.flagList[this.isactive];
  329. } else if (this.direction === 'left') {
  330. this.isactive++;
  331. if (this.isactive > 2) {
  332. this.isactive = 2;
  333. this.more = 'noMore'
  334. return;
  335. }
  336. this.params.orderFlag = this.flagList[this.isactive];
  337. }
  338. this.getOrderList();
  339. } else {
  340. return;
  341. }
  342. },
  343. // 打开日历
  344. openTime() {
  345. this.startdate = '';
  346. this.enddate = '';
  347. this.sunday = 1;
  348. this.$refs.calendar.open();
  349. },
  350. // 确认时间后
  351. confirm(e) {
  352. this.more = 'loading';
  353. this.startdate = e.range.before;
  354. this.enddate = e.range.after;
  355. if (!this.startdate || !this.enddate) {
  356. this.startdate = e.fulldate;
  357. this.enddate = e.fulldate;
  358. this.sunday = 1;
  359. this.params.overTimeArray = [this.startdate, this.enddate];
  360. this.getOrderList();
  361. return;
  362. }
  363. this.sunday = e.range.data.length;
  364. this.params.overTimeArray = [this.startdate, this.enddate];
  365. this.getOrderList();
  366. },
  367. // 根据订单号或者手机号查询
  368. orderByNum() {
  369. this.more = 'loading';
  370. let num = '';
  371. num = this.params.buyPhone;
  372. const pattern = /^1[345678]\d{9}$/;
  373. if (pattern.test(this.params.buyPhone)) {
  374. this.params.buyPhone = num;
  375. this.params.ordersNo = '';
  376. } else {
  377. this.params.buyPhone = '';
  378. this.params.ordersNo = num;
  379. }
  380. this.getOrderList();
  381. },
  382. // 商铺选择
  383. bindPickerChange(e) {
  384. this.more = 'loading';
  385. this.index = e.detail.value;
  386. this.params.shopId = this.shopArray[this.index].id;
  387. this.getOrderList();
  388. },
  389. // tab
  390. changeTab(type, falg) {
  391. this.direction = '' // 关闭动画
  392. this.more = 'loading';
  393. this.params.pageNum = 1;
  394. this.isactive = type;
  395. console.log(this.isactive);
  396. this.params.orderFlag = falg;
  397. this.getOrderList();
  398. },
  399. // 跳转详情
  400. todetail(num) {
  401. uni.setStorageSync('order', num);
  402. this.$mRouter.push({ route: '/pages/order/orderdetail' });
  403. },
  404. // 获取店铺列表
  405. async getShopList() {
  406. await this.$http.get('/homePage/getShopByMerId').then((res) => {
  407. if (res.data && res.code === 200) {
  408. let newarr = [{ name: '全部', id: '' }];
  409. this.shopArray = newarr.concat(res.data);
  410. }
  411. });
  412. },
  413. // 订单列表
  414. async getOrderList() {
  415. this.soleStatus = 1;
  416. this.orderList = [];
  417. await this.$http
  418. .post('/orders/proList', this.params)
  419. .then(async (res) => {
  420. if (res.data.list.length > 0) {
  421. this.orderList = res.data.list;
  422. if (res.data.nextPage === 0) {
  423. this.more = 'noMore';
  424. }
  425. } else {
  426. this.more = 'noMore';
  427. }
  428. });
  429. uni.stopPullDownRefresh();
  430. },
  431. // 上拉加载
  432. async loadMoreList() {
  433. this.params.pageNum++;
  434. await this.$http
  435. .post('/orders/proList', this.params)
  436. .then(async (res) => {
  437. if (res.data.list.length > 0) {
  438. this.orderList = this.orderList.concat(res.data.list);
  439. if (res.data.nextPage === 0) {
  440. this.more = 'noMore';
  441. }
  442. } else {
  443. this.more = 'noMore';
  444. return;
  445. }
  446. });
  447. },
  448. },
  449. };
  450. </script>
  451. <style lang="scss" scoped>
  452. .order {
  453. background-color: #f4f4f4;
  454. height: 100vh;
  455. .header-warp {
  456. width: 100%;
  457. background-color: #fff;
  458. padding: 15upx 33upx 0;
  459. position: fixed;
  460. .header-search {
  461. display: flex;
  462. align-items: center;
  463. .search {
  464. width: 100%;
  465. display: flex;
  466. align-items: center;
  467. height: 80upx;
  468. margin-left: 20upx;
  469. background-color: #f7f7f7;
  470. border-radius: 10upx;
  471. .cellphone {
  472. flex: 1;
  473. height: 100%;
  474. color: $titleColor;
  475. padding-left: 20upx;
  476. }
  477. .search-holder {
  478. color: #f00;
  479. }
  480. .txt {
  481. height: 72upx;
  482. width: 90upx;
  483. text-align: center;
  484. line-height: 72upx;
  485. color: #a95cff;
  486. font-size: 28upx;
  487. }
  488. }
  489. }
  490. .uni-list-cell {
  491. padding: 0 20upx;
  492. border-bottom: 1px solid #f4f4f4;
  493. .uni-list-cell-db {
  494. height: 80upx;
  495. font-size: 28upx;
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. background-color: #fff;
  500. color: #8f8f8f;
  501. font-size: 30upx;
  502. }
  503. .uni-input {
  504. height: 100%;
  505. line-height: 80upx;
  506. }
  507. .icon-warp {
  508. width: 19upx;
  509. .iconRight {
  510. width: 19upx;
  511. height: 27upx;
  512. }
  513. }
  514. }
  515. .btn-time {
  516. width: 100%;
  517. height: 80upx;
  518. display: flex;
  519. justify-content: center;
  520. align-items: center;
  521. border-bottom: 1px solid #f4f4f4;
  522. padding: 0 20upx;
  523. .opentime {
  524. flex: 1;
  525. display: flex;
  526. align-items: center;
  527. color: #8f8f8f;
  528. .start {
  529. font-size: 30upx;
  530. }
  531. .guo {
  532. padding: 0 45upx;
  533. font-size: 32upx;
  534. }
  535. .end {
  536. font-size: 30upx;
  537. }
  538. .sundate {
  539. font-size: 28upx;
  540. padding-left: 40upx;
  541. }
  542. }
  543. .iconRight {
  544. width: 19upx;
  545. height: 27upx;
  546. }
  547. }
  548. .header-bar {
  549. display: flex;
  550. justify-content: center;
  551. align-items: center;
  552. position: relative;
  553. .item {
  554. position: relative;
  555. width: 33.33%;
  556. height: 99upx;
  557. display: flex;
  558. justify-content: center;
  559. align-items: center;
  560. flex-direction: column;
  561. .ordertype {
  562. position: relative;
  563. font-size: 30upx;
  564. letter-spacing: 3upx;
  565. color: #7a7c7c;
  566. }
  567. .heng {
  568. position: absolute;
  569. display: none;
  570. bottom: 0;
  571. width: 40upx;
  572. height: 6upx;
  573. border-radius: 4upx;
  574. background-color: #a95cff;
  575. }
  576. }
  577. .active .ordertype {
  578. color: #a95cff;
  579. }
  580. .active .heng {
  581. display: block;
  582. }
  583. .henganimationLeft .heng {
  584. transition: all .5s;
  585. animation: hengRightToLeft .5s;
  586. }
  587. .henganimationRight .heng {
  588. transition: all .5s;
  589. animation: hengLeftToRight .5s;
  590. }
  591. @keyframes hengRightToLeft {
  592. from{
  593. transform: translateX(141upx);
  594. }
  595. to{
  596. transform: translateX(0);
  597. }
  598. }
  599. @keyframes hengLeftToRight {
  600. from{
  601. transform: translateX(-141upx);
  602. }
  603. to{
  604. transform: translateX(0);
  605. }
  606. }
  607. }
  608. }
  609. .order-content {
  610. padding: 24upx 32upx 0;
  611. .order-list {
  612. background-color: #fff;
  613. border-radius: 10upx;
  614. padding: 30upx 24upx 33upx;
  615. margin-bottom: 24upx;
  616. .order-title {
  617. border-bottom: 1px solid $bordrColor;
  618. display: flex;
  619. justify-content: space-between;
  620. align-items: center;
  621. padding-bottom: 22upx;
  622. .ordernum {
  623. font-size: 30upx;
  624. color: #232828;
  625. .num {
  626. margin-left: 10upx;
  627. }
  628. }
  629. .ordertime {
  630. color: #a3a8a8;
  631. }
  632. }
  633. .order-detail {
  634. margin-top: 24upx;
  635. .name {
  636. font-size: 34upx;
  637. }
  638. .door,
  639. .num,
  640. .status,
  641. .playtime {
  642. font-size: 26upx;
  643. color: #7a7c7c;
  644. margin-top: 14upx;
  645. }
  646. .message {
  647. margin-left: 10upx;
  648. }
  649. }
  650. }
  651. }
  652. .leaveRightToLeft {
  653. transition: all 0.5s linear;
  654. animation: leaveinRihthToLeft .5s;
  655. z-index: 10;
  656. }
  657. .leaveLeftToRight {
  658. transition: all 0.5s linear;
  659. animation: leaveLeftToRight .5s;
  660. z-index: 10;
  661. }
  662. @keyframes leaveinRihthToLeft {
  663. from {
  664. transform: translateX(768upx);
  665. }
  666. to {
  667. transform: translateX(0);
  668. }
  669. }
  670. @keyframes leaveLeftToRight {
  671. from {
  672. transform: translateX(-768upx);
  673. }
  674. to {
  675. transform: translateX(0);
  676. }
  677. }
  678. }
  679. </style>