Browse Source

接口接入

release_0.0.1
liujiangyong 3 years ago
parent
commit
14083c32ec
  1. 2
      weapp/src/actions/auth.js
  2. 2
      weapp/src/config.js
  3. 34
      weapp/src/packages/patrolView/index.jsx
  4. 8
      weapp/src/packages/patrolView/index.scss
  5. 4
      weapp/src/pages/auth/login/login.jsx
  6. 2
      weapp/src/pages/user/index.jsx
  7. 7
      weapp/src/services/api.js

2
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;

2
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/',

34
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() {
</View>
</View>
<View style={{ marginTop: '70px' }}>
<View style={{ marginTop: '110px' }}>
{
data && data.length > 0 ? data && data.map((e, index) => {
listData && listData.length > 0 ? listData && listData.map((e, index) => {
return (
<View className='cardBox' key={index} onClick={() => handleDetail(index)}>
<View className='card-item' >
<Image className='card-bg' src={cardImg} />
<View className='card-position'>
<View className='card-title'>{e.place.name}</View>
<View className='card-title'>{e.road}</View>
<View style={{ float: 'left', width: '100%', fontSize: '28rpx', marginTop: '16rpx' }}>
<View style={{ float: 'left' }}>填报人</View>
<View style={{ float: 'left' }}>{e.user.name}</View>

8
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;

4
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) => {
<View className='form-label'>登录</View>
<View className='form-input'>
<Image className='icon-phone' src={PhoneIcon}></Image>
<Input name='username' value={username} placeholder='请输入账号' onInput={handleUsernameChange} />
<Input name='username' value={username} placeholder='请输入账号' maxlength={11} onInput={handleUsernameChange} />
</View>
</View>
<View className='form-item'>

2
weapp/src/pages/user/index.jsx

@ -36,7 +36,7 @@ const Index = ({ ...props }) => {
<View className='my-top'>
<Image className='my-portrait' src={headImg} />
<View className='my-item'>
<View className='my-username'>{userInfo.displayName}</View>
<View className='my-username'>{userInfo.name}</View>
<View className='my-phone'>{userInfo.phone}</View>
</View>
</View>

7
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`

Loading…
Cancel
Save