推广小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

608 lines
15 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
5 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
5 months ago
7 months ago
5 months ago
7 months ago
7 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
5 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
5 months ago
7 months ago
5 months ago
7 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
5 months ago
7 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
5 months ago
5 months ago
6 months ago
5 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
5 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
5 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
5 months ago
7 months ago
5 months ago
7 months ago
6 months ago
7 months ago
5 months ago
7 months ago
5 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
  1. <template>
  2. <view class="page">
  3. <view class="head-box"></view>
  4. <uv-navbar :title="navTitle" leftIcon=" " :titleStyle="{color:'#fff'}" :bgColor="bgColor" height="100rpx"></uv-navbar>
  5. <view class="content">
  6. <view class="search-box">
  7. <view class="search-box-l"
  8. @click="$refs.popup.open()">
  9. <image class="address-img" src="@/static/image/home/address-icon.png" mode="widthFix"></image>
  10. <view>{{ selectArea.city }}</view>
  11. <image class="sjx-img" src="@/static/image/home/sjx-icon.png" mode="widthFix"></image>
  12. </view>
  13. <view class="search-box-r">
  14. <uv-search @search="search" placeholder="搜索相关内容" v-model="params.title" shape="square" :showAction="false" color="#fff" placeholderColor="#BDABAC" :clearabled="false" searchIconColor="#fff" searchIconSize="50rpx" bgColor="#4A2A2B" height="63rpx"></uv-search>
  15. </view>
  16. </view>
  17. <view class="swipe-box">
  18. <uv-swiper :list="list"
  19. keyName="image"
  20. height="336rpx" radius="30rpx"
  21. bgColor="transparent" indicator
  22. @click="swiperClick"
  23. indicatorMode="dot"></uv-swiper>
  24. </view>
  25. <view class="ydsk-box">
  26. <view class="ydsk-box-title">悦动时刻</view>
  27. <view class="ydsk-box-gird">
  28. <view class="gird-l" @click="skip('')">
  29. <view class="left-box">
  30. <view class="title-box">
  31. <view>活动签到</view>
  32. <view>签到有好礼</view>
  33. </view>
  34. <view class="btn-box">立即查看</view>
  35. </view>
  36. <image class="hdqd-img" :src="configList.index_sign" mode="widthFix"></image>
  37. <!-- <image class="hdqd-img" src="@/static/image/home/hdqd-img.png" mode="widthFix"></image> -->
  38. </view>
  39. <view class="gird-r">
  40. <view class="hd-box" @click="skip('activeList')">
  41. <view class="left-box">
  42. <view class="title-box">
  43. 活动
  44. </view>
  45. <view class="btn-box">立即查看</view>
  46. </view>
  47. <image class="hdqd-img" :src="configList.index_huodong" mode="widthFix"></image>
  48. <!-- <image class="hdqd-img" src="@/static/image/home/hd-img.png" mode="widthFix"></image> -->
  49. </view>
  50. <view class="hd-box lx-box" @click="skip('travelList')">
  51. <view class="left-box">
  52. <view class="title-box">
  53. 旅行
  54. </view>
  55. <view class="btn-box">立即查看</view>
  56. </view>
  57. <image class="hdqd-img" :src="configList.index_lvxing" mode="widthFix"></image>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="hd-list">
  63. <uv-tabs
  64. @click="tabs"
  65. :list="hdList"
  66. lineWidth="50rpx"
  67. :lineColor="`url(${lineBg}) 100% 100%`"
  68. :activeStyle="{
  69. color: '#fff',
  70. fontWeight: 'bold',
  71. transform: 'scale(1.05)'
  72. }"
  73. :inactiveStyle="{
  74. color: '#999',
  75. transform: 'scale(1)'
  76. }"
  77. itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;"
  78. ></uv-tabs>
  79. <!-- <uv-tabs
  80. @click="({index}) => type = index"
  81. :list="typeList"
  82. lineWidth="50rpx"
  83. :lineColor="`url(${lineBg}) 100% 100%`"
  84. :activeStyle="{
  85. color: '#fff',
  86. fontWeight: 'bold',
  87. transform: 'scale(1.05)'
  88. }"
  89. :inactiveStyle="{
  90. color: '#999',
  91. transform: 'scale(1)'
  92. }"
  93. itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;"
  94. ></uv-tabs> -->
  95. <view v-for="(item, index) in cardListData"
  96. :key="item.id">
  97. <active-item :cardListData="[item]"/>
  98. </view>
  99. <uv-load-more :status="status" fontSize="24rpx" dashed line />
  100. </view>
  101. </view>
  102. <uv-popup ref="popup" mode="bottom" bgColor="">
  103. <view class="popup-cont">
  104. <view class="popup-title">
  105. <view></view>
  106. <view>选择地区</view>
  107. <uv-icon name="close" color="#fff" @click="$refs.popup.close();"></uv-icon>
  108. </view>
  109. <view class="popup-list">
  110. <scroll-view
  111. style="height: 100%;"
  112. scroll-y="true">
  113. <view class="list-item"
  114. v-for="(item,i) in areaList"
  115. :key="i"
  116. @click="$store.commit('setArea', i)">
  117. <view class="item-l" :class="selectArea.id == item.id ? 'chooose-class' : ''">
  118. <view>{{item.city}}</view>
  119. <!-- <view class="item-l-val">{{item.price}}</view> -->
  120. </view>
  121. <uv-icon name="checkmark" color="#FF5858" v-if="selectArea.id == item.id"></uv-icon>
  122. </view>
  123. </scroll-view>
  124. </view>
  125. <view class="confirm-box">
  126. <uv-button @click="clickArea"
  127. text="确定" color="#381615"
  128. shape="circle"
  129. :customStyle="{
  130. color:'#FF5858'
  131. }"></uv-button>
  132. </view>
  133. </view>
  134. </uv-popup>
  135. <tabber select="home" />
  136. </view>
  137. </template>
  138. <script>
  139. // import Position from '@/utils/position.js'
  140. import tabber from '@/components/base/tabbar.vue'
  141. import activeItem from '@/components/active/active-item.vue'
  142. import travelList from '@/components/travel/travelList.vue'
  143. import { mapState } from 'vuex'
  144. export default {
  145. components:{
  146. tabber,
  147. activeItem,
  148. travelList,
  149. },
  150. data() {
  151. return {
  152. status:"loading",
  153. params:{
  154. title : '',
  155. state : 0,
  156. pageNo : 1,
  157. pageSize : 10
  158. },
  159. totalPage:0,
  160. bgColor:'transparent',
  161. navTitle:'',
  162. keyword:'',
  163. list: [],
  164. hdList: [
  165. { id: 0, name: '近期' },
  166. { id: 1, name: '往期' },
  167. ],
  168. typeList: [
  169. { id: 0, name: '活动' },
  170. { id: 1, name: '旅行' },
  171. ],
  172. type : 0,
  173. lineBg: require('@/static/image/cart/tabIcon.png'),
  174. cardListData: [],
  175. city : '定位中',
  176. travelList : [],
  177. }
  178. },
  179. onPageScroll(e) {
  180. if(e.scrollTop > 50) {
  181. this.bgColor = '#49070c'
  182. this.navTitle = '首页'
  183. }else{
  184. this.bgColor = 'transparent'
  185. this.navTitle = ''
  186. }
  187. },
  188. onReachBottom() {
  189. if(this.params.pageNo >= this.totalPage) return
  190. this.params.pageNo ++
  191. this.getActivityPageList()
  192. },
  193. computed : {
  194. ...mapState(['areaList']),
  195. },
  196. onLoad() {
  197. this.getBanner()
  198. // this.getLocationDetail()
  199. this.$store.commit('getArea', list => {
  200. if(!this.selectArea.id){
  201. this.$store.commit('setArea', 0)
  202. this.$nextTick(() => {
  203. this.getActivityPageList()
  204. })
  205. }
  206. })
  207. if(this.selectArea.id){
  208. this.getActivityPageList()
  209. }
  210. },
  211. onPullDownRefresh() {
  212. this.search()
  213. },
  214. methods:{
  215. getLocationDetail(){
  216. Position.getLocationDetail()
  217. .then(res => {
  218. this.city = res.addressDetail.city
  219. })
  220. },
  221. search() {
  222. this.params.pageNo = 1
  223. this.cardListData = []
  224. this.travelList = []
  225. this.getActivityPageList()
  226. },
  227. async getActivityPageList() {
  228. // this.$api('activityPageList', {
  229. // ...this.params,
  230. // cityId : this.selectArea.id
  231. // }, res=>{
  232. // uni.stopPullDownRefresh()
  233. // if(res.code == 200) {
  234. // this.totalPage = res.result.pages
  235. // this.cardListData = [...this.cardListData,...res.result.records]
  236. // if(this.params.pageNo >= this.totalPage) {
  237. // this.status = "nomore"
  238. // }else {
  239. // this.status = "loadmore"
  240. // }
  241. // }
  242. // })
  243. // this.$api('travelPageList', {
  244. // ...this.params,
  245. // // pageNo: this.params.pageNo,
  246. // // pageSize: this.params.pageSize,
  247. // // title: this.params.title,
  248. // // state: this.params.state,
  249. // }, res=>{
  250. // uni.stopPullDownRefresh()
  251. // if(res.code == 200) {
  252. // this.totalPage = res.result.pages
  253. // this.travelList = [...this.travelList,...res.result.records]
  254. // }
  255. // })
  256. let list1 = await this.getApi('activityPageList')
  257. let list2 = await this.getApi('travelPageList')
  258. console.log(list1, list2);
  259. list1.forEach(n => {
  260. n.ntype = 0
  261. })
  262. list2.forEach(n => {
  263. n.ntype = 1
  264. })
  265. if(this.params.pageNo >= this.totalPage) {
  266. this.status = "nomore"
  267. }else {
  268. this.status = "loadmore"
  269. }
  270. this.cardListData = [...this.cardListData, ...list1, ...list2]
  271. this.cardListData.sort((a, b) => {
  272. return this.$dayjs(a.startTime).valueOf() - this.$dayjs(b.startTime).valueOf()
  273. })
  274. },
  275. getApi(api){
  276. return new Promise((success, error) => {
  277. this.$api(api, {
  278. ...this.params,
  279. cityId : this.selectArea.id
  280. }, res => {
  281. if(res.code == 200) {
  282. if(this.totalPage < res.result.pages){
  283. this.totalPage = res.result.pages
  284. }
  285. success(res.result.records)
  286. }
  287. })
  288. })
  289. },
  290. getBanner() {
  291. this.$api('banner',res=>{
  292. if(res.code == 200) {
  293. this.list = res.result
  294. }
  295. })
  296. },
  297. tabs(val) {
  298. this.params.state = val.id
  299. this.search()
  300. },
  301. skip(val) {
  302. if(!val) {
  303. if(!uni.getStorageSync('token')){
  304. return this.$utils.toLogin()
  305. }
  306. uni.setStorageSync('currentState',1)
  307. uni.switchTab({
  308. url:'/pages/index/cart'
  309. })
  310. }else{
  311. uni.navigateTo({
  312. url: `/pages_my/${val}`
  313. })
  314. }
  315. },
  316. clickArea(){
  317. this.tabs({id : 0})
  318. this.$refs.popup.close()
  319. },
  320. swiperClick(index){
  321. let item = this.list[index]
  322. if(item.type == 1){
  323. uni.navigateTo({
  324. url:`/pages_order/lvyou-detail?travelId=${item.travelId}`
  325. })
  326. }else if(item.type == 0){
  327. uni.navigateTo({
  328. url:`/pages_order/huodong-detail?activityId=${item.activityId}`
  329. })
  330. }
  331. },
  332. }
  333. }
  334. </script>
  335. <style lang="scss">
  336. page {
  337. background-color: #060504;
  338. }
  339. </style>
  340. <style scoped lang="scss">
  341. .page {
  342. .head-box {
  343. background: url('@/static/image/nav-bg.png') no-repeat;
  344. background-size: 100% 100%;
  345. width: 100%;
  346. height: 534rpx;
  347. position: absolute;
  348. top: 0;
  349. z-index: -1;
  350. }
  351. .content {
  352. margin-top: 40rpx;
  353. color: #fff;
  354. padding: 0 30rpx;
  355. padding-top: calc(var(--status-bar-height) + 110rpx);
  356. .search-box {
  357. display: flex;
  358. align-items: center;
  359. margin-bottom: 32rpx;
  360. position: relative;
  361. z-index: 9999;
  362. &-l {
  363. display: flex;
  364. align-items: center;
  365. margin-right: 30rpx;
  366. position: relative;
  367. view {
  368. font-weight: 400;
  369. font-size: 27rpx;
  370. color: #FFFFFF;
  371. margin: 0 18rpx 0 15rpx;
  372. }
  373. .address-img {
  374. width: 26rpx;
  375. }
  376. .sjx-img {
  377. width: 13rpx;
  378. }
  379. }
  380. &-r {
  381. flex:1;
  382. }
  383. }
  384. .swipe-box {
  385. margin-bottom: 41rpx;
  386. }
  387. .ydsk-box {
  388. margin-bottom: 10rpx;
  389. &-title {
  390. width: 250rpx;
  391. background: url('@/static/image/home/title-bg.png') no-repeat;
  392. background-size: 100% 100%;
  393. text-align: center;
  394. height: 31rpx;
  395. line-height: 31rpx;
  396. font-weight: bold;
  397. font-size: 35rpx;
  398. color: #FFFFFF;
  399. margin: 0 auto 33rpx;
  400. }
  401. &-gird {
  402. display: flex;
  403. justify-content: space-between;
  404. .gird-l {
  405. box-sizing: border-box;
  406. width: 378rpx;
  407. height: 278rpx;
  408. padding: 36rpx 0 24rpx 26rpx;
  409. background: url('@/static/image/home/hdqd-bg.png') no-repeat;
  410. background-size: 100% 100%;
  411. position: relative;
  412. .hdqd-img {
  413. position: absolute;
  414. right: 34rpx;
  415. top: 48rpx;
  416. width: 200rpx;
  417. }
  418. .left-box {
  419. height: 100%;
  420. display: flex;
  421. flex-direction: column;
  422. justify-content: space-between;
  423. .title-box {
  424. view {
  425. font-weight: bold;
  426. font-size: 29rpx;
  427. color: #060504;
  428. &:nth-child(2) {
  429. font-weight: 400;
  430. font-size: 21rpx;
  431. color: #4C4C4C;
  432. margin-top: 20rpx;
  433. }
  434. }
  435. }
  436. .btn-box {
  437. width: 108rpx;
  438. height: 41rpx;
  439. background: url('@/static/image/home/hdqd-btn.png') no-repeat;
  440. background-size: 100% 100%;
  441. font-weight: 500;
  442. font-size: 17rpx;
  443. color: #FFFFFF;
  444. text-align: center;
  445. line-height: 41rpx;
  446. }
  447. }
  448. }
  449. .gird-r {
  450. .hd-box {
  451. width: 288rpx;
  452. height: 130rpx;
  453. padding: 25rpx 0 24rpx 26rpx;
  454. box-sizing: border-box;
  455. background: url('@/static/image/home/hd-bg.png') no-repeat;
  456. background-size: 100% 100%;
  457. position: relative;
  458. display: flex;
  459. align-items: center;
  460. justify-content: space-between;
  461. .left-box {
  462. height: 100%;
  463. display: flex;
  464. flex-direction: column;
  465. justify-content: space-between;
  466. .title-box {
  467. font-weight: bold;
  468. font-size: 28rpx;
  469. color: #57270F;
  470. }
  471. .btn-box {
  472. width: 98rpx;
  473. height: 35rpx;
  474. background: url('@/static/image/home/hd-btn.png') no-repeat;
  475. background-size: 100% 100%;
  476. font-weight: 500;
  477. font-size: 16rpx;
  478. color: #FFFFFF;
  479. text-align: center;
  480. line-height: 35rpx;
  481. }
  482. }
  483. .hdqd-img {
  484. // position: absolute;
  485. // right: 22rpx;
  486. // top: 25rpx;
  487. width: 123rpx;
  488. height: 100rpx;
  489. }
  490. }
  491. .lx-box {
  492. width: 288rpx;
  493. height: 130rpx;
  494. padding: 25rpx 0 24rpx 26rpx;
  495. box-sizing: border-box;
  496. background: url('@/static/image/home/lx-bg.png') no-repeat;
  497. background-size: 100% 100%;
  498. position: relative;
  499. margin-top: 18rpx;
  500. display: flex;
  501. align-items: center;
  502. justify-content: space-between;
  503. .left-box {
  504. height: 100%;
  505. display: flex;
  506. flex-direction: column;
  507. justify-content: space-between;
  508. .title-box {
  509. font-weight: bold;
  510. font-size: 28rpx;
  511. color: #57270F;
  512. }
  513. .btn-box {
  514. width: 98rpx;
  515. height: 35rpx;
  516. background: url('@/static/image/home/lx-btn.png') no-repeat;
  517. background-size: 100% 100%;
  518. font-weight: 500;
  519. font-size: 16rpx;
  520. color: #FFFFFF;
  521. text-align: center;
  522. line-height: 35rpx;
  523. }
  524. }
  525. .hdqd-img {
  526. // position: absolute;
  527. // right: 22rpx;
  528. // top: 25rpx;
  529. width: 123rpx;
  530. height: 100rpx;
  531. }
  532. }
  533. }
  534. }
  535. }
  536. }
  537. .popup-cont {
  538. width: 95%;
  539. margin: 0 auto;
  540. background-image: linear-gradient(to top, #000000, #331212);
  541. height:662rpx;
  542. border-radius: 33rpx 33rpx 0 0;
  543. .popup-title {
  544. display: flex;
  545. align-items: center;
  546. justify-content: space-between;
  547. padding: 54rpx 52rpx;
  548. font-weight: 500;
  549. font-size: 29rpx;
  550. color: #999999;
  551. }
  552. .popup-list {
  553. padding: 0 50rpx;
  554. height: 400rpx;
  555. .list-item {
  556. display: flex;
  557. justify-content: space-between;
  558. align-items: center;
  559. height: 110rpx;
  560. border-bottom: 1px solid #3F3535;
  561. .item-l {
  562. font-weight: 500;
  563. font-size: 29rpx;
  564. color: #CCCCCC;
  565. display: flex;
  566. align-items: center;
  567. .item-l-val {
  568. margin-left: 40rpx;
  569. }
  570. }
  571. .chooose-class {
  572. color: #FF5858;
  573. }
  574. }
  575. }
  576. .confirm-box {
  577. padding: 0 50rpx;
  578. margin-top: 30rpx;
  579. .confirm-btn-box {
  580. }
  581. }
  582. }
  583. }
  584. </style>