index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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 seckill from '../../components/seckill/seckill.vue';
  92. import { loadIndexs } from '@/api/index.js';
  93. // import { getUserInfo } from '@/api/user.js';
  94. // import { setCoupons } from '@/api/functionalUnit.js';
  95. // import { getBargainList } from '@/api/product.js';
  96. // import { interceptor } from '@/utils/loginUtils';
  97. import {
  98. mapState
  99. } from 'vuex';
  100. export default {
  101. components: {
  102. },
  103. watch: {
  104. //自适应swiper高度
  105. checkid(newValue, oldValue) {
  106. let obj = this;
  107. if (newValue == 0) {
  108. let bHeight = Math.ceil(obj.bastList.length / 2);
  109. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  110. }
  111. if (newValue == 1) {
  112. let bHeight = Math.ceil(obj.goodsList.length / 2);
  113. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  114. }
  115. if (newValue == 2) {
  116. let bHeight = Math.ceil(obj.bastBanner.length / 2);
  117. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  118. }
  119. },
  120. // 初次加载页面高度时修改页面高度
  121. },
  122. data() {
  123. return {
  124. carouselList: [], //轮播列表
  125. couponArray: '',
  126. bastList: [],//精品推荐
  127. }
  128. },
  129. onLoad() {
  130. this.loadData()
  131. },
  132. methods: {
  133. // 请求载入数据
  134. async loadData() {
  135. loadIndexs({})
  136. .then(({ data }) => {
  137. console.log(data,'dddd')
  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. console.log(this.bastList, 'this.bastList6666666666666666666666');
  145. this.bastBanner = data.benefit; //促销单品
  146. this.$set(this, 'couponArray', data.couponList); //保存卡包券
  147. uni.stopPullDownRefresh();
  148. })
  149. .catch(e => {
  150. uni.stopPullDownRefresh();
  151. });
  152. },
  153. swiperClick() {
  154. },
  155. // 点击搜索框
  156. clickSearch() {
  157. console.log('点击')
  158. uni.navigateTo({
  159. url: '/pages/product/search'
  160. });
  161. },
  162. navTo(url) {
  163. uni.navigateTo({
  164. url
  165. })
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. page {
  172. height: auto;
  173. background-color: #D4FDF9;
  174. }
  175. .container {
  176. min-height: 100%;
  177. height: auto;
  178. }
  179. .searchbackground {
  180. position: relative;
  181. .backgroundimg {
  182. position: absolute;
  183. width: 750rpx;
  184. image {
  185. width: 100%;
  186. }
  187. }
  188. }
  189. // .fiexd {
  190. // position: fiexd;
  191. // bottom: 0;
  192. // width: 750rpx;
  193. // height: 750rpx;
  194. // image {
  195. // width: 100%;
  196. // height: 100%;
  197. // }
  198. // }
  199. .content {
  200. flex-direction: column;
  201. justify-content: center;
  202. height: 100%;
  203. .input-box {
  204. position: absolute;
  205. left: 0;
  206. top: 0;
  207. margin: 66rpx 25rpx;
  208. justify-content: center;
  209. background: #FFFFFF;
  210. box-shadow: 0rpx 1rpx 21rpx 0rpx rgba(255, 255, 255, 0.12);
  211. border-radius: 35rpx;
  212. width: 700rpx;
  213. height: 70rpx;
  214. .input {
  215. font-size: 28rpx;
  216. font-family: PingFang SC;
  217. font-weight: 500;
  218. color: #C4C4C4;
  219. line-height: 38rpx;
  220. }
  221. }
  222. .carousel {
  223. margin-top: 165rpx;
  224. width: 700rpx;
  225. height: 370rpx;
  226. .carousel-item {
  227. image {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. .customs {
  234. margin-top: 20rpx;
  235. width: 700rpx;
  236. height: 180rpx;
  237. image {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. }
  242. .customs-content {
  243. position: relative;
  244. padding-top: 14rpx;
  245. .backgroundimg1 {
  246. width: 700rpx;
  247. height: 300rpx;
  248. image {
  249. height: 100%;
  250. width: 100%;
  251. }
  252. }
  253. .box {
  254. position: absolute;
  255. margin-top: -250rpx;
  256. padding: 0 38rpx;
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. .customs-img {
  261. width: 200rpx;
  262. height: 200rpx;
  263. image {
  264. width: 100%;
  265. height: 100%;
  266. }
  267. }
  268. .customstext {
  269. margin-left: 14rpx;
  270. height: 200rpx;
  271. // display: flex;
  272. // flex-direction: column;
  273. // justify-content: space-around;
  274. position: relative;
  275. .customstext1 {
  276. .customstext-title {
  277. width: 350rpx;
  278. font-size: 34rpx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #3F7C1F;
  282. }
  283. .customstext-product {
  284. // margin-top: 25rpx;
  285. width: 400rpx;
  286. padding-top: 10rpx;
  287. font-size: 26rpx;
  288. font-family: PingFang SC;
  289. font-weight: bold;
  290. color: #ABD56F;
  291. }
  292. }
  293. .customsprice {
  294. position: absolute;
  295. bottom: 0;
  296. left: 0;
  297. display: flex;
  298. align-items: center;
  299. justify-content: flex-start;
  300. width: 100%;
  301. .customsprice-left {
  302. font-size: 28rpx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #FF0000;
  306. flex-shrink: 0;
  307. }
  308. .customsprice-between {
  309. font-size: 42rpx;
  310. font-family: PingFang SC;
  311. font-weight: 500;
  312. color: #FF0000;
  313. flex-shrink: 0;
  314. }
  315. .customsprice-right {
  316. text-align: center;
  317. width: 137rpx;
  318. height: 52rpx;
  319. line-height: 52rpx;
  320. background: #3F7C1F;
  321. border-radius: 26rpx;
  322. font-size: 26rpx;
  323. font-family: PingFang SC;
  324. font-weight: 400;
  325. color: #FFFFFF;
  326. position: absolute;
  327. right: 0;
  328. bottom: 0;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. .jifen-content {
  335. width: 700rpx;
  336. padding-bottom: 20rpx;
  337. display: flex;
  338. flex-wrap: wrap;
  339. justify-content: space-between;
  340. .jifen-box {
  341. margin: 20rpx 0;
  342. display: flex;
  343. flex-direction: column;
  344. align-items: center;
  345. width: 342rpx;
  346. height: 512rpx;
  347. padding-top: 20rpx;
  348. background: #E6FCFA;
  349. box-shadow: 0px 7px 10px 1px #8BAFAB;
  350. .img {
  351. flex-shrink: 0;
  352. // margin-top: 20rpx;
  353. height: 312rpx;
  354. width: 312rpx;
  355. background-color: #eee;
  356. image {
  357. height: 100%;
  358. width: 100%;
  359. }
  360. }
  361. .jifen-list {
  362. // margin-left: -80rpx;
  363. width: 312rpx;
  364. height: 100%;
  365. position: relative;
  366. .box-title {
  367. .top {
  368. margin: 20rpx 0 10rpx 0;
  369. // padding: 20rpx 0 10rpx 0;
  370. font-size: 30rpx;
  371. font-family: PingFang SC;
  372. font-weight: bold;
  373. color: #3F7C1F;
  374. line-height: 35rpx;
  375. }
  376. .button {
  377. padding-bottom: 20rpx;
  378. font-size: 26rpx;
  379. font-family: PingFang SC;
  380. font-weight: 500;
  381. color: #3F7C1F;
  382. line-height: 35rpx;
  383. opacity: 0.8;
  384. }
  385. }
  386. .box-price {
  387. display: flex;
  388. align-items: center;
  389. position: absolute;
  390. bottom: 20rpx;
  391. .pricebox {
  392. height: 25rpx;
  393. width: 25rpx;
  394. image {
  395. height: 100%;
  396. width: 100%;
  397. }
  398. }
  399. .price-left {
  400. font-size: 36rpx;
  401. font-family: PingFang SC;
  402. font-weight: bold;
  403. color: #FF0000;
  404. line-height: 35rpx;
  405. }
  406. .price-right {
  407. font-size: 26rpx;
  408. font-family: PingFang SC;
  409. font-weight: 500;
  410. text-decoration: line-through;
  411. color: #999999;
  412. line-height: 35rpx;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. </style>