李志伟 3 лет назад
Родитель
Сommit
2f0f219c89

+ 17
- 14
src/pages/index/components/order/index.jsx Просмотреть файл

@@ -1,4 +1,4 @@
1
-import React, { useState } from "react"
1
+import React, { useState , useEffect } from "react"
2 2
 import Taro from "@tarojs/taro";
3 3
 import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView } from "@tarojs/components"
4 4
 import positionImg from '@/assets/comm/position.png'
@@ -6,26 +6,29 @@ import searchImg from '@/assets/comm/search.png'
6 6
 import orderImg from '@/assets/comm/orderList.png'
7 7
 import Footer from "@/components/Footer";
8 8
 import MyCard from "@/components/MyCard";
9
+import { getBannerList } from "@/services/banner";
9 10
 import './style.less'
10 11
 
11
-export default () => {
12 12
 
13
-  const [swiperImgHeightList, setSwiperImgHeightList] = useState([])
14
-  const [swiperImgWidthList, setSwiperImgWidthList] = useState([])
15
-  const imglist = [
16
-    {
17
-      url: require('@/assets/banner/1.jpg')
18
-    },
19
-    {
20
-      url: require('@/assets/banner/2.jpg')
21
-    },
22
-  ]
13
+export default () => {
14
+  const [imgList,setImgList]=useState([])
23 15
   const handleSearch = (e) => {
24 16
     console.log(e.detail.value)
25 17
   }
26 18
   const handleMore = () => {
27 19
     Taro.navigateTo({ url: '/pages/moreOrder/index' });
28 20
   }
21
+  useEffect(() => {
22
+    getBannerList({ position: 'bannerWorker' })
23
+      .then(res => {
24
+        setImgList(res)
25
+      }).catch(err => {
26
+        Taro.showToast({
27
+          title: '网络异常, 请刷新小程序重试',
28
+          icon: 'none',
29
+        })
30
+      })
31
+  }, [])
29 32
   return (
30 33
     <View className='orderIndex'>
31 34
       <View className='top'>
@@ -46,9 +49,9 @@ export default () => {
46 49
             autoplay
47 50
             className='swiper'
48 51
           >
49
-            {imglist.map((item, inx) => (
52
+            {imgList.map((item, inx) => (
50 53
               <SwiperItem key={inx}>
51
-                <Image src={item.url} mode='widthFix' className='storeImage' />
54
+                <Image src={item.thumb} mode='widthFix' className='storeImage' />
52 55
               </SwiperItem>
53 56
             ))}
54 57
           </Swiper>

+ 3
- 3
src/pages/index/components/order/style.less Просмотреть файл

@@ -14,7 +14,7 @@
14 14
       color: #202020;
15 15
       line-height: 68px;
16 16
       .pImg{
17
-        width: 28px;
17
+        width: 34px;
18 18
         height: 34px;
19 19
         margin-right: 9px;
20 20
       }
@@ -50,11 +50,11 @@
50 50
     }
51 51
   }
52 52
   .swiper {
53
-    height: calc( calc(100vw - 60px) * 0.62);
53
+    height: calc( calc(100vw - 60px) * 0.6);
54 54
     text-align: center;
55 55
     margin: 30px;
56 56
     .storeImage {
57
-      height: 100%;
57
+      width: 100%;
58 58
     }
59 59
   }
60 60
   .orderList{

+ 8
- 0
src/services/banner.js Просмотреть файл

@@ -0,0 +1,8 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+ * banner列表
5
+ * @param {*} 
6
+ * @returns 
7
+ */
8
+ export const getBannerList = (params) => request(`/banner`, { params })