index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="container">
  3. <view class="searchbackground">
  4. <view class="backgroundimg">
  5. <image src="../../static/image/background01.png" mode=""></image>
  6. </view>
  7. </view>
  8. <view class="content flex">
  9. <view class="input-box flex" @click="clickSearch">
  10. <view class=" input-content flex">
  11. <view class="iconfont iconsearch"></view>
  12. <view class="input"><input type="text" disabled placeholder="请输入搜索内容" /></view>
  13. </view>
  14. </view>
  15. <!-- 轮播图 -->
  16. <swiper class="carousel" autoplay="true" :interval="5000" :duration="400">
  17. <swiper-item @click="swiperClick" class="carousel-item" v-for="(item,index) in carouselList"
  18. :key="index">
  19. <image :src="item.pic"></image>
  20. </swiper-item>
  21. <view class="swiper-dots">
  22. </view>
  23. </swiper>
  24. <view class="customs">
  25. <image src="../../static/image/baodan.png" mode=""></image>
  26. </view>
  27. <view class="customs-content">
  28. <view class="backgroundimg1">
  29. <image src="../../static/image/background02.png" mode=""></image>
  30. </view>
  31. <view class="box">
  32. <view class="customs-img">
  33. <image src="../../static/img/reduce.png" mode=""></image>
  34. </view>
  35. <view class="customstext">
  36. <view class="customstext1">
  37. <view class="customstext-title clamp">
  38. 竹胎酵素健康饮竹胎酵素健康饮竹胎酵素健康饮
  39. </view>
  40. <view class="customstext-product clamp">
  41. 健康生态饮品纯植物无香精竹胎酵素健康饮竹胎酵素健康饮
  42. </view>
  43. </view>
  44. <view class="customsprice">
  45. <view class="customsprice-left">
  46. 健康价:¥
  47. </view>
  48. <view class="customsprice-between">
  49. 199
  50. </view>
  51. <view class="customsprice-right">
  52. 立即复购
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="customs">
  59. <image src="../../static/image/jifen.png" mode=""></image>
  60. </view>
  61. <view class="jifen-content">
  62. <view class="jifen-box" v-for="(item,index) in bastList" :key="index" @click="navTo('/pages/product/product?id=' + item.id)">
  63. <view class="img">
  64. <image :src="item.image" mode=""></image>
  65. </view>
  66. <view class="jifen-list">
  67. <view class="box-title">
  68. <view class="top clamp2">
  69. {{item.store_name}}
  70. </view>
  71. </view>
  72. <view class="box-price">
  73. <view class="price-left">
  74. ¥{{item.price}}
  75. </view>
  76. <view class="price-right">
  77. ¥{{item.ot_price}}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <!--
  85. <view class="fiexd">
  86. <image src="../../static/image/background03.png" mode=""></image>
  87. </view> -->
  88. </view>
  89. </template>
  90. <script>
  91. import { loadIndexs } from '@/api/index.js';
  92. import {
  93. mapState
  94. } from 'vuex';
  95. export default {
  96. components: {
  97. },
  98. watch: {
  99. //自适应swiper高度
  100. checkid(newValue, oldValue) {
  101. let obj = this;
  102. if (newValue == 0) {
  103. let bHeight = Math.ceil(obj.bastList.length / 2);
  104. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  105. }
  106. if (newValue == 1) {
  107. let bHeight = Math.ceil(obj.goodsList.length / 2);
  108. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  109. }
  110. if (newValue == 2) {
  111. let bHeight = Math.ceil(obj.bastBanner.length / 2);
  112. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  113. }
  114. },
  115. // 初次加载页面高度时修改页面高度
  116. },
  117. data() {
  118. return {
  119. carouselList: [], //轮播列表
  120. couponArray: '',
  121. bastList: [],//精品推荐
  122. }
  123. },
  124. onLoad() {
  125. this.loadData()
  126. },
  127. methods: {
  128. // 请求载入数据
  129. async loadData() {
  130. loadIndexs({})
  131. .then(({ data }) => {
  132. console.log(data,'dddd')
  133. let goods = data.info;
  134. this.carouselList = data.banner;
  135. this.swiperLength = this.carouselList.length;
  136. this.menusList = data.menus;
  137. this.goodsList = goods.firstList; //最新商品
  138. this.bastList = goods.bastList; //精品推荐
  139. console.log(this.bastList, 'this.bastList6666666666666666666666');
  140. this.bastBanner = data.benefit; //促销单品
  141. this.$set(this, 'couponArray', data.couponList); //保存卡包券
  142. uni.stopPullDownRefresh();
  143. })
  144. .catch(e => {
  145. uni.stopPullDownRefresh();
  146. });
  147. },
  148. swiperClick() {
  149. },
  150. // 点击搜索框
  151. clickSearch() {
  152. console.log('点击')
  153. uni.navigateTo({
  154. url: '/pages/product/search'
  155. });
  156. },
  157. navTo(url) {
  158. uni.navigateTo({
  159. url
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. page {
  167. height: auto;
  168. background-color: #D4FDF9;
  169. }
  170. .container {
  171. min-height: 100%;
  172. height: auto;
  173. }
  174. .searchbackground {
  175. position: relative;
  176. .backgroundimg {
  177. position: absolute;
  178. width: 750rpx;
  179. image {
  180. width: 100%;
  181. }
  182. }
  183. }
  184. // .fiexd {
  185. // position: fiexd;
  186. // bottom: 0;
  187. // width: 750rpx;
  188. // height: 750rpx;
  189. // image {
  190. // width: 100%;
  191. // height: 100%;
  192. // }
  193. // }
  194. .content {
  195. flex-direction: column;
  196. justify-content: center;
  197. height: 100%;
  198. .input-box {
  199. position: absolute;
  200. left: 0;
  201. top: 0;
  202. margin: 66rpx 25rpx;
  203. justify-content: center;
  204. background: #FFFFFF;
  205. box-shadow: 0rpx 1rpx 21rpx 0rpx rgba(255, 255, 255, 0.12);
  206. border-radius: 35rpx;
  207. width: 700rpx;
  208. height: 70rpx;
  209. .input {
  210. font-size: 28rpx;
  211. font-family: PingFang SC;
  212. font-weight: 500;
  213. color: #C4C4C4;
  214. line-height: 38rpx;
  215. }
  216. }
  217. .carousel {
  218. margin-top: 165rpx;
  219. width: 700rpx;
  220. height: 370rpx;
  221. .carousel-item {
  222. image {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. }
  227. }
  228. .customs {
  229. margin-top: 20rpx;
  230. width: 700rpx;
  231. height: 180rpx;
  232. image {
  233. width: 100%;
  234. height: 100%;
  235. }
  236. }
  237. .customs-content {
  238. position: relative;
  239. padding-top: 14rpx;
  240. .backgroundimg1 {
  241. width: 700rpx;
  242. height: 300rpx;
  243. image {
  244. height: 100%;
  245. width: 100%;
  246. }
  247. }
  248. .box {
  249. position: absolute;
  250. margin-top: -250rpx;
  251. padding: 0 38rpx;
  252. display: flex;
  253. justify-content: space-between;
  254. align-items: center;
  255. .customs-img {
  256. width: 200rpx;
  257. height: 200rpx;
  258. image {
  259. width: 100%;
  260. height: 100%;
  261. }
  262. }
  263. .customstext {
  264. margin-left: 14rpx;
  265. height: 200rpx;
  266. // display: flex;
  267. // flex-direction: column;
  268. // justify-content: space-around;
  269. position: relative;
  270. .customstext1 {
  271. .customstext-title {
  272. width: 350rpx;
  273. font-size: 34rpx;
  274. font-family: PingFang SC;
  275. font-weight: bold;
  276. color: #3F7C1F;
  277. }
  278. .customstext-product {
  279. // margin-top: 25rpx;
  280. width: 400rpx;
  281. padding-top: 10rpx;
  282. font-size: 26rpx;
  283. font-family: PingFang SC;
  284. font-weight: bold;
  285. color: #ABD56F;
  286. }
  287. }
  288. .customsprice {
  289. position: absolute;
  290. bottom: 0;
  291. left: 0;
  292. display: flex;
  293. align-items: center;
  294. justify-content: flex-start;
  295. width: 100%;
  296. .customsprice-left {
  297. font-size: 28rpx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #FF0000;
  301. flex-shrink: 0;
  302. }
  303. .customsprice-between {
  304. font-size: 42rpx;
  305. font-family: PingFang SC;
  306. font-weight: 500;
  307. color: #FF0000;
  308. flex-shrink: 0;
  309. }
  310. .customsprice-right {
  311. text-align: center;
  312. width: 137rpx;
  313. height: 52rpx;
  314. line-height: 52rpx;
  315. background: #3F7C1F;
  316. border-radius: 26rpx;
  317. font-size: 26rpx;
  318. font-family: PingFang SC;
  319. font-weight: 400;
  320. color: #FFFFFF;
  321. position: absolute;
  322. right: 0;
  323. bottom: 0;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .jifen-content {
  330. width: 700rpx;
  331. padding-bottom: 20rpx;
  332. display: flex;
  333. flex-wrap: wrap;
  334. justify-content: space-between;
  335. .jifen-box {
  336. margin: 20rpx 0;
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. width: 342rpx;
  341. height: 512rpx;
  342. padding-top: 20rpx;
  343. background: #E6FCFA;
  344. box-shadow: 0px 7px 10px 1px #8BAFAB;
  345. .img {
  346. flex-shrink: 0;
  347. // margin-top: 20rpx;
  348. height: 312rpx;
  349. width: 312rpx;
  350. background-color: #eee;
  351. image {
  352. height: 100%;
  353. width: 100%;
  354. }
  355. }
  356. .jifen-list {
  357. // margin-left: -80rpx;
  358. width: 312rpx;
  359. height: 100%;
  360. position: relative;
  361. .box-title {
  362. .top {
  363. margin: 20rpx 0 10rpx 0;
  364. // padding: 20rpx 0 10rpx 0;
  365. font-size: 30rpx;
  366. font-family: PingFang SC;
  367. font-weight: bold;
  368. color: #3F7C1F;
  369. line-height: 35rpx;
  370. }
  371. .button {
  372. padding-bottom: 20rpx;
  373. font-size: 26rpx;
  374. font-family: PingFang SC;
  375. font-weight: 500;
  376. color: #3F7C1F;
  377. line-height: 35rpx;
  378. opacity: 0.8;
  379. }
  380. }
  381. .box-price {
  382. display: flex;
  383. align-items: center;
  384. position: absolute;
  385. bottom: 20rpx;
  386. .pricebox {
  387. height: 25rpx;
  388. width: 25rpx;
  389. image {
  390. height: 100%;
  391. width: 100%;
  392. }
  393. }
  394. .price-left {
  395. font-size: 36rpx;
  396. font-family: PingFang SC;
  397. font-weight: bold;
  398. color: #FF0000;
  399. line-height: 35rpx;
  400. }
  401. .price-right {
  402. font-size: 26rpx;
  403. font-family: PingFang SC;
  404. font-weight: 500;
  405. text-decoration: line-through;
  406. color: #999999;
  407. line-height: 35rpx;
  408. }
  409. }
  410. }
  411. }
  412. }
  413. }
  414. </style>