Browse Source

修改密码功能

release_0.0.4
liujiangyong 2 years ago
parent
commit
e2f055affa
  1. 4
      weapp/src/app.config.js
  2. 3
      weapp/src/packages/changePassword/index.config.js
  3. 63
      weapp/src/packages/changePassword/index.jsx
  4. 6
      weapp/src/packages/changePassword/index.scss
  5. 3
      weapp/src/packages/changePassword/success/index.config.js
  6. 19
      weapp/src/packages/changePassword/success/index.jsx
  7. 0
      weapp/src/packages/changePassword/success/index.scss
  8. 2
      weapp/src/packages/patrol/index.jsx
  9. 62
      weapp/src/packages/patrolView/index.jsx
  10. 4
      weapp/src/pages/auth/login/login.jsx
  11. 25
      weapp/src/pages/user/index.jsx
  12. 6
      weapp/src/services/api.js

4
weapp/src/app.config.js

@ -8,7 +8,9 @@ export default {
'root': 'packages/', 'root': 'packages/',
'pages': [ 'pages': [
'patrol/index', 'patrol/index',
'patrolView/index' 'patrolView/index',
'changePassword/index',
'changePassword/success/index'
] ]
}], }],
permission: { permission: {

3
weapp/src/packages/changePassword/index.config.js

@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '修改密码'
}

63
weapp/src/packages/changePassword/index.jsx

@ -0,0 +1,63 @@
import React, { useState } from 'react'
import Taro from '@tarojs/taro'
import { View, Input } from '@tarojs/components'
import { AtButton } from 'taro-ui'
import request from '@/services/request'
import { putPassword } from '@/services/api'
import './index.scss'
function Index() {
const userInfo = Taro.getStorageSync('userInfo') || null;
const [password, setPassword] = useState('')
const [password2, setPassword2] = useState('')
function confirm() {
if (!password) {
Taro.showToast({ title: '请输入密码' })
return
} else if (password !== password2) {
Taro.showToast({ title: '两次输入的密码不一致' })
return
} else {
Taro.showModal({
title: '提示',
content: '确定修改吗',
success: function (res) {
if (res.confirm) {
Taro.showLoading({
title: '修改中'
})
request.put(putPassword(userInfo.id), { password }).then(res => {
Taro.hideLoading()
if (res.statusCode == 200 || res.statusCode == 204) {
Taro.removeStorageSync('token')
Taro.removeStorageSync('userInfo')
Taro.reLaunch({ url: '/packages/changePassword/success/index' })
}
})
}
}
})
}
}
return (
<View className='page'>
<View className='phone'>
<View className='title'>手机号码</View>
<Input />
</View>
<View className='pswd'>
<View className='title'>新的密码</View>
<Input value={password} onInput={e => setPassword(e.detail.value)} />
</View>
<View className='pswd'>
<View className='title'>再次输入新的密码</View>
<Input value={password2} onInput={e => setPassword2(e.detail.value)} />
</View>
<AtButton className='btn' type='primary' onClick={confirm}>确认</AtButton>
</View>
)
}
export default Index

6
weapp/src/packages/changePassword/index.scss

@ -0,0 +1,6 @@
.page {
height: 100vh;
width: 100vw;
background-color: #f6f6f6;
}

3
weapp/src/packages/changePassword/success/index.config.js

@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '修改密码'
}

19
weapp/src/packages/changePassword/success/index.jsx

@ -0,0 +1,19 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import { AtButton } from 'taro-ui'
function Index() {
function handleClick() {
Taro.reLaunch({ url: '/pages/auth/login/login' })
}
return (
<View>
修改成功
<AtButton onClick={handleClick}>返回登录</AtButton>
</View>
)
}
export default Index

0
weapp/src/packages/changePassword/success/index.scss

2
weapp/src/packages/patrol/index.jsx

@ -377,12 +377,12 @@ const Index = () => {
</View> </View>
<AtTextarea <AtTextarea
count={false}
title='巡查内容:' title='巡查内容:'
placeholder={isView ? '' : '请输入巡查内容'} placeholder={isView ? '' : '请输入巡查内容'}
value={content} value={content}
onChange={(v, e) => handleInput(e, 'content')} onChange={(v, e) => handleInput(e, 'content')}
disabled={isView} disabled={isView}
maxLength={50}
/> />
{ {
reportType === 'patrol' ? reportType === 'patrol' ?

62
weapp/src/packages/patrolView/index.jsx

@ -18,13 +18,17 @@ function Index() {
const [isPatrol, setIsPatrol] = useState(true) const [isPatrol, setIsPatrol] = useState(true)
const [datePicker, setDatePicker] = useState(moment().format('YYYY-MM-DD')) const [datePicker, setDatePicker] = useState(moment().format('YYYY-MM-DD'))
const [listData, setListData] = useState([]) const [listData, setListData] = useState([])
const [inputSite, setInputSite] = useState('') const [showListData, setShowListData] = useState([])
const [page, setPage] = useState(0) const [filterText, setFilterText] = useState('')
const [total, setTotal] = useState(0)
const [num, setNum] = useState(Math.random())
const [systemInfo, setSystemInfo] = useState('') const [systemInfo, setSystemInfo] = useState('')
const userInfo = Taro.getStorageSync('userInfo') || {}; useEffect(() => {
getList()
}, [datePicker])
useEffect(() => {
setShowListData(listData.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve'))
}, [isPatrol])
function dealError(error) { function dealError(error) {
Taro.showToast({ Taro.showToast({
@ -34,11 +38,17 @@ function Index() {
}); });
throw new Error(error); throw new Error(error);
} }
useEffect(() => { const getList = () => {
request.get(getReportList(), {}, { hideErrorToast: true, hideLoading: true }).then(res => { Taro.showLoading({ title: '加载中' })
request.get(
getReportList(),
{ startTime: datePicker + ' 00:00:00', endTime: datePicker + ' 23:59:59' },
{ hideErrorToast: true, hideLoading: true }
).then(res => {
Taro.hideLoading()
if (res.statusCode == 200) { if (res.statusCode == 200) {
// console.log(res);
setListData(res.data) setListData(res.data)
setShowListData(res.data.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve'))
return res.data; return res.data;
} else { } else {
dealError(res.data.message || '请求出错'); dealError(res.data.message || '请求出错');
@ -46,13 +56,11 @@ function Index() {
}, err => { }, err => {
dealError(err.message || '请求出错'); dealError(err.message || '请求出错');
}); });
}, []) }
useDidShow(() => { useDidShow(() => {
let refresh = Taro.getStorageSync('refresh'); // let refresh = Taro.getStorageSync('refresh'); //
if (refresh) { if (refresh) {
setPage(0)
setNum(Math.random())
Taro.removeStorageSync('refresh'); // Taro.removeStorageSync('refresh'); //
} }
Taro.getSystemInfo({ Taro.getSystemInfo({
@ -72,25 +80,21 @@ function Index() {
setDatePicker(e.detail.value); setDatePicker(e.detail.value);
} }
const handleConfirm = () => { const handleConfirm = e => {
setPage(0) let nextList = listData.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve')
setListData([]); nextList = nextList.filter(item => item.road.includes(e.detail.value))
setTotal(0); setShowListData(nextList)
setNum(Math.random())
} }
const handleInput = e => { const handleInput = e => {
setInputSite(e.detail.value); setFilterText(e.detail.value);
if (!e.detail.value) { if (!e.detail.value) {
setPage(0) setShowListData(listData.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve'));
setListData([]);
setTotal(0);
setNum(Math.random())
} }
} }
const handleDetail = index => { const handleDetail = index => {
Taro.navigateTo({ url: `/packages/patrol/index?type=view&id=${listData[index].id}` }) Taro.navigateTo({ url: `/packages/patrol/index?type=view&id=${showListData[index].id}` })
} }
return ( return (
@ -109,20 +113,27 @@ function Index() {
<View className='filter-box'> <View className='filter-box'>
<View className='filter-item'> <View className='filter-item'>
<View style={{ float: 'left', marginLeft: '20rpx', color: '#333' }}>日期</View> <View style={{ float: 'left', marginLeft: '20rpx', color: '#333' }}>日期</View>
<Picker className='picker' style={{ overflow: 'hidden', float: 'left' }} mode='date' end={(systemInfo == 'windows' || systemInfo == 'mac') ? moment().add(1, 'd').format('YYYY-MM-DD') : moment().format('YYYY-MM-DD')} onChange={onDateChange}> <Picker
className='picker'
style={{ overflow: 'hidden', float: 'left' }}
mode='date'
end={(systemInfo == 'windows' || systemInfo == 'mac')
? moment().add(1, 'd').format('YYYY-MM-DD')
: moment().format('YYYY-MM-DD')} onChange={onDateChange}
>
<View className='filter-name'>{datePicker || '请选择'}</View> <View className='filter-name'>{datePicker || '请选择'}</View>
<Image className='filter-img' src={chevronDown} /> <Image className='filter-img' src={chevronDown} />
</Picker> </Picker>
</View> </View>
<View class='head-search'> <View class='head-search'>
<Image className='search-img' src={searchIcon} /> <Image className='search-img' src={searchIcon} />
<Input class='heard-search-input' value={inputSite} placeholder='请输入场所名称' onConfirm={handleConfirm} onInput={handleInput} /> <Input class='heard-search-input' value={filterText} placeholder='请输入道路名称' onConfirm={handleConfirm} onInput={handleInput} />
</View> </View>
</View> </View>
<View style={{ marginTop: '110px' }}> <View style={{ marginTop: '110px' }}>
{ {
listData && listData.length > 0 ? listData && listData.map((e, index) => { showListData && showListData.length > 0 ? showListData && showListData.map((e, index) => {
return ( return (
<View className='cardBox' key={index} onClick={() => handleDetail(index)}> <View className='cardBox' key={index} onClick={() => handleDetail(index)}>
<View className='card-item' > <View className='card-item' >
@ -144,5 +155,4 @@ function Index() {
</View> </View>
) )
} }
export default Index export default Index

4
weapp/src/pages/auth/login/login.jsx

@ -18,6 +18,10 @@ const LoginPage = (props) => {
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const doLogin = () => { const doLogin = () => {
if (!username || !password) {
Taro.showToast({ title: '请输入账号和密码', icon: 'none' })
return
}
login(getLoginUrl(), { phone: username, password }).then(res => { login(getLoginUrl(), { phone: username, password }).then(res => {
Taro.reLaunch({ Taro.reLaunch({
url: '/pages/home/index' url: '/pages/home/index'

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

@ -17,17 +17,24 @@ const { webUrl } = cfg;
const Index = ({ ...props }) => { const Index = ({ ...props }) => {
const userInfo = Taro.getStorageSync('userInfo') || {}; const userInfo = Taro.getStorageSync('userInfo') || {};
const goRedirect = () => { const changePassword = () => {
Taro.navigateTo({ url: '/packages/changePassword/index' })
} }
const onLogout = () => { const onLogout = () => {
logout(getLogoutUrl()).then(() => { Taro.showModal({
Taro.reLaunch({ title: '提示',
url: '/pages/auth/login/login' content: '确定退出登录吗',
}); success: function (res) {
}); if (res.confirm) {
logout(getLogoutUrl()).then(() => {
Taro.reLaunch({
url: '/pages/auth/login/login'
});
});
}
}
})
} }
return ( return (
@ -48,7 +55,7 @@ const Index = ({ ...props }) => {
<Image className='img' src={moreImg} /> <Image className='img' src={moreImg} />
</View> </View>
<View className='box' onClick={() => goRedirect(2)} style={{ marginTop: '2rpx' }}> <View className='box' onClick={changePassword} style={{ marginTop: '2rpx' }}>
<Image className='box-img' src={pswdImg} /> <Image className='box-img' src={pswdImg} />
<View className='box-txt'>修改密码</View> <View className='box-txt'>修改密码</View>
<Image className='img' src={moreImg} /> <Image className='img' src={moreImg} />

6
weapp/src/services/api.js

@ -24,10 +24,14 @@ export const getReportDetail = id => {
// 删除上报 // 删除上报
export const delReport = id => { export const delReport = id => {
console.log(id)
return `/report/${id}`; return `/report/${id}`;
}; };
// 修改密码
export const putPassword = id => {
return `/department/user/${id}/password`;
};
// 获取道路路段 // 获取道路路段
export const getRoadSection = () => { export const getRoadSection = () => {
return `/road/section`; return `/road/section`;

Loading…
Cancel
Save