index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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">{{item.name||'暂无'}}</view>
  61. <view class="type">#{{item.zhType||'暂无'}}</view>
  62. <view class="other">
  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 0;
  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. .left {
  302. .left_1 {
  303. font-size: var(--font14Size);
  304. .time {
  305. font-weight: 500;
  306. margin: 0 1vw;
  307. }
  308. .text_1 {
  309. padding: 1px;
  310. color: var(--mainColor);
  311. background-color: mediumseagreen;
  312. }
  313. .text_2 {
  314. padding: 1px;
  315. color: var(--mainColor);
  316. background-color: red;
  317. }
  318. }
  319. .left_2 {
  320. font-size: var(--font12Size);
  321. margin: 2vw 0;
  322. text {
  323. margin: 0 2px 0 0;
  324. padding: 2px 3px;
  325. border: 1px solid #964726;
  326. color: #964726;
  327. border-radius: 5px;
  328. }
  329. }
  330. }
  331. .right {
  332. display: flex;
  333. align-items: center;
  334. font-size: var(--font14Size);
  335. color: var(--f85Color);
  336. }
  337. }
  338. .two_3 {
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. font-size: var(--font14Size);
  343. .right {
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. font-size: var(--font12Size);
  348. padding: 0 5vw 0 0;
  349. .iconfont {
  350. font-size: 20px;
  351. }
  352. }
  353. }
  354. .two_4 {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. padding: 2vw;
  359. font-size: var(--font14Size);
  360. background-color: var(--mainColor);
  361. border-radius: 10px;
  362. margin: 1vw 0;
  363. .right {
  364. display: flex;
  365. align-items: center;
  366. font-size: var(--font14Size);
  367. color: var(--fF0Color);
  368. }
  369. }
  370. }
  371. .thr {
  372. .thr_1 {
  373. padding: 2vw 0;
  374. font-size: var(--font18Size);
  375. font-weight: bold;
  376. }
  377. .thr_2 {
  378. padding: 1vw 0;
  379. .text {
  380. margin: 0 5px 0 0;
  381. padding: 1vw;
  382. border-radius: 5px;
  383. font-size: var(--font12Size);
  384. color: var(--f69Color);
  385. background-color: var(--mainColor);
  386. .iconfont {
  387. font-size: 14px;
  388. }
  389. }
  390. }
  391. .thr_3 {
  392. display: flex;
  393. justify-content: space-between;
  394. padding: 1vw 0;
  395. font-size: var(--font15Size);
  396. margin: 1vw 0 0 0;
  397. .list {
  398. .text {
  399. margin: 0 5px 0 0;
  400. padding: 1vw;
  401. border-radius: 5px;
  402. font-size: var(--font12Size);
  403. color: var(--f69Color);
  404. background-color: var(--mainColor);
  405. .iconfont {
  406. font-size: 14px;
  407. }
  408. }
  409. }
  410. }
  411. .thr_4 {
  412. position: relative;
  413. height: 82vh;
  414. .list {
  415. display: flex;
  416. justify-content: space-between;
  417. background-color: var(--mainColor);
  418. border: 1px solid var(--f5Color);
  419. padding: 2vw;
  420. margin: 2vw 2vw 0 2vw;
  421. border-radius: 5px;
  422. .left {
  423. .name {
  424. padding: 2vw 0;
  425. font-size: var(--font18Size);
  426. font-weight: bold;
  427. }
  428. .type {
  429. padding: 0 0 1vw 0;
  430. color: var(--f3CColor);
  431. font-size: var(--font12Size);
  432. }
  433. .other {
  434. color: var(--f69Color);
  435. font-size: var(--font12Size);
  436. }
  437. }
  438. .right {
  439. display: flex;
  440. flex-direction: column;
  441. justify-content: space-between;
  442. .money {
  443. color: var(--fF0Color);
  444. font-size: var(--font16Size);
  445. font-weight: bold;
  446. text:first-child {
  447. text-decoration: line-through;
  448. color: var(--f69Color);
  449. font-size: var(--font12Size);
  450. font-weight: 400;
  451. }
  452. }
  453. .button {
  454. button {
  455. font-size: var(--font14Size);
  456. border-radius: 40px;
  457. background: linear-gradient(to right, #00BFFF, #007AFF);
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464. }
  465. }
  466. .scroll-view {
  467. position: absolute;
  468. top: 0;
  469. left: 0;
  470. right: 0;
  471. bottom: 0;
  472. .list-scroll-view {
  473. display: flex;
  474. flex-direction: column;
  475. }
  476. }
  477. .is_bottom {
  478. width: 100%;
  479. text-align: center;
  480. text {
  481. padding: 2vw 0;
  482. display: inline-block;
  483. color: var(--f85Color);
  484. font-size: var(--font14Size);
  485. }
  486. }
  487. </style>