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. 15
      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/',
'pages': [
'patrol/index',
'patrolView/index'
'patrolView/index',
'changePassword/index',
'changePassword/success/index'
]
}],
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>
<AtTextarea
count={false}
title='巡查内容:'
placeholder={isView ? '' : '请输入巡查内容'}
value={content}
onChange={(v, e) => handleInput(e, 'content')}
disabled={isView}
maxLength={50}
/>
{
reportType === 'patrol' ?

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

@ -18,13 +18,17 @@ function Index() {
const [isPatrol, setIsPatrol] = useState(true)
const [datePicker, setDatePicker] = useState(moment().format('YYYY-MM-DD'))
const [listData, setListData] = useState([])
const [inputSite, setInputSite] = useState('')
const [page, setPage] = useState(0)
const [total, setTotal] = useState(0)
const [num, setNum] = useState(Math.random())
const [showListData, setShowListData] = useState([])
const [filterText, setFilterText] = 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) {
Taro.showToast({
@ -34,11 +38,17 @@ function Index() {
});
throw new Error(error);
}
useEffect(() => {
request.get(getReportList(), {}, { hideErrorToast: true, hideLoading: true }).then(res => {
const getList = () => {
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) {
// console.log(res);
setListData(res.data)
setShowListData(res.data.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve'))
return res.data;
} else {
dealError(res.data.message || '请求出错');
@ -46,13 +56,11 @@ function Index() {
}, err => {
dealError(err.message || '请求出错');
});
}, [])
}
useDidShow(() => {
let refresh = Taro.getStorageSync('refresh'); //
if (refresh) {
setPage(0)
setNum(Math.random())
Taro.removeStorageSync('refresh'); //
}
Taro.getSystemInfo({
@ -72,25 +80,21 @@ function Index() {
setDatePicker(e.detail.value);
}
const handleConfirm = () => {
setPage(0)
setListData([]);
setTotal(0);
setNum(Math.random())
const handleConfirm = e => {
let nextList = listData.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve')
nextList = nextList.filter(item => item.road.includes(e.detail.value))
setShowListData(nextList)
}
const handleInput = e => {
setInputSite(e.detail.value);
setFilterText(e.detail.value);
if (!e.detail.value) {
setPage(0)
setListData([]);
setTotal(0);
setNum(Math.random())
setShowListData(listData.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve'));
}
}
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 (
@ -109,20 +113,27 @@ function Index() {
<View className='filter-box'>
<View className='filter-item'>
<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>
<Image className='filter-img' src={chevronDown} />
</Picker>
</View>
<View class='head-search'>
<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 style={{ marginTop: '110px' }}>
{
listData && listData.length > 0 ? listData && listData.map((e, index) => {
showListData && showListData.length > 0 ? showListData && showListData.map((e, index) => {
return (
<View className='cardBox' key={index} onClick={() => handleDetail(index)}>
<View className='card-item' >
@ -144,5 +155,4 @@ function Index() {
</View>
)
}
export default Index

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

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

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

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

6
weapp/src/services/api.js

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

Loading…
Cancel
Save