推广小程序前端代码
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.

616 lines
15 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
2 months ago
4 months ago
4 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
2 months ago
2 months ago
2 months ago
4 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
3 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 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 state = this.params.state
  257. let list1 = await this.getApi('activityPageList')
  258. let list2 = await this.getApi('travelPageList')
  259. console.log(list1, list2);
  260. list1.forEach(n => {
  261. n.ntype = 0
  262. })
  263. list2.forEach(n => {
  264. n.ntype = 1
  265. })
  266. if(this.params.pageNo >= this.totalPage) {
  267. this.status = "nomore"
  268. }else {
  269. this.status = "loadmore"
  270. }
  271. this.cardListData = [...this.cardListData, ...list1, ...list2]
  272. if(state == 0){
  273. this.cardListData.sort((a, b) => {
  274. return this.$dayjs(a.startTime).valueOf() - this.$dayjs(b.startTime).valueOf()
  275. })
  276. }else{
  277. this.cardListData.sort((a, b) => {
  278. return this.$dayjs(b.startTime).valueOf() - this.$dayjs(a.startTime).valueOf()
  279. })
  280. }
  281. },
  282. getApi(api){
  283. return new Promise((success, error) => {
  284. this.$api(api, {
  285. ...this.params,
  286. cityId : this.selectArea.id
  287. }, res => {
  288. if(res.code == 200) {
  289. if(this.totalPage < res.result.pages){
  290. this.totalPage = res.result.pages
  291. }
  292. success(res.result.records)
  293. }
  294. })
  295. })
  296. },
  297. getBanner() {
  298. this.$api('banner',res=>{
  299. if(res.code == 200) {
  300. this.list = res.result
  301. }
  302. })
  303. },
  304. tabs(val) {
  305. this.params.state = val.id
  306. this.search()
  307. },
  308. skip(val) {
  309. if(!val) {
  310. if(!uni.getStorageSync('token')){
  311. return this.$utils.toLogin()
  312. }
  313. uni.setStorageSync('currentState',1)
  314. uni.switchTab({
  315. url:'/pages/index/cart'
  316. })
  317. }else{
  318. uni.navigateTo({
  319. url: `/pages_my/${val}`
  320. })
  321. }
  322. },
  323. clickArea(){
  324. this.tabs({id : 0})
  325. this.$refs.popup.close()
  326. },
  327. swiperClick(index){
  328. let item = this.list[index]
  329. if(item.type == 1){
  330. uni.navigateTo({
  331. url:`/pages_order/lvyou-detail?travelId=${item.travelId}`
  332. })
  333. }else if(item.type == 0){
  334. uni.navigateTo({
  335. url:`/pages_order/huodong-detail?activityId=${item.activityId}`
  336. })
  337. }
  338. },
  339. }
  340. }
  341. </script>
  342. <style lang="scss">
  343. page {
  344. background-color: #060504;
  345. }
  346. </style>
  347. <style scoped lang="scss">
  348. .page {
  349. .head-box {
  350. background: url('@/static/image/nav-bg.png') no-repeat;
  351. background-size: 100% 100%;
  352. width: 100%;
  353. height: 534rpx;
  354. position: absolute;
  355. top: 0;
  356. z-index: -1;
  357. }
  358. .content {
  359. margin-top: 40rpx;
  360. color: #fff;
  361. padding: 0 30rpx;
  362. padding-top: calc(var(--status-bar-height) + 110rpx);
  363. .search-box {
  364. display: flex;
  365. align-items: center;
  366. margin-bottom: 32rpx;
  367. position: relative;
  368. z-index: 9999;
  369. &-l {
  370. display: flex;
  371. align-items: center;
  372. margin-right: 30rpx;
  373. position: relative;
  374. view {
  375. font-weight: 400;
  376. font-size: 27rpx;
  377. color: #FFFFFF;
  378. margin: 0 18rpx 0 15rpx;
  379. }
  380. .address-img {
  381. width: 26rpx;
  382. }
  383. .sjx-img {
  384. width: 13rpx;
  385. }
  386. }
  387. &-r {
  388. flex:1;
  389. }
  390. }
  391. .swipe-box {
  392. margin-bottom: 41rpx;
  393. }
  394. .ydsk-box {
  395. margin-bottom: 10rpx;
  396. &-title {
  397. width: 250rpx;
  398. background: url('@/static/image/home/title-bg.png') no-repeat;
  399. background-size: 100% 100%;
  400. text-align: center;
  401. height: 31rpx;
  402. line-height: 31rpx;
  403. font-weight: bold;
  404. font-size: 35rpx;
  405. color: #FFFFFF;
  406. margin: 0 auto 33rpx;
  407. }
  408. &-gird {
  409. display: flex;
  410. justify-content: space-between;
  411. .gird-l {
  412. box-sizing: border-box;
  413. width: 378rpx;
  414. height: 278rpx;
  415. padding: 36rpx 0 24rpx 26rpx;
  416. background: url('@/static/image/home/hdqd-bg.png') no-repeat;
  417. background-size: 100% 100%;
  418. position: relative;
  419. .hdqd-img {
  420. position: absolute;
  421. right: 34rpx;
  422. top: 48rpx;
  423. width: 200rpx;
  424. }
  425. .left-box {
  426. height: 100%;
  427. display: flex;
  428. flex-direction: column;
  429. justify-content: space-between;
  430. .title-box {
  431. view {
  432. font-weight: bold;
  433. font-size: 29rpx;
  434. color: #060504;
  435. &:nth-child(2) {
  436. font-weight: 400;
  437. font-size: 21rpx;
  438. color: #4C4C4C;
  439. margin-top: 20rpx;
  440. }
  441. }
  442. }
  443. .btn-box {
  444. width: 108rpx;
  445. height: 41rpx;
  446. background: url('@/static/image/home/hdqd-btn.png') no-repeat;
  447. background-size: 100% 100%;
  448. font-weight: 500;
  449. font-size: 17rpx;
  450. color: #FFFFFF;
  451. text-align: center;
  452. line-height: 41rpx;
  453. }
  454. }
  455. }
  456. .gird-r {
  457. .hd-box {
  458. width: 288rpx;
  459. height: 130rpx;
  460. padding: 25rpx 0 24rpx 26rpx;
  461. box-sizing: border-box;
  462. background: url('@/static/image/home/hd-bg.png') no-repeat;
  463. background-size: 100% 100%;
  464. position: relative;
  465. display: flex;
  466. align-items: center;
  467. justify-content: space-between;
  468. .left-box {
  469. height: 100%;
  470. display: flex;
  471. flex-direction: column;
  472. justify-content: space-between;
  473. .title-box {
  474. font-weight: bold;
  475. font-size: 28rpx;
  476. color: #57270F;
  477. }
  478. .btn-box {
  479. width: 98rpx;
  480. height: 35rpx;
  481. background: url('@/static/image/home/hd-btn.png') no-repeat;
  482. background-size: 100% 100%;
  483. font-weight: 500;
  484. font-size: 16rpx;
  485. color: #FFFFFF;
  486. text-align: center;
  487. line-height: 35rpx;
  488. }
  489. }
  490. .hdqd-img {
  491. // position: absolute;
  492. // right: 22rpx;
  493. // top: 25rpx;
  494. width: 123rpx;
  495. height: 100rpx;
  496. }
  497. }
  498. .lx-box {
  499. width: 288rpx;
  500. height: 130rpx;
  501. padding: 25rpx 0 24rpx 26rpx;
  502. box-sizing: border-box;
  503. background: url('@/static/image/home/lx-bg.png') no-repeat;
  504. background-size: 100% 100%;
  505. position: relative;
  506. margin-top: 18rpx;
  507. display: flex;
  508. align-items: center;
  509. justify-content: space-between;
  510. .left-box {
  511. height: 100%;
  512. display: flex;
  513. flex-direction: column;
  514. justify-content: space-between;
  515. .title-box {
  516. font-weight: bold;
  517. font-size: 28rpx;
  518. color: #57270F;
  519. }
  520. .btn-box {
  521. width: 98rpx;
  522. height: 35rpx;
  523. background: url('@/static/image/home/lx-btn.png') no-repeat;
  524. background-size: 100% 100%;
  525. font-weight: 500;
  526. font-size: 16rpx;
  527. color: #FFFFFF;
  528. text-align: center;
  529. line-height: 35rpx;
  530. }
  531. }
  532. .hdqd-img {
  533. // position: absolute;
  534. // right: 22rpx;
  535. // top: 25rpx;
  536. width: 123rpx;
  537. height: 100rpx;
  538. }
  539. }
  540. }
  541. }
  542. }
  543. }
  544. .popup-cont {
  545. width: 95%;
  546. margin: 0 auto;
  547. background-image: linear-gradient(to top, #000000, #331212);
  548. height:662rpx;
  549. border-radius: 33rpx 33rpx 0 0;
  550. .popup-title {
  551. display: flex;
  552. align-items: center;
  553. justify-content: space-between;
  554. padding: 54rpx 52rpx;
  555. font-weight: 500;
  556. font-size: 29rpx;
  557. color: #999999;
  558. }
  559. .popup-list {
  560. padding: 0 50rpx;
  561. height: 400rpx;
  562. .list-item {
  563. display: flex;
  564. justify-content: space-between;
  565. align-items: center;
  566. height: 110rpx;
  567. border-bottom: 1px solid #3F3535;
  568. .item-l {
  569. font-weight: 500;
  570. font-size: 29rpx;
  571. color: #CCCCCC;
  572. display: flex;
  573. align-items: center;
  574. .item-l-val {
  575. margin-left: 40rpx;
  576. }
  577. }
  578. .chooose-class {
  579. color: #FF5858;
  580. }
  581. }
  582. }
  583. .confirm-box {
  584. padding: 0 50rpx;
  585. margin-top: 30rpx;
  586. .confirm-btn-box {
  587. }
  588. }
  589. }
  590. }
  591. </style>