张延森 3 vuotta sitten
vanhempi
commit
411f2992da
3 muutettua tiedostoa jossa 44 lisäystä ja 28 poistoa
  1. 14
    14
      src/components/Notice/index.jsx
  2. 18
    13
      src/pages/index/index.jsx
  3. 12
    1
      src/services/dogAPI.js

+ 14
- 14
src/components/Notice/index.jsx Näytä tiedosto

@@ -5,31 +5,31 @@ import noticeIcon from '@/assets/notice.png'
5 5
 import './style.less'
6 6
 
7 7
 export default (props) => {
8
-  const { Notice, onMoreClick, onClick } = props;
8
+  const { NoticeList, onMoreClick, onClick } = props;
9 9
 
10 10
   return (
11 11
     <View className='Notice-box'>
12 12
       <View className='weui-flex notice-item-row'>
13 13
         <View className='weui-flex__item notice-item-title'>
14 14
           <Image src={noticeIcon} mode='widthFix' />
15
-          <Text>消息通知</Text>          
15
+          <Text>消息通知</Text>
16 16
         </View>
17 17
         <View className='weui-flex__item notice-item-ft' onClick={onMoreClick}>
18 18
           查看更多 &gt;
19 19
         </View>
20 20
       </View>
21
-      <View className='weui-flex notice-item-row' onClick={onClick}>
22
-        <View className='weui-flex__item notice-item-bd'>2021年养狗新政策2021年养狗新政策2021年养狗新政策2021年养狗新政策2021年养狗新政策2021年养狗新政策</View>
23
-        <View className='weui-flex__item notice-item-ft'>2022.05.26</View>
24
-      </View>
25
-      <View className='weui-flex notice-item-row' onClick={onClick}>
26
-        <View className='weui-flex__item notice-item-bd'>2021年养狗新政策</View>
27
-        <View className='weui-flex__item notice-item-ft'>2022.05.26</View>
28
-      </View>
29
-      <View className='weui-flex notice-item-row' onClick={onClick}>
30
-        <View className='weui-flex__item notice-item-bd'>2021年养狗新政策</View>
31
-        <View className='weui-flex__item notice-item-ft'>2022.05.26</View>
32
-      </View>
21
+      {
22
+        NoticeList.map((item, index) => {
23
+          return (
24
+            <View className='weui-flex notice-item-row' onClick={() => { onClick(item.noticeId) }} key={index}>
25
+              <View className='weui-flex__item notice-item-bd'>{item.title}</View>
26
+              <View className='weui-flex__item notice-item-ft'>{item.createDate.slice(0, 10)}</View>
27
+            </View>
28
+
29
+          )
30
+        })
31
+      }
32
+
33 33
     </View>
34 34
   )
35 35
 }

+ 18
- 13
src/pages/index/index.jsx Näytä tiedosto

@@ -1,4 +1,4 @@
1
-import { useState } from 'react'
1
+import { useEffect, useState } from 'react'
2 2
 import { View, ScrollView, Text } from '@tarojs/components'
3 3
 import Taro from '@tarojs/taro'
4 4
 import Banner from '@/components/Banner'
@@ -10,6 +10,7 @@ import withBasic from '@/layouts/withBasic'
10 10
 import MenuItem from './components/MenuItem'
11 11
 
12 12
 import './style.less'
13
+import { getNoticeList } from '../../services/dogAPI'
13 14
 
14 15
 const pt16 = {
15 16
   paddingTop: '16px'
@@ -22,26 +23,29 @@ const ml16 = {
22 23
 const IndexPage = (props) => {
23 24
   const { pets, cards } = useModel('userData')
24 25
   const [totalApplyNum, setTotalApplyNum] = useState(0)
25
-
26
+  const [noticeList, setNoticeList] = useState([])
26 27
   const banner = [
27 28
     { imgUrl: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.yd6uU_V7fqswON8cwWUfewHaE7?w=300&h=200&c=7&r=0&o=5&pid=1.7' },
28 29
     { imgUrl: 'https://tse4-mm.cn.bing.net/th/id/OIP-C.A31N2pd7ApUojqrR6x41bwHaFj?pid=ImgDet&rs=1' },
29 30
     { imgUrl: 'https://tse1-mm.cn.bing.net/th/id/R-C.413cf61f5c976cdaddafb30e3aeeb547?rik=AJJ41q9z0C1Anw&riu=http%3a%2f%2ffunpicimg.loveinhere.com%2f1008%2f1%2f4770.jpg&ehk=bP4qnBFW9Ha6lXMKKtVhAnkL2hTHv15pjb5oQpAhF6o%3d&risl=&pid=ImgRaw&r=0' },
30 31
     { imgUrl: 'https://img.zcool.cn/community/01c62e565d10e76ac7253403cbde61.jpg@1280w_1l_2o_100sh.jpg' }
31 32
   ]
32
-  const NoticeList = [
33
-    { text: '我是官方系统通知Notice' },
34
-    { text: '我是第二条通知奥奥奥奥奥奥' },
35
-    { text: '我是第3165656565' },
36
-    { text: '我是第四条通知啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' }
37
-  ]
38 33
   
39
-  const goNoticeList=()=>{
40
-    Taro.navigateTo({url:'/pages/noticeList/index'})
34
+  useEffect(() => {
35
+    getNoticeList({ pageSize: 5 }).then((res) => {
36
+      console.log('res', res);
37
+      setNoticeList(res.records)
38
+    })
39
+  }, [])
40
+
41
+  const goNoticeList = (e) => {
42
+
43
+    Taro.navigateTo({ url: '/pages/noticeList/index' })
41 44
   }
45
+  const goDetail = (id) => {
46
+    console.log("🚀 ~ file: index.jsx ~ line 52 ~ goNoticeList ~ e", e)
42 47
 
43
-  const goDetail = () => {
44
-    Taro.navigateTo({ url: '/pages/noticeInfo/index' })
48
+    Taro.navigateTo({ url: `/pages/noticeInfo/index?id=${id}` })
45 49
   }
46 50
 
47 51
   return (
@@ -111,7 +115,8 @@ const IndexPage = (props) => {
111 115
         </View>
112 116
 
113 117
         <View className='message-box'>
114
-          <Notice onMoreClick={goNoticeList} onClick={goDetail} />
118
+          <Notice NoticeList={noticeList} onMoreClick={goNoticeList} onClick={goDetail} />
119
+
115 120
         </View>
116 121
       </View>
117 122
     </ScrollView>

+ 12
- 1
src/services/dogAPI.js Näytä tiedosto

@@ -95,7 +95,7 @@ export const getDogCardInfo = (id, data) => request(`/card/${id}`, { data, metho
95 95
  * @param {*} data
96 96
  * @returns
97 97
  */
98
- export const getApplicationList = (params) => request(`/application`, { params })
98
+export const getApplicationList = (params) => request(`/application`, { params })
99 99
 
100 100
 
101 101
 /**
@@ -104,3 +104,14 @@ export const getDogCardInfo = (id, data) => request(`/card/${id}`, { data, metho
104 104
 * @returns
105 105
 */
106 106
 export const getDogType = (id, data) => request(`/setting/dog_type`, { data, method: 'GET' })
107
+
108
+
109
+
110
+
111
+
112
+/**
113
+* 消息列表
114
+* @param {*} data
115
+* @returns
116
+*/
117
+export const getNoticeList = (id, data) => request(`/notice?`, { data, method: 'GET' })