index.vue 17 KB

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