index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <view class="home">
  3. <MyNav title="洲际酒店集团中国西区" bgColor="" :backIcon="false"></MyNav>
  4. <!-- swiper -->
  5. <view class="home-swiper">
  6. <uni-swiper-dot :info="infoList" :current="current1" :mode="mode" :dots-styles="dotsStyles">
  7. <swiper class="swiper-box" @change="change1" circular>
  8. <swiper-item v-for="(item ,index) in infoList" :key="index">
  9. <view class="swiper-item" v-if="item.resource_type == 1"
  10. @click="jumpHAppID(item.jump_type,item.jump_config)">
  11. <image style="width: 100%;height:592rpx;" :src="item.img" mode="aspectFill"></image>
  12. </view>
  13. <view class="swiper-item" v-if="item.resource_type == 2">
  14. <video id="swiperVideo" ref="swiperVideo" style="width: 100%; height: 592rpx;"
  15. :src="item.video_url" controls :enable-progress-gesture="false">
  16. </video>
  17. </view>
  18. </swiper-item>
  19. </swiper>
  20. </uni-swiper-dot>
  21. </view>
  22. <!-- 金刚图 -->
  23. <view class="home-nav">
  24. <view class="home-nav-item" v-for="(item,index) in navList" :key="index"
  25. @click="jumpHAppID(item.jump_type,item.jump_config)">
  26. <image style="width: 101.96rpx;height: 103.96rpx;" :src="item.img" mode=""></image>
  27. <text style="color: #333;font-size: 24rpx;margin-top: 18rpx; ">{{item.title}}</text>
  28. </view>
  29. </view>
  30. <!-- 活动专区 -->
  31. <view class="home-special-area">
  32. <view class="home-special-area-left">
  33. <text>非凡西区</text>
  34. <view class="text-shadow"></view>
  35. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  36. </image>
  37. </view>
  38. <view @click="goSpecialList" class="home-special-area-right">
  39. <text>全部</text>
  40. <image style="width: 12rpx; height: 20rpx;margin-left: 8rpx;" src="/static/icon/right01.png" mode="">
  41. </image>
  42. </view>
  43. </view>
  44. <!-- 活动图片 -->
  45. <view class="home-special-img">
  46. <template v-for="(item,index) in specialList" >
  47. <view class="ListItem" v-if="item.show_status" :key="index" @click="activeDetail(item.id)">
  48. <image style="width: 312rpx;height: 200rpx; border-radius: 12rpx; "
  49. :src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'" mode=""></image>
  50. <view class="kudosicon" @click.stop="kudosActive(item.id,index)">
  51. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos.png" v-if="item.is_like==0">
  52. </image>
  53. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos(1).png" v-if="item.is_like==1">
  54. </image>
  55. </view>
  56. <text style="color: #333;font-weight: bold;font-size: 28rpx;">{{item.title}}</text>
  57. </view>
  58. </template>
  59. </view>
  60. <!-- 广告图 -->
  61. <view class="home-banner" v-if="!isShowAdver">
  62. <view class="home-banner-img" v-if="in_page==1 && type == 1 ">
  63. <image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" @click="jumpHAppID(advData.jump_type, advData.jump_config)"></image>
  64. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  65. src="/static/icon/clean.png" mode="">
  66. </image>
  67. </view>
  68. <view class="home-banner-img" v-if="in_page==1 && type == 2">
  69. <image class="banner-img" v-if="!isOpenVideo" @click="openVideoPlay"
  70. style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="videoCoverImg" mode=""></image>
  71. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  72. src="/static/icon/clean.png" mode="">
  73. </image>
  74. <video class="baner-video" id="myVideo" ref="myVideo"
  75. style="width: 100%; height: 576rpx;border-radius: 12rpx; " :src="videoSrc" controls
  76. :enable-progress-gesture="false">
  77. </video>
  78. </view>
  79. </view>
  80. <movable-area class="movableArea">
  81. <movable-view class="movableView" direction="all" x="630rpx" y="700rpx">
  82. <view class="img-IHg" @click="goJoin">
  83. <image style="width: 64rpx; height: 58rpx; " src="/static/icon/vip.png" mode=""></image>
  84. </view>
  85. </movable-view>
  86. </movable-area>
  87. <!-- 广告的附图 -->
  88. <view class="home-attach" @click="jumpHAppID(advInsetImg.jump_type, advInsetImg.jump_config)">
  89. <image style="width: 690rpx;height: 156rpx;border-radius: 79rpx;" :src="advInsetImg.img" mode=""></image>
  90. </view>
  91. <!-- 酒店推荐 -->
  92. <view class="home-hotel home-special-area">
  93. <view class="home-special-area-left">
  94. <text>西区优品</text>
  95. <view class="text-shadow"></view>
  96. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  97. </image>
  98. </view>
  99. </view>
  100. <!-- 酒店推荐图片 -->
  101. <view class="home-hotel-img">
  102. <view class="home-hotel-img-content">
  103. <view @click="produceDetail(item.id)" class="home-hotel-img-content-item" v-for="(item,index) in goodsList" :key="index"
  104. :style="{marginTop:item.marginTop || 0 }">
  105. <image class="home-hotel-img-content-item-img"
  106. :class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
  107. :src="item.cover_img" mode=""></image>
  108. <view class="text">
  109. <text class="text-top">{{item.name}}</text>
  110. <!-- <text class="text-main">{{item.title}}</text> -->
  111. </view>
  112. </view>
  113. </view>
  114. <view class="home-hotel-img-more" @click="goProduceList">
  115. <text>查看更多商品</text>
  116. </view>
  117. </view>
  118. <!-- 酒店品牌 -->
  119. <view class="home-brand home-special-area">
  120. <view class="home-special-area-left">
  121. <text>洲际酒店集团品牌</text>
  122. <view class="text-shadow"></view>
  123. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  124. </image>
  125. </view>
  126. </view>
  127. <!-- 酒店品牌图片 -->
  128. <view class="home-brand-img">
  129. <uni-swiper-dot :info="info" mode="default" :current="current2" :dots-styles="dotsStylesBand">
  130. <swiper class="swiper-box" circular @change="change2">
  131. <swiper-item v-for="(items ,index) in info" :key="index">
  132. <view v-for="(item ,j) in items" :key="j" class="swiper-item"
  133. @click="jumpHAppID(item.jump_type,item.jump_config)">
  134. <image style="width:144rpx;height:142rpx;" :src="item.img" mode="aspectFill"></image>
  135. </view>
  136. </swiper-item>
  137. </swiper>
  138. </uni-swiper-dot>
  139. </view>
  140. <!-- 触底 -->
  141. <view class="home-bottom">
  142. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  143. </view>
  144. <!-- 弹窗广告 -->
  145. <uni-popup ref="popup" type="center">
  146. <view class="popup-banner">
  147. <image @click="jumpHAppID(popupData.jump_type, popupData.jump_config)" style="width: 656rpx;height: 916rpx;border-radius: 12rpx;" :src="popupData.img">
  148. </image>
  149. <view class="popup-banner-clean" @click='closePopupBanner'>
  150. <image style="width: 20rpx; height: 20rpx; " src="/static/icon/clean.png" mode="">
  151. </view>
  152. </view>
  153. </uni-popup>
  154. <view style="height:168rpx; background-color: #f9f9f9; "></view>
  155. <tab-bar></tab-bar>
  156. </view>
  157. </template>
  158. <script>
  159. import TabBar from '../../components/TabBar/tabbar.vue'
  160. import SwiperBox from '../../components/SwiperBox/index.vue'
  161. import MyNav from "@/components/my-nav/my-nav.vue"
  162. export default {
  163. components: {
  164. TabBar,
  165. SwiperBox,
  166. MyNav
  167. },
  168. data() {
  169. return {
  170. //用户个人信息,判断是否登录
  171. admin: '',
  172. //获取token
  173. data: {},
  174. //录播图是展示视频1:图片2:视频
  175. resource_type: '',
  176. //广告弹框跳转
  177. jup_type: '',
  178. jump_config: '',
  179. //广告弹框图
  180. popupData:{},
  181. //弹窗的类型 1只弹一次首次 2就是每次都弹啊
  182. times_type:'',
  183. //弹窗的显示0不显示 1显示
  184. popupImgStatus:'',
  185. //视频封面图
  186. isOpenVideo: false,
  187. videoCoverImg: '',
  188. videoSrc: '',
  189. in_page: '',
  190. type: '',
  191. //隐藏广告图
  192. isShowAdver: false,
  193. //广告图
  194. advertis: '',
  195. advData: {},
  196. //广告附图展示图片
  197. advertisInsetImg: '',
  198. advInsetImg:{},
  199. //广告图展示图片:
  200. advertisImg: '',
  201. //广告图展示视频
  202. goodsList: [],
  203. status: 'noMore',
  204. contentText: {
  205. contentdown: '查看更多',
  206. contentrefresh: '加载中',
  207. contentnomore: '—— 已经到底啦 ——'
  208. },
  209. infoList: [],
  210. //轮播图
  211. info: [],
  212. dotsStyles: {
  213. bottom: 24,
  214. backgroundColor: 'rgba(255, 255, 255, .3)',
  215. border: '1px rgba(255, 255, 255, .3) solid',
  216. color: '#fff',
  217. selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  218. selectedBorder: '1px rgba(255, 255, 255, 1) solid'
  219. },
  220. dotsStylesBand: {
  221. bottom: -24,
  222. backgroundColor: 'rgba(198, 198, 198, 1)',
  223. border: '1px rgba(0, 0, 0, .3) solid',
  224. color: '#fff',
  225. selectedBackgroundColor: 'rgba(151, 151, 151, 1)',
  226. selectedBorder: '1px rgba(0, 0, 0, .9) solid'
  227. },
  228. //指示点显示位置
  229. current1: 0,
  230. current2: 0,
  231. //指示点模式
  232. mode: 'dot',
  233. // 金刚图
  234. navList: [],
  235. //活动专区
  236. specialList: []
  237. }
  238. },
  239. onTabItemTap(e){
  240. console.log(e)
  241. },
  242. // 下拉刷新
  243. onPullDownRefresh() {
  244. setTimeout(() => {
  245. uni.stopPullDownRefresh();
  246. this.$store.dispatch('user/allset', null)
  247. this.getAllSet()
  248. this.getList()
  249. }, 1000);
  250. },
  251. onReady: function(res) {
  252. this.videoContext = uni.createVideoContext('myVideo')
  253. },
  254. onShow() {
  255. //获取token
  256. this.getmsg()
  257. this.admin = this.$store.getters.userInfo
  258. },
  259. onLoad() {
  260. // this.shortLong()
  261. this.getGoodsList()
  262. this.getAllSet()
  263. },
  264. methods: {
  265. // **************** Data ***************//
  266. //获取配置数据
  267. getAllSet() {
  268. this.$api.document.allSet().then(res => {
  269. this.$store.dispatch('user/allset', res.data)
  270. this.infoList = this.$store.getters.allset.banners
  271. this.navList = this.$store.getters.allset.nav_icon
  272. this.info = this.$store.getters.allset.partner
  273. //广告图
  274. this.advertis = this.$store.getters.allset.advertises.filter(item => {
  275. return item.in_page == 1
  276. })
  277. this.advData = this.advertis[0];
  278. if (this.advertis[0].type == 1) {
  279. this.in_page = 1
  280. this.type = 1
  281. this.advertisImg = this.advertis[0].img
  282. } else if (this.advertis[0].type == 2) {
  283. this.in_page = 1
  284. this.type = 2
  285. this.videoCoverImg = this.advertis[0].video_cover
  286. this.videoSrc = this.advertis[0].video
  287. }
  288. //胶囊图
  289. this.advertisInset = this.$store.getters.allset.advertises.filter(item => {
  290. return item.in_page == 2
  291. })
  292. this.advInsetImg = this.advertisInset[0]
  293. this.advertisInsetImg = this.advertisInset[0].img
  294. //广告弹框图
  295. this.popupData = this.$store.getters.allset.popup_ads[0]
  296. //弹窗是否展示
  297. this.popupImgStatus = this.popupData?.status
  298. this.times_type = this.popupData?.times_type
  299. //广告弹框跳转h5和小程序和内部
  300. this.jump_type = this.popupData?.jump_type,
  301. this.jump_config = this.popupData?.jump_config
  302. this.open()
  303. })
  304. },
  305. // 获取活动列表
  306. getList() {
  307. this.$api.active.getActiveList({
  308. page: 0,
  309. keyword: '',
  310. category_id: ''
  311. }).then(res => {
  312. console.log(res, '活动列表')
  313. if (res.code == 0) {
  314. this.specialList = res.data.data
  315. }
  316. })
  317. },
  318. //产品列表type:1,第三方购买产品
  319. getGoodsList(category_id) {
  320. this.$api.product.getProducts({
  321. type: 1,
  322. page: 0,
  323. }).then(res => {
  324. this.goodsList = res.data.data.slice(0,4)
  325. this.shortLong()
  326. console.log(this.goodsList,'------>产品图');
  327. })
  328. },
  329. //产品详情
  330. produceDetail(id){
  331. uni.navigateTo({
  332. url:`/pages/goods/goods-detail/index?id=${id}&type=1`
  333. })
  334. },
  335. // **************** Dev ***************//
  336. shortLong() {
  337. this.goodsList.forEach((item, index, arr) => {
  338. if (index % 4 === 0) {
  339. item.short = true
  340. }
  341. if (index % 4 === 1) {
  342. item.long = true
  343. }
  344. if (index % 4 === 2) {
  345. item.long = true
  346. item.marginTop = -68 + "rpx"
  347. }
  348. if (index % 4 === 3) {
  349. item.short = true
  350. }
  351. })
  352. },
  353. //隐藏图片
  354. cleanCoverImg() {
  355. this.isShowAdver = !this.isShowAdver
  356. },
  357. //打开弹框
  358. open() {
  359. console.log(this.popupImgStatus,this.times_type);
  360. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  361. if(this.popupImgStatus == 1){
  362. if(this.times_type == 1){
  363. //首次进入弹窗
  364. const value = uni.getStorageSync('launchFlag');
  365. if (value) {
  366. console.log('首次弹窗')
  367. } else {
  368. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  369. uni.setStorage({
  370. key: 'launchFlag',
  371. data: true
  372. });
  373. this.$refs.popup.open('center')
  374. }
  375. }else{
  376. this.$refs.popup.open('center')//每次都弹
  377. }
  378. }else{
  379. this.$refs.popup.close()//不显示广告弹框
  380. }
  381. },
  382. //关闭弹框
  383. closePopupBanner() {
  384. this.$refs.popup.close()
  385. },
  386. //点击视频封面图片,播放视频
  387. openVideoPlay() {
  388. this.isOpenVideo = !this.isOpenVideo
  389. this.videoContext.play()
  390. },
  391. // **************** 跳转 ***************//
  392. //合同伙伴跳转h5和小程序
  393. goGoodsDetail(id, urls) {
  394. console.log(urls, '----->url');
  395. if (id == 1) {
  396. const url = urls; // 跳转的外链
  397. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  398. uni.navigateTo({
  399. // 跳转到webview页面
  400. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  401. success: () => {
  402. console.log('成功')
  403. },
  404. fail: (e) => {
  405. console.log(e, "失败")
  406. }
  407. });
  408. } else if (id == 2) {
  409. let obj = JSON.parse(urls);
  410. wx.navigateToMiniProgram({
  411. appId: `${obj.appid}`, //appid
  412. path: `${obj.path}`, //path
  413. extraData: { //参数
  414. foo: 'bar'
  415. },
  416. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  417. success(res) {
  418. console.log('成功')
  419. // 打开成功
  420. },
  421. fail(e) {
  422. console.log(e, '失败')
  423. }
  424. })
  425. }
  426. },
  427. // 活动详情页
  428. activeDetail(id) {
  429. uni.navigateTo({
  430. url: '/pages/index/active-detail/index?id=' + id
  431. })
  432. },
  433. // 点赞活动
  434. kudosActive(id, index) {
  435. let beforeLike = this.specialList[index].is_like
  436. this.$api.active.kudos({
  437. activity_id: id
  438. }).then(res => {
  439. console.log(res, '点赞')
  440. if (res.code == 0) {
  441. if (beforeLike == 1) {
  442. this.specialList[index].is_like = 0
  443. uni.showToast({
  444. icon: 'none',
  445. title: '取消点赞'
  446. })
  447. } else {
  448. this.specialList[index].is_like = 1
  449. uni.showToast({
  450. icon: 'none',
  451. title: '点赞成功'
  452. })
  453. }
  454. }
  455. })
  456. },
  457. //跳转方法
  458. jumpHAppID(id, urls) {
  459. if (id == 1) {
  460. const url = urls; // 跳转的外链
  461. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  462. uni.navigateTo({
  463. // 跳转到webview页面
  464. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  465. success: () => {
  466. console.log('成功')
  467. },
  468. fail: (e) => {
  469. console.log(e, "失败")
  470. }
  471. });
  472. } else if (id == 2) {
  473. let obj = JSON.parse(urls);
  474. wx.navigateToMiniProgram({
  475. appId: `${obj.appid}`, //appid
  476. path: `${obj.path}`, //path
  477. extraData: { //参数
  478. foo: 'bar'
  479. },
  480. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  481. success(res) {
  482. console.log('成功')
  483. // 打开成功
  484. },
  485. fail(e) {
  486. console.log(e, '失败')
  487. }
  488. })
  489. } else if (id == 3) {
  490. uni.reLaunch({
  491. url: urls,
  492. fail:(err)=>{
  493. uni.navigateTo({
  494. url: urls
  495. })
  496. }
  497. })
  498. }
  499. },
  500. // 跳转其他小程序
  501. goJoin() {
  502. wx.navigateToMiniProgram({
  503. appId: 'wx255b58f0992b3c53', //appid
  504. path: 'newUIMain/enrollment/enrollment', //path
  505. extraData: { //参数
  506. foo: 'bar'
  507. },
  508. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  509. success(res) {
  510. console.log('成功')
  511. // 打开成功
  512. },
  513. fail(e) {
  514. console.log(e, '失败')
  515. }
  516. })
  517. },
  518. // 跳转到h5页面
  519. goH5() {
  520. let inset = this.advertisInset[0].jump_type
  521. let inserPath = this.advertisInset[0].jump_config
  522. //跳转h5
  523. if (inset == 1) {
  524. const url = inserPath; // 跳转的外链
  525. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  526. uni.navigateTo({
  527. // 跳转到webview页面
  528. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  529. success: () => {
  530. console.log('成功')
  531. },
  532. fail: (e) => {
  533. console.log(e, "失败")
  534. }
  535. });
  536. } else if (inset == 2) {
  537. let obj = JSON.parse(inserPath);
  538. wx.navigateToMiniProgram({
  539. appId: `${obj.appid}`, //appid
  540. path: `${obj.path}`, //path
  541. extraData: { //参数
  542. foo: 'bar'
  543. },
  544. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  545. success(res) {
  546. console.log('成功')
  547. // 打开成功
  548. },
  549. fail(e) {
  550. console.log(e, '失败')
  551. }
  552. })
  553. }
  554. },
  555. //产品列表
  556. goProduceList() {
  557. uni.navigateTo({
  558. url: '/pages/goods/goods'
  559. })
  560. },
  561. //活动列表
  562. goSpecialList() {
  563. uni.navigateTo({
  564. url: '/pages/index/active-list/index'
  565. })
  566. },
  567. // 切换轮播图指示点
  568. change1(e) {
  569. this.current1 = e.detail.current;
  570. },
  571. change2(e) {
  572. this.current2 = e.detail.current;
  573. },
  574. getCode() {
  575. return new Promise((resolve, reject) => {
  576. uni.getUserInfo({
  577. success: loginRes => {
  578. console.log(loginRes);
  579. this.data.encryptData = loginRes.encryptedData,
  580. this.data.iv = loginRes.iv
  581. resolve(this.data)
  582. }
  583. })
  584. })
  585. },
  586. //获取微信登录的code码
  587. getmsg() {
  588. uni.login({
  589. provider: uni.$u.platform,
  590. success: res => {
  591. console.log(res, '------->res');
  592. this.getCode().then((data) => {
  593. console.log(this.data, '------>data');
  594. const params = {
  595. code: res.code,
  596. iv: data.iv,
  597. encryptData: data.encryptData
  598. }
  599. console.log(params);
  600. this.$api.my.myLogin(params).then(res => {
  601. let {
  602. token
  603. } = res.data
  604. this.$store.dispatch('user/token', token)
  605. // 获取活动列表
  606. this.getList()
  607. })
  608. })
  609. }
  610. })
  611. }
  612. },
  613. }
  614. </script>
  615. <style lang="scss" src="./index.scss" scoped></style>