海南旅游项目 前端仓库
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.

335 lines
9.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <swiper class="head" :current="banner_current" >
  4. <swiper-item @click="clickBanner" v-for="(item,index) of banner">
  5. <image :src="item.url" class="swipe-img" mode="aspectFill"></image>
  6. </swiper-item>
  7. </swiper>
  8. <view class="content">
  9. <!-- 消息模块 -->
  10. <view class="lf-row-between lf-m-b-34 message-box" v-for="(item,index) of notice">
  11. <view class="lf-flex">
  12. <text class="lf-iconfont lf-icon-tongzhi lf-text-vertical"></text>
  13. <view class="lf-m-l-12 lf-line-1" style="max-width: 510rpx;">{{item.title}}</view>
  14. </view>
  15. <view class="message-btn" hover-class="lf-opacity" @click="$url('/pages/notice/notice?notice_id='+item.id)">详情</view>
  16. </view>
  17. <!-- 频道 -->
  18. <view class="lf-row-between lf-m-b-10">
  19. <view class="lf-font-36 lf-font-bold lf-color-333">添加频道</view>
  20. <view class="lf-flex lf-color-555" @click="$url('/pages/channel/index')">
  21. <view class="lf-m-r-10">编辑</view>
  22. <view class="lf-iconfont lf-icon-xiangyou lf-text-vertical"></view>
  23. </view>
  24. </view>
  25. <view class="lf-flex-wrap">
  26. <view class="channel-item" v-for="(item, index) in channel_list" @click="$url('/pages/goodsList/index?channel_id='+item.id)">
  27. <image :src="item.icon" class="channel-mask" mode="aspectFill"></image>
  28. <view class="lf-row-center channe-text lf-font-bold">{{item.name}}</view>
  29. <!-- <view>
  30. <u-icon name="lock-fill lf-text-vertical"></u-icon>
  31. </view> -->
  32. </view>
  33. </view>
  34. <!-- 中间广告模块 -->
  35. <view class="lf-m-t-40 ad" v-for="(item,index) of home_ad1" :key="index">
  36. <image @click="clickAD(item.id)" :src="item.picture_ad" mode="aspectFill" class="lf-w-100 lf-h-100"></image>
  37. </view>
  38. <!-- <swiper class="lf-m-t-40 ad" :current="banner_current" >
  39. <swiper-item @click="clickAD">
  40. <image :src="home_ad1" class="lf-w-100 lf-h-100"></image>
  41. </swiper-item>
  42. </swiper> -->
  43. <!-- 人气爆款 -->
  44. <view class="lf-row-between lf-m-t-40">
  45. <view class="lf-font-36 lf-font-bold lf-color-333">人气爆款</view>
  46. <view class="lf-flex lf-color-555" @click="$url('/pages/goodsDetail/index')">
  47. <view class="lf-m-r-10">更多</view>
  48. <view class="lf-iconfont lf-icon-xiangyou lf-text-vertical"></view>
  49. </view>
  50. </view>
  51. <view class="recomm lf-m-t-20 lf-m-b-30">
  52. <view class="lf-row-between">
  53. <view class="max-recomm-img" @click="$url('/pages/goodsDetail/index?goods_id='+hot_list[0].id)">
  54. <image :src="hot_list[0].product.picture" class="lf-w-100 lf-h-100"></image>
  55. <view class="recomm-title">
  56. <view class="lf-line-2 lf-m-b-10">{{hot_list[0].product.title}}</view>
  57. <lf-price :price="hot_number" v-if="hot_number"></lf-price>
  58. <!-- <view class="lf-font-42 lf-font-bold lf-m-t-10" style="color: #FF0000;">3999.00</view> -->
  59. </view>
  60. </view>
  61. <view>
  62. <view class="recomm-img" @click="$url('/pages/goodsDetail/index?goods_id='+hot_list[1].id)">
  63. <image :src="hot_list[1].product.picture" class="lf-w-100 lf-h-100"></image>
  64. </view>
  65. <view class="recomm-img lf-m-t-10" @click="$url('/pages/goodsDetail/index?goods_id='+hot_list[2].id)">
  66. <image :src="hot_list[2].product.picture" class="lf-w-100 lf-h-100"></image>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="lf-row-between lf-m-t-10">
  71. <view class="recomm-img" @click="$url('/pages/goodsDetail/index?goods_id='+item.id)" v-for="(item,index) of hot_list" v-if="index>2">
  72. <image :src="item.product.picture" class="lf-w-100 lf-h-100"></image>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- tab标签 -->
  77. <!-- <view class="lf-m-t-40">
  78. <u-tabs :list="tab_list" :is-scroll="true" :current="current" @change="tabChange"></u-tabs>
  79. </view> -->
  80. <!-- 推荐 -->
  81. <!-- <view class="lf-row-between lf-m-t-40 lf-m-b-10">
  82. <view class="lf-font-36 lf-font-bold lf-color-333">推荐</view>
  83. <view class="lf-flex lf-color-555">
  84. <view class="lf-m-r-10">更多</view>
  85. <u-icon name="lock-fill lf-text-vertical"></u-icon>
  86. </view>
  87. </view> -->
  88. </view>
  89. <!-- 猜你喜欢 -->
  90. <lf-title-line></lf-title-line>
  91. <!-- 商品列表-瀑布流 -->
  92. <view style="padding: 0 20rpx;">
  93. <lf-waterfall :list="recomm_list"></lf-waterfall>
  94. <!-- <u-loadmore v-if="recomm_list.length" status="已加载全部数据~" @loadmore="addRandomData"></u-loadmore> -->
  95. <view class="loading-more">
  96. <text :class="{'loading-more-text': loading_class}" v-if="recomm_list.length">{{ loading_text }}</text>
  97. <lf-nocontent v-else></lf-nocontent>
  98. </view>
  99. </view>
  100. <!-- 回到顶部 -->
  101. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  102. </view>
  103. </template>
  104. <script>
  105. import lfWaterfall from '@/components/lf-waterfall/lf-waterfall.vue';
  106. import lfTitleLine from '@/components/lf-title-line/lf-title-line.vue';
  107. export default {
  108. components: {
  109. lfWaterfall,
  110. lfTitleLine
  111. },
  112. data() {
  113. return {
  114. banner: [],
  115. banner_current: 0,
  116. recomm_list: [],
  117. channel_list: [],
  118. current: 0,
  119. loading_class: false,
  120. hot_list: [],
  121. loading_text: '已加载全部数据~',
  122. home_ad1: [],
  123. hot_number: '',
  124. list: [],
  125. notice: []
  126. }
  127. },
  128. onShow() {
  129. // this.addRandomData();
  130. this.getIndexData()
  131. this.getFavourite()
  132. },
  133. methods: {
  134. // 瀑布流随机模拟数据
  135. addRandomData() {
  136. for(let i = 0; i < 10; i++) {
  137. let index = this.$u.random(0, this.list.length - 1);
  138. // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
  139. let item = JSON.parse(JSON.stringify(this.list[index]))
  140. item.id = this.$u.guid();
  141. this.recomm_list.push(item);
  142. }
  143. },
  144. //获取猜你喜欢
  145. getFavourite() {
  146. this.$http(this.API.API_FAVOURITE).then(res => {
  147. this.recomm_list = res.data.data
  148. console.log(res)
  149. }).catch(err => {
  150. })
  151. },
  152. getIndexData() {
  153. this.$http(this.API.API_INDEX).then(res => {
  154. this.notice = res.data?.notice
  155. this.hot_list = res.data?.hots
  156. this.hot_number = parseInt(this.hot_list[0].price)
  157. this.banner = res.data?.slide
  158. this.channel_list = res.data?.my_channels
  159. this.home_ad1 = res.data?.special
  160. uni.stopPullDownRefresh();
  161. console.log(this.home_ad1)
  162. }).catch(err => {
  163. })
  164. },
  165. // tabs标签切换时件,现已费弃
  166. tabChange(current){
  167. this.current = current;
  168. },
  169. // swiper页面被滑动切换
  170. pageChange(event){
  171. console.log(event)
  172. this.current = event.detail.current;
  173. },
  174. // banner图被点击
  175. clickBanner(){
  176. this.$msg('您点击了banner图')
  177. },
  178. // ad被点击
  179. clickAD(id){
  180. // this.$msg('您点击了ad广告')
  181. this.$url('/pages/activityList/index?special_id='+id)
  182. }
  183. },
  184. onReachBottom() {
  185. },
  186. onPullDownRefresh(){
  187. this.getIndexData()
  188. },
  189. onShareAppMessage(){
  190. let shareInfo = {
  191. title: '欢迎使用海南旅游小程序',
  192. path: '/pages/route/index?route=home'
  193. }
  194. return shareInfo;
  195. }
  196. }
  197. </script>
  198. <style>
  199. page{
  200. background-color: #F6F6F6;
  201. }
  202. </style>
  203. <style lang="scss" scoped>
  204. .head{
  205. width: 750rpx;
  206. height: 360rpx;
  207. .swipe-img{
  208. width: 100%;
  209. height: 100%;
  210. }
  211. }
  212. .content{
  213. width: 750rpx;
  214. // height: 600rpx;
  215. height: max-content;
  216. border-radius: 30rpx 30rpx 0rpx 0rpx;
  217. position: relative;
  218. top: -30rpx;
  219. background-color: #FFFFFF;
  220. box-sizing: border-box;
  221. padding: 40rpx 32rpx 10rpx;
  222. .message-box{
  223. width: 686rpx;
  224. height: 53rpx;
  225. background: #CFE7FD;
  226. border-radius: 27rpx;
  227. color: #1998FE;
  228. box-sizing: border-box;
  229. padding: 0 20rpx;
  230. font-size: 24rpx;
  231. .message-btn{
  232. width: 80rpx;
  233. height: 33rpx;
  234. border-radius: 10rpx;
  235. border: 1rpx solid #1998FE;
  236. text-align: center;
  237. line-height: 31rpx;
  238. }
  239. }
  240. }
  241. .channel-item{
  242. width: 160rpx;
  243. height: 160rpx;
  244. border-radius: 15rpx;
  245. margin-top: 15rpx;
  246. margin-right: 15rpx;
  247. position: relative;
  248. overflow: hidden;
  249. &:nth-child(4n){
  250. margin-right: 0;
  251. }
  252. image{
  253. width: 160rpx;
  254. height: 160rpx;
  255. position: absolute;
  256. z-index: 0;
  257. }
  258. // view{
  259. // position: absolute;
  260. // right: 0;
  261. // bottom: 0;
  262. // background-color: rgba(255,255,255,0.5);
  263. // width: 42rpx;
  264. // height: 42rpx;
  265. // color: #FFFFFF;
  266. // display: flex;
  267. // justify-content: center;
  268. // align-items: center;
  269. // border-radius: 10rpx 0rpx 15rpx 0rpx;
  270. // z-index: 2;
  271. // }
  272. .channel-mask::after{
  273. width: 100%;
  274. height: 100%;
  275. content: '';
  276. position: absolute;
  277. z-index: 1;
  278. background: rgba(0, 0, 0, 0.5);
  279. top: 0;
  280. left: 0;
  281. }
  282. .channe-text{
  283. position: absolute;
  284. top: 0;
  285. left: 0;
  286. width: 100%;
  287. height: 100%;
  288. z-index: 2;
  289. color: #FFFFFF;
  290. font-size: 28rpx;
  291. }
  292. }
  293. .ad{
  294. height: 230rpx;
  295. width: 100%;
  296. }
  297. .recomm{
  298. width: 100%;
  299. height: max-content;
  300. .recomm-img{
  301. width: 222rpx;
  302. height: 222rpx;
  303. border-radius: 5rpx;
  304. }
  305. .max-recomm-img{
  306. width: 455rpx;
  307. height: 455rpx;
  308. position: relative;
  309. border-radius: 5rpx;
  310. overflow: hidden;
  311. .recomm-title{
  312. // height: 142rpx;
  313. height: max-content;
  314. width: 100%;
  315. background-color: rgba(0,0,0,0.65);
  316. box-sizing: border-box;
  317. padding: 15rpx;
  318. position: absolute;
  319. bottom: 0;
  320. color: #FFFFFF;
  321. border-radius: 0rpx 0rpx 20rpx 20rpx;
  322. }
  323. }
  324. }
  325. </style>