book-month - 副本.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="book-month">
  3. <view class="book-month-xq flex-n fac fja">
  4. <view v-for="(item,index) in xqday" :key="index" :class="index==5||index==6?'book-month-zm':''">{{item}}</view>
  5. </view>
  6. <swiper class="book-out" :disable-touch="disabletouch" :current="1" circular @change="change" @animationfinish="animationfinish"
  7. @transition="transition">
  8. <swiper-item class="book-month-area" :key='index' v-for="(item,index) in threeMonthList">
  9. <scroll-view id="book-out" class="book-in" scroll-y :show-scrollbar="false">
  10. <view class="book-month-area_rows" v-for="(itm,idx) in item" :key="idx">
  11. <view class="flex-n">
  12. <view class="book-month-area_columns line-1 flex-1 ptb-10" :class="itm2.mm!=item[1][3].mm?'book-month-area_columns_gray':''"
  13. v-for="(itm2,idx2) in itm" :key="itm2.dd" @click="showDateInfo(itm2,idx,idx2)">
  14. <view class="flex-n fac fjc">
  15. <!-- (new Date().getFullYear()==itm2.yy&&(new Date().getMonth()+1)==itm2.mm&&(new Date().getDate()==itm2.dd))?'item_today':'' -->
  16. <view class="item_day" :class="[{'item_today':new Date().getFullYear()==itm2.yy&&(new Date().getMonth()+1)==itm2.mm&&(new Date().getDate()==itm2.dd),'item_day_select':row==idx&&column==idx2}]">{{itm2.dd}}</view>
  17. <view class="iconfont iconxing2" v-if="ImpList[idx*7+idx2]&&ImpList[idx*7+idx2].importantDates&&ImpList[idx*7+idx2].importantDates.length>0"
  18. style="color: #e64340;font-size: 25rpx;transform: scale(0.8);width: 20rpx;"></view>
  19. <view class="item_daycn " :class="ImpList[idx*7+idx2]&&ImpList[idx*7+idx2].importantDates&&ImpList[idx*7+idx2].importantDates.length>0?'':'ml-22'">{{itm2.IDayCn}}</view>
  20. </view>
  21. <view class="book-month-area_data " v-if="orderTotalList[idx*7+idx2]&&orderTotalList[idx*7+idx2].houseOrderCalc.length>0">
  22. <view v-for="(itmorder,idxorder) in orderTotalList[idx*7+idx2].houseOrderCalc" :key="idxorder">
  23. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='01'">
  24. <image class="icon" src="../../../static/c1.png"></image>
  25. <view class="num flex-1">{{itmorder.orderCount}}</view>
  26. </view>
  27. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='03'">
  28. <image class="icon" src="../../../static/c2.png"></image>
  29. <view class="num flex-1">{{itmorder.orderCount}}</view>
  30. </view>
  31. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='02'">
  32. <image class="icon" src="../../../static/c3.png"></image>
  33. <view class="num flex-1">{{itmorder.orderCount}}</view>
  34. </view>
  35. </view>
  36. <view class="flex-n fac" v-if="isDisplayPrein=='1'">
  37. <image class="icon" src="../../../static/c4.png"></image>
  38. <view class="num flex-1 line-1">{{orderTotalList[idx*7+idx2].totalMoney}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <scroll-view scroll-y class="book-month-area_list" v-if="idx==row&&current==index" :animation="showDataAnimate"
  44. @scrolltolower="scrolltolower" :show-scrollbar="false" @scroll="scroll">
  45. <view class="book-month-area_list_content">
  46. <template v-if="dataList.length">
  47. <z-timeline align="center" v-for="(item,index) in dataList" :key="index" @click.native="gotoDetail(item.id)">
  48. <z-timeline-item>
  49. <view class="item shadow-1 mtb-5 flex-n fac">
  50. <view class="content1 flex-1">
  51. <view class="content1_1">{{item.orderDate}} {{item.activityBeginTime==item.activityBeginTimeReal?item.activityBeginTime:('次日'+item.activityBeginTimeReal)}}~{{item.activityEndTime==item.activityEndTimeReal?item.activityEndTime:('次日'+item.activityEndTimeReal)}}</view>
  52. <view class="content1_2">
  53. <text class="mr-20" v-if="item.isWedding&&item.hasWedding=='1'">{{item.maleName}}/{{item.femaleName}}</text>
  54. <text class="mr-20" v-else>{{item.customName}}</text>
  55. {{item.houseName}} {{item.packageName}}{{item.paycontent}}</view>
  56. </view>
  57. <view class="content2">{{item.orderStateText}}</view>
  58. <view class="content3 ml-55 iconfont icondianhua-copy" @click.stop="showMakePhone=true;callPhone=item.phone"></view>
  59. </view>
  60. </z-timeline-item>
  61. </z-timeline>
  62. </template>
  63. <z-nodata v-if="dataList.length==0"></z-nodata>
  64. <z-loading :showLoading="showLoading" :length="dataList.length" :total="total" v-else></z-loading>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. </scroll-view>
  69. </swiper-item>
  70. </swiper>
  71. <z-select-popup :visible.sync="showMakePhone">
  72. <view @click="gotoMakePhone">{{callPhone||'无联系电话'}}</view>
  73. </z-select-popup>
  74. <u-toast ref="uToast"></u-toast>
  75. </view>
  76. </template>
  77. <script>
  78. const app = getApp({
  79. allowDefault: true
  80. });
  81. export default {
  82. name: 'book-month',
  83. props: {
  84. refresh: Boolean
  85. },
  86. data() {
  87. return {
  88. current: 1,
  89. left: 0,
  90. right: 2,
  91. xqday: ['一', '二', '三', '四', '五', '六', '日'],
  92. monthList: [],
  93. ImpList: [], //重点日期
  94. orderTotalList: [], //订单总计数
  95. threeMonthList: ['', '', ''],
  96. dataList: [],
  97. callPhone: '',
  98. column: -1,
  99. row: -1,
  100. disabletouch: false,
  101. monthday: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  102. showDataAnimate: {},
  103. dx: 0,
  104. weekName: ['一', '二', '三', '四', '五', '六', '日'],
  105. showday: {}, //需要传入的值
  106. choose: 0,
  107. animateIn: '',
  108. timeout: '',
  109. showMakePhone: false,
  110. date: '',
  111. total: 0,
  112. pageNum: 1,
  113. scrollTop: 0,
  114. showLoading: false,
  115. savedata:{},
  116. isDisplayPrein:'0'
  117. }
  118. },
  119. watch: {
  120. '$store.state.searchDate'(newval, oldval) {
  121. console.log(newval)
  122. this.column = -1;
  123. this.row = -1;
  124. this.dataList = [];
  125. var date = newval.split('-');
  126. var datelist = this.$Date.getDayDate({
  127. yy: date[0],
  128. mm: date[1],
  129. dd: 15
  130. });
  131. this.getDateList(datelist, this.current, this.left, this.right);
  132. },
  133. refresh(newval, oldval) {
  134. console.log(newval)
  135. if (newval) {
  136. // this.pageNum = 1;
  137. // this.dataList = [];
  138. // console.log(this.savedata)
  139. // this.showDateInfo(this.savedata.info, this.savedata.row, this.savedata.column)
  140. // this.bookList(this.date);
  141. // this.bookImportantDate()
  142. this.getDateList(this.$Date.getDayDate(), 1, 0, 2);
  143. }else{
  144. this.row=-1;
  145. this.current=1;
  146. }
  147. }
  148. },
  149. mounted() {
  150. this.getDateList(this.$Date.getDayDate(), 1, 0, 2);
  151. this.animateIn = uni.createAnimation({
  152. transformOrigin: "50% 0",
  153. duration: 300,
  154. timingFunction: 'ease-out'
  155. })
  156. },
  157. methods: {
  158. doNothing() {},
  159. //重点日期从
  160. bookImportantDate(dataList) {
  161. this.$axios.post("app/order/orderImportantDate", {
  162. "startTime": dataList[0].date,
  163. "endTime": dataList[dataList.length - 1].date,
  164. "storeId": uni.getStorageSync('storeId')
  165. }).then(res => {
  166. console.log(res)
  167. this.ImpList = res.data.list;
  168. }).catch(err => {
  169. this.$refs.uToast.error(err.msg)
  170. })
  171. },
  172. //日历订单汇总
  173. orderCalendarTotal(dataList) {
  174. var houseTypeIds = uni.getStorageSync('searchField')||[];
  175. this.$axios.post("app/order/orderCalendarTotalCalc", {
  176. "startTime": dataList[0].date,
  177. "endTime": dataList[dataList.length - 1].date,
  178. "storeId": uni.getStorageSync('storeId'),
  179. "houseTypeIds": houseTypeIds,
  180. }).then(res => {
  181. console.log(res)
  182. this.orderTotalList = res.data.list;
  183. }).catch(err => {
  184. this.$refs.uToast.error(err.msg)
  185. })
  186. },
  187. showDateInfo(info, row, column) {
  188. // console.log(info, row, column)
  189. this.savedata={
  190. info:info,
  191. row:row,
  192. column:column
  193. }
  194. this.pageNum = 1;
  195. this.dataList = [];
  196. if (this.row == row && this.column == column) {
  197. this.animateIn.height(0).step({
  198. delay: 0
  199. });
  200. this.showDataAnimate = this.animateIn.export();
  201. this.timeout = setTimeout(() => {
  202. this.row = -1;
  203. this.column = -1;
  204. }, 300)
  205. } else {
  206. clearTimeout(this.timeout);
  207. this.row = row;
  208. this.column = column;
  209. this.animateIn.height(0).step({
  210. duration: 0,
  211. delay: 0
  212. }).height(250).step();
  213. this.showDataAnimate = this.animateIn.export();
  214. this.date = info.date;
  215. this.getData(info.date);
  216. uni.showLoading({
  217. title: '数据加载中',
  218. mask: true
  219. })
  220. }
  221. },
  222. getData(date) {
  223. console.log(date)
  224. var houseTypeIds = uni.getStorageSync('searchField')||[];
  225. this.$axios.post('app/order/orderList', {
  226. "storeId": uni.getStorageSync('storeId'),
  227. "customName": "",
  228. "phone": "",
  229. "startTime": date,
  230. "endTime": date,
  231. "houseId": "",
  232. "packageId": "",
  233. "confirmState": "-1",
  234. "pageNum": this.pageNum,
  235. "houseTypeIds": houseTypeIds,
  236. "pageSize": 4
  237. }).then(res => {
  238. console.log('预定列表', res)
  239. var dataList = res.data.list;
  240. for (var i in dataList) {
  241. var paycontent = '';
  242. if (dataList[i].mainPayType == '03') {
  243. paycontent += '包场地'
  244. if (dataList[i].payTypes.length > 1) {
  245. paycontent += '('
  246. }
  247. }
  248. for (var j in dataList[i].payTypes) {
  249. if (dataList[i].payTypes[j].payTypeCode == '01') {
  250. paycontent += (dataList[i].payTypes[j].orderCount || 0) + '人、'
  251. }
  252. if (dataList[i].payTypes[j].payTypeCode == '02') {
  253. paycontent += (dataList[i].payTypes[j].orderCount || 0) + '桌、'
  254. }
  255. }
  256. if (paycontent.length > 0) {
  257. paycontent = paycontent.substring(0, paycontent.length - 1);
  258. }
  259. if (dataList[i].mainPayType == '03' && dataList[i].payTypes.length > 1) {
  260. paycontent += ')'
  261. }
  262. dataList[i].paycontent = paycontent.length > 0 ? ('[' + paycontent + ']') : ''
  263. }
  264. this.dataList = this.dataList.concat(dataList);
  265. uni.hideLoading();
  266. this.total = res.data.total;
  267. this.showLoading = false;
  268. }).catch(err => {
  269. uni.hideLoading();
  270. this.$refs.uToast.error(err.msg);
  271. this.showLoading = false;
  272. })
  273. },
  274. //获取日期数据 获取上一月 下一周月
  275. getDateList(datelist, current, x1, x2) {
  276. var dateString = '',
  277. oneList = [],
  278. twoList = [],
  279. threeList = [];
  280. //#ifdef APP-PLUS
  281. dateString = datelist.yy + '/' + Number(datelist.mm) + '/' + Number(datelist.dd);
  282. //#endif
  283. //#ifndef APP-PLUS
  284. dateString = datelist.date;
  285. //#endif
  286. var before = new Date(new Date(dateString).getTime() - datelist.dd * 24 * 60 * 60 * 1000),
  287. after = new Date(new Date(dateString).getTime() + (32 - datelist.dd) * 24 * 60 * 60 * 1000);
  288. var a1 = this.$Date.getMonthDate({
  289. yy: before.getFullYear(),
  290. mm: before.getMonth() + 1,
  291. dd: before.getDate()
  292. });
  293. for (var i = 0; i < a1.length / 7; i++) {
  294. oneList.push([])
  295. }
  296. for (var i = 0, len = a1.length; i < len; i++) {
  297. oneList[Math.floor(i / 7)].push(a1[i])
  298. }
  299. var a2 = this.$Date.getMonthDate(datelist);
  300. for (var i = 0; i < a2.length / 7; i++) {
  301. twoList.push([])
  302. }
  303. for (var i = 0, len = a2.length; i < len; i++) {
  304. twoList[Math.floor(i / 7)].push(a2[i])
  305. }
  306. var a3 = this.$Date.getMonthDate({
  307. yy: after.getFullYear(),
  308. mm: after.getMonth() + 1,
  309. dd: after.getDate()
  310. });
  311. for (var i = 0; i < a3.length / 7; i++) {
  312. threeList.push([])
  313. }
  314. for (var i = 0, len = a3.length; i < len; i++) {
  315. threeList[Math.floor(i / 7)].push(a3[i])
  316. }
  317. this.threeMonthList.splice(x1, 1, oneList);
  318. this.threeMonthList.splice(current, 1, twoList);
  319. this.threeMonthList.splice(x2, 1, threeList);
  320. this.$emit('getDateInfo', a2[15])
  321. this.disabletouch = false;
  322. var list = this.$Date.getMonthDate({
  323. yy: datelist.yy,
  324. mm: datelist.mm,
  325. dd: datelist.dd
  326. });
  327. this.bookImportantDate(list);
  328. this.orderCalendarTotal(list);
  329. console.log('yue', list)
  330. this.getAuthState();
  331. },
  332. getAuthState(){
  333. this.$axios.post("storeAuth/findByRoleIdStoreId",{
  334. "roleId":uni.getStorageSync('roleId'),
  335. "storeId": uni.getStorageSync('storeId')
  336. }).then(res=>{
  337. console.log(res.data)
  338. //不可编辑
  339. this.isDisplayPrein=res.data.auth.isDisplayPrein;
  340. }).catch(err=>{
  341. this.$refs.uToast.error(err.msg);
  342. })
  343. },
  344. //选择的日期
  345. chooseDate(idx) {
  346. this.choose = idx;
  347. },
  348. change(e) {
  349. this.row = -1;
  350. this.column = -1;
  351. this.disabletouch = true;
  352. },
  353. animationfinish(e) {
  354. clearTimeout(this.timeout);
  355. var current = e.detail.current;
  356. this.current = current;
  357. var left = 0,
  358. right = 0;
  359. if (current - 1 >= 0) {
  360. left = current - 1;
  361. } else {
  362. left = 2;
  363. }
  364. if (current + 1 > 2) {
  365. right = 0;
  366. } else {
  367. right = current + 1;
  368. }
  369. this.left = left;
  370. this.right = right;
  371. if (this.dx < 0) {
  372. this.getDateList(this.threeMonthList[current][1][1], current, left, right);
  373. // console.log('左滑:左面是', left, '当前是', current, '右面是', right);
  374. } else if (this.dx > 0) {
  375. this.getDateList(this.threeMonthList[current][1][1], current, left, right);
  376. // console.log('右滑:左面是', left, '当前是', current, '右面是', right);
  377. } else {
  378. // console.log('没有滑动:左面是', left, '当前是', current, '右面是', right);
  379. this.disabletouch = false;
  380. }
  381. this.dx = 0;
  382. },
  383. transition(e) {
  384. this.dx = e.detail.dx;
  385. },
  386. //拨打电话
  387. gotoMakePhone() {
  388. var that = this;
  389. uni.makePhoneCall({
  390. phoneNumber: this.callPhone,
  391. complete: function() {
  392. that.showMakePhone = false;
  393. }
  394. });
  395. },
  396. gotoDetail(id) {
  397. this.row = -1;
  398. this.column = -1;
  399. uni.navigateTo({
  400. url: '../detail/index?id=' + id
  401. })
  402. },
  403. scroll(e) {
  404. this.scrollTop = e.detail.scrollTop
  405. },
  406. scrolltolower() {
  407. var totalPage = Math.ceil(Number(this.total) / 4)
  408. if (this.pageNum < totalPage) {
  409. this.pageNum++;
  410. this.showLoading = true;
  411. this.getData(this.date);
  412. }
  413. },
  414. scrolltoupper() {
  415. this.pageNum = 1;
  416. this.dataList = [];
  417. this.showLoading = true;
  418. this.getData(this.date);
  419. }
  420. }
  421. }
  422. </script>
  423. <style scoped lang="scss">
  424. .norecord {
  425. width: 457rpx;
  426. margin-left: 147rpx;
  427. margin-top: 20rpx;
  428. }
  429. .book-out {
  430. height: calc(100% - 82rpx);
  431. .book-in {
  432. height: 100%;
  433. }
  434. }
  435. .book-month {
  436. height: 100%;
  437. .book-month-xq {
  438. height: 80rpx;
  439. color: #333333;
  440. font-size: 28rpx;
  441. border-bottom: 1px solid #E4E4E4;
  442. .book-month-zm {
  443. color: #F7913D;
  444. }
  445. }
  446. .book-month-area {
  447. height: 100%;
  448. .book-month-area_rows {
  449. border-bottom: 1px solid #E4E4E4;
  450. .book-month-area_columns_gray {
  451. background: #FAFAFA;
  452. .item_day {
  453. color: #999999;
  454. font-size: 24rpx;
  455. }
  456. }
  457. .item_day_select{
  458. border:2rpx solid #F7913D!important;
  459. border-radius: 50%;
  460. width: 32rpx;
  461. height: 32rpx;
  462. text-align:center;
  463. line-height: 32rpx;
  464. }
  465. .item_today{
  466. border:2rpx solid #F7913D!important;
  467. color: white!important;
  468. background: #F7913D;
  469. border-radius: 50%;
  470. width: 32rpx;
  471. height: 32rpx;
  472. text-align:center;
  473. line-height: 32rpx;
  474. }
  475. .book-month-area_columns {
  476. border-right: 1px solid #E4E4E4;
  477. min-height: 160rpx;
  478. .item_day {
  479. color: #333333;
  480. font-size: 24rpx;
  481. }
  482. .item_daycn {
  483. color: #BBBBBB;
  484. font-size: 18rpx;
  485. }
  486. .book-month-area_data {
  487. padding: 0 10rpx;
  488. .icon {
  489. width: 30rpx;
  490. min-width: 30rpx;
  491. height: 30rpx;
  492. margin-top: 4rpx;
  493. }
  494. .num {
  495. color: #666666;
  496. font-size: 20rpx;
  497. text-align: center;
  498. }
  499. }
  500. }
  501. .book-month-area_columns:last-child {
  502. border-right: none;
  503. }
  504. .book-month-area_list {
  505. border-top: 1px solid #E4E4E4;
  506. background: #FAFBFF;
  507. max-height: 400rpx;
  508. height: auto;
  509. .book-month-area_list_content {
  510. padding: 20rpx 40rpx 20rpx 20rpx;
  511. }
  512. .item {
  513. padding: 10rpx 20rpx 10rpx 30rpx;
  514. .content1 {
  515. .content1_1 {
  516. color: #999999;
  517. font-size: 20rpx;
  518. }
  519. .content1_2 {
  520. color: #333333;
  521. font-size: 24rpx;
  522. }
  523. }
  524. .content2 {
  525. color: #999999;
  526. font-size: 20rpx;
  527. }
  528. .content3 {
  529. width: 38rpx;
  530. min-width: 38rpx;
  531. height: 38rpx;
  532. color: #007AFF;
  533. }
  534. }
  535. }
  536. }
  537. }
  538. }
  539. </style>