index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <view class="vheigh"></view>
  5. <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
  6. <view class="top-main flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/img/search.png" mode=""></image>
  9. <view class="search-font">输入关键词搜索</view>
  10. </view>
  11. </view>
  12. </view>
  13. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  14. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item" @click="bannerNavToUrl(item)"><image :src="item.pic" /></swiper-item>
  15. </swiper>
  16. <view class="tongz flex">
  17. <view>
  18. <view class="tongz-bg"><image src="../../static/img/tongz-bg.png" mode=""></image></view>
  19. <view class="tongz-left flex">
  20. <image class="image-left" src="../../static/img/ling.png" mode=""></image>
  21. <u-notice-bar
  22. style="width: 100%;"
  23. mode="vertical"
  24. type="none"
  25. :volume-icon="false"
  26. :more-icon="true"
  27. :list="text"
  28. @click="goDetails"
  29. @getMore="nav('/pages/index/message?type=1')"
  30. ></u-notice-bar>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="navbar flex">
  35. <view class="navbar-item" v-for="(item, index) in navbarList[0].children" @click="nav('/pages/product/list?tid=' + item.id)">
  36. <image class="nitem-image" :src="item.pic" mode=""></image>
  37. <view class="nitem-font">{{ item.cate_name }}</view>
  38. </view>
  39. </view>
  40. <view class="shingle" v-if="list">
  41. <view class="shingle-top flex">
  42. <view class="shingle-title">CBB潮贝抢货通道</view>
  43. <view class="shingle-btn" @click="nav('/pages/hall/hall')">
  44. 更多CBB代理团队
  45. <text>></text>
  46. </view>
  47. </view>
  48. <view class="shingle-main" @click="navTo(list)">
  49. <view class="shingle-bg"><image :src="list.image" mode=""></image></view>
  50. <view class="shinglem-title flex">
  51. <image class="tbg" src="../../static/img/tbg-left.png" mode=""></image>
  52. <view class="shinglemt-center">
  53. <image class="address" src="../../static/img/address.png" mode=""></image>
  54. <view class="shingle-font">{{ list.name || 'null' }}</view>
  55. </view>
  56. <image class="tbg" src="../../static/img/tbg-right.png" mode=""></image>
  57. </view>
  58. <view class="shingle-mmain flex">
  59. <view class="smmain-item">
  60. <view class="smitem-top">开放中</view>
  61. <view class="smitem-bottom">状态</view>
  62. </view>
  63. <view class="shu"></view>
  64. <view class="smmain-item">
  65. <view class="smitem-top clamp">{{ list.nickname }}</view>
  66. <view class="smitem-bottom">CBB潮倍贝</view>
  67. </view>
  68. <view class="shu"></view>
  69. <view class="smmain-item">
  70. <view class="people flex">
  71. <view class="peopleitem" v-for="item in 1"><image src="../../static/img/busy.png" mode=""></image></view>
  72. <view class="peopleitem" v-for="item in 4"><image src="../../static/img/leisure.png" mode=""></image></view>
  73. </view>
  74. <view class="smitem-bottom">流畅</view>
  75. </view>
  76. </view>
  77. <image class="right-bottom" src="../../static/img/right-bottom.png" mode=""></image>
  78. </view>
  79. </view>
  80. <!-- 秒杀楼层 -->
  81. <!-- <seckill></seckill> -->
  82. <view class="ge" v-if="stop.length != 0"></view>
  83. <!-- <view class="serve" v-if="stop.length != 0">
  84. <view class="seckill-title flex">
  85. <view class="seckill-left flex">
  86. <image class="seckill-inco" src="../../static/img/serve.png" mode=""></image>
  87. <view class="seckill-font">服务专区推荐</view>
  88. </view>
  89. <view class="seckill-right" @click="nav('/pages/store/store')">
  90. <view class="seckill-rfont">更多</view>
  91. <image class="seckill-back" src="../../static/img/back.png" mode=""></image>
  92. </view>
  93. </view>
  94. <view class="serve-main flex">
  95. <view class="serve-item" @click="nav('/pages/store/storeInfo?id=' + item.id)" v-for="(item, index) in stop" :key="index">
  96. <image class="serve-price" :src="item.image" mode=""></image>
  97. <view class="clamp serve-title">{{ item.name }}</view>
  98. <view class="serve-address flex" v-if="item.jl">
  99. <image class="saddress-inco" src="../../static/img/address.png" mode=""></image>
  100. <view class="saddress-font">距离{{ item.jl }}KM</view>
  101. </view>
  102. </view>
  103. </view>
  104. </view> -->
  105. <view class="product" v-for="(item, index) in navbarList[0].children">
  106. <view class="seckill-title flex">
  107. <view class="seckill-left flex">
  108. <view class="seckill-font">{{ item.cate_name }}</view>
  109. </view>
  110. <view class="seckill-right" @click="nav('/pages/product/list?tid=' + item.id)">
  111. <view class="seckill-rfont">更多</view>
  112. <image class="seckill-back" src="../../static/img/back.png" mode=""></image>
  113. </view>
  114. </view>
  115. <view class="priduct-main">
  116. <view class="priduct-item" v-for="itm in item.product" :key="itm.id" @click="navToDetailPage(itm)">
  117. <view class="priduct-main-image"><image :src="itm.image" mode="scaleToFill"></image></view>
  118. <view class="priduct-main-name clamp margin-c-20">{{ itm.store_name }}</view>
  119. <view class="priduct-main-price">
  120. <view class="price" v-if="item.integral != 0">¥{{ itm.price * 1 }} + {{ itm.integral }}趣豆</view>
  121. <view class="price" v-else>¥{{ itm.price }}</view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. <u-tabbar activeColor="#f42b4e" v-model="current" :list="tabbar"></u-tabbar>
  127. </view>
  128. </template>
  129. <script>
  130. import { tabbar1 } from '@/utils/tabbar.js';
  131. import seckill from '../../components/seckill/seckill.vue';
  132. import { article } from '@/api/user.js';
  133. import { getCategoryList, getProducts } from '@/api/product.js';
  134. import { loadIndexs, store_list } from '@/api/index.js';
  135. import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
  136. // #ifdef H5
  137. // import { openMap } from '@/utils/rocessor.js';
  138. // #endif
  139. import { auction_gu } from '@/api/hall.js';
  140. export default {
  141. components: {
  142. seckill,
  143. uniCountdowns
  144. },
  145. data() {
  146. return {
  147. current: 0,
  148. tabbar: tabbar1,
  149. titleNViewBackground: '',
  150. swiperCurrent: 0,
  151. swiperLength: 0,
  152. longitude: '', //经度
  153. latitude: '', //纬度
  154. dataList: '',
  155. carouselList: [], //轮播图列表
  156. text: [],
  157. article: [],
  158. list: {},
  159. stop: [],
  160. navbarList: [{ child: [] }]
  161. };
  162. },
  163. onPullDownRefresh() {
  164. console.log('111');
  165. this.loadData();
  166. this.getaddress();
  167. setTimeout(function() {
  168. uni.stopPullDownRefresh();
  169. }, 1000);
  170. },
  171. onShow() {
  172. this.loadData();
  173. this.getnavbar();
  174. this.getaddress();
  175. },
  176. methods: {
  177. getnavbar() {
  178. let obj = this;
  179. getCategoryList({})
  180. .then(({ data }) => {
  181. data[0].children.forEach(e => {
  182. getProducts({ page: 1, limit: 2, sid: e.id }).then(info => {
  183. obj.$set(e, 'product', info.data);
  184. });
  185. });
  186. this.navbarList = data;
  187. console.log(data, '123456');
  188. })
  189. .catch(err => {
  190. console.log(err);
  191. });
  192. },
  193. loadData() {
  194. article({}, 1).then(({ data }) => {
  195. data.forEach(e => {
  196. this.text.push(e.synopsis);
  197. });
  198. this.article = data;
  199. });
  200. auction_gu({ pages: 1, limit: 1 })
  201. .then(({ data }) => {
  202. this.list = data[0];
  203. })
  204. .catch(e => {
  205. console.log(e);
  206. });
  207. loadIndexs({})
  208. .then(({ data }) => {
  209. let goods = data.info;
  210. this.dataList = goods.bastList; //精品推荐
  211. this.carouselList = data.banner;
  212. })
  213. .catch(e => {});
  214. },
  215. //根据经纬度计算距离
  216. getFlatternDistance(lat1, lng1, lat2, lng2) {
  217. let radLat1 = (lat1 * Math.PI) / 180.0;
  218. let radLat2 = (lat2 * Math.PI) / 180.0;
  219. let a = radLat1 - radLat2;
  220. let b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  221. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  222. s = s * 6378.137;
  223. s = Math.round(s * 10000) / 10000;
  224. return s;
  225. },
  226. getaddress() {
  227. let obj = this;
  228. uni.getLocation({
  229. type: 'gcj02',
  230. success: res => {
  231. console.log('dizhi+++++++++++');
  232. this.longitude = res.longitude; //经度
  233. this.latitude = res.latitude; //纬度
  234. store_list({
  235. page: 1,
  236. limit: 3,
  237. latitude: res.latitude,
  238. longitude: res.longitude
  239. }).then(e => {
  240. if (e.data.length != 0) {
  241. e.data.list.forEach(e => {
  242. e.jl = this.getFlatternDistance(this.latitude, this.longitude, e.latitude, e.longitude);
  243. });
  244. }
  245. obj.stop = e.data.list;
  246. console.log(e);
  247. });
  248. },
  249. fail: err => {
  250. // #ifdef H5
  251. openMap().then(e => {
  252. this.getaddress();
  253. });
  254. // #endif
  255. }
  256. });
  257. },
  258. goDetails(e) {
  259. uni.navigateTo({
  260. url: '/pages/index/messageInfo?id=' + this.article[e].id
  261. });
  262. },
  263. nav(url) {
  264. uni.navigateTo({
  265. url,
  266. fail() {
  267. uni.switchTab({
  268. url
  269. });
  270. }
  271. });
  272. },
  273. //轮播图切换修改背景色
  274. swiperChange(e) {
  275. const index = e.detail.current;
  276. this.swiperCurrent = index;
  277. this.titleNViewBackground = this.carouselList[index].background;
  278. },
  279. // 點擊搜索框
  280. clickSearch() {
  281. uni.navigateTo({
  282. url: '/pages/product/search'
  283. });
  284. },
  285. navTo(item) {
  286. uni.navigateTo({
  287. url: '/pages/hall/halllist?id=' + item.id + '&name=' + item.name + '&peoplename=' + item.nickname
  288. });
  289. },
  290. //详情页
  291. navToDetailPage(item) {
  292. let id = item.id;
  293. uni.navigateTo({
  294. url: '/pages/product/product?id=' + id
  295. });
  296. }
  297. }
  298. };
  299. </script>
  300. <style lang="scss">
  301. page,
  302. .center {
  303. min-height: 100%;
  304. height: auto;
  305. background: #ffffff;
  306. }
  307. .vheigh {
  308. height: var(--status-bar-height);
  309. background-color: $base-color;
  310. }
  311. .top {
  312. position: relative;
  313. width: 100%;
  314. height: 360rpx;
  315. .top-bg {
  316. position: absolute;
  317. top: 0;
  318. left: 0;
  319. right: 0;
  320. width: 100%;
  321. height: 100%;
  322. }
  323. .top-main {
  324. position: relative;
  325. z-index: 2;
  326. padding: 30rpx;
  327. .search-box {
  328. justify-content: center;
  329. width: 698rpx;
  330. height: 60rpx;
  331. background: rgba(255, 240, 245, 0.4);
  332. box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  333. border-radius: 30rpx;
  334. .search {
  335. width: 34rpx;
  336. height: 34rpx;
  337. }
  338. .search-font {
  339. margin-left: 14rpx;
  340. font-size: 28rpx;
  341. font-family: PingFang SC;
  342. font-weight: 500;
  343. color: #ffffff;
  344. }
  345. }
  346. }
  347. }
  348. .carousel {
  349. width: 700rpx;
  350. height: 276rpx;
  351. /* #ifndef APP-PLUS */
  352. margin: -240rpx auto 0;
  353. /* #endif */
  354. /* #ifdef APP-PLUS */
  355. margin: -180rpx auto 0;
  356. /* #endif */
  357. border-radius: 40rpx;
  358. image {
  359. border-radius: 40rpx;
  360. width: 700rpx;
  361. height: 276rpx;
  362. }
  363. }
  364. .tongz {
  365. width: 690rpx;
  366. height: 70rpx;
  367. margin: 32rpx auto 0;
  368. padding: 18rpx 30rpx 18rpx 24rpx;
  369. align-items: center;
  370. position: relative;
  371. .tongz-bg {
  372. position: absolute;
  373. top: 0;
  374. right: 0;
  375. left: 0;
  376. width: 690rpx;
  377. height: 70rpx;
  378. image {
  379. width: 100%;
  380. height: 100%;
  381. }
  382. }
  383. .tongz-left {
  384. width: 640rpx;
  385. .image-left {
  386. width: 28rpx;
  387. height: 34rpx;
  388. }
  389. .tongz-font {
  390. margin-left: 22rpx;
  391. font-size: 28rpx;
  392. font-family: Source Han Sans CN;
  393. font-weight: 400;
  394. color: #0f253a;
  395. }
  396. }
  397. .tongz-right {
  398. position: relative;
  399. z-index: 11;
  400. width: 12rpx;
  401. height: 26rpx;
  402. image {
  403. width: 100%;
  404. height: 100%;
  405. }
  406. }
  407. }
  408. .navbar {
  409. justify-content: flex-start;
  410. flex-wrap: wrap;
  411. .navbar-item {
  412. margin-top: 42rpx;
  413. width: 25%;
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. .nitem-image {
  418. width: 90rpx;
  419. height: 90rpx;
  420. }
  421. .nitem-font {
  422. margin-top: 10rpx;
  423. font-size: 24rpx;
  424. font-family: PingFang SC;
  425. font-weight: 500;
  426. color: #0c1732;
  427. }
  428. }
  429. }
  430. .shingle {
  431. width: 750rpx;
  432. background: #f8f8f8;
  433. border-radius: 10rpx;
  434. margin: 60rpx auto 0rpx;
  435. padding: 44rpx 50rpx 40rpx;
  436. .shingle-top {
  437. padding-left: 2rpx;
  438. .shingle-title {
  439. font-size: 36rpx;
  440. font-family: PingFang SC;
  441. font-weight: bold;
  442. color: #dc262b;
  443. }
  444. .shingle-btn {
  445. width: 250rpx;
  446. height: 50rpx;
  447. border: 2rpx solid #dc262b;
  448. border-radius: 10rpx;
  449. padding: 0 16rpx;
  450. text-align: left;
  451. font-size: 24rpx;
  452. font-family: PingFang SC;
  453. font-weight: 500;
  454. color: #dc262b;
  455. line-height: 50rpx;
  456. text {
  457. display: inline-block;
  458. padding-left: 6rpx;
  459. }
  460. }
  461. }
  462. .shingle-main {
  463. margin: 20rpx auto;
  464. width: 650rpx;
  465. height: 206rpx;
  466. position: relative;
  467. .shingle-bg {
  468. position: absolute;
  469. top: 0;
  470. left: 0;
  471. right: 0;
  472. width: 650rpx;
  473. height: 206rpx;
  474. image {
  475. width: 650rpx;
  476. height: 206rpx;
  477. }
  478. }
  479. .shinglem-title {
  480. position: relative;
  481. z-index: 2;
  482. justify-content: center;
  483. height: 70rpx;
  484. .tbg {
  485. height: 70rpx;
  486. width: 40rpx;
  487. }
  488. .shinglemt-center {
  489. display: flex;
  490. align-items: center;
  491. background: rgba(220, 38, 43, 0.66);
  492. }
  493. .address {
  494. width: 28rpx;
  495. height: 30rpx;
  496. }
  497. .shingle-font {
  498. font-size: 36rpx;
  499. font-family: PingFang SC;
  500. font-weight: bold;
  501. color: #ffffff;
  502. line-height: 70rpx;
  503. margin-left: 14rpx;
  504. }
  505. }
  506. .shingle-mmain {
  507. position: relative;
  508. z-index: 2;
  509. margin-top: 30rpx;
  510. .smmain-item {
  511. width: 33%;
  512. display: flex;
  513. flex-direction: column;
  514. align-items: center;
  515. .smitem-top {
  516. text-align: center;
  517. width: 90%;
  518. font-size: 30rpx;
  519. font-family: PingFang SC;
  520. font-weight: bold;
  521. color: #ffffff;
  522. }
  523. .smitem-bottom {
  524. margin-top: 10rpx;
  525. font-size: 30rpx;
  526. font-family: PingFang SC;
  527. font-weight: bold;
  528. color: #ffffff;
  529. }
  530. .people {
  531. justify-content: center;
  532. .peopleitem {
  533. width: 24rpx;
  534. height: 34rpx;
  535. image {
  536. width: 100%;
  537. height: 100%;
  538. }
  539. }
  540. }
  541. }
  542. .shu {
  543. width: 2rpx;
  544. height: 70rpx;
  545. background: #ffffff;
  546. }
  547. }
  548. .right-bottom {
  549. position: absolute;
  550. z-index: 2;
  551. right: 0;
  552. bottom: 0;
  553. width: 94rpx;
  554. height: 92rpx;
  555. }
  556. }
  557. }
  558. .seckill-title {
  559. padding: 32rpx 30rpx 0;
  560. }
  561. .seckill-left {
  562. justify-content: flex-start;
  563. .seckill-inco {
  564. width: 36rpx;
  565. height: 36rpx;
  566. flex-shrink: 0;
  567. }
  568. .seckill-font {
  569. margin-left: 8rpx;
  570. font-size: 40rpx;
  571. font-family: PingFang SC;
  572. font-weight: bold;
  573. color: #333333;
  574. }
  575. .djs {
  576. margin-left: 12rpx;
  577. font-size: 20rpx;
  578. font-family: PingFang SC;
  579. font-weight: bold;
  580. color: #dc262b;
  581. }
  582. }
  583. .seckill-right {
  584. display: flex;
  585. justify-content: flex-start;
  586. align-items: center;
  587. .seckill-rfont {
  588. font-size: 24rpx;
  589. font-family: PingFang SC;
  590. font-weight: 500;
  591. color: #999999;
  592. margin-right: 8rpx;
  593. }
  594. .seckill-back {
  595. width: 10rpx;
  596. height: 20rpx;
  597. }
  598. }
  599. .ge {
  600. height: 20rpx;
  601. width: 750rpx;
  602. background: #f8f8f8;
  603. }
  604. .serve {
  605. padding: 32rpx 30rpx;
  606. padding: 32rpx 30rpx;
  607. background: #ffffff;
  608. .serve-main {
  609. margin-top: 24rpx;
  610. flex-wrap: wrap;
  611. justify-content: flex-start;
  612. .serve-item:first-child {
  613. margin-left: 0rpx;
  614. }
  615. .serve-item {
  616. width: 220rpx;
  617. background: #f6f6f6;
  618. border-radius: 10rpx;
  619. margin-left: 14rpx;
  620. padding-bottom: 22rpx;
  621. .serve-price {
  622. width: 220rpx;
  623. height: 220rpx;
  624. border-radius: 10rpx 10rpx 0px 0px;
  625. background: #03a9f4;
  626. }
  627. .serve-title {
  628. margin-top: 16rpx;
  629. padding: 0 14rpx;
  630. font-size: 26rpx;
  631. font-family: PingFang SC;
  632. font-weight: 500;
  633. color: #0a122b;
  634. }
  635. .serve-address {
  636. justify-content: flex-start;
  637. margin-top: 10rpx;
  638. padding: 0 14rpx;
  639. .saddress-inco {
  640. width: 18rpx;
  641. height: 24rpx;
  642. }
  643. .saddress-font {
  644. margin-left: 4rpx;
  645. font-size: 20rpx;
  646. font-family: PingFang SC;
  647. font-weight: 500;
  648. color: #666666;
  649. }
  650. }
  651. }
  652. }
  653. }
  654. .product {
  655. background: #f0f0f0;
  656. }
  657. .priduct-main {
  658. margin-top: 38rpx;
  659. width: 100%;
  660. display: flex;
  661. flex-wrap: wrap;
  662. padding: 0 32rpx;
  663. .priduct-item {
  664. width: 48%;
  665. background-color: #ffffff;
  666. border-radius: 12rpx;
  667. margin-bottom: 24rpx;
  668. &:nth-child(2n + 1) {
  669. margin-right: 24rpx;
  670. }
  671. .priduct-main-image {
  672. width: 100%;
  673. height: 330rpx;
  674. // background: red;
  675. border-radius: 3px;
  676. overflow: hidden;
  677. image {
  678. width: 100%;
  679. height: 100%;
  680. opacity: 1;
  681. border-radius: 12rpx 12rpx 0 0;
  682. }
  683. }
  684. .priduct-main-name {
  685. font-size: $font-base;
  686. color: $font-color-dark;
  687. font-weight: bold;
  688. line-height: 80rpx;
  689. }
  690. .priduct-main-price {
  691. display: flex;
  692. justify-content: space-between;
  693. padding: 0 16rpx 12rpx;
  694. .price {
  695. font-size: 36rpx;
  696. font-weight: bold;
  697. color: #fd3b39;
  698. }
  699. .cart-icon {
  700. image {
  701. width: 44rpx;
  702. height: 44rpx;
  703. }
  704. }
  705. }
  706. }
  707. }
  708. </style>