index.vue 18 KB

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