index.bak.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view class="home">
  3. <!--S 头部搜索 -->
  4. <view class="home_bar">
  5. <view class="home_bar_nav"></view>
  6. <view class="home_bar_con flex">
  7. <view class="home_bar_logo">
  8. <image :src="logo" mode="aspectFill"></image>
  9. </view>
  10. <view class="home_bar_search flexs" @click="goSearch">
  11. <image src="https://www.chaomangdao.com/image/home/sousuo@2x.png" mode=""></image>
  12. <input type="text" disabled placeholder="输入您要搜索的内容" placeholder-style="color:#808080" />
  13. </view>
  14. <view class="home_bar_serve" @click="goServe">
  15. <image src="https://www.chaomangdao.com/image/home/kefu@2x.png" mode=""></image>
  16. </view>
  17. </view>
  18. </view>
  19. <!--E 头部搜索 -->
  20. <!--S 轮播图 -->
  21. <view class="home_swiper">
  22. <swiper autoplay circular class="swiper">
  23. <swiper-item v-for="(item,index) in bannerList" :key="index" @click="changeBanner(item)">
  24. <image :src="item.image" mode="aspectFill"></image>
  25. </swiper-item>
  26. </swiper>
  27. <view class="home_swiper_ul flex">
  28. <view class="home_swiper_li flexs" v-for="(item,index) in iconList" :key="index">
  29. <image :src="item.image" mode=""></image>
  30. <text>{{ item.name }}</text>
  31. </view>
  32. </view>
  33. <view class="home_swiper_nav flex">
  34. <view class="home_swiper_nav_li center" v-for="(item,index) in navList" :key="index" @click="changeNav(item)">
  35. <image :src="item.image" mode=""></image>
  36. <text>{{ item.name }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <!--E 轮播图 -->
  41. <!-- S 试一试 -->
  42. <!--view class="home_trial flex">
  43. <view class="home_trial_img flexs">
  44. <text>试试手气</text>
  45. <image src="/static/image/home/zuijia@2x.png" mode=""></image>
  46. </view>
  47. <view class="home_trial_go" @click="goMessage(0,1)">
  48. <image src="/static/image/home/jinru@2x.png" mode=""></image>
  49. </view>
  50. </view-->
  51. <!-- E 试一试 -->
  52. <!-- S 最新开箱 -->
  53. <!--view class="home_newest">
  54. <view class="home_newest_head flex">
  55. <view class="home_newest_head_new">最新开箱</view>
  56. <view class="home_newest_head_go flexs" @click="goNewBox">
  57. <text>查看更多</text>
  58. <image src="/static/image/publice/jinruer@2x.png" mode=""></image>
  59. </view>
  60. </view>
  61. <scroll-view scroll-x="true" class="scroll-view">
  62. <view class="scroll-view_li" v-for="(item,index) in newBoxList" :key="index" @click="goMessage(item,0)">
  63. <view class="scroll-view_li_img">
  64. <image :src="item.goods_images[0]" mode="aspectFill"></image>
  65. </view>
  66. <view class="scroll-view_li_price flexs">
  67. <text>¥</text>
  68. <text>{{ item.coin_price }}</text>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. <view class="home_newest_ul flex">
  73. <view class="home_newest_li flexs" v-for="(item,index) in hotList" :key="index" @click="changeHot(item)">
  74. <view class="home_newest_img">
  75. <image :src="item.image" mode=""></image>
  76. </view>
  77. <view class="home_newest_con">
  78. <view class="home_newest_name">{{ item.name }}</view>
  79. <view class="home_newest_title">{{ item.title }}</view>
  80. </view>
  81. </view>
  82. </view>
  83. </view-->
  84. <!-- E 最新开箱 -->
  85. <!-- S 推荐盲盒 -->
  86. <view class="home_recommend home_newest">
  87. <view class="home_newest_head flex">
  88. <view class="home_newest_head_new">推荐盲盒</view>
  89. <view class="home_newest_head_go flexs" @click="goRecommend">
  90. <text>更多分类</text>
  91. <image src="/static/image/publice/jinruer@2x.png" mode=""></image>
  92. </view>
  93. </view>
  94. <view class="home_recommend_ul flex">
  95. <view class="home_recommend_li" v-for="(item,index) in shopList" :key="index" @click="goMessage(item,0)">
  96. <view class="home_recommend_li_img">
  97. <view class="home_recommend_li_img_top flex">
  98. <view class="home_recommend_li_img_box">
  99. <image :src="item.image" mode="aspectFill"></image>
  100. </view>
  101. <view class="home_recommend_li_img_right" v-if="item.right.length != 0">
  102. <image :src="items" mode="aspectFill" v-for="(items,index) in item.right" :key="index"></image>
  103. </view>
  104. </view>
  105. <view class="home_recommend_li_img_bot">
  106. <image :src="items" mode="aspectFill" v-for="(items,index) in item.bot" :key="index"></image>
  107. </view>
  108. </view>
  109. <view class="home_recommend_li_main">
  110. <view class="home_recommend_li_price">价值:¥{{ item.price_min }}~¥{{ item.price_max }}</view>
  111. <view class="home_recommend_li_name">{{ item.box_name }}</view>
  112. <view class="home_recommend_li_glod flex">
  113. <text>{{ item.coin_price }}金币</text>
  114. <text>共{{ item.goods_num }}款商品</text>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <!-- E 推荐盲盒 -->
  121. </view>
  122. </template>
  123. <script>
  124. export default {
  125. data() {
  126. return {
  127. iconList:[
  128. {
  129. image:'https://www.chaomangdao.com/image/home/zhengpinbaozheng@2x.png',
  130. name:'官方正品保证'
  131. },
  132. {
  133. image:'https://www.chaomangdao.com/image/home/yijianhuishou@2x.png',
  134. name:'一键秒回收'
  135. },
  136. {
  137. image:'https://www.chaomangdao.com/image/home/youhui@2x.png',
  138. name:'全网最优惠'
  139. }
  140. ],
  141. navList:[
  142. {
  143. image:'https://www.chaomangdao.com/image/home/chaowanmanghe@2x.png',
  144. name:'盲盒商城',
  145. url:'/pages/index/more'
  146. },
  147. {
  148. image:'https://www.chaomangdao.com/image/home/youhuichongzhi@2x.png',
  149. name:'优惠充值',
  150. url:'/pages/me/recharge'
  151. },
  152. {
  153. image:'https://www.chaomangdao.com/image/home/fahuoliucheng@2x.png',
  154. name:'发货流程',
  155. url:'/pages/index/flow'
  156. },
  157. {
  158. image:'https://www.chaomangdao.com/image/home/xinshoubangzhu@2x.png',
  159. name:'新手帮助',
  160. url:'/pages/index/help'
  161. }
  162. ],//导航列表
  163. hotList:[
  164. {
  165. image:'https://www.chaomangdao.com/image/home/remen@2x.png',
  166. name:'热门专区',
  167. title:'跟随热门手气更欧',
  168. url:'/pages/index/hot?type=0'
  169. },
  170. {
  171. image:'https://www.chaomangdao.com/image/home/dijia@2x.png',
  172. name:'低价专区',
  173. title:'低价试试手气',
  174. url:'/pages/index/hot?type=1'
  175. }
  176. ],
  177. bannerList:[],//轮播图
  178. logo:'',//logo
  179. shopList:[],//获取推荐列表
  180. newBoxList:[],//最新开箱
  181. pages:0,
  182. page:1,//
  183. };
  184. },
  185. methods:{
  186. //去客服
  187. goServe () {
  188. uni.navigateTo({url:'/pagesB/pages/server'})
  189. },
  190. //去推荐,盲盒
  191. goRecommend () {
  192. uni.navigateTo({url:'/pages/index/recommend'})
  193. },
  194. //最新开箱
  195. goNewBox () {
  196. uni.navigateTo({url:'/pages/index/newBox'})
  197. },
  198. //轮播图
  199. changeBanner (item) {
  200. if (item.type == "word") {
  201. uni.setStorageSync('bannerMessage',JSON.stringify(item.value))
  202. uni.navigateTo({url:'/pagesA/pages/bannerMessage'})
  203. } else if (item.type == 'link') {
  204. location.href = item.value
  205. } else if (item.type == 'box'){
  206. uni.navigateTo({url:'/pages/index/details?id=' + item.value + '&type=0'})
  207. }
  208. },
  209. //去搜索
  210. goSearch () {
  211. uni.navigateTo({url:'/pages/index/search'})
  212. },
  213. //去详情
  214. goMessage (item,type) {
  215. uni.navigateTo({url:'/pages/index/details?id=' + item.box_id + '&type=' + type})
  216. },
  217. //热门专区
  218. changeHot (item) {
  219. uni.navigateTo({url:item.url})
  220. },
  221. //头部四个
  222. changeNav (item) {
  223. uni.navigateTo({url:item.url})
  224. },
  225. //获取轮播图
  226. getbannerList () {
  227. },
  228. //最新开箱
  229. getNewbox () {
  230. this.$api.newestOpen().then(res=>{
  231. if (res.code === 1) {
  232. this.newBoxList = res.data
  233. }
  234. })
  235. },
  236. //获取推荐列表
  237. getShopList () {
  238. this.$api.recommend().then(res=>{
  239. if (res.code === 1) {
  240. res.data.data.forEach(item=>{
  241. item.image = item.goods_images[0]
  242. item.right = []
  243. item.bot = []
  244. item.goods_images.forEach((em,index)=>{
  245. if (index > 0 && index < 3) {
  246. item.right.push(em)
  247. }
  248. if (index > 2) {
  249. item.bot.push(em)
  250. }
  251. })
  252. })
  253. this.shopList = this.page == 1 ? res.data.data : [...this.shopList,...res.data.data],
  254. this.pages = res.data.last_page
  255. }
  256. })
  257. },
  258. //获取首页信息
  259. getBaseInfo () {
  260. this.$api.baseInfo().then(res=>{
  261. if (res.code === 1) {
  262. this.logo = res.data.logo
  263. this.bannerList = res.data.banner
  264. }
  265. })
  266. }
  267. },
  268. onLoad({sharecode,token}) {
  269. if (sharecode) {
  270. uni.setStorageSync('sharecode',sharecode)
  271. }
  272. if (token) {
  273. uni.setStorageSync('token',token)
  274. }
  275. this.getBaseInfo()
  276. this.getbannerList()
  277. this.getNewbox()
  278. this.getShopList()
  279. },
  280. onReachBottom () {
  281. if (this.page < this.pages) {
  282. this.page++
  283. this.getShopList()
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss">
  289. .home_bar {
  290. width: 100%;
  291. position: sticky;
  292. top: 0;
  293. left: 0;
  294. padding: 0 30rpx;
  295. z-index: 2021;
  296. background: #FFFFFF;
  297. .home_bar_nav {width: 100%;}
  298. .home_bar_con {
  299. height: 88rpx;
  300. }
  301. .home_bar_logo {
  302. width: 66rpx;
  303. height: 66rpx;
  304. }
  305. .home_bar_search {
  306. width: 520rpx;
  307. height: 58rpx;
  308. padding: 0 20rpx;
  309. background: #F7F7F7;
  310. border-radius: 29rpx;
  311. image {
  312. width: 44rpx;
  313. height: 44rpx;
  314. }
  315. input {
  316. flex: 1;
  317. font-size: 26rpx;
  318. margin-left: 15rpx;
  319. }
  320. }
  321. .home_bar_serve {
  322. width: 44rpx;
  323. height: 44rpx;
  324. }
  325. }
  326. .home_swiper {
  327. padding: 0 30rpx;
  328. background: #FFFFFF;
  329. .swiper {
  330. height: 266rpx;
  331. image {
  332. border-radius: 20rpx;
  333. }
  334. }
  335. .home_swiper_li {
  336. height: 64rpx;
  337. image {
  338. width: 34rpx;
  339. height: 34rpx;
  340. margin-right: 10rpx;
  341. }
  342. text {
  343. color: #666666;
  344. }
  345. }
  346. .home_swiper_nav_li {
  347. height: 150rpx;
  348. flex-direction: column;
  349. image {
  350. width: 70rpx;
  351. height: 70rpx;
  352. margin-bottom: 10rpx;
  353. }
  354. text {
  355. color: #000000;
  356. font-size: 26rpx;
  357. }
  358. }
  359. }
  360. .home_trial {
  361. height: 88rpx;
  362. margin: 10rpx 0;
  363. padding: 0 30rpx;
  364. background: #FFFFFF;
  365. .home_trial_img {
  366. text {
  367. font-size: 28rpx;
  368. }
  369. image {
  370. width: 38rpx;
  371. height: 38rpx;
  372. margin-left: 10rpx;
  373. }
  374. }
  375. .home_trial_go {
  376. width: 50rpx;
  377. height: 50rpx;
  378. }
  379. }
  380. .home_newest {
  381. margin-bottom: 10rpx;
  382. background: #FFFFFF;
  383. .home_newest_head {
  384. padding: 30rpx 28rpx;
  385. .home_newest_head_new {
  386. font-size: 28rpx;
  387. font-weight: bold;
  388. }
  389. .home_newest_head_go {
  390. text {
  391. color: #999999;
  392. }
  393. image {
  394. width: 22rpx;
  395. height: 22rpx;
  396. margin-left: 10rpx;
  397. }
  398. }
  399. }
  400. .scroll-view {
  401. white-space:nowrap;
  402. box-sizing: border-box;
  403. padding-left: 28rpx;
  404. .scroll-view_li {
  405. margin-right: 20rpx;
  406. display: inline-block;
  407. .scroll-view_li_img {
  408. image{
  409. width: 150rpx;
  410. height: 150rpx;
  411. border-radius: 10rpx;
  412. }
  413. margin-bottom: 20rpx;
  414. }
  415. .scroll-view_li_price {
  416. text {
  417. color: #CF271B;
  418. &:last-child {
  419. font-size: 30rpx;
  420. }
  421. }
  422. }
  423. }
  424. }
  425. .home_newest_ul {
  426. padding: 36rpx 28rpx 24rpx 28rpx;
  427. .home_newest_li {
  428. width: 332rpx;
  429. height: 130rpx;
  430. padding-left: 30rpx;
  431. background: #F8FAFB;
  432. border-radius: 6rpx;
  433. .home_newest_img {
  434. width: 70rpx;
  435. height: 70rpx;
  436. margin-right: 24rpx;
  437. }
  438. .home_newest_name {
  439. font-size: 30rpx;
  440. font-weight: bold;
  441. }
  442. .home_newest_title {
  443. color: #999999;
  444. margin-top: 10rpx;
  445. }
  446. }
  447. }
  448. }
  449. .home_recommend_ul {
  450. flex-wrap: wrap;
  451. padding: 0 28rpx;
  452. .home_recommend_li {
  453. width: 332rpx;
  454. padding: 20rpx;
  455. margin-bottom: 30rpx;
  456. background: #FFFFFF;
  457. box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(153, 153, 153, 0.1);
  458. border-radius: 10rpx;
  459. .home_recommend_li_img {
  460. height: 295rpx;
  461. .home_recommend_li_img_top {
  462. align-items: flex-start;
  463. }
  464. .home_recommend_li_img_bot {
  465. display: flex;
  466. margin-top: 20rpx;
  467. justify-content: flex-end;
  468. image {
  469. width: 85rpx;
  470. height: 85rpx;
  471. margin-left: 20rpx;
  472. &:first-child {
  473. margin-left: 0;
  474. }
  475. border-radius: 6rpx;
  476. }
  477. }
  478. .home_recommend_li_img_box {
  479. image {
  480. width: 190rpx;
  481. height: 190rpx;
  482. border-radius: 6rpx;
  483. }
  484. }
  485. .home_recommend_li_img_right {
  486. image {
  487. width: 85rpx;
  488. height: 85rpx;
  489. border-radius: 6rpx;
  490. &:first-child {
  491. margin-bottom: 20rpx;
  492. }
  493. }
  494. }
  495. }
  496. .home_recommend_li_price {
  497. // width: 280rpx;
  498. height: 40rpx;
  499. color: #FFFFFF;
  500. margin: 20rpx 0;
  501. font-size: 26rpx;
  502. line-height: 40rpx;
  503. padding-left: 18rpx;
  504. background: #F6AF32;
  505. border-radius: 20rpx;
  506. }
  507. .home_recommend_li_name {
  508. font-size: 28rpx;
  509. display: -webkit-box;
  510. -webkit-box-orient: vertical;
  511. -webkit-line-clamp: 2;
  512. overflow: hidden;
  513. height: 76rpx;
  514. }
  515. .home_recommend_li_glod {
  516. margin-top: 30rpx;
  517. text {
  518. color: #CF271B;
  519. font-size: 26tpx;
  520. &:last-child {
  521. color: #666666;
  522. font-size: 24rpx;
  523. }
  524. }
  525. }
  526. }
  527. }
  528. </style>