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

631 lines
16 KiB

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