index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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">简介<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">
  33. <text class="iconfont icon-ditu"></text>
  34. <text>地图</text>
  35. </view>
  36. </view>
  37. <view class="two_4">
  38. <view class="left">优惠卷</view>
  39. <view class="right">领卷<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">今日出游</text>
  46. <text class="text">明日出游</text>
  47. <text class="text">指定日期<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">
  51. <text class="text">{{item.label}}</text>
  52. </view>
  53. <view>筛选</view>
  54. </view>
  55. <view class="thr_4">
  56. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  57. <view class="list-scroll-view">
  58. <view class="list" v-for="(item, index) in list" :key="index">
  59. <view class="left">
  60. <view class="name textOne">{{item.name||'暂无'}}</view>
  61. <view class="type textOne">#{{item.zhType||'暂无'}}</view>
  62. <view class="other textOne">
  63. 已售 {{item.buy_num||0}} | 购买须知
  64. <text class="iconfont icon-dayuhao"></text>
  65. </view>
  66. </view>
  67. <view class="right">
  68. <view class="money">
  69. <text>¥{{item.original_price||'暂无'}}</text>
  70. <text>¥{{item.money||'暂无'}}起</text>
  71. </view>
  72. <view class="button">
  73. <button type="warn" @tap.stop="toBuy(item)">预订</button>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="is_bottom" v-if="is_bottom">
  79. <text>{{config.bottom_title||'到底了!'}}</text>
  80. </view>
  81. </scroll-view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. type: '',
  92. searchInfo: {},
  93. config: {},
  94. user: {},
  95. list: [],
  96. total: 0,
  97. skip: 0,
  98. limit: 10,
  99. page: 0,
  100. // 数据是否触底
  101. is_bottom: false,
  102. scrollTop: 0,
  103. // 字典表
  104. statusList: [],
  105. personList: [],
  106. typeList: [],
  107. totalList: []
  108. }
  109. },
  110. onLoad: async function(e) {
  111. const that = this;
  112. that.$set(that, `type`, e && e.type || '');
  113. uni.setNavigationBarTitle({
  114. title: e && e.title || '分类'
  115. });
  116. await that.searchOther();
  117. that.searchConfig();
  118. that.searchToken();
  119. that.search();
  120. },
  121. methods: {
  122. searchToken() {
  123. const that = this;
  124. try {
  125. const res = uni.getStorageSync('token');
  126. if (res) that.$set(that, `user`, res);
  127. } catch (e) {
  128. uni.showToast({
  129. title: err.errmsg,
  130. icon: 'error',
  131. duration: 2000
  132. });
  133. }
  134. },
  135. searchConfig() {
  136. const that = this;
  137. try {
  138. const res = uni.getStorageSync('config');
  139. if (res) {
  140. const status = that.statusList.find(i => i.value == res.status)
  141. if (status) res.zhStatus = status.label
  142. that.$set(that, `config`, res);
  143. }
  144. } catch (e) {
  145. uni.showToast({
  146. title: err.errmsg,
  147. icon: 'error',
  148. duration: 2000
  149. });
  150. }
  151. },
  152. // 查询
  153. async search() {
  154. const that = this;
  155. let info = {
  156. skip: that.skip,
  157. limit: that.limit,
  158. is_use: '0',
  159. status: '1'
  160. }
  161. const res = await that.$api(`/ticket`, 'GET', {
  162. ...info,
  163. ...that.searchInfo
  164. })
  165. if (res.errcode == '0') {
  166. let list = [...that.list, ...res.data];
  167. for (let val of list) {
  168. const type = that.typeList.find(i => i.value == val.type)
  169. if (type) val.zhType = type.label
  170. }
  171. that.$set(that, `list`, list)
  172. that.$set(that, `total`, res.total)
  173. } else {
  174. uni.showToast({
  175. title: res.errmsg,
  176. });
  177. }
  178. },
  179. // 输入框
  180. toInput(e) {
  181. const that = this;
  182. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  183. else that.$set(that, `searchInfo`, {})
  184. that.clearPage();
  185. that.search();
  186. },
  187. // 详情
  188. toInfo(e) {
  189. uni.navigateTo({
  190. url: `/pagesHome/hotel/info?id=${e.id||e._id}`
  191. })
  192. },
  193. // 预订
  194. toBuy(item) {
  195. const that = this;
  196. if (that.user && that.user._id) {
  197. console.log(item);
  198. } else {
  199. uni.navigateTo({
  200. url: `/pagesIndex/login/index`
  201. })
  202. }
  203. },
  204. // 查询其他信息
  205. async searchOther() {
  206. const that = this;
  207. let res;
  208. // 查询状态
  209. res = await that.$api(`/dictData`, 'GET', {
  210. type: 'config_status',
  211. is_use: '0',
  212. })
  213. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  214. // 出游人群
  215. res = await that.$api(`/dictData`, 'GET', {
  216. type: 'ticket_person',
  217. is_use: '0',
  218. })
  219. if (res.errcode == '0') that.$set(that, `personList`, res.data);
  220. // 服务特色
  221. res = await that.$api(`/dictData`, 'GET', {
  222. type: 'ticket_type',
  223. is_use: '0',
  224. })
  225. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  226. that.$set(that, `totalList`, [...that.personList, ...that.typeList].slice(0, 7));
  227. },
  228. // 分页
  229. toPage(e) {
  230. const that = this;
  231. let list = that.list;
  232. let limit = that.limit;
  233. if (that.total > list.length) {
  234. uni.showLoading({
  235. title: '加载中',
  236. mask: true
  237. })
  238. let page = that.page + 1;
  239. that.$set(that, `page`, page)
  240. let skip = page * limit;
  241. that.$set(that, `skip`, skip)
  242. that.searchComment();
  243. uni.hideLoading();
  244. } else that.$set(that, `is_bottom`, true)
  245. },
  246. // 触底
  247. toScroll(e) {
  248. const that = this;
  249. let up = that.scrollTop;
  250. that.$set(that, `scrollTop`, e.detail.scrollTop);
  251. let num = Math.sign(up - e.detail.scrollTop);
  252. if (num == 1) that.$set(that, `is_bottom`, false);
  253. },
  254. // 清空列表
  255. clearPage() {
  256. const that = this;
  257. that.$set(that, `list`, [])
  258. that.$set(that, `skip`, 0)
  259. that.$set(that, `limit`, 10)
  260. that.$set(that, `page`, 0)
  261. },
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. .main {
  267. display: flex;
  268. flex-direction: column;
  269. width: 100vw;
  270. height: 100vh;
  271. .one {
  272. padding: 0 0 2vw 0;
  273. .swiper {
  274. height: 60vw;
  275. .list {
  276. .image {
  277. width: 100%;
  278. height: 100%;
  279. }
  280. }
  281. }
  282. }
  283. .bottom {
  284. position: absolute;
  285. top: 55vw;
  286. left: 0;
  287. right: 0;
  288. background-color: var(--f9Color);
  289. border-radius: 20px;
  290. padding: 2vw;
  291. .two {
  292. .two_1 {
  293. padding: 2vw;
  294. font-size: var(--font18Size);
  295. font-weight: bold;
  296. }
  297. .two_2 {
  298. display: flex;
  299. justify-content: space-between;
  300. align-items: center;
  301. padding: 1vw 2vw;
  302. .left {
  303. .left_1 {
  304. font-size: var(--font12Size);
  305. .time {
  306. font-weight: 500;
  307. margin: 0 1vw;
  308. }
  309. .text_1 {
  310. padding: 1px;
  311. color: var(--mainColor);
  312. background-color: mediumseagreen;
  313. }
  314. .text_2 {
  315. padding: 1px;
  316. color: var(--mainColor);
  317. background-color: red;
  318. }
  319. }
  320. .left_2 {
  321. font-size: var(--font12Size);
  322. margin: 2vw 0;
  323. text {
  324. margin: 0 2px 0 0;
  325. padding: 2px 3px;
  326. border: 1px solid var(--f3CColor);
  327. color: var(--f3CColor);
  328. border-radius: 5px;
  329. }
  330. }
  331. }
  332. .right {
  333. display: flex;
  334. align-items: center;
  335. font-size: var(--font14Size);
  336. color: var(--f85Color);
  337. }
  338. }
  339. .two_3 {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. font-size: var(--font13Size);
  344. padding: 0 2vw;
  345. .right {
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. font-size: var(--font12Size);
  350. padding: 0 5vw 0 0;
  351. .iconfont {
  352. font-size: 20px;
  353. }
  354. }
  355. }
  356. .two_4 {
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. padding: 3vw 2vw;
  361. font-size: var(--font14Size);
  362. background-color: var(--mainColor);
  363. border-radius: 10px;
  364. margin: 1vw 0;
  365. .right {
  366. display: flex;
  367. align-items: center;
  368. font-size: var(--font14Size);
  369. color: var(--fF0Color);
  370. }
  371. }
  372. }
  373. .thr {
  374. .thr_1 {
  375. padding: 2vw 1vw;
  376. font-size: var(--font16Size);
  377. font-weight: bold;
  378. }
  379. .thr_2 {
  380. padding: 1vw 0;
  381. .text {
  382. margin: 0 5px 0 0;
  383. padding: 1vw;
  384. border-radius: 5px;
  385. font-size: var(--font12Size);
  386. color: var(--f69Color);
  387. background-color: var(--mainColor);
  388. .iconfont {
  389. font-size: 14px;
  390. }
  391. }
  392. }
  393. .thr_3 {
  394. display: flex;
  395. justify-content: space-between;
  396. padding: 1vw 0;
  397. font-size: var(--font15Size);
  398. margin: 1vw 0 0 0;
  399. .list {
  400. .text {
  401. margin: 0 5px 0 0;
  402. padding: 1vw;
  403. border-radius: 5px;
  404. font-size: var(--font12Size);
  405. color: var(--f69Color);
  406. background-color: var(--mainColor);
  407. .iconfont {
  408. font-size: 14px;
  409. }
  410. }
  411. }
  412. }
  413. .thr_4 {
  414. position: relative;
  415. height: 82vh;
  416. .list {
  417. display: flex;
  418. justify-content: space-between;
  419. background-color: var(--mainColor);
  420. border: 1px solid var(--f5Color);
  421. padding: 2vw;
  422. margin: 2vw 2vw 0 2vw;
  423. border-radius: 10px;
  424. .left {
  425. padding: 2vw 0;
  426. width: 55vw;
  427. .name {
  428. padding: 2vw 0;
  429. font-size: var(--font16Size);
  430. font-weight: bold;
  431. }
  432. .type {
  433. padding: 0 0 1vw 0;
  434. color: var(--f3CColor);
  435. font-size: var(--font12Size);
  436. }
  437. .other {
  438. color: var(--f69Color);
  439. font-size: var(--font12Size);
  440. .iconfont {
  441. font-size: 14px;
  442. }
  443. }
  444. }
  445. .right {
  446. width: 28vw;
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: space-between;
  450. padding: 2vw 0;
  451. .money {
  452. text-align: right;
  453. color: var(--fF0Color);
  454. font-size: var(--font16Size);
  455. font-weight: bold;
  456. text:first-child {
  457. text-decoration: line-through;
  458. color: var(--f69Color);
  459. font-size: var(--font12Size);
  460. font-weight: 400;
  461. }
  462. }
  463. .button {
  464. button {
  465. font-size: var(--font14Size);
  466. border-radius: 40px;
  467. background: linear-gradient(to right, #00BFFF, #007AFF);
  468. }
  469. }
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .scroll-view {
  477. position: absolute;
  478. top: 0;
  479. left: 0;
  480. right: 0;
  481. bottom: 0;
  482. .list-scroll-view {
  483. display: flex;
  484. flex-direction: column;
  485. }
  486. }
  487. .is_bottom {
  488. width: 100%;
  489. text-align: center;
  490. text {
  491. padding: 2vw 0;
  492. display: inline-block;
  493. color: var(--f85Color);
  494. font-size: var(--font14Size);
  495. }
  496. }
  497. </style>