index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view class="center">
  3. <view class="top"></view>
  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="carousel">
  15. <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
  16. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image src="" /></swiper-item>
  17. </swiper>
  18. </view>
  19. <view class="swiper-dot">
  20. <template v-for="item in swiperLength">
  21. <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
  22. </template>
  23. </view>
  24. <view class="cate-section">
  25. <view class="cate-item" @click="nav('/pages/category/category')">
  26. <image src="/static/icon/c3.png"></image>
  27. <view class="cate-font">品牌介绍</view>
  28. </view>
  29. <view class="cate-item" @click="nav('/pages/category/articleList')">
  30. <image src="/static/icon/c5.png"></image>
  31. <view class="cate-font">产品百科</view>
  32. </view>
  33. <view class="cate-item" @click="showPopup()">
  34. <image src="/static/icon/c7.png"></image>
  35. <view class="cate-font">免费咨询</view>
  36. </view>
  37. <view class="cate-item">
  38. <image src="/static/icon/c8.png" @click="nav('/pages/user/shareQrCode')"></image>
  39. <view class="cate-font">邀请有礼</view>
  40. </view>
  41. </view>
  42. <view class="xian"></view>
  43. <view class="main">
  44. <view class="main-top flex">
  45. <view class="main-left">
  46. <view class="shu"></view>
  47. <view class="main-title">热销推荐</view>
  48. <view class="main-tip">在售精品</view>
  49. </view>
  50. </view>
  51. <view class="list-box-h">
  52. <view v-for="(item, index) in dataList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  53. <image :src="item.image"></image>
  54. <view class="guess-box">
  55. <view class="title clamp2">
  56. {{ item.store_name }}
  57. </view>
  58. <view class="price-box flex">
  59. <view class="yuanprice">{{ item.ot_price }}</view>
  60. <image src="../../static/img/jiantou.png" mode=""></image>
  61. <view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view>
  62. </view>
  63. <view class="price">¥{{ item.price }}</view>
  64. <view class="btn">马上拼</view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <uni-popup ref="popup" type="center">
  70. <view class="popup-box">
  71. <view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
  72. <view class="mian">
  73. <view class="delivery">
  74. <view class="title">已经为您定制专属客服</view>
  75. <image src="../../static/img/img010.png" mode=""></image>
  76. </view>
  77. <view class="nocancel">客服微信: {{ text }}</view>
  78. <view class="comfirm-box">
  79. <view class="cancel" @click="cancel">取消</view>
  80. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  81. </view>
  82. </view>
  83. </view>
  84. </uni-popup>
  85. </view>
  86. </template>
  87. <script>
  88. import { loadIndexs } from '@/api/index.js';
  89. import { mapState } from 'vuex';
  90. export default {
  91. data() {
  92. return {
  93. carouselList: [''], //轮播图
  94. swiperCurrent: 0,
  95. dataList:[],
  96. text: 'Zjxwcm',//客服微信
  97. swiperLength: 1 //图片数量
  98. };
  99. },
  100. onLoad: function(option) {
  101. // #ifndef MP
  102. if (option.spread) {
  103. // 存储其他邀请人
  104. uni.setStorageSync('spread', option.spread);
  105. }
  106. // #endif
  107. // #ifdef MP
  108. if (option.scene) {
  109. // 存储小程序邀请人
  110. uni.setStorage({
  111. key: 'spread_code',
  112. data: option.scene
  113. });
  114. }
  115. // #endif
  116. },
  117. onShow: function() {
  118. // 判断是否强制登录
  119. if (this.loginInterceptor && !this.hasLogin) {
  120. // 登录拦截
  121. interceptor();
  122. }
  123. this.loadData();
  124. },
  125. //下拉刷新
  126. onPullDownRefresh() {
  127. this.loadData();
  128. },
  129. // #ifndef MP
  130. // 监听导航栏输入框点击事件
  131. onNavigationBarSearchInputClicked(e) {
  132. //跳转到搜索页面
  133. this.clickSearch();
  134. },
  135. //点击导航栏 buttons 时触发
  136. onNavigationBarButtonTap(e) {
  137. uni.navigateTo({
  138. url: '/pages/user/notice'
  139. });
  140. },
  141. // #endif
  142. methods: {
  143. // 监听切换事件
  144. listChange(e) {
  145. this.checkid = e.detail.current;
  146. },
  147. // 點擊搜索框
  148. clickSearch() {
  149. uni.navigateTo({
  150. url: '/pages/product/search'
  151. });
  152. },
  153. nav(url){
  154. uni.navigateTo({
  155. url,
  156. fail: () => {
  157. console.log(1)
  158. uni.switchTab({
  159. url
  160. })
  161. }
  162. })
  163. },
  164. showPopup() {
  165. this.$refs.popup.open();
  166. },
  167. cancel() {
  168. this.$refs.popup.close();
  169. },
  170. uniCopy(content) {
  171. /**
  172. * 小程序端 和 app端的复制逻辑
  173. */
  174. //#ifndef H5
  175. uni.setClipboardData({
  176. data: content,
  177. success: function() {
  178. console.log('success');
  179. return true;
  180. }
  181. });
  182. //#endif
  183. /**
  184. * H5端的复制逻辑
  185. */
  186. // #ifdef H5
  187. if (!document.queryCommandSupported('copy')) {
  188. //为了兼容有些浏览器 queryCommandSupported 的判断
  189. // 不支持
  190. return false;
  191. }
  192. let textarea = document.createElement('textarea');
  193. textarea.value = content;
  194. textarea.readOnly = 'readOnly';
  195. document.body.appendChild(textarea);
  196. textarea.select(); // 选择对象
  197. textarea.setSelectionRange(0, content.length); //核心
  198. let result = document.execCommand('copy'); // 执行浏览器复制命令
  199. textarea.remove();
  200. return result;
  201. // #endif
  202. },
  203. comfirm(text) {
  204. console.log(text);
  205. const result = this.uniCopy(text);
  206. if (result === false) {
  207. uni.showToast({
  208. title: '不支持'
  209. });
  210. } else {
  211. uni.showToast({
  212. title: '复制成功',
  213. icon: 'none'
  214. });
  215. }
  216. this.$refs.popup.close();
  217. },
  218. // 请求载入数据
  219. async loadData() {
  220. loadIndexs({})
  221. .then(({ data }) => {
  222. let goods = data.info;
  223. this.carouselList = data.banner;
  224. this.swiperLength = this.carouselList.length;
  225. this.menusList = data.menus;
  226. this.goodsList = goods.firstList; //最新商品
  227. this.bastList = goods.bastList; //精品推荐
  228. this.bastBanner = data.benefit; //促销单品
  229. this.$set(this, 'couponArray', data.couponList); //保存卡包券
  230. uni.stopPullDownRefresh();
  231. })
  232. .catch(e => {
  233. uni.stopPullDownRefresh();
  234. });
  235. },
  236. //详情页
  237. navToDetailPage(item) {
  238. let id = item.id;
  239. uni.navigateTo({
  240. url: '/pages/product/product?id=' + id
  241. });
  242. }
  243. }
  244. };
  245. </script>
  246. <style lang="scss">
  247. page,
  248. .center {
  249. height: auto;
  250. min-height: 100%;
  251. background-color: #ffffff;
  252. }
  253. /* #ifdef MP || APP-PLUS*/
  254. .input-box {
  255. padding: 25rpx;
  256. /* #ifdef APP-PLUS */
  257. margin-top: var(--status-bar-height);
  258. /* #endif */
  259. background-color: #fe8119;
  260. height: 44px;
  261. .iconsearch {
  262. font-size: 50rpx;
  263. }
  264. .input-content {
  265. border-radius: 99rpx;
  266. flex-grow: 1;
  267. padding: 5rpx 30rpx;
  268. // background-color: rgba(231, 231, 231, 0.7);
  269. background: #ffffff;
  270. .input {
  271. flex-grow: 1;
  272. input {
  273. font-size: $font-base;
  274. }
  275. }
  276. }
  277. .input-button {
  278. padding-left: 20rpx;
  279. font-size: $font-base;
  280. height: 100%;
  281. }
  282. }
  283. /* #endif */
  284. .top {
  285. width: 1000rpx;
  286. height: 282rpx;
  287. background: linear-gradient(180deg, #08c4e6, #50ead2);
  288. overflow: hidden;
  289. text-align: center;
  290. border-bottom-left-radius: 50%;
  291. border-bottom-right-radius: 50%;
  292. margin-left: -125rpx;
  293. }
  294. .carousel {
  295. width: 700rpx;
  296. height: 300rpx;
  297. border-radius: 14rpx;
  298. margin: 0 auto;
  299. margin-top: calc(-128rpx + var(--status-bar-height));
  300. .bor {
  301. border-radius: 14rpx;
  302. .carousel-item {
  303. background-color: #4cd964;
  304. image {
  305. width: 100%;
  306. height: 100%;
  307. border-radius: 14rpx;
  308. }
  309. }
  310. }
  311. }
  312. .swiper-dot {
  313. position: relative;
  314. z-index: 10;
  315. margin-top: -40rpx;
  316. display: flex;
  317. justify-content: center;
  318. .swiper-dots-item {
  319. width: 14rpx;
  320. height: 14rpx;
  321. background: #aaaaaa;
  322. border-radius: 50%;
  323. margin: 0 16rpx;
  324. // z-index: 999;
  325. }
  326. .action {
  327. background-color: #ffffff;
  328. }
  329. }
  330. .cate-section {
  331. display: flex;
  332. justify-content: space-around;
  333. align-items: center;
  334. flex-wrap: wrap;
  335. padding: 40rpx 22rpx;
  336. .cate-item {
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. font-size: $font-sm + 4rpx;
  341. color: $font-color-dark;
  342. }
  343. .cate-font {
  344. margin-top: -26rpx;
  345. }
  346. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  347. image {
  348. width: 150rpx;
  349. height: 150rpx;
  350. margin-bottom: 14rpx;
  351. border-radius: 50%;
  352. }
  353. }
  354. .xian {
  355. width: 750rpx;
  356. height: 20rpx;
  357. background: #f5f5f5;
  358. }
  359. .main {
  360. margin-top: 40rpx;
  361. padding: 0 40rpx;
  362. .main-top {
  363. align-items: center;
  364. .main-left {
  365. display: flex;
  366. justify-content: flex-start;
  367. align-items: center;
  368. .shu {
  369. width: 8rpx;
  370. height: 38rpx;
  371. background: #05ab81;
  372. border-radius: 4rpx;
  373. }
  374. .main-title {
  375. margin-left: 10rpx;
  376. font-size: 36rpx;
  377. font-family: PingFang SC;
  378. font-weight: bold;
  379. color: #202739;
  380. }
  381. .main-tip {
  382. font-size: 22rpx;
  383. font-family: PingFang SC;
  384. font-weight: bold;
  385. color: #95A0B1;
  386. margin-left: 14rpx;
  387. }
  388. }
  389. }
  390. }
  391. .guess-item {
  392. display: flex;
  393. width: 710rpx;
  394. height: 290rpx;
  395. background: #ffffff;
  396. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  397. border-radius: 10rpx;
  398. padding: 15rpx;
  399. padding-bottom: 150rpx;
  400. margin: 20rpx auto 0;
  401. position: relative;
  402. image {
  403. width: 260rpx;
  404. height: 260rpx;
  405. border-radius: 10rpx;
  406. }
  407. .guess-box {
  408. padding: 12rpx 0 0 24rpx;
  409. width: 436rpx;
  410. .title {
  411. font-size: 30rpx;
  412. padding-left: 4rpx;
  413. font-family: PingFang SC;
  414. font-weight: 500;
  415. color: #333333;
  416. width: 368rpx;
  417. line-height: 36rpx;
  418. .tuanF {
  419. display: inline-block;
  420. margin-right: 4rpx;
  421. position: relative;
  422. top: -6rpx;
  423. .tuan {
  424. display: flex;
  425. align-items: center;
  426. padding: 10rpx;
  427. height: 36rpx;
  428. background: #ffebe9;
  429. border-radius: 18rpx;
  430. .tuan-image {
  431. width: 18rpx;
  432. height: 18rpx;
  433. }
  434. .tuan-font {
  435. display: inline;
  436. font-size: 20rpx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #ff1135;
  440. margin-left: 2rpx;
  441. }
  442. }
  443. }
  444. }
  445. .ping-box {
  446. margin-top: 15rpx;
  447. justify-content: flex-start;
  448. .ping {
  449. margin-left: 10rpx;
  450. height: 39rpx;
  451. background: #fdf7eb;
  452. border-radius: 5rpx;
  453. font-size: 22rpx;
  454. font-family: PingFang SC;
  455. font-weight: 500;
  456. color: #ff911f;
  457. display: flex;
  458. align-items: center;
  459. padding: 0 10rpx;
  460. }
  461. }
  462. .price-box {
  463. margin-top: 38rpx;
  464. justify-content: flex-start;
  465. .yuanprice {
  466. font-size: 26rpx;
  467. font-family: PingFang SC;
  468. font-weight: 500;
  469. text-decoration: line-through;
  470. color: #999999;
  471. padding-right: 6rpx;
  472. }
  473. image {
  474. width: 14rpx;
  475. height: 16rpx;
  476. }
  477. .jiang {
  478. padding-left: 2rpx;
  479. font-size: 24rpx;
  480. font-family: PingFang SC;
  481. font-weight: bold;
  482. color: #b59467;
  483. }
  484. }
  485. .price {
  486. font-size: 36rpx;
  487. font-family: PingFang SC;
  488. font-weight: bold;
  489. color: #ff1135;
  490. }
  491. .btn {
  492. width: 137rpx;
  493. height: 56rpx;
  494. background: linear-gradient(-35deg, #f8dd4f, #fbeb77);
  495. border-radius: 28rpx;
  496. font-size: 28rpx;
  497. font-family: PingFang SC;
  498. font-weight: 500;
  499. color: #333333;
  500. line-height: 56rpx;
  501. text-align: center;
  502. position: absolute;
  503. bottom: 25rpx;
  504. right: 25rpx;
  505. }
  506. }
  507. }
  508. .popup-box {
  509. width: 522rpx;
  510. height: 605rpx;
  511. background-color: #ffffff;
  512. border-radius: 20rpx;
  513. position: relative;
  514. .img {
  515. position: relative;
  516. top: -56rpx;
  517. left: 0;
  518. width: 522rpx;
  519. height: 132rpx;
  520. display: flex;
  521. justify-content: center;
  522. image {
  523. border-radius: 20rpx 20rpx 0 0;
  524. width: 450rpx;
  525. height: 132rpx;
  526. }
  527. }
  528. .mian {
  529. margin-top: -44rpx;
  530. display: flex;
  531. flex-direction: column;
  532. align-items: center;
  533. // padding: 32rpx 32rpx;
  534. background-color: #ffffff;
  535. border-radius: 0 0 20rpx 20rpx;
  536. text-align: center;
  537. .delivery {
  538. font-size: 40rpx;
  539. color: #333333;
  540. display: flex;
  541. align-items: center;
  542. flex-direction: column;
  543. .title {}
  544. image {
  545. margin-top: 48rpx;
  546. width: 172rpx;
  547. height: 160rpx;
  548. }
  549. }
  550. .nocancel {
  551. font-size: 32rpx;
  552. color: #333333;
  553. margin-top: 14rpx;
  554. }
  555. .comfirm-box {
  556. margin-top: 52rpx;
  557. display: flex;
  558. // margin-bottom: 32rpx;
  559. // justify-content: space-around;
  560. .cancel {
  561. display: flex;
  562. align-items: center;
  563. justify-content: center;
  564. width: 197rpx;
  565. height: 74rpx;
  566. border: 1px solid #dcc786;
  567. border-radius: 38rpx;
  568. font-size: 32rpx;
  569. color: #605128;
  570. }
  571. .comfirm {
  572. margin-left: 32rpx;
  573. display: flex;
  574. align-items: center;
  575. justify-content: center;
  576. width: 197rpx;
  577. height: 74rpx;
  578. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  579. border-radius: 38px;
  580. font-size: 32rpx;
  581. color: #605128;
  582. }
  583. }
  584. }
  585. }
  586. </style>