index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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="fugou.image" mode=""></image>
  34. </view>
  35. <view class="customstext">
  36. <view class="customstext1">
  37. <view class="customstext-title clamp">
  38. {{fugou.store_name}}
  39. </view>
  40. <view class="customstext-product clamp">
  41. {{fugou.store_info}}
  42. </view>
  43. </view>
  44. <view class="customsprice">
  45. <view class="customsprice-left">
  46. 健康价:¥
  47. </view>
  48. <view class="customsprice-between">
  49. {{price}}
  50. </view>
  51. <view class="customsprice-right" @click="navTo('/pages/index/fugou')">
  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. fugou:'',//复购商品
  123. price:'',//复购价格
  124. }
  125. },
  126. onLoad() {
  127. this.loadData()
  128. },
  129. methods: {
  130. // 请求载入数据
  131. async loadData() {
  132. loadIndexs({})
  133. .then(({ data }) => {
  134. console.log(data,'dddd')
  135. this.fugou = data.register_order;
  136. this.price = data.register_price;
  137. let goods = data.info;
  138. this.carouselList = data.banner;
  139. this.swiperLength = this.carouselList.length;
  140. this.menusList = data.menus;
  141. this.goodsList = goods.firstList; //最新商品
  142. this.bastList = goods.bastList; //精品推荐
  143. console.log(this.bastList, 'this.bastList6666666666666666666666');
  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. swiperClick() {
  153. },
  154. // 点击搜索框
  155. clickSearch() {
  156. console.log('点击')
  157. uni.navigateTo({
  158. url: '/pages/product/search'
  159. });
  160. },
  161. navTo(url) {
  162. uni.navigateTo({
  163. url
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. page {
  171. height: auto;
  172. background-color: #D4FDF9;
  173. }
  174. .container {
  175. min-height: 100%;
  176. height: auto;
  177. }
  178. .searchbackground {
  179. position: relative;
  180. .backgroundimg {
  181. position: absolute;
  182. width: 750rpx;
  183. image {
  184. width: 100%;
  185. }
  186. }
  187. }
  188. // .fiexd {
  189. // position: fiexd;
  190. // bottom: 0;
  191. // width: 750rpx;
  192. // height: 750rpx;
  193. // image {
  194. // width: 100%;
  195. // height: 100%;
  196. // }
  197. // }
  198. .content {
  199. flex-direction: column;
  200. justify-content: center;
  201. height: 100%;
  202. .input-box {
  203. position: absolute;
  204. left: 0;
  205. top: 0;
  206. margin: 66rpx 25rpx;
  207. justify-content: center;
  208. background: #FFFFFF;
  209. box-shadow: 0rpx 1rpx 21rpx 0rpx rgba(255, 255, 255, 0.12);
  210. border-radius: 35rpx;
  211. width: 700rpx;
  212. height: 70rpx;
  213. .input {
  214. font-size: 28rpx;
  215. font-family: PingFang SC;
  216. font-weight: 500;
  217. color: #C4C4C4;
  218. line-height: 38rpx;
  219. }
  220. }
  221. .carousel {
  222. margin-top: 165rpx;
  223. width: 700rpx;
  224. height: 370rpx;
  225. .carousel-item {
  226. image {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. }
  232. .customs {
  233. margin-top: 20rpx;
  234. width: 700rpx;
  235. height: 180rpx;
  236. image {
  237. width: 100%;
  238. height: 100%;
  239. }
  240. }
  241. .customs-content {
  242. position: relative;
  243. padding-top: 14rpx;
  244. .backgroundimg1 {
  245. width: 700rpx;
  246. height: 300rpx;
  247. image {
  248. height: 100%;
  249. width: 100%;
  250. }
  251. }
  252. .box {
  253. position: absolute;
  254. margin-top: -250rpx;
  255. padding: 0 38rpx;
  256. display: flex;
  257. justify-content: space-between;
  258. align-items: center;
  259. .customs-img {
  260. width: 200rpx;
  261. height: 200rpx;
  262. image {
  263. width: 100%;
  264. height: 100%;
  265. }
  266. }
  267. .customstext {
  268. margin-left: 14rpx;
  269. height: 200rpx;
  270. // display: flex;
  271. // flex-direction: column;
  272. // justify-content: space-around;
  273. position: relative;
  274. .customstext1 {
  275. .customstext-title {
  276. width: 350rpx;
  277. font-size: 34rpx;
  278. font-family: PingFang SC;
  279. font-weight: bold;
  280. color: #3F7C1F;
  281. }
  282. .customstext-product {
  283. // margin-top: 25rpx;
  284. width: 400rpx;
  285. padding-top: 10rpx;
  286. font-size: 26rpx;
  287. font-family: PingFang SC;
  288. font-weight: bold;
  289. color: #ABD56F;
  290. }
  291. }
  292. .customsprice {
  293. position: absolute;
  294. bottom: 0;
  295. left: 0;
  296. display: flex;
  297. align-items: center;
  298. justify-content: flex-start;
  299. width: 100%;
  300. .customsprice-left {
  301. font-size: 28rpx;
  302. font-family: PingFang SC;
  303. font-weight: 500;
  304. color: #FF0000;
  305. flex-shrink: 0;
  306. }
  307. .customsprice-between {
  308. font-size: 42rpx;
  309. font-family: PingFang SC;
  310. font-weight: 500;
  311. color: #FF0000;
  312. flex-shrink: 0;
  313. }
  314. .customsprice-right {
  315. text-align: center;
  316. width: 137rpx;
  317. height: 52rpx;
  318. line-height: 52rpx;
  319. background: #3F7C1F;
  320. border-radius: 26rpx;
  321. font-size: 26rpx;
  322. font-family: PingFang SC;
  323. font-weight: 400;
  324. color: #FFFFFF;
  325. position: absolute;
  326. right: 0;
  327. bottom: 0;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. .jifen-content {
  334. width: 700rpx;
  335. padding-bottom: 20rpx;
  336. display: flex;
  337. flex-wrap: wrap;
  338. justify-content: space-between;
  339. .jifen-box {
  340. margin: 20rpx 0;
  341. display: flex;
  342. flex-direction: column;
  343. align-items: center;
  344. width: 342rpx;
  345. height: 512rpx;
  346. padding-top: 20rpx;
  347. background: #E6FCFA;
  348. box-shadow: 0px 7px 10px 1px #8BAFAB;
  349. .img {
  350. flex-shrink: 0;
  351. // margin-top: 20rpx;
  352. height: 312rpx;
  353. width: 312rpx;
  354. background-color: #eee;
  355. image {
  356. height: 100%;
  357. width: 100%;
  358. }
  359. }
  360. .jifen-list {
  361. // margin-left: -80rpx;
  362. width: 312rpx;
  363. height: 100%;
  364. position: relative;
  365. .box-title {
  366. .top {
  367. margin: 20rpx 0 10rpx 0;
  368. // padding: 20rpx 0 10rpx 0;
  369. font-size: 30rpx;
  370. font-family: PingFang SC;
  371. font-weight: bold;
  372. color: #3F7C1F;
  373. line-height: 35rpx;
  374. }
  375. .button {
  376. padding-bottom: 20rpx;
  377. font-size: 26rpx;
  378. font-family: PingFang SC;
  379. font-weight: 500;
  380. color: #3F7C1F;
  381. line-height: 35rpx;
  382. opacity: 0.8;
  383. }
  384. }
  385. .box-price {
  386. display: flex;
  387. align-items: center;
  388. position: absolute;
  389. bottom: 20rpx;
  390. .pricebox {
  391. height: 25rpx;
  392. width: 25rpx;
  393. image {
  394. height: 100%;
  395. width: 100%;
  396. }
  397. }
  398. .price-left {
  399. font-size: 36rpx;
  400. font-family: PingFang SC;
  401. font-weight: bold;
  402. color: #FF0000;
  403. line-height: 35rpx;
  404. }
  405. .price-right {
  406. font-size: 26rpx;
  407. font-family: PingFang SC;
  408. font-weight: 500;
  409. text-decoration: line-through;
  410. color: #999999;
  411. line-height: 35rpx;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. </style>