李志伟 3 年前
父节点
当前提交
2f0f219c89
共有 3 个文件被更改,包括 28 次插入17 次删除
  1. 17
    14
      src/pages/index/components/order/index.jsx
  2. 3
    3
      src/pages/index/components/order/style.less
  3. 8
    0
      src/services/banner.js

+ 17
- 14
src/pages/index/components/order/index.jsx 查看文件

1
-import React, { useState } from "react"
1
+import React, { useState , useEffect } from "react"
2
 import Taro from "@tarojs/taro";
2
 import Taro from "@tarojs/taro";
3
 import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView } from "@tarojs/components"
3
 import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView } from "@tarojs/components"
4
 import positionImg from '@/assets/comm/position.png'
4
 import positionImg from '@/assets/comm/position.png'
6
 import orderImg from '@/assets/comm/orderList.png'
6
 import orderImg from '@/assets/comm/orderList.png'
7
 import Footer from "@/components/Footer";
7
 import Footer from "@/components/Footer";
8
 import MyCard from "@/components/MyCard";
8
 import MyCard from "@/components/MyCard";
9
+import { getBannerList } from "@/services/banner";
9
 import './style.less'
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
   const handleSearch = (e) => {
15
   const handleSearch = (e) => {
24
     console.log(e.detail.value)
16
     console.log(e.detail.value)
25
   }
17
   }
26
   const handleMore = () => {
18
   const handleMore = () => {
27
     Taro.navigateTo({ url: '/pages/moreOrder/index' });
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
   return (
32
   return (
30
     <View className='orderIndex'>
33
     <View className='orderIndex'>
31
       <View className='top'>
34
       <View className='top'>
46
             autoplay
49
             autoplay
47
             className='swiper'
50
             className='swiper'
48
           >
51
           >
49
-            {imglist.map((item, inx) => (
52
+            {imgList.map((item, inx) => (
50
               <SwiperItem key={inx}>
53
               <SwiperItem key={inx}>
51
-                <Image src={item.url} mode='widthFix' className='storeImage' />
54
+                <Image src={item.thumb} mode='widthFix' className='storeImage' />
52
               </SwiperItem>
55
               </SwiperItem>
53
             ))}
56
             ))}
54
           </Swiper>
57
           </Swiper>

+ 3
- 3
src/pages/index/components/order/style.less 查看文件

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

+ 8
- 0
src/services/banner.js 查看文件

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