index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. <template>
  2. <view class="center">
  3. <!-- 小程序头部兼容 -->
  4. <!-- #ifdef MP -->
  5. <navigator url="/pages/product/search">
  6. <view class="input-box flex">
  7. <view class=" input-content flex">
  8. <view class="iconfont iconsearch"></view>
  9. <view class="input"><input disabled placeholder="请输入搜索内容" /></view>
  10. </view>
  11. </view>
  12. </navigator>
  13. <!-- #endif -->
  14. <view class="top"></view>
  15. <view class="carousel">
  16. <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
  17. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item">
  18. <image :src="item.pic" />
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <view class="swiper-dot">
  23. <template v-for="item in swiperLength">
  24. <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
  25. </template>
  26. </view>
  27. <view class="cate-section">
  28. <view class="cate-item" @click="nav('/pages/index/artList?cid=1&tit=' + encodeURI('众赢集团'))">
  29. <image src="/static/icon/in1.png"></image>
  30. <view class="cate-font">众赢集团</view>
  31. </view>
  32. <view class="cate-item" @click="nav('/pages/category/articleList')">
  33. <image src="/static/icon/in2.png"></image>
  34. <view class="cate-font">康养旅居</view>
  35. </view>
  36. <view class="cate-item">
  37. <image src="/static/icon/in3.png" @click="nav('/pages/index/vip')"></image>
  38. <view class="cate-font">调理养护</view>
  39. </view>
  40. <view class="cate-item">
  41. <image src="/static/icon/in4.png" @click="nav('/pages/index/vip')"></image>
  42. <view class="cate-font">专家专项</view>
  43. </view>
  44. <view class="cate-item">
  45. <image src="/static/icon/in5.png" @click="nav('/pages/category/category')"></image>
  46. <view class="cate-font">商品分类</view>
  47. </view>
  48. <view class="cate-item">
  49. <image src="/static/icon/in6.png" @click="nav('/pages/index/vip')"></image>
  50. <view class="cate-font">热销推荐</view>
  51. </view>
  52. <view class="cate-item">
  53. <image src="/static/icon/in7.png" @click="nav('/pages/index/vip')"></image>
  54. <view class="cate-font">会员中心</view>
  55. </view>
  56. <view class="cate-item" @click="nav('/pages/index/jifenShop')">
  57. <image src="/static/icon/in8.png"></image>
  58. <view class="cate-font">分享有礼</view>
  59. </view>
  60. </view>
  61. <view class="jj-tit" >
  62. <view class="left">
  63. <image src="../../static/icon/gsjj.png" mode="" class="jj-log"></image>
  64. <view class="jj-title">
  65. 公司文化
  66. </view>
  67. </view>
  68. <view class="right" @click="nav('/pages/index/artList?cid=1&tit=' + encodeURI('公司文化'))">
  69. <view class="jj-more-tit">
  70. 更多
  71. </view>
  72. <image src="../../static/img/img39.png" mode="" class="jj-more"></image>
  73. </view>
  74. </view>
  75. <view class="jj-wrap">
  76. <view class="jj" v-for="ls in hostList" @click="nav('/pages/index/artDetail?id=' + ls.id)">
  77. <image :src="ls.image_input[0]" mode="" class="jj-img"></image>
  78. <view class="jj-info">
  79. <view class="jj-tit-tit clamp">
  80. {{ls.title}}
  81. </view>
  82. <view class="jj-val clamp2">
  83. 更新时间:{{ls.add_time}}
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="xian"></view>
  89. <view class="main">
  90. <!-- <view class="main-top flex">
  91. <view class="main-left">
  92. <view class="shu"></view>
  93. <view class="main-title">热销推荐</view>
  94. <view class="main-tip">在售精品</view>
  95. </view>
  96. </view> -->
  97. <view class="main-t-t">
  98. <image src="../../static/img/jxhh.png" mode="" class="main-t-t-i"></image>
  99. </view>
  100. <view class="list-box-h">
  101. <view v-for="(item, index) in dataList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  102. <image :src="item.image"></image>
  103. <view class="guess-box">
  104. <view class="title clamp2">{{ item.store_name }}</view>
  105. <view class="price-box flex">
  106. <view class="yuanprice">{{ item.ot_price }}</view>
  107. <image src="../../static/img/jiantou.png" mode=""></image>
  108. <view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view>
  109. </view>
  110. <view class="price">¥{{ item.price }}</view>
  111. <view class="btn">立即购买</view>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import {
  120. loadIndexs,
  121. hotList
  122. } from '@/api/index.js';
  123. import {
  124. mapState
  125. } from 'vuex';
  126. import {
  127. saveUrl,
  128. interceptor
  129. } from '@/utils/loginUtils.js';
  130. import {
  131. service
  132. } from '@/api/user.js';
  133. // #ifdef H5
  134. import {
  135. weixindata,
  136. weixinlocation,
  137. shareLoad
  138. } from '@/utils/wxAuthorized';
  139. import weixinObj from '@/plugin/jweixin-module/index.js';
  140. // #endif
  141. export default {
  142. data() {
  143. return {
  144. carouselList: [], //轮播图
  145. swiperCurrent: 0,
  146. dataList: [],
  147. swiperLength: 1 ,//图片数量
  148. hostList:[],//热门文章列表
  149. };
  150. },
  151. onLoad: function(option) {
  152. // #ifndef MP
  153. if (option.spread) {
  154. // 存储其他邀请人
  155. uni.setStorageSync('spread', option.spread);
  156. }
  157. // #endif
  158. // #ifdef MP
  159. if (option.scene) {
  160. // 存储小程序邀请人
  161. uni.setStorage({
  162. key: 'spread_code',
  163. data: option.scene
  164. });
  165. }
  166. // #endif
  167. // #ifdef H5
  168. if (this.hasLogin) {
  169. console.log('显示');
  170. weixinObj.hideAllNonBaseMenuItem();
  171. this.IndexShare();
  172. } else {
  173. console.log('隐藏');
  174. weixinObj.hideAllNonBaseMenuItem();
  175. }
  176. //#endif
  177. // 获取热门文章页
  178. this.hotList();
  179. },
  180. computed: {
  181. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  182. ...mapState(['baseURL'])
  183. },
  184. onShow: function() {
  185. // 判断是否强制登录
  186. if (!this.hasLogin) {
  187. // 登录拦截
  188. uni.showModal({
  189. title: '登录',
  190. content: '您未登录,是否马上登陆?',
  191. success: e => {
  192. if (e.confirm) {
  193. interceptor();
  194. }
  195. },
  196. fail: e => {
  197. console.log(e);
  198. }
  199. });
  200. }
  201. this.loadData();
  202. },
  203. //下拉刷新
  204. onPullDownRefresh() {
  205. this.loadData();
  206. },
  207. // #ifndef MP
  208. // 监听导航栏输入框点击事件
  209. onNavigationBarSearchInputClicked(e) {
  210. //跳转到搜索页面
  211. this.clickSearch();
  212. },
  213. //点击导航栏 buttons 时触发
  214. onNavigationBarButtonTap(e) {
  215. uni.navigateTo({
  216. url: '/pages/user/notice'
  217. });
  218. },
  219. // #endif
  220. methods: {
  221. // 获取热门文章
  222. hotList(){
  223. hotList().then((e) => {
  224. this.hostList = e.data;
  225. console.log(e);
  226. }).catch((e) => {
  227. console.log(e);
  228. })
  229. },
  230. // #ifdef H5
  231. IndexShare() {
  232. let obj = this;
  233. let pages = getCurrentPages();
  234. // 获取当前页面
  235. let page = pages[pages.length - 1];
  236. let path = '/#/' + page.route + '?';
  237. // 保存传值
  238. for (let i in page.options) {
  239. path += i + '=' + page.options[i] + '&';
  240. }
  241. console.log(obj.Path);
  242. // 保存邀请人
  243. path += 'spread=' + this.userInfo.uid;
  244. let data = {
  245. link: this.baseURL + '/index/' + path,
  246. title: this.userInfo.nickname + '邀请您进入鼎立足行',
  247. desc: '欢迎加入鼎立足行',
  248. imgUrl: 'https://dlzx.liuniu946.com/index/static/img/logo.png'
  249. };
  250. shareLoad(data);
  251. },
  252. // #endif
  253. // 监听切换事件
  254. listChange(e) {
  255. this.checkid = e.detail.current;
  256. },
  257. // 點擊搜索框
  258. clickSearch() {
  259. uni.navigateTo({
  260. url: '/pages/product/search'
  261. });
  262. },
  263. nav(url) {
  264. uni.navigateTo({
  265. url,
  266. fail: (e) => {
  267. console.log(e);
  268. uni.switchTab({
  269. url
  270. });
  271. }
  272. });
  273. },
  274. //轮播图切换修改背景色
  275. swiperChange(e) {
  276. const index = e.detail.current;
  277. this.swiperCurrent = index;
  278. },
  279. comfirm(text) {
  280. console.log(text);
  281. const result = this.uniCopy(text);
  282. if (result === false) {
  283. uni.showToast({
  284. title: '不支持'
  285. });
  286. } else {
  287. uni.showToast({
  288. title: '复制成功',
  289. icon: 'none'
  290. });
  291. }
  292. this.$refs.popup.close();
  293. },
  294. bc_code() {
  295. let that = this;
  296. console.log('保存二维码', this.erweima);
  297. uni.downloadFile({
  298. //获得二维码的临时地址
  299. url: this.erweima,
  300. success: res => {
  301. //console.log('获取url',res)
  302. if (res.statusCode == 200) {
  303. uni.saveImageToPhotosAlbum({
  304. filePath: res.tempFilePath, //传入临时地址
  305. success() {
  306. that.$api.msg('保存成功'); //封装的提示
  307. },
  308. fail() {
  309. that.$api.msg('保存失败');
  310. }
  311. });
  312. }
  313. }
  314. });
  315. },
  316. // 请求载入数据
  317. async loadData() {
  318. loadIndexs({})
  319. .then(({
  320. data
  321. }) => {
  322. console.log(data);
  323. this.carouselList = data.banner;
  324. this.swiperLength = this.carouselList.length;
  325. this.dataList = data.likeInfo; //最新商品
  326. uni.stopPullDownRefresh();
  327. })
  328. .catch(e => {
  329. uni.stopPullDownRefresh();
  330. });
  331. // service({}).then(({
  332. // data
  333. // }) => {
  334. // this.erweima = data.service_qr;
  335. // this.weixin = data.service_wechat;
  336. // });
  337. },
  338. //详情页
  339. navToDetailPage(item) {
  340. let id = item.id;
  341. uni.navigateTo({
  342. url: '/pages/product/product?id=' + id
  343. });
  344. }
  345. }
  346. };
  347. </script>
  348. <style lang="scss">
  349. page,
  350. .center {
  351. height: auto;
  352. min-height: 100%;
  353. background-color: #ffffff;
  354. }
  355. /* #ifdef MP || APP-PLUS*/
  356. .input-box {
  357. padding: 25rpx;
  358. /* #ifdef APP-PLUS */
  359. margin-top: var(--status-bar-height);
  360. /* #endif */
  361. background-color: #0fc8e4;
  362. height: 44px;
  363. .iconsearch {
  364. font-size: 50rpx;
  365. }
  366. .input-content {
  367. border-radius: 99rpx;
  368. flex-grow: 1;
  369. padding: 5rpx 30rpx;
  370. // background-color: rgba(231, 231, 231, 0.7);
  371. background: #ffffff;
  372. .input {
  373. flex-grow: 1;
  374. input {
  375. font-size: $font-base;
  376. }
  377. }
  378. }
  379. .input-button {
  380. padding-left: 20rpx;
  381. font-size: $font-base;
  382. height: 100%;
  383. }
  384. }
  385. /* #endif */
  386. .top {
  387. width: 1000rpx;
  388. height: 240rpx;
  389. background: linear-gradient(180deg, #52c696, #52c696);
  390. overflow: hidden;
  391. text-align: center;
  392. border-bottom-left-radius: 50%;
  393. border-bottom-right-radius: 50%;
  394. margin-left: -125rpx;
  395. }
  396. .carousel {
  397. width: 700rpx;
  398. height: 300rpx;
  399. border-radius: 14rpx;
  400. margin: 0 auto;
  401. margin-top: calc(-240rpx + var(--status-bar-height));
  402. .bor {
  403. border-radius: 14rpx;
  404. .carousel-item {
  405. image {
  406. width: 100%;
  407. height: 100%;
  408. border-radius: 14rpx;
  409. }
  410. }
  411. }
  412. }
  413. .swiper-dot {
  414. position: relative;
  415. z-index: 10;
  416. margin-top: -40rpx;
  417. display: flex;
  418. justify-content: center;
  419. .swiper-dots-item {
  420. width: 14rpx;
  421. height: 14rpx;
  422. background: #aaaaaa;
  423. border-radius: 50%;
  424. margin: 0 16rpx;
  425. // z-index: 999;
  426. }
  427. .action {
  428. background-color: #ffffff;
  429. }
  430. }
  431. .cate-section {
  432. display: flex;
  433. // justify-content: space-around;
  434. justify-content: flex-start;
  435. align-items: center;
  436. flex-wrap: wrap;
  437. padding: 60rpx 0 20rpx;
  438. .cate-item {
  439. width: 25%;
  440. display: flex;
  441. flex-direction: column;
  442. align-items: center;
  443. font-size: $font-sm + 4rpx;
  444. color: $font-color-dark;
  445. image {
  446. width: 118rpx;
  447. height: 103rpx;
  448. }
  449. }
  450. .cate-font {
  451. // margin-top: -26rpx;
  452. margin-bottom: 20rpx;
  453. }
  454. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  455. image {
  456. width: 150rpx;
  457. height: 150rpx;
  458. // margin-bottom: 14rpx;
  459. border-radius: 50%;
  460. }
  461. }
  462. .xian {
  463. width: 750rpx;
  464. height: 20rpx;
  465. background: #f5f5f5;
  466. }
  467. .main {
  468. margin-top: 40rpx;
  469. padding: 0 40rpx;
  470. .main-t-t {
  471. // width: 100;
  472. display: flex;
  473. justify-content: center;
  474. .main-t-t-i {
  475. width: 376rpx;
  476. height: 34rpx;
  477. margin: auto;
  478. }
  479. }
  480. .main-top {
  481. align-items: center;
  482. .main-left {
  483. display: flex;
  484. justify-content: flex-start;
  485. align-items: center;
  486. .shu {
  487. width: 8rpx;
  488. height: 38rpx;
  489. background: #05ab81;
  490. border-radius: 4rpx;
  491. }
  492. .main-title {
  493. margin-left: 10rpx;
  494. font-size: 36rpx;
  495. font-family: PingFang SC;
  496. font-weight: bold;
  497. color: #202739;
  498. }
  499. .main-tip {
  500. font-size: 22rpx;
  501. font-family: PingFang SC;
  502. font-weight: bold;
  503. color: #95a0b1;
  504. margin-left: 14rpx;
  505. }
  506. }
  507. }
  508. }
  509. .guess-item {
  510. display: flex;
  511. width: 710rpx;
  512. height: 290rpx;
  513. background: #ffffff;
  514. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  515. border-radius: 10rpx;
  516. padding: 15rpx;
  517. padding-bottom: 150rpx;
  518. margin: 20rpx auto 0;
  519. position: relative;
  520. image {
  521. width: 260rpx;
  522. height: 260rpx;
  523. border-radius: 10rpx;
  524. }
  525. .guess-box {
  526. padding: 12rpx 0 0 24rpx;
  527. width: 436rpx;
  528. .title {
  529. font-size: 30rpx;
  530. padding-left: 4rpx;
  531. font-family: PingFang SC;
  532. font-weight: bold;
  533. color: #333333;
  534. width: 368rpx;
  535. line-height: 36rpx;
  536. .tuanF {
  537. display: inline-block;
  538. margin-right: 4rpx;
  539. position: relative;
  540. top: -6rpx;
  541. .tuan {
  542. display: flex;
  543. align-items: center;
  544. padding: 10rpx;
  545. height: 36rpx;
  546. background: #ffebe9;
  547. border-radius: 18rpx;
  548. .tuan-image {
  549. width: 18rpx;
  550. height: 18rpx;
  551. }
  552. .tuan-font {
  553. display: inline;
  554. font-size: 20rpx;
  555. font-family: PingFang SC;
  556. font-weight: 500;
  557. color: #ff1135;
  558. margin-left: 2rpx;
  559. }
  560. }
  561. }
  562. }
  563. .ping-box {
  564. margin-top: 15rpx;
  565. justify-content: flex-start;
  566. .ping {
  567. margin-left: 10rpx;
  568. height: 39rpx;
  569. background: #fdf7eb;
  570. border-radius: 5rpx;
  571. font-size: 22rpx;
  572. font-family: PingFang SC;
  573. font-weight: 500;
  574. color: #ff911f;
  575. display: flex;
  576. align-items: center;
  577. padding: 0 10rpx;
  578. }
  579. }
  580. .price-box {
  581. margin-top: 80rpx;
  582. justify-content: flex-start;
  583. .yuanprice {
  584. font-size: 26rpx;
  585. font-family: PingFang SC;
  586. font-weight: 500;
  587. text-decoration: line-through;
  588. color: #999999;
  589. padding-right: 6rpx;
  590. }
  591. image {
  592. width: 14rpx;
  593. height: 16rpx;
  594. }
  595. .jiang {
  596. padding-left: 2rpx;
  597. font-size: 24rpx;
  598. font-family: PingFang SC;
  599. font-weight: bold;
  600. color: #b59467;
  601. }
  602. }
  603. .price {
  604. font-size: 36rpx;
  605. font-family: PingFang SC;
  606. font-weight: bold;
  607. color: #FF6F0F;
  608. }
  609. .btn {
  610. width: 137rpx;
  611. height: 56rpx;
  612. background: #16cc9f;
  613. border-radius: 28rpx;
  614. font-size: 28rpx;
  615. font-family: PingFang SC;
  616. font-weight: 500;
  617. color: #ffffff;
  618. line-height: 56rpx;
  619. text-align: center;
  620. position: absolute;
  621. bottom: 25rpx;
  622. right: 25rpx;
  623. }
  624. }
  625. }
  626. .popup {
  627. width: 640rpx;
  628. background-color: #ffffff;
  629. border-radius: 15rpx;
  630. text-align: center;
  631. .popup-dox {
  632. position: relative;
  633. top: -60rpx;
  634. .popup-logo {
  635. width: 460rpx;
  636. height: 132rpx;
  637. }
  638. .pop-title {
  639. font-size: 40rpx;
  640. font-weight: bold;
  641. color: #333333;
  642. padding: 25rpx 0rpx;
  643. margin-bottom: 50rpx;
  644. }
  645. .popup-text {
  646. width: 400rpx;
  647. height: 400rpx;
  648. margin-bottom: 50rpx;
  649. }
  650. .btn {
  651. width: 300rpx;
  652. height: 50rpx;
  653. line-height: 50rpx;
  654. background: #96e4f2;
  655. margin: 0 auto;
  656. color: #ffffff;
  657. border-radius: 25rpx;
  658. }
  659. .pop-tip {
  660. font-size: 30rpx;
  661. font-weight: 500;
  662. color: #333333;
  663. justify-content: center;
  664. margin-top: 20rpx;
  665. .weixin {
  666. width: 48rpx;
  667. height: 40rpx;
  668. margin-right: 14rpx;
  669. image {
  670. width: 48rpx;
  671. height: 40rpx;
  672. }
  673. }
  674. }
  675. }
  676. }
  677. .close_icon {
  678. width: 60rpx;
  679. height: 60rpx;
  680. margin: 88rpx auto 0;
  681. image {
  682. width: 100%;
  683. height: 100%;
  684. }
  685. }
  686. .jj-tit {
  687. display: flex;
  688. // height: 50rpx;
  689. justify-content: space-between;
  690. background-color: #fff;
  691. padding-top: 20rpx;
  692. .left {
  693. padding-left: 30rpx;
  694. display: flex;
  695. .jj-log {
  696. width: 45rpx;
  697. height: 45rpx;
  698. }
  699. .jj-title {
  700. font-weight: bold;
  701. font-size: 32rpx;
  702. padding-left: 15rpx;
  703. }
  704. }
  705. .right {
  706. display: flex;
  707. width: 200rpx;
  708. font-size: 22rpx;
  709. // justify-content: sp;
  710. justify-content: flex-end;
  711. align-items: center;
  712. padding-right: 30rpx;
  713. color: #999;
  714. .jj-more {
  715. margin-left: 10rpx;
  716. width: 15rpx;
  717. height: 22rpx;
  718. }
  719. }
  720. }
  721. .jj-wrap {
  722. background-color: #fff;
  723. // margin: 20rpx 0;
  724. .jj {
  725. margin: auto;
  726. width: 689rpx;
  727. height: 202rpx;
  728. border-bottom: 1px solid #e5e5e5;
  729. padding: 20rpx;
  730. padding-left: 0;
  731. display: flex;
  732. &:last-of-type {
  733. border-bottom: none;
  734. }
  735. .jj-img {
  736. flex-shrink: 0;
  737. width: 222rpx;
  738. height: 158rpx;
  739. background-color: #eee;
  740. border-radius: 10rpx;
  741. }
  742. .jj-info {
  743. width: 450rpx;
  744. // flex-shrink: 0;
  745. padding: 10rpx;
  746. padding-left: 15rpx;
  747. font-size: 32rpx;
  748. font-weight: bold;
  749. display: flex;
  750. flex-direction: column;
  751. justify-content: space-between;
  752. .jj-tit-tit {
  753. }
  754. .jj-val {
  755. padding-top: 20rpx;
  756. font-size: 28rpx;
  757. font-weight: 500;
  758. }
  759. }
  760. }
  761. }
  762. </style>