index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <template>
  2. <view class="center">
  3. <view class="topcontent padding-b-30">
  4. <view class="top">
  5. <view class="vheigh"></view>
  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">
  14. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  15. @click="bannerNavToUrl(item)">
  16. <image :src="item.pic" />
  17. </swiper-item>
  18. </swiper>
  19. <view class="stre flex">
  20. <view class="ic-text flex">
  21. <image class="ic-tubiao" src="../../static/icon/shou-ic.png" mode=""></image>
  22. <view class="ic-wen">自用购物优惠</view>
  23. </view>
  24. <view class="ic-text flex">
  25. <image class="ic-tubiao" src="../../static/icon/shou-ic.png" mode=""></image>
  26. <view class="ic-wen">分享好友赚钱</view>
  27. </view>
  28. <view class="ic-text flex">
  29. <image class="ic-tubiao" src="../../static/icon/shou-ic.png" mode=""></image>
  30. <view class="ic-wen">超值正品优惠</view>
  31. </view>
  32. </view>
  33. <view class="zhishi flex">
  34. <navigator url="/pages/index/artDetail?id=5">
  35. <view class="zhishi-item">
  36. <image class="zhishi-ic" src="../../static/icon/shou-tro.png" mode=""></image>
  37. <view class="zhishi-te">行业介绍</view>
  38. </view>
  39. </navigator>
  40. <navigator url="/pages/index/artDetail?id=6">
  41. <view class="zhishi-item">
  42. <image class="zhishi-ic" src="../../static/icon/shou-we.png" mode=""></image>
  43. <view class="zhishi-te">关于我们</view>
  44. </view>
  45. </navigator>
  46. <view class="zhishi-item" @click="openKf">
  47. <image class="zhishi-ic" src="../../static/icon/shou-kefu.png" mode=""></image>
  48. <view class="zhishi-te">联系客服</view>
  49. </view>
  50. <navigator url="/pages/user/shareQrCode">
  51. <view class="zhishi-item">
  52. <image class="zhishi-ic" src="../../static/icon/firend.png" mode=""></image>
  53. <view class="zhishi-te">邀请好友</view>
  54. </view>
  55. </navigator>
  56. </view>
  57. <view class="tongz">
  58. <view class="tongz-left flex padding-l-30">
  59. <image class="image-left" src="../../static/icon/shou-gonggao.png" mode=""></image>
  60. <u-notice-bar class="notice" mode="vertical" type="none" :volume-icon="false" :more-icon="true"
  61. :list="text" @click="goDetails" @getMore="nav('/pages/index/message?type=1')"></u-notice-bar>
  62. </view>
  63. </view>
  64. <view class="product-list flex">
  65. <template v-for="(item,ind) in dataList">
  66. <view class="list-left" v-if="ind==0">
  67. <navigator :url="`/pages/index/artDetail?id=${item.id}`">
  68. <image class="imgleft" :src="item.image_input[0]" mode="scaleToFill"></image>
  69. </navigator>
  70. </view>
  71. </template>
  72. <view class="list-right flex" v-if="dataList.length>1">
  73. <view class="item" v-for="(item,ind) in dataList" v-if="ind>0">
  74. <navigator :url="`/pages/index/artDetail?id=${item.id}`">
  75. <image class="imgleft" :src="item.image_input[0]" mode="scaleToFill"></image>
  76. </navigator>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="bottom-box margin-t-30">
  82. <view class="bottom-title padding-b-30">
  83. <image class="image" src="../../static/img/image-title.png" mode="scaleToFill"></image>
  84. </view>
  85. <swiper previous-margin='150rpx' next-margin='150rpx' class="product-art-list" circular autoplay
  86. duration="400" interval="5000" @change='changeBottom'>
  87. <swiper-item v-for="(item, index) in article" :key="index" class="product-art-item">
  88. <navigator :url="`/pages/index/artDetail?id=${item.id}`">
  89. <view class="image-box">
  90. <image class="image" :src="item.image_input[0]" />
  91. </view>
  92. </navigator>
  93. </swiper-item>
  94. </swiper>
  95. <view class="product-detail">
  96. {{article[actionArtInd].synopsis}}
  97. </view>
  98. </view>
  99. <uni-popup ref="popupkf" type="center">
  100. <view class="popup-box">
  101. <view class="img">
  102. <image src="../../static/img/img009.png" mode=""></image>
  103. </view>
  104. <view class="mian">
  105. <view class="delivery">
  106. <view class="title">已经为您定制专属客服</view>
  107. <image src="../../static/img/img010.png" mode=""></image>
  108. </view>
  109. <view class="nocancel">客服VX:{{ kefu }}</view>
  110. <view class="comfirm-box">
  111. <view class="cancel" @click="cancel">取消</view>
  112. <view class="comfirm" @click="comfirm(kefu)">复制微信</view>
  113. </view>
  114. </view>
  115. </view>
  116. </uni-popup>
  117. <u-tabbar activeColor="#333333" inactive-color='#999999' v-model="current" :list="tabbar"></u-tabbar>
  118. </view>
  119. </template>
  120. <script>
  121. import {
  122. tabbar1
  123. } from '@/utils/tabbar.js';
  124. import seckill from '../../components/seckill/seckill.vue';
  125. import {
  126. article
  127. } from '@/api/user.js';
  128. import {
  129. getCategoryList,
  130. getProducts
  131. } from '@/api/product.js';
  132. import {
  133. loadIndexs,
  134. store_list
  135. } from '@/api/index.js';
  136. import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
  137. // #ifdef H5
  138. // import { openMap } from '@/utils/rocessor.js';
  139. // #endif
  140. import {
  141. auction_gu
  142. } from '@/api/hall.js';
  143. import {
  144. mapState,
  145. mapMutations
  146. } from 'vuex';
  147. export default {
  148. components: {
  149. seckill,
  150. uniCountdowns
  151. },
  152. data() {
  153. return {
  154. current: 0,
  155. tabbar: tabbar1,
  156. longitude: '', //经度
  157. latitude: '', //纬度
  158. carouselList: [], //轮播图列表
  159. text: [], //公告
  160. article: [], //精品展示
  161. dataList: [], //产品介绍
  162. kefu: '',
  163. actionArtInd: 0, //默认选中的精品展示对象
  164. };
  165. },
  166. onPullDownRefresh() {
  167. console.log('111');
  168. this.loadData();
  169. this.getaddress();
  170. setTimeout(function() {
  171. uni.stopPullDownRefresh();
  172. }, 1000);
  173. },
  174. onShow() {
  175. this.loadData();
  176. this.getaddress();
  177. },
  178. methods: {
  179. ...mapMutations(['setLat', 'setLon', 'setChoose']),
  180. // 底部轮播图切换
  181. changeBottom(res) {
  182. this.actionArtInd = res.detail.current;
  183. console.log(res);
  184. },
  185. // 打开客服
  186. openKf() {
  187. this.$refs.popupkf.open();
  188. },
  189. // 关闭客服
  190. cancel() {
  191. this.$refs.popupkf.close();
  192. },
  193. loadData() {
  194. article({}, 1).then(({
  195. data
  196. }) => {
  197. this.text = data.map((e) => {
  198. return e.synopsis
  199. })
  200. });
  201. // 精品展示
  202. article({}, 2).then(({
  203. data
  204. }) => {
  205. this.article = data.map((e) => {
  206. e.imageurl = e.image_input[0];
  207. return e
  208. })
  209. });
  210. // 产品介绍
  211. article({}, 3).then(({
  212. data
  213. }) => {
  214. this.dataList = data.map((e) => {
  215. return e
  216. })
  217. });
  218. loadIndexs({})
  219. .then(({
  220. data
  221. }) => {
  222. let goods = data.info;
  223. // this.dataList = goods.bastList; //精品推荐
  224. this.carouselList = data.banner;
  225. })
  226. .catch(e => {});
  227. },
  228. out_of_china(lng, lat) {
  229. return lng < 72.004 || lng > 137.8347 || (lat < 0.8293 || lat > 55.8271 || false);
  230. },
  231. transformlat(lng, lat) {
  232. const x_PI = (3.14159265358979324 * 3000.0) / 180.0;
  233. const PI = 3.1415926535897932384626;
  234. const a = 6378245.0;
  235. const ee = 0.00669342162296594323;
  236. let ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(
  237. lng));
  238. ret += ((20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0) / 3.0;
  239. ret += ((20.0 * Math.sin(lat * PI) + 40.0 * Math.sin((lat / 3.0) * PI)) * 2.0) / 3.0;
  240. ret += ((160.0 * Math.sin((lat / 12.0) * PI) + 320 * Math.sin((lat * PI) / 30.0)) * 2.0) / 3.0;
  241. return ret;
  242. },
  243. transformlng(lng, lat) {
  244. const x_PI = (3.14159265358979324 * 3000.0) / 180.0;
  245. const PI = 3.1415926535897932384626;
  246. const a = 6378245.0;
  247. const ee = 0.00669342162296594323;
  248. let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
  249. ret += ((20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0) / 3.0;
  250. ret += ((20.0 * Math.sin(lng * PI) + 40.0 * Math.sin((lng / 3.0) * PI)) * 2.0) / 3.0;
  251. ret += ((150.0 * Math.sin((lng / 12.0) * PI) + 300.0 * Math.sin((lng / 30.0) * PI)) * 2.0) / 3.0;
  252. return ret;
  253. },
  254. wgs84Togcj02(lng, lat) {
  255. if (this.out_of_china(lng, lat)) {
  256. return [lng, lat];
  257. }
  258. //定义一些常量
  259. //GCJ02 转换为 WGS84
  260. var that = this;
  261. const x_PI = (3.14159265358979324 * 3000.0) / 180.0;
  262. const PI = 3.1415926535897932384626;
  263. const a = 6378245.0;
  264. const ee = 0.00669342162296594323;
  265. let dlat = that.transformlat(lng - 105.0, lat - 35.0);
  266. let dlng = that.transformlng(lng - 105.0, lat - 35.0);
  267. let radlat = (lat / 180.0) * PI;
  268. let magic = Math.sin(radlat);
  269. magic = 1 - ee * magic * magic;
  270. let sqrtmagic = Math.sqrt(magic);
  271. dlat = (dlat * 180.0) / (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
  272. dlng = (dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
  273. var mglat = lat + dlat;
  274. var mglng = lng + dlng;
  275. return [mglng, mglat];
  276. },
  277. toBack() {
  278. uni.navigateTo({
  279. url: '/pages/navigation/index'
  280. })
  281. },
  282. getaddress() {
  283. console.log('dizhi+++++++++++');
  284. let obj = this;
  285. uni.getLocation({
  286. type: 'wgs84',
  287. success: res => {
  288. let wz = obj.wgs84Togcj02(res.longitude, res.latitude);
  289. obj.setLat(wz[1]);
  290. obj.setLon(wz[0]);
  291. console.log(wz, '经纬度');
  292. },
  293. fail: err => {
  294. console.log(err, '经纬度');
  295. openMap().then(e => {
  296. this.getaddress();
  297. });
  298. }
  299. });
  300. },
  301. goDetails(e) {
  302. uni.navigateTo({
  303. url: '/pages/index/messageInfo?id=' + this.article[e].id
  304. });
  305. },
  306. nav(url) {
  307. console.log(url, '123456');
  308. uni.navigateTo({
  309. url,
  310. fail() {
  311. uni.switchTab({
  312. url
  313. });
  314. }
  315. });
  316. },
  317. // 點擊搜索框
  318. clickSearch() {
  319. uni.navigateTo({
  320. url: '/pages/product/search'
  321. });
  322. },
  323. navTo(item) {
  324. uni.navigateTo({
  325. url: '/pages/hall/halllist?id=' + item.id + '&name=' + item.name + '&peoplename=' + item
  326. .nickname
  327. });
  328. },
  329. //详情页
  330. navToDetailPage(item) {
  331. let id = item.id;
  332. uni.navigateTo({
  333. url: '/pages/product/product?id=' + id
  334. });
  335. }
  336. }
  337. };
  338. </script>
  339. <style lang="scss">
  340. .center {
  341. padding-bottom: 30rpx;
  342. }
  343. .topcontent {
  344. background-color: #FFFFFF;
  345. }
  346. .vheigh {
  347. height: var(--status-bar-height);
  348. background-color: $base-color;
  349. }
  350. .top {
  351. position: relative;
  352. width: 100%;
  353. height: 360rpx;
  354. .top-bg {
  355. position: absolute;
  356. top: 0;
  357. left: 0;
  358. right: 0;
  359. width: 100%;
  360. height: 100%;
  361. }
  362. .top-main {
  363. position: relative;
  364. z-index: 2;
  365. padding: 30rpx;
  366. .search-box {
  367. justify-content: center;
  368. width: 698rpx;
  369. height: 60rpx;
  370. background: rgba(255, 240, 245, 0.4);
  371. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  372. border-radius: 30rpx;
  373. background-color: #EEEEEE;
  374. .search {
  375. width: 34rpx;
  376. height: 34rpx;
  377. }
  378. .search-font {
  379. margin-left: 14rpx;
  380. font-size: 28rpx;
  381. font-family: PingFang SC;
  382. font-weight: 500;
  383. color: #CBCBCB;
  384. }
  385. }
  386. }
  387. }
  388. .carousel {
  389. width: 700rpx;
  390. height: 276rpx;
  391. /* #ifndef APP-PLUS */
  392. margin: -230rpx auto 0;
  393. // margin: -160rpx auto 0;
  394. /* #endif */
  395. /* #ifdef APP-PLUS */
  396. margin: -100rpx auto 0;
  397. /* #endif */
  398. border-radius: 40rpx;
  399. image {
  400. border-radius: 40rpx;
  401. width: 700rpx;
  402. height: 276rpx;
  403. }
  404. }
  405. .ic-text {
  406. margin: 0 60rpx 0 40rpx;
  407. .ic-tubiao {
  408. width: 27rpx;
  409. height: 27rpx;
  410. margin-top: 16rpx;
  411. margin-right: 10rpx;
  412. }
  413. .ic-wen {
  414. width: 121rpx;
  415. height: 20rpx;
  416. font-size: 21rpx;
  417. color: #333333;
  418. margin-top: 5rpx;
  419. }
  420. }
  421. .zhishi {
  422. padding: 30rpx;
  423. .zhishi-item {
  424. .zhishi-ic {
  425. width: 90rpx;
  426. height: 90rpx;
  427. }
  428. .zhishi-te {
  429. font-size: 24rpx;
  430. color: #666666;
  431. }
  432. }
  433. }
  434. .tongz {
  435. height: 70rpx;
  436. margin: 0 30rpx 30rpx 30rpx;
  437. border-radius: 20rpx;
  438. overflow: hidden;
  439. align-items: center;
  440. position: relative;
  441. background-color: #F8F8FA;
  442. .tongz-left {
  443. .notice {
  444. flex-grow: 1;
  445. }
  446. .image-left {
  447. width: 28rpx;
  448. height: 28rpx;
  449. }
  450. .tongz-font {
  451. margin-left: 22rpx;
  452. font-size: 28rpx;
  453. font-family: Source Han Sans CN;
  454. font-weight: 400;
  455. color: #0f253a;
  456. }
  457. }
  458. .tongz-right {
  459. position: relative;
  460. z-index: 11;
  461. width: 12rpx;
  462. height: 26rpx;
  463. image {
  464. width: 100%;
  465. height: 100%;
  466. }
  467. }
  468. }
  469. .popup-box {
  470. width: 522rpx;
  471. height: 605rpx;
  472. background-color: #ffffff;
  473. border-radius: 20rpx;
  474. position: relative;
  475. .img {
  476. position: relative;
  477. top: -56rpx;
  478. left: 0;
  479. width: 522rpx;
  480. height: 132rpx;
  481. display: flex;
  482. justify-content: center;
  483. image {
  484. border-radius: 20rpx 20rpx 0 0;
  485. width: 450rpx;
  486. height: 132rpx;
  487. }
  488. }
  489. .mian {
  490. margin-top: -44rpx;
  491. display: flex;
  492. flex-direction: column;
  493. align-items: center;
  494. // padding: 32rpx 32rpx;
  495. background-color: #ffffff;
  496. border-radius: 0 0 20rpx 20rpx;
  497. text-align: center;
  498. .delivery {
  499. font-size: 40rpx;
  500. color: #333333;
  501. display: flex;
  502. align-items: center;
  503. flex-direction: column;
  504. .title {}
  505. image {
  506. margin-top: 48rpx;
  507. width: 172rpx;
  508. height: 160rpx;
  509. }
  510. }
  511. .nocancel {
  512. font-size: 32rpx;
  513. color: #333333;
  514. margin-top: 14rpx;
  515. }
  516. .comfirm-box {
  517. margin-top: 52rpx;
  518. display: flex;
  519. // margin-bottom: 32rpx;
  520. // justify-content: space-around;
  521. .cancel {
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. width: 197rpx;
  526. height: 74rpx;
  527. border: 1px solid #dcc786;
  528. border-radius: 38rpx;
  529. font-size: 32rpx;
  530. color: #605128;
  531. }
  532. .comfirm {
  533. margin-left: 32rpx;
  534. display: flex;
  535. align-items: center;
  536. justify-content: center;
  537. width: 197rpx;
  538. height: 74rpx;
  539. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  540. border-radius: 38px;
  541. font-size: 32rpx;
  542. color: #605128;
  543. }
  544. }
  545. }
  546. }
  547. .product-list {
  548. padding: 0 30rpx;
  549. line-height: 0;
  550. align-items: stretch;
  551. .list-left {
  552. .imgleft {
  553. width: 306rpx;
  554. height: 319rpx;
  555. }
  556. }
  557. .list-right {
  558. flex-direction: column;
  559. .imgleft {
  560. width: 366rpx;
  561. height: 152rpx;
  562. }
  563. }
  564. }
  565. .bottom-box {
  566. padding: 30rpx 0;
  567. background-color: #FFFFFF;
  568. .bottom-title {
  569. text-align: center;
  570. .image {
  571. width: 609rpx;
  572. height: 31rpx;
  573. }
  574. }
  575. .product-art-list {
  576. .product-art-item {
  577. .image-box {
  578. text-align: center;
  579. .image {
  580. width: 432rpx;
  581. height: 432rpx;
  582. }
  583. }
  584. }
  585. }
  586. .product-detail {
  587. margin: 30rpx;
  588. height: 4em;
  589. overflow: hidden;
  590. text-indent: 2em;
  591. text-overflow: ellipsis;
  592. display: -webkit-box;
  593. -webkit-line-clamp: 4;
  594. -webkit-box-orient: vertical;
  595. }
  596. }
  597. </style>