From 14083c32ec306167dd7159cfe295f49e16787104 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Mon, 25 Jul 2022 11:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/actions/auth.js | 2 +- weapp/src/config.js | 2 +- weapp/src/packages/patrolView/index.jsx | 34 +++++++++++++++++++++--- weapp/src/packages/patrolView/index.scss | 8 ++++-- weapp/src/pages/auth/login/login.jsx | 4 +-- weapp/src/pages/user/index.jsx | 2 +- weapp/src/services/api.js | 7 +++-- 7 files changed, 46 insertions(+), 13 deletions(-) diff --git a/weapp/src/actions/auth.js b/weapp/src/actions/auth.js index 5b33a8f2..30fdf382 100644 --- a/weapp/src/actions/auth.js +++ b/weapp/src/actions/auth.js @@ -37,7 +37,7 @@ export const login = (url, data) => { export const logout = (url, data) => { - return request.post(url, data).then(res => { + return request.put(url, data).then(res => { if (res.statusCode == 200 || res.statusCode == 204) { Taro.clearStorage(); return res.data; diff --git a/weapp/src/config.js b/weapp/src/config.js index a50b38d3..71b3443d 100644 --- a/weapp/src/config.js +++ b/weapp/src/config.js @@ -8,7 +8,7 @@ const baseConfig = { }; const development = { - baseUrl: 'https://smartwater.anxinyun.cn/api', + baseUrl: 'https://3024-117-90-36-177.jp.ngrok.io', webUrl: 'https://smartwater.anxinyun.cn', pcode: 'fce4afe2-5b6a-408a-ab18-a2afa7fa027c', imgUrl: 'http://test.resources.anxinyun.cn/', diff --git a/weapp/src/packages/patrolView/index.jsx b/weapp/src/packages/patrolView/index.jsx index ed52ad54..db072309 100644 --- a/weapp/src/packages/patrolView/index.jsx +++ b/weapp/src/packages/patrolView/index.jsx @@ -1,9 +1,11 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import Taro, { useDidShow } from '@tarojs/taro' import { View, Picker, Input, Image } from '@tarojs/components' import moment from 'moment' import './index.scss' import NoData from '@/components/no-data/noData' +import request from '@/services/request' +import { getReportList } from '@/services/api'; import chevronDown from '../../static/img/patrolView/chevron-down.png' import searchIcon from '../../static/img/patrolView/search.png' import cardImg from '../../static/img/patrolView/card-img.png' @@ -22,6 +24,8 @@ function Index() { const [num, setNum] = useState(Math.random()) const [systemInfo, setSystemInfo] = useState('') + const userInfo = Taro.getStorageSync('userInfo') || {}; + const data = [ { place: { @@ -34,6 +38,28 @@ function Index() { } ] + function dealError(error) { + Taro.showToast({ + title: error, + icon: 'none', + duration: 1500 + }); + throw new Error(error); + } + useEffect(() => { + request.get(getReportList(), {}, { hideErrorToast: true, hideLoading: true }).then(res => { + if (res.statusCode == 200) { + console.log(res); + setListData(res.data) + return res.data; + } else { + dealError(res.data.message || '请求出错'); + } + }, err => { + dealError(err.message || '请求出错'); + }); + }, []) + useDidShow(() => { let refresh = Taro.getStorageSync('refresh'); // 返回列表需要刷新 if (refresh) { @@ -102,15 +128,15 @@ function Index() { - + { - data && data.length > 0 ? data && data.map((e, index) => { + listData && listData.length > 0 ? listData && listData.map((e, index) => { return ( handleDetail(index)}> - {e.place.name} + {e.road} 填报人: {e.user.name} diff --git a/weapp/src/packages/patrolView/index.scss b/weapp/src/packages/patrolView/index.scss index fc705a70..7de6c587 100644 --- a/weapp/src/packages/patrolView/index.scss +++ b/weapp/src/packages/patrolView/index.scss @@ -2,6 +2,10 @@ page { background-color: #f6f6f6; .type-box { + position: fixed; + top: 0px; + width: 100%; + z-index: 100; background-color: #fff; height: 80px; display: flex; @@ -20,8 +24,8 @@ page { margin: 0 10px; } } + .line { - width: 1px; height: 30px; background-color: #f6f6f6; @@ -88,7 +92,7 @@ page { .cardBox { width: 690rpx; - margin: 50rpx auto; + margin: 40rpx auto; .card-item { position: relative; diff --git a/weapp/src/pages/auth/login/login.jsx b/weapp/src/pages/auth/login/login.jsx index 70779dc8..5f45438f 100644 --- a/weapp/src/pages/auth/login/login.jsx +++ b/weapp/src/pages/auth/login/login.jsx @@ -18,7 +18,7 @@ const LoginPage = (props) => { const [password, setPassword] = useState(''); const doLogin = () => { - login(getLoginUrl(), { username, password, pcode }).then(res => { + login(getLoginUrl(), { phone: username, password }).then(res => { Taro.reLaunch({ url: '/pages/home/index' }); @@ -50,7 +50,7 @@ const LoginPage = (props) => { 登录 - + diff --git a/weapp/src/pages/user/index.jsx b/weapp/src/pages/user/index.jsx index 299a8eec..b1a7009d 100644 --- a/weapp/src/pages/user/index.jsx +++ b/weapp/src/pages/user/index.jsx @@ -36,7 +36,7 @@ const Index = ({ ...props }) => { - {userInfo.displayName} + {userInfo.name} {userInfo.phone} diff --git a/weapp/src/services/api.js b/weapp/src/services/api.js index 08fe03f8..bc0f6aeb 100644 --- a/weapp/src/services/api.js +++ b/weapp/src/services/api.js @@ -1,13 +1,16 @@ export const getLoginUrl = () => { - return `/login`; + return `/wxLogin`; }; - export const getLogoutUrl = () => { return `/logout`; }; +export const getReportList = () => { + return `/report/list`; +}; + //行业查询 export const getIndustryUrl = () => { return `/elec/business/industry`