index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <app-layout>
  3. <view class="book-index">
  4. <view class="custom-header-container">
  5. <view class="header-bg" :style="{height:headerBgHeight}">
  6. <image src="../../../static/image/course/bg.png"/>
  7. </view>
  8. <view class="custom-header-status-bar" :style="{height:getStausBarHeight}"></view>
  9. <view class="custom-header-top-container">
  10. <view class="custom-header-title">场地预约</view>
  11. </view>
  12. </view>
  13. <view class="swiper-container">
  14. <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
  15. <swiper-item class="swiper-item">
  16. <image class="swiper-item-img" src="../../../static/image/course/banner.png" mode=""></image>
  17. </swiper-item>
  18. </swiper>
  19. </view>
  20. <!-- <view class="check-container">
  21. <view class="check-item" v-for="(item, index) in dateArr"
  22. :key="index" @click="dateActive(index, item)"
  23. :class="(index == dateArrIndex) && dateArrActive?'check-item-active' : ''">
  24. <view class="week">{{item.week}}</view>
  25. <view class="data">{{item.date}}</view>
  26. </view>
  27. </view> -->
  28. <view class="check-container">
  29. <view class="check-item" v-for="(item, index) in dateArr"
  30. :key="index" @click="dateActive(index, item)"
  31. :class="index == dateArrIndex?'check-item-active' : ''">
  32. <view class="week">{{item.week}}</view>
  33. <view class="data">{{item.date}}</view>
  34. </view>
  35. </view>
  36. <view class="page-width quick-navigation">
  37. <app-quick-navigation></app-quick-navigation>
  38. </view>
  39. <!-- <view class="page-width head-nav-list">
  40. <app-head-nav-list
  41. v-bind:catList="catList"
  42. @click="changeStatus"
  43. v-bind:cat_id="cat_id"
  44. ></app-head-nav-list>
  45. </view>
  46. -->
  47. <view class="page-width product-list" v-if="goods_list.length > 0">
  48. <view class="title">
  49. <view class="title-icon">
  50. <image src="../../../static/image/reservation.png" mode=""></image>
  51. </view>
  52. <text class="title-content">场地预约</text>
  53. </view>
  54. <app-product-list v-bind:goodsList="goods_list"></app-product-list>
  55. </view>
  56. <view class="page-width no-goods" v-else>
  57. <app-no-goods background="#f7f7f7"></app-no-goods>
  58. </view>
  59. </view>
  60. </app-layout>
  61. </template>
  62. <script>
  63. import appHeadNavList from '../components/app-head-nav-list.vue';
  64. import appProductList from '../components/app-product-list.vue';
  65. import appQuickNavigation from "../../../components/page-component/app-quick-navigation/app-quick-navigation.vue";
  66. import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
  67. export default {
  68. name: "index",
  69. data() {
  70. return {
  71. catList: [
  72. {
  73. name: '全部',
  74. id: 0
  75. }
  76. ],
  77. cat_id: 0,
  78. page: 1,
  79. goods_list: [],
  80. page_count: 1,
  81. dateArr:[],
  82. // dateArrIndex: -1,
  83. dateArrIndex: 0,
  84. dateArrActive: false
  85. }
  86. },
  87. onLoad(option) {
  88. uni.showLoading({
  89. title: '加载中',
  90. });
  91. if (option.cat_id) {
  92. this.cat_id = option.cat_id;
  93. } else {
  94. this.cat_id = this.catList[0].id;
  95. }
  96. this.request();
  97. this.$request({
  98. url: this.$api.book.cats
  99. }).then(response => {
  100. uni.hideLoading();
  101. if (response.code === 0) {
  102. this.catList = [...this.catList, ...response.data.cat];
  103. // this.request();
  104. }
  105. });
  106. // uni.removeStorage({
  107. // key: 'date'
  108. // })
  109. this.getDate(7)
  110. },
  111. computed:{
  112. getStausBarHeight(){
  113. try {
  114. const res = uni.getSystemInfoSync();
  115. return res.statusBarHeight + 'px';
  116. } catch (err) {
  117. console.log(err)
  118. }
  119. },
  120. headerBgHeight(){
  121. try {
  122. const res = uni.getSystemInfoSync();
  123. return 120+44+res.statusBarHeight + 'px';
  124. } catch (err) {
  125. console.log(err)
  126. }
  127. }
  128. },
  129. methods: {
  130. dateActive(index, item){
  131. uni.showToast({
  132. icon: 'none',
  133. title: '选中日期',
  134. duration: 1000
  135. });
  136. // if(this.dateArrIndex == index){
  137. // uni.showToast({
  138. // icon: 'none',
  139. // title: '取消日期',
  140. // duration: 1000
  141. // });
  142. // uni.removeStorage({
  143. // key: 'date'
  144. // })
  145. // this.dateArrActive = !this.dateArrActive
  146. // }else{
  147. this.dateArrIndex = index
  148. this.dateArrActive = true
  149. uni.setStorage({
  150. key: 'date',
  151. data: item
  152. })
  153. // }
  154. },
  155. changeStatus(status) {
  156. this.page = 1;
  157. this.cat_id = status;
  158. this.goods_list = [];
  159. this.request();
  160. },
  161. async request() {
  162. uni.showLoading({
  163. title: '加载中',
  164. });
  165. const res = await this.$request({
  166. url: this.$api.book.list,
  167. data: {
  168. page: this.page,
  169. cat_id: this.cat_id,
  170. }
  171. });
  172. uni.hideLoading();
  173. if (res.code === 0) {
  174. this.dataProcessing(res.data);
  175. }
  176. },
  177. dataProcessing(data) {
  178. for (let i = 0; i < data.list.length; i+=2) {
  179. if (i+1 !== data.list.length) {
  180. this.goods_list.push([data.list[i], data.list[i+1]]);
  181. } else {
  182. this.goods_list.push([data.list[i]]);
  183. }
  184. }
  185. this.page_count = data.pagination.page_count;
  186. },
  187. getDate(num){
  188. // 获取当前时间
  189. let Date1 = new Date()
  190. for(let i = 0; i < num; i++ ){
  191. let Date2 = new Date()
  192. Date2.setDate(Date1.getDate() + i + 1)
  193. let time = (Date2.getMonth() + 1) + "月" + Date2.getDate() + "日";
  194. console.log(time)
  195. let Day = Date2.getDay()
  196. let days;
  197. switch(Day){
  198. case 1:
  199. days = '星期一';
  200. break;
  201. case 2:
  202. days = '星期二';
  203. break;
  204. case 3:
  205. days = '星期三';
  206. break;
  207. case 4:
  208. days = '星期四';
  209. break;
  210. case 5:
  211. days = '星期五';
  212. break;
  213. case 6:
  214. days = '星期六';
  215. break;
  216. case 0:
  217. days = '星期日';
  218. break;
  219. }
  220. console.log(days)
  221. let dateObj = {
  222. date: time,
  223. week: days,
  224. }
  225. this.dateArr.push(dateObj)
  226. for(i in this.dateArr){
  227. if(i == this.dateArrIndex){
  228. uni.setStorage({
  229. key: 'date',
  230. data: this.dateArr[i]
  231. })
  232. }
  233. }
  234. }
  235. }
  236. },
  237. onReachBottom() {
  238. if (this.page < this.page_count) {
  239. this.page++;
  240. this.request();
  241. }
  242. },
  243. onShareAppMessage() {
  244. return this.$shareAppMessage({
  245. path: '/plugins/book/index/index',
  246. title: this.$children[0].navigationBarTitle,
  247. });
  248. },
  249. components: {
  250. 'app-head-nav-list': appHeadNavList,
  251. 'app-product-list': appProductList,
  252. 'app-quick-navigation': appQuickNavigation,
  253. 'app-no-goods': appNoGoods,
  254. },
  255. }
  256. </script>
  257. <style scoped lang="scss">
  258. .head-nav-list {
  259. position: fixed;
  260. top: 0;
  261. left: 0;
  262. z-index: 1500;
  263. }
  264. // .product-list {
  265. // margin-top: #{100rpx};
  266. // }
  267. .product-list {
  268. margin-top: #{30rpx};
  269. }
  270. .no-goods {
  271. margin-top: #{150rpx};
  272. }
  273. .custom-header-container{
  274. width: 100%;
  275. top: 0;
  276. z-index: 0;
  277. display: flex;
  278. flex-direction: column;
  279. align-items: center;
  280. background: #fff;
  281. font-size: 26upx;
  282. background: transparent;
  283. .header-bg{
  284. width: 100%;
  285. position: absolute;
  286. overflow: hidden;
  287. z-index: 0;
  288. image{
  289. width: 100%;
  290. height: 230px;
  291. }
  292. }
  293. .custom-header-status-bar{
  294. width: 100%;
  295. top: 0;
  296. position: sticky;
  297. z-index: 100;
  298. }
  299. .custom-header-top-container{
  300. width: 100%;
  301. display: flex;
  302. justify-content: center;
  303. align-items: center;
  304. padding: 0 15upx;
  305. .custom-header-title{
  306. height: 44px;
  307. line-height: 44px;
  308. font-size: 36upx;
  309. font-weight:400;
  310. font-family:Source Han Sans CN;
  311. color: #FBF9F9;
  312. z-index: 1;
  313. }
  314. }
  315. .cu-bar{
  316. width: 100%;
  317. height: 55px;
  318. }
  319. .head-search{
  320. width: 100%;
  321. height: 60upx;
  322. .head-search-item{
  323. width: 690upx;
  324. height: 65upx;
  325. background: #fff;
  326. border-radius: 50%;
  327. }
  328. }
  329. }
  330. .title{
  331. height: 80upx;
  332. line-height: 80upx;
  333. padding: 0 24upx;
  334. font-size: 28upx;
  335. background-color: #ffffff;
  336. position: relative;
  337. display: flex;
  338. align-items: center;
  339. .title-icon{
  340. width: 33upx;
  341. height: 33upx;
  342. display: flex;
  343. justify-content: center;
  344. align-items: center;
  345. // display: inline-block;
  346. image{
  347. width: 100%;
  348. height: 100%;
  349. }
  350. }
  351. .title-content{
  352. display: inline-block;
  353. font-size: 34upx;
  354. font-family: Source Han Sans CN;
  355. font-weight: 500;
  356. color: #3D3D3D;
  357. margin-left: 10upx;
  358. }
  359. }
  360. .swiper-container{
  361. width: 94vw;
  362. height: auto;
  363. margin: 0 3vw;
  364. padding: 5vw 0;
  365. z-index: 1;
  366. .swiper-item{
  367. position: absolute;
  368. width: 100%;
  369. height: 100%;
  370. transform: translate(0%, 0px) translateZ(0px);
  371. .swiper-item-img{
  372. width: 100%;
  373. height: 100%;
  374. }
  375. }
  376. }
  377. .check-container{
  378. width: 100%;
  379. height: 115upx;
  380. display: flex;
  381. align-items: center;
  382. justify-content: space-around;
  383. border-top: 2rpx solid #D8D8D8;
  384. border-bottom: 2rpx solid #D8D8D8;
  385. .check-item{
  386. width: 90upx;
  387. height: 80upx;
  388. color: #000;
  389. background: #F2F2F2;
  390. font-size: 18upx;
  391. border-radius: 8upx;
  392. display: flex;
  393. align-items: center;
  394. flex-direction: column;
  395. justify-content: center;
  396. .week{
  397. text-align: center;
  398. }
  399. .data{
  400. margin-top: 10upx;
  401. text-align: center;
  402. }
  403. }
  404. .check-item-active{
  405. background: #F09A21;
  406. color: #FFFFFF;
  407. }
  408. }
  409. </style>