index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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">
  26. <image src="/static/icon/c3.png"></image>
  27. <view class="cate-font">品牌介绍</view>
  28. </view>
  29. <view class="cate-item">
  30. <image src="/static/icon/c5.png"></image>
  31. <view class="cate-font">产品百科</view>
  32. </view>
  33. <view class="cate-item">
  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"></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. </view>
  70. </template>
  71. <script>
  72. import { loadIndexs } from '@/api/index.js';
  73. import { mapState } from 'vuex';
  74. export default {
  75. data() {
  76. return {
  77. carouselList: [''], //轮播图
  78. swiperLength: 1 //图片数量
  79. };
  80. },
  81. onLoad: function(option) {
  82. // #ifndef MP
  83. if (option.spread) {
  84. // 存储其他邀请人
  85. uni.setStorageSync('spread', option.spread);
  86. }
  87. // #endif
  88. // #ifdef MP
  89. if (option.scene) {
  90. // 存储小程序邀请人
  91. uni.setStorage({
  92. key: 'spread_code',
  93. data: option.scene
  94. });
  95. }
  96. // #endif
  97. },
  98. onShow: function() {
  99. // 判断是否强制登录
  100. if (this.loginInterceptor && !this.hasLogin) {
  101. // 登录拦截
  102. interceptor();
  103. }
  104. this.loadData();
  105. },
  106. //下拉刷新
  107. onPullDownRefresh() {
  108. this.loadData();
  109. },
  110. // #ifndef MP
  111. // 监听导航栏输入框点击事件
  112. onNavigationBarSearchInputClicked(e) {
  113. //跳转到搜索页面
  114. this.clickSearch();
  115. },
  116. //点击导航栏 buttons 时触发
  117. onNavigationBarButtonTap(e) {
  118. uni.navigateTo({
  119. url: '/pages/user/notice'
  120. });
  121. },
  122. // #endif
  123. methods: {
  124. // 监听切换事件
  125. listChange(e) {
  126. this.checkid = e.detail.current;
  127. },
  128. // 點擊搜索框
  129. clickSearch() {
  130. uni.navigateTo({
  131. url: '/pages/product/search'
  132. });
  133. },
  134. // 请求载入数据
  135. async loadData() {
  136. loadIndexs({})
  137. .then(({ data }) => {
  138. let goods = data.info;
  139. this.carouselList = data.banner;
  140. this.swiperLength = this.carouselList.length;
  141. this.menusList = data.menus;
  142. this.goodsList = goods.firstList; //最新商品
  143. this.bastList = goods.bastList; //精品推荐
  144. this.bastBanner = data.benefit; //促销单品
  145. this.$set(this, 'couponArray', data.couponList); //保存卡包券
  146. uni.stopPullDownRefresh();
  147. })
  148. .catch(e => {
  149. uni.stopPullDownRefresh();
  150. });
  151. },
  152. //详情页
  153. navToDetailPage(item) {
  154. let id = item.id;
  155. uni.navigateTo({
  156. url: '/pages/product/product?id=' + id
  157. });
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss">
  163. page,
  164. .center {
  165. height: auto;
  166. min-height: 100%;
  167. background-color: #ffffff;
  168. }
  169. /* #ifdef MP || APP-PLUS*/
  170. .input-box {
  171. padding: 25rpx;
  172. /* #ifdef APP-PLUS */
  173. margin-top: var(--status-bar-height);
  174. /* #endif */
  175. background-color: #fe8119;
  176. height: 44px;
  177. .iconsearch {
  178. font-size: 50rpx;
  179. }
  180. .input-content {
  181. border-radius: 99rpx;
  182. flex-grow: 1;
  183. padding: 5rpx 30rpx;
  184. // background-color: rgba(231, 231, 231, 0.7);
  185. background: #ffffff;
  186. .input {
  187. flex-grow: 1;
  188. input {
  189. font-size: $font-base;
  190. }
  191. }
  192. }
  193. .input-button {
  194. padding-left: 20rpx;
  195. font-size: $font-base;
  196. height: 100%;
  197. }
  198. }
  199. /* #endif */
  200. .top {
  201. width: 1000rpx;
  202. height: 282rpx;
  203. background: linear-gradient(180deg, #08c4e6, #50ead2);
  204. overflow: hidden;
  205. text-align: center;
  206. border-bottom-left-radius: 50%;
  207. border-bottom-right-radius: 50%;
  208. margin-left: -125rpx;
  209. }
  210. .carousel {
  211. width: 700rpx;
  212. height: 300rpx;
  213. border-radius: 14rpx;
  214. margin: 0 auto;
  215. margin-top: calc(-128rpx + var(--status-bar-height));
  216. .bor {
  217. border-radius: 14rpx;
  218. .carousel-item {
  219. background-color: #4cd964;
  220. image {
  221. width: 100%;
  222. height: 100%;
  223. border-radius: 14rpx;
  224. }
  225. }
  226. }
  227. }
  228. .swiper-dot {
  229. position: relative;
  230. z-index: 10;
  231. margin-top: -40rpx;
  232. display: flex;
  233. justify-content: center;
  234. .swiper-dots-item {
  235. width: 14rpx;
  236. height: 14rpx;
  237. background: #aaaaaa;
  238. border-radius: 50%;
  239. margin: 0 16rpx;
  240. // z-index: 999;
  241. }
  242. .action {
  243. background-color: #ffffff;
  244. }
  245. }
  246. .cate-section {
  247. display: flex;
  248. justify-content: space-around;
  249. align-items: center;
  250. flex-wrap: wrap;
  251. padding: 40rpx 22rpx;
  252. .cate-item {
  253. display: flex;
  254. flex-direction: column;
  255. align-items: center;
  256. font-size: $font-sm + 4rpx;
  257. color: $font-color-dark;
  258. }
  259. .cate-font {
  260. margin-top: -26rpx;
  261. }
  262. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  263. image {
  264. width: 150rpx;
  265. height: 150rpx;
  266. margin-bottom: 14rpx;
  267. border-radius: 50%;
  268. }
  269. }
  270. .xian {
  271. width: 750rpx;
  272. height: 20rpx;
  273. background: #f5f5f5;
  274. }
  275. .main {
  276. margin-top: 40rpx;
  277. padding: 0 40rpx;
  278. .main-top {
  279. align-items: center;
  280. .main-left {
  281. display: flex;
  282. justify-content: flex-start;
  283. align-items: center;
  284. .shu {
  285. width: 8rpx;
  286. height: 38rpx;
  287. background: #05ab81;
  288. border-radius: 4rpx;
  289. }
  290. .main-title {
  291. margin-left: 10rpx;
  292. font-size: 36rpx;
  293. font-family: PingFang SC;
  294. font-weight: bold;
  295. color: #202739;
  296. }
  297. .main-tip {
  298. font-size: 22rpx;
  299. font-family: PingFang SC;
  300. font-weight: bold;
  301. color: #95A0B1;
  302. margin-left: 14rpx;
  303. }
  304. }
  305. }
  306. }
  307. .guess-item {
  308. display: flex;
  309. width: 710rpx;
  310. height: 290rpx;
  311. background: #ffffff;
  312. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  313. border-radius: 10rpx;
  314. padding: 15rpx;
  315. padding-bottom: 150rpx;
  316. margin: 20rpx auto 0;
  317. position: relative;
  318. image {
  319. width: 260rpx;
  320. height: 260rpx;
  321. border-radius: 10rpx;
  322. }
  323. .guess-box {
  324. padding: 12rpx 0 0 24rpx;
  325. width: 436rpx;
  326. .title {
  327. font-size: 30rpx;
  328. padding-left: 4rpx;
  329. font-family: PingFang SC;
  330. font-weight: 500;
  331. color: #333333;
  332. width: 368rpx;
  333. line-height: 36rpx;
  334. .tuanF {
  335. display: inline-block;
  336. margin-right: 4rpx;
  337. position: relative;
  338. top: -6rpx;
  339. .tuan {
  340. display: flex;
  341. align-items: center;
  342. padding: 10rpx;
  343. height: 36rpx;
  344. background: #ffebe9;
  345. border-radius: 18rpx;
  346. .tuan-image {
  347. width: 18rpx;
  348. height: 18rpx;
  349. }
  350. .tuan-font {
  351. display: inline;
  352. font-size: 20rpx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #ff1135;
  356. margin-left: 2rpx;
  357. }
  358. }
  359. }
  360. }
  361. .ping-box {
  362. margin-top: 15rpx;
  363. justify-content: flex-start;
  364. .ping {
  365. margin-left: 10rpx;
  366. height: 39rpx;
  367. background: #fdf7eb;
  368. border-radius: 5rpx;
  369. font-size: 22rpx;
  370. font-family: PingFang SC;
  371. font-weight: 500;
  372. color: #ff911f;
  373. display: flex;
  374. align-items: center;
  375. padding: 0 10rpx;
  376. }
  377. }
  378. .price-box {
  379. margin-top: 38rpx;
  380. justify-content: flex-start;
  381. .yuanprice {
  382. font-size: 26rpx;
  383. font-family: PingFang SC;
  384. font-weight: 500;
  385. text-decoration: line-through;
  386. color: #999999;
  387. padding-right: 6rpx;
  388. }
  389. image {
  390. width: 14rpx;
  391. height: 16rpx;
  392. }
  393. .jiang {
  394. padding-left: 2rpx;
  395. font-size: 24rpx;
  396. font-family: PingFang SC;
  397. font-weight: bold;
  398. color: #b59467;
  399. }
  400. }
  401. .price {
  402. font-size: 36rpx;
  403. font-family: PingFang SC;
  404. font-weight: bold;
  405. color: #ff1135;
  406. }
  407. .btn {
  408. width: 137rpx;
  409. height: 56rpx;
  410. background: linear-gradient(-35deg, #f8dd4f, #fbeb77);
  411. border-radius: 28rpx;
  412. font-size: 28rpx;
  413. font-family: PingFang SC;
  414. font-weight: 500;
  415. color: #333333;
  416. line-height: 56rpx;
  417. text-align: center;
  418. position: absolute;
  419. bottom: 25rpx;
  420. right: 25rpx;
  421. }
  422. }
  423. }
  424. </style>