index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  5. indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
  6. <swiper-item class="list" v-for="(item,index) in config.file" :key="index">
  7. <image class="image" :src="item.url" mode="">
  8. </image>
  9. </swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="bottom">
  13. <view class="two">
  14. <view class="two_1">{{config.name||'暂无'}}</view>
  15. <view class="two_2">
  16. <view class="left">
  17. <view class="left_1">
  18. <text :class="[config.status=='0'?'text_1':'text_2']">{{config.zhStatus||'暂无'}}</text>
  19. <text class="time">{{config.open_time||'暂无'}}</text>
  20. </view>
  21. <view class="left_2">
  22. <text>有优待政策</text>
  23. <text>景区电话</text>
  24. <text>有免费停车</text>
  25. <text>院内交通</text>
  26. </view>
  27. </view>
  28. <view class="right" @tap="toBrief">简介<text class="iconfont icon-dayuhao"></text></view>
  29. </view>
  30. <view class="two_3">
  31. <view class="left">{{config.address||'暂无'}}</view>
  32. <view class="right" @tap="toMap">
  33. <text class="iconfont icon-ditu"></text>
  34. <text>地图</text>
  35. </view>
  36. </view>
  37. <view class="two_4" v-if="couponList.length>0">
  38. <view class="left">优惠卷</view>
  39. <view class="right" @click="toCoupon">领卷<text class="iconfont icon-dayuhao"></text></view>
  40. </view>
  41. </view>
  42. <view class="thr">
  43. <view class="thr_1">门票</view>
  44. <view class="thr_2">
  45. <text class="text" @tap="toChoose('0')">今日出游</text>
  46. <text class="text" @tap="toChoose('1')">明日出游</text>
  47. <text class="text" @tap="toOpen">指定日期<text class="iconfont icon-dayuhao"></text></text>
  48. </view>
  49. <view class="thr_3">
  50. <scroll-view class="scroll-view_H" scroll-x="true">
  51. <text v-for="(item, index) in totalList" :key="index" @tap="toType(item)"
  52. :class="[is_type==item._id||is_person==item._id?'text_1':'text']">{{item.label}}</text>
  53. </scroll-view>
  54. <view @tap="toSelect">
  55. 筛选
  56. <uni-icons v-if="is_select" type="top"></uni-icons>
  57. <uni-icons v-else type="bottom"></uni-icons>
  58. </view>
  59. </view>
  60. <view class="thr_4">
  61. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  62. <view class="list-scroll-view">
  63. <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
  64. <view class="left">
  65. <view class="name textOne">{{item.name||'暂无'}}</view>
  66. <view class="type textOne">#{{item.zhType||'暂无'}}</view>
  67. <view class="other textOne">
  68. 已售 {{item.buy_num||0}} | 购买须知
  69. <text class="iconfont icon-dayuhao"></text>
  70. </view>
  71. </view>
  72. <view class="right">
  73. <view class="money">
  74. <text>¥{{item.original_price||'暂无'}}</text>
  75. <text>¥{{item.money||'暂无'}}起</text>
  76. </view>
  77. <view class="button">
  78. <button @tap.stop="toBuy(item)">预订</button>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="is_bottom" v-if="is_bottom">
  84. <text>{{config.bottom_title||'到底了!'}}</text>
  85. </view>
  86. </scroll-view>
  87. </view>
  88. </view>
  89. </view>
  90. <!-- 日历选择 -->
  91. <uni-calendar ref="calendar" :clear-date="true" :insert="false" :lunar="true" :range="false"
  92. @confirm="toConfirm" />
  93. <!-- 筛选门票类型 -->
  94. <uni-popup ref="popup" type="top" background-color="#fff" @maskClick="toClose">
  95. <view class="popup">
  96. <view class="one">
  97. <view class="name">出游人群</view>
  98. <view class="cotent">
  99. <view class="list" v-for="(item, index) in personList" :key="index" @tap="toScreen(item,'0')">
  100. <text :class="[is_person==item._id?'text_1':'text']">{{item.label}}</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="one">
  105. <view class="name">服务特色</view>
  106. <view class="cotent">
  107. <view class="list" v-for="(item, index) in typeList" :key="index" @tap="toScreen(item,'1')">
  108. <text :class="[is_type==item._id?'text_1':'text']">{{item.label}}</text>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="button">
  113. <button class="button_1" type="default" @tap.stop="toReset">重置</button>
  114. <button class="button_2" type="default" @tap.stop="toSubmit">确定</button>
  115. </view>
  116. </view>
  117. </uni-popup>
  118. </view>
  119. </template>
  120. <script>
  121. import moment from 'moment';
  122. export default {
  123. data() {
  124. return {
  125. type: '',
  126. searchInfo: {},
  127. config: {},
  128. user: {},
  129. list: [],
  130. total: 0,
  131. skip: 0,
  132. limit: 10,
  133. page: 0,
  134. // 数据是否触底
  135. is_bottom: false,
  136. scrollTop: 0,
  137. // 优惠卷
  138. couponList: [],
  139. // 字典表
  140. statusList: [],
  141. personList: [],
  142. typeList: [],
  143. totalList: [],
  144. // 是否筛选
  145. is_select: false,
  146. is_person: '',
  147. is_type: '',
  148. }
  149. },
  150. onLoad: async function(e) {
  151. const that = this;
  152. that.$set(that, `type`, e && e.type || '');
  153. uni.setNavigationBarTitle({
  154. title: e && e.title || '分类'
  155. });
  156. that.searchConfig();
  157. },
  158. onShow: async function(e) {
  159. const that = this;
  160. await that.searchOther();
  161. await that.searchToken();
  162. await that.clearPage();
  163. await that.search();
  164. },
  165. methods: {
  166. searchToken() {
  167. const that = this;
  168. try {
  169. const res = uni.getStorageSync('token');
  170. if (res) that.$set(that, `user`, res);
  171. } catch (e) {
  172. uni.showToast({
  173. title: err.errmsg,
  174. icon: 'error',
  175. duration: 2000
  176. });
  177. }
  178. },
  179. searchConfig() {
  180. const that = this;
  181. try {
  182. const res = uni.getStorageSync('config');
  183. if (res) {
  184. const status = that.statusList.find(i => i.value == res.status)
  185. if (status) res.zhStatus = status.label
  186. that.$set(that, `config`, res);
  187. }
  188. } catch (e) {
  189. uni.showToast({
  190. title: err.errmsg,
  191. icon: 'error',
  192. duration: 2000
  193. });
  194. }
  195. },
  196. // 查询
  197. async search() {
  198. const that = this;
  199. let info = {
  200. skip: that.skip,
  201. limit: that.limit,
  202. is_use: '0',
  203. status: '1'
  204. }
  205. const res = await that.$api(`/ticket/queryDate`, 'GET', {
  206. ...info,
  207. ...that.searchInfo
  208. })
  209. if (res.errcode == '0') {
  210. let list = [...that.list, ...res.data];
  211. for (let val of list) {
  212. const type = that.typeList.find(i => i.value == val.type)
  213. if (type) val.zhType = type.label
  214. }
  215. that.$set(that, `list`, list)
  216. that.$set(that, `total`, res.total)
  217. } else {
  218. uni.showToast({
  219. title: res.errmsg,
  220. });
  221. }
  222. },
  223. // 输入框
  224. toInput(e) {
  225. const that = this;
  226. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  227. else that.$set(that, `searchInfo`, {})
  228. that.clearPage();
  229. that.search();
  230. },
  231. // 简介
  232. toBrief() {
  233. uni.navigateTo({
  234. url: `/pagesHome/info/index`
  235. })
  236. },
  237. // 地图
  238. toMap() {
  239. uni.reLaunch({
  240. url: `/pages/map/index`
  241. })
  242. },
  243. // 领卷
  244. toCoupon() {
  245. },
  246. // 打开日历
  247. toOpen() {
  248. const that = this;
  249. that.$refs.calendar.open()
  250. },
  251. // 选择的日期
  252. toConfirm(e) {
  253. const that = this;
  254. that.$set(that.searchInfo, `date`, e.fulldate)
  255. that.clearPage();
  256. that.search();
  257. },
  258. // 选择当天还是明天
  259. toChoose(type) {
  260. const that = this;
  261. if (type == '0') that.$set(that.searchInfo, `date`, moment().format('YYYY-MM-DD'))
  262. else that.$set(that.searchInfo, `date`, moment(new Date()).add(1, 'days').format("YYYY-MM-DD"))
  263. that.clearPage();
  264. that.search();
  265. },
  266. // 选择类型
  267. toType(item) {
  268. const that = this;
  269. if (item.type == 'ticket_person') {
  270. if (item._id == that.is_person) {
  271. that.$set(that, `is_person`, '')
  272. delete that.searchInfo.person
  273. } else {
  274. that.$set(that, `is_person`, item._id)
  275. that.$set(that.searchInfo, `person`, item.value)
  276. }
  277. } else {
  278. if (item._id == that.is_type) {
  279. that.$set(that, `is_type`, '')
  280. delete that.searchInfo.type
  281. } else {
  282. that.$set(that, `is_type`, item._id)
  283. that.$set(that.searchInfo, `type`, item.value)
  284. }
  285. }
  286. that.clearPage();
  287. that.search();
  288. },
  289. // 筛选打开弹窗
  290. toSelect() {
  291. const that = this;
  292. that.$set(that, `is_select`, true)
  293. that.$refs.popup.open()
  294. },
  295. // 关闭弹窗
  296. toClose() {
  297. const that = this;
  298. that.$set(that, `is_select`, false)
  299. that.$refs.popup.close()
  300. },
  301. // 筛选
  302. toScreen(item, type) {
  303. const that = this;
  304. if (type == '0') that.$set(that, `is_person`, item._id)
  305. else that.$set(that, `is_type`, item._id)
  306. },
  307. // 重置
  308. toReset() {
  309. const that = this;
  310. that.$set(that, `is_person`, '')
  311. that.$set(that, `is_type`, '')
  312. delete that.searchInfo.person
  313. delete that.searchInfo.type
  314. },
  315. // 确定
  316. toSubmit() {
  317. const that = this;
  318. const person = that.personList.find(i => i._id == that.is_person)
  319. if (person) that.$set(that.searchInfo, `person`, person.value)
  320. const type = that.typeList.find(i => i._id == that.is_type)
  321. if (type) that.$set(that.searchInfo, `type`, type.value)
  322. that.clearPage();
  323. that.search();
  324. that.toClose();
  325. },
  326. // 详情
  327. toInfo(e) {
  328. uni.navigateTo({
  329. url: `/pagesHome/ticket/info?id=${e.id||e._id}`
  330. })
  331. },
  332. // 预订
  333. toBuy(item) {
  334. const that = this;
  335. if (that.user && that.user._id) {
  336. uni.navigateTo({
  337. url: `/pagesIndex/order/order?id=${item.id||item._id}`
  338. })
  339. } else {
  340. uni.navigateTo({
  341. url: `/pagesIndex/login/index`
  342. })
  343. }
  344. },
  345. // 查询其他信息
  346. async searchOther() {
  347. const that = this;
  348. let res;
  349. // 查询状态
  350. res = await that.$api(`/dictData`, 'GET', {
  351. type: 'config_status',
  352. is_use: '0',
  353. })
  354. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  355. // 出游人群
  356. res = await that.$api(`/dictData`, 'GET', {
  357. type: 'ticket_person',
  358. is_use: '0',
  359. })
  360. if (res.errcode == '0') that.$set(that, `personList`, res.data);
  361. // 服务特色
  362. res = await that.$api(`/dictData`, 'GET', {
  363. type: 'ticket_type',
  364. is_use: '0',
  365. })
  366. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  367. that.$set(that, `totalList`, [...that.personList, ...that.typeList]);
  368. },
  369. // 分页
  370. toPage(e) {
  371. const that = this;
  372. let list = that.list;
  373. let limit = that.limit;
  374. if (that.total > list.length) {
  375. uni.showLoading({
  376. title: '加载中',
  377. mask: true
  378. })
  379. let page = that.page + 1;
  380. that.$set(that, `page`, page)
  381. let skip = page * limit;
  382. that.$set(that, `skip`, skip)
  383. that.searchComment();
  384. uni.hideLoading();
  385. } else that.$set(that, `is_bottom`, true)
  386. },
  387. // 触底
  388. toScroll(e) {
  389. const that = this;
  390. let up = that.scrollTop;
  391. that.$set(that, `scrollTop`, e.detail.scrollTop);
  392. let num = Math.sign(up - e.detail.scrollTop);
  393. if (num == 1) that.$set(that, `is_bottom`, false);
  394. },
  395. // 清空列表
  396. clearPage() {
  397. const that = this;
  398. that.$set(that, `list`, [])
  399. that.$set(that, `skip`, 0)
  400. that.$set(that, `limit`, 10)
  401. that.$set(that, `page`, 0)
  402. },
  403. }
  404. }
  405. </script>
  406. <style lang="scss" scoped>
  407. .main {
  408. display: flex;
  409. flex-direction: column;
  410. width: 100vw;
  411. height: 100vh;
  412. .one {
  413. padding: 0 0 2vw 0;
  414. .swiper {
  415. height: 60vw;
  416. .list {
  417. .image {
  418. width: 100%;
  419. height: 100%;
  420. }
  421. }
  422. }
  423. }
  424. .bottom {
  425. position: absolute;
  426. top: 55vw;
  427. left: 0;
  428. right: 0;
  429. background-color: var(--f9Color);
  430. border-radius: 20px;
  431. padding: 2vw;
  432. .two {
  433. .two_1 {
  434. padding: 2vw;
  435. font-size: var(--font18Size);
  436. font-weight: bold;
  437. }
  438. .two_2 {
  439. display: flex;
  440. justify-content: space-between;
  441. align-items: center;
  442. padding: 1vw 2vw;
  443. .left {
  444. .left_1 {
  445. font-size: var(--font12Size);
  446. .time {
  447. font-weight: 500;
  448. margin: 0 1vw;
  449. }
  450. .text_1 {
  451. padding: 1px;
  452. color: var(--mainColor);
  453. background-color: mediumseagreen;
  454. }
  455. .text_2 {
  456. padding: 1px;
  457. color: var(--mainColor);
  458. background-color: red;
  459. }
  460. }
  461. .left_2 {
  462. font-size: var(--font12Size);
  463. margin: 2vw 0;
  464. text {
  465. margin: 0 2px 0 0;
  466. padding: 2px 3px;
  467. border: 1px solid var(--f3CColor);
  468. color: var(--f3CColor);
  469. border-radius: 5px;
  470. }
  471. }
  472. }
  473. .right {
  474. display: flex;
  475. align-items: center;
  476. font-size: var(--font14Size);
  477. color: var(--f85Color);
  478. }
  479. }
  480. .two_3 {
  481. display: flex;
  482. justify-content: space-between;
  483. align-items: center;
  484. font-size: var(--font13Size);
  485. padding: 0 2vw;
  486. .right {
  487. display: flex;
  488. flex-direction: column;
  489. align-items: center;
  490. font-size: var(--font12Size);
  491. padding: 0 2vw 0 0;
  492. .iconfont {
  493. font-size: 20px;
  494. }
  495. }
  496. }
  497. .two_4 {
  498. display: flex;
  499. justify-content: space-between;
  500. align-items: center;
  501. padding: 3vw 2vw;
  502. font-size: var(--font14Size);
  503. background-color: var(--mainColor);
  504. border-radius: 10px;
  505. margin: 1vw 0;
  506. .right {
  507. display: flex;
  508. align-items: center;
  509. font-size: var(--font14Size);
  510. color: var(--fF0Color);
  511. }
  512. }
  513. }
  514. .thr {
  515. .thr_1 {
  516. padding: 2vw 1vw;
  517. font-size: var(--font16Size);
  518. font-weight: bold;
  519. }
  520. .thr_2 {
  521. padding: 1vw 0;
  522. .text {
  523. margin: 0 5px 0 0;
  524. padding: 1vw;
  525. border-radius: 5px;
  526. font-size: var(--font12Size);
  527. color: var(--f69Color);
  528. background-color: var(--mainColor);
  529. .iconfont {
  530. font-size: 14px;
  531. }
  532. }
  533. }
  534. .thr_3 {
  535. display: flex;
  536. justify-content: space-between;
  537. padding: 1vw 0;
  538. font-size: var(--font15Size);
  539. margin: 1vw 0 0 0;
  540. .scroll-view_H {
  541. white-space: nowrap;
  542. width: 80vw;
  543. height: 5vh;
  544. .text {
  545. margin: 0 5px 0 0;
  546. padding: 1vw 2vw;
  547. border-radius: 5px;
  548. font-size: var(--font12Size);
  549. color: var(--f69Color);
  550. background-color: var(--mainColor);
  551. .iconfont {
  552. font-size: 14px;
  553. }
  554. }
  555. .text_1 {
  556. margin: 0 5px 0 0;
  557. padding: 1vw 2vw;
  558. border-radius: 5px;
  559. font-size: var(--font12Size);
  560. color: var(--mainColor);
  561. background-color: var(--f3CColor);
  562. .iconfont {
  563. font-size: 14px;
  564. }
  565. }
  566. }
  567. }
  568. .thr_4 {
  569. position: relative;
  570. height: 82vh;
  571. .list {
  572. display: flex;
  573. justify-content: space-between;
  574. background-color: var(--mainColor);
  575. border: 1px solid var(--f5Color);
  576. padding: 2vw;
  577. margin: 2vw 2vw 0 2vw;
  578. border-radius: 10px;
  579. .left {
  580. padding: 2vw 0;
  581. width: 55vw;
  582. .name {
  583. padding: 2vw 0;
  584. font-size: var(--font16Size);
  585. font-weight: bold;
  586. }
  587. .type {
  588. padding: 0 0 1vw 0;
  589. color: var(--f3CColor);
  590. font-size: var(--font12Size);
  591. }
  592. .other {
  593. color: var(--f69Color);
  594. font-size: var(--font12Size);
  595. .iconfont {
  596. font-size: 14px;
  597. }
  598. }
  599. }
  600. .right {
  601. width: 28vw;
  602. display: flex;
  603. flex-direction: column;
  604. justify-content: space-between;
  605. padding: 2vw 0;
  606. .money {
  607. text-align: right;
  608. color: var(--fF0Color);
  609. font-size: var(--font16Size);
  610. font-weight: bold;
  611. text:first-child {
  612. text-decoration: line-through;
  613. color: var(--f69Color);
  614. font-size: var(--font12Size);
  615. font-weight: 400;
  616. }
  617. }
  618. .button {
  619. button {
  620. font-size: var(--font14Size);
  621. border-radius: 40px;
  622. color: var(--mainColor);
  623. background: linear-gradient(to right, #00BFFF, #007AFF);
  624. }
  625. }
  626. }
  627. }
  628. }
  629. }
  630. }
  631. }
  632. .popup {
  633. padding: 2vw;
  634. .one {
  635. padding: 2vw;
  636. .name {
  637. padding: 2vw 0;
  638. font-size: var(--font16Size);
  639. font-weight: bold;
  640. }
  641. .cotent {
  642. display: flex;
  643. flex-wrap: wrap;
  644. margin: 5vw 0;
  645. .list {
  646. margin: 0 0 5vw 0;
  647. .text {
  648. margin: 0 5px 0 0;
  649. padding: 2vw 7vw;
  650. border-radius: 5px;
  651. font-size: var(--font14Size);
  652. color: var(--f69Color);
  653. background-color: var(--f9Color);
  654. }
  655. .text_1 {
  656. margin: 0 5px 0 0;
  657. padding: 2vw 7vw;
  658. border-radius: 5px;
  659. font-size: var(--font14Size);
  660. color: var(--mainColor);
  661. background-color: var(--f3CColor);
  662. }
  663. }
  664. }
  665. }
  666. .button {
  667. display: flex;
  668. padding: 2vw;
  669. button {
  670. width: 30vw;
  671. font-size: var(--font16Size);
  672. border-radius: 40px;
  673. }
  674. button:last-child {
  675. color: var(--mainColor);
  676. background: linear-gradient(to right, #00BFFF, #007AFF);
  677. }
  678. }
  679. }
  680. .scroll-view {
  681. position: absolute;
  682. top: 0;
  683. left: 0;
  684. right: 0;
  685. bottom: 0;
  686. .list-scroll-view {
  687. display: flex;
  688. flex-direction: column;
  689. }
  690. }
  691. .is_bottom {
  692. width: 100%;
  693. text-align: center;
  694. text {
  695. padding: 2vw 0;
  696. display: inline-block;
  697. color: var(--f85Color);
  698. font-size: var(--font14Size);
  699. }
  700. }
  701. </style>