提交 c630a5c1 作者: 吴佳伟

fix: 修复bug及修改登录方式为验证码

上级 78020c8b
...@@ -3,7 +3,7 @@ import { otherHttp } from '/@/utils/http/axios' ...@@ -3,7 +3,7 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api { enum Api {
getUserInfo = '/sys/user/login/setting/getUserData', // 查询登录用户信息 getUserInfo = '/sys/user/login/setting/getUserData', // 查询登录用户信息
logout = '/sys/logout', // 登出 logout = '/sys/logout', // 登出
sysLogin = '/sys/mLogin', // 登陆 sysLogin = '/app/user/login', // 登陆
dictList = '/sys/dict/queryAllDictItems', // 获取字典数据 dictList = '/sys/dict/queryAllDictItems', // 获取字典数据
location = '/tianditu/geocode', // 根据经纬度获取地址 location = '/tianditu/geocode', // 根据经纬度获取地址
sysSmsCode = '/app/user/getSmsCode', // 短信验证码 sysSmsCode = '/app/user/getSmsCode', // 短信验证码
......
...@@ -187,7 +187,18 @@ ...@@ -187,7 +187,18 @@
"backgroundColorBottom": "#F2F2F2", "backgroundColorBottom": "#F2F2F2",
"onReachBottomDistance": 50, "onReachBottomDistance": 50,
"app-plus": { "app-plus": {
"titleNView": {} "titleNView": {
"titleSize": "20",
"buttons": [
{
"text": "重置",
"fontSrc": "/static/uni.ttf",
"color": "#fff",
"fontSize": "28rpx",
"width": "auto"
}
]
}
} }
} }
}, },
......
...@@ -61,17 +61,19 @@ ...@@ -61,17 +61,19 @@
isLogin: false, isLogin: false,
loading: false, loading: false,
text: defaultText, text: defaultText,
countdown: 0, // 倒计时秒数
countdownTimer: null, // 倒计时定时器
form: { form: {
rules: [ rules: [
{ {
name: 'username', name: 'username',
rule: ['required'], rule: ['required'],
msg: ['请输入手机号/账号'], msg: ['请输入手机号'],
}, },
{ {
name: 'password', name: 'code',
rule: ['required'], rule: ['required'],
msg: ['请输入码'], msg: ['请输入验证码'],
}, },
{ {
name: 'read', name: 'read',
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
], ],
data: { data: {
username: '', username: '',
password: '', code: '',
read: false, read: false,
deviceId: '', deviceId: '',
}, },
...@@ -97,9 +99,9 @@ ...@@ -97,9 +99,9 @@
// TODO: 开发环境快速填入账户密码,并默认勾选已读隐私政策和服务协议 // TODO: 开发环境快速填入账户密码,并默认勾选已读隐私政策和服务协议
if (isDevMode()) { if (isDevMode()) {
model.form.data.username = 'admin' model.form.data.username = ''
model.form.data.password = 'ZzqEUxdqARrd!aeH' model.form.data.code = ''
model.form.data.read = true model.form.data.read = false
} }
/** /**
...@@ -111,7 +113,7 @@ ...@@ -111,7 +113,7 @@
// 登录参数 // 登录参数
const params = { const params = {
username: model.form.data.username, username: model.form.data.username,
password: model.form.data.password, captcha: model.form.data.code,
} }
// 短信登录 // 短信登录
...@@ -141,6 +143,49 @@ ...@@ -141,6 +143,49 @@
} }
}) })
} }
/**
* 获取验证码
*/
function smsCode() {
form?.value.validator(model.form.data, model.form.rulesPhone).then(async (res: { isPassed: boolean }) => {
if (res.isPassed) {
// 如果已经在倒计时中,不重复发送
if (model.countdown > 0) {
return
}
const params = {
phone: model.form.data.phone,
}
API.sysSmsCode(params)
.then(async (body) => {
console.log('body', body)
// 开始倒计时
startCountdown()
})
.catch(() => {
// 即使请求失败也显示倒计时,防止重复点击
startCountdown()
})
}
})
}
/**
* 开始倒计时
*/
function startCountdown() {
model.countdown = 60
model.countdownTimer = setInterval(() => {
model.countdown--
if (model.countdown <= 0) {
clearInterval(model.countdownTimer)
model.countdownTimer = null
}
}, 1000)
}
/** /**
* 跳转到门户页 * 跳转到门户页
...@@ -232,7 +277,7 @@ ...@@ -232,7 +277,7 @@
:required="false" :required="false"
clearable clearable
trim trim
placeholder="请输入手机号/账号" placeholder="请输入手机号"
v-model="model.form.data.username" v-model="model.form.data.username"
name="mobile" name="mobile"
backgroundColor="transparent" backgroundColor="transparent"
...@@ -247,26 +292,29 @@ ...@@ -247,26 +292,29 @@
</fui-input> </fui-input>
<fui-input <fui-input
height="100rpx" :padding="['20rpx', '32rpx']"
class="input" placeholder="请输入验证码"
password :bottomLeft="0"
autocomplete="new-password" marginTop="10"
code v-model="model.form.data.code"
:required="false"
clearable
trim
placeholder="请输入密码"
v-model="model.form.data.password"
name="code"
marginTop="50"
backgroundColor="transparent" backgroundColor="transparent"
borderColor="#DDDDDD" borderColor="#DDDDDD"
> >
<template #left> <template #left>
<view class="fui-left__icon mr-2"> <view class="fui-left__icon mr-2">
<fui-icon name="lock" color="#333" :size="48" /> <fui-icon name="keyboard" color="#333" :size="48" />
</view> </view>
</template> </template>
<fui-button
width="200rpx"
height="64rpx"
:background="model.countdown > 0 ? '#CCCCCC' : '#67c17a'"
:color="model.countdown > 0 ? '#67c17a' : '#fff'"
@click="smsCode"
:size="28"
:disabled="model.countdown > 0"
:text="model.countdown > 0 ? `${model.countdown}秒后重试` : '获取验证码'"
/>
</fui-input> </fui-input>
<view class="btn__box flex-center p-32rpx box-border"> <view class="btn__box flex-center p-32rpx box-border">
<fui-button <fui-button
......
...@@ -22,11 +22,6 @@ ...@@ -22,11 +22,6 @@
msg: ['请输入手机号'], msg: ['请输入手机号'],
}, },
{ {
name: 'password',
rule: ['required'],
msg: ['请输入密码'],
},
{
name: 'code', name: 'code',
rule: ['required'], rule: ['required'],
msg: ['请输入验证码'], msg: ['请输入验证码'],
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { useDictStore } from '@/store/modules/dict'
import { areaTree } from '@/utils/areaData'
const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
...@@ -95,8 +92,41 @@ ...@@ -95,8 +92,41 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
console.log(dictStore.getDictList) nongjifuwu.cascaderHn().then((res) => {
pageData.options.address = areaTree pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return []
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels.join(' / ')
} }
function getDetails(id) { function getDetails(id) {
...@@ -139,7 +169,7 @@ ...@@ -139,7 +169,7 @@
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.scope = e.text.join('/') pageData.form.scope = e.value.join(',')
pageData.show.address = false pageData.show.address = false
} }
const toastRef = ref() const toastRef = ref()
...@@ -217,16 +247,8 @@ ...@@ -217,16 +247,8 @@
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ form.scope || '请选择省/市/区县' }} {{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }}
</text>
</view>
</view>
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">所在地区</text>
<view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !form.scope }">
{{ form.scope || '请选择省/市/区县' }}
</text> </text>
</view> </view>
</view> </view>
...@@ -240,11 +262,13 @@ ...@@ -240,11 +262,13 @@
/> />
<fui-input <fui-input
required required
type="number"
label="联系方式" label="联系方式"
placeholder="请输入联系方式" placeholder="请输入联系方式"
v-model="form.phone" v-model="form.phone"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
:maxlength="11"
/> />
</view> </view>
<view class="mt20"> <view class="mt20">
...@@ -263,13 +287,13 @@ ...@@ -263,13 +287,13 @@
<view class="time-range"> <view class="time-range">
<view class="time-input" @click="show.time1 = true"> <view class="time-input" @click="show.time1 = true">
<text class="time-text" :class="{ placeholder: !form.startTime }"> <text class="time-text" :class="{ placeholder: !form.startTime }">
{{ form.startTime || '作业开始时间' }} {{ form.startTime || '开始时间' }}
</text> </text>
</view> </view>
<text class="time-separator">-</text> <text class="time-separator">-</text>
<view class="time-input" @click="show.time2 = true"> <view class="time-input" @click="show.time2 = true">
<text class="time-text" :class="{ placeholder: !form.endTime }"> <text class="time-text" :class="{ placeholder: !form.endTime }">
{{ form.endTime || '作业结束时间' }} {{ form.endTime || '结束时间' }}
</text> </text>
</view> </view>
</view> </view>
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { useDictStore } from '@/store/modules/dict'
import { areaTree } from '@/utils/areaData'
const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
...@@ -82,8 +79,41 @@ ...@@ -82,8 +79,41 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
console.log(dictStore.getDictList) nongjifuwu.cascaderHn().then((res) => {
pageData.options.address = areaTree pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return []
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels.join(' / ')
} }
function getDetails(id) { function getDetails(id) {
...@@ -175,7 +205,7 @@ ...@@ -175,7 +205,7 @@
}) })
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.scope = e.text.join('/') pageData.form.scope = e.value.join(',')
pageData.show.address = false pageData.show.address = false
} }
</script> </script>
...@@ -204,8 +234,8 @@ ...@@ -204,8 +234,8 @@
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ form.scope || '请选择省/市/区县' }} {{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }}
</text> </text>
</view> </view>
</view> </view>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { s } from 'vite/dist/node/types.d-aGj9QkWt'
onLoad((option) => { onLoad((option) => {
pageData.search.serviceType = Number(option.type) || 1 pageData.search.serviceType = Number(option.type) || 1
...@@ -17,9 +18,14 @@ ...@@ -17,9 +18,14 @@
getCascader() getCascader()
}) })
const options = ref([])
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
show: {
time: false,
classify: false,
address: false,
},
options: [],
// 分类标签 // 分类标签
categoryTabs: [ categoryTabs: [
{ id: 1, name: '找农机' }, { id: 1, name: '找农机' },
...@@ -29,6 +35,7 @@ ...@@ -29,6 +35,7 @@
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
serviceType: 1, serviceType: 1,
scope: null,
}, },
farmMachineList: [], farmMachineList: [],
total: 0, total: 0,
...@@ -47,9 +54,22 @@ ...@@ -47,9 +54,22 @@
}) })
} }
function search() {
pageData.loading = true
NongjifuwuAPI.farmMachineList(pageData.search)
.then((res) => {
const { records, total } = res
pageData.farmMachineList = records
pageData.total = total
})
.finally(() => {
pageData.loading = false
})
}
function getCascader() { function getCascader() {
NongjifuwuAPI.cascaderHn().then((res) => { NongjifuwuAPI.cascaderHn().then((res) => {
options.value = res[0].children; pageData.options = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
}) })
} }
...@@ -87,8 +107,8 @@ ...@@ -87,8 +107,8 @@
} }
function getScope(scope: any) { function getScope(scope: any) {
if (!scope || !options.value || options.value.length === 0) { if (!scope || !pageData.options || pageData.options.length === 0) {
return [] return ''
} }
const values = scope.split(',') const values = scope.split(',')
...@@ -98,7 +118,7 @@ ...@@ -98,7 +118,7 @@
const findLabel = (nodes, value) => { const findLabel = (nodes, value) => {
for (const node of nodes) { for (const node of nodes) {
if (node.value === value) { if (node.value === value) {
return node.label return node.text
} }
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value) const found = findLabel(node.children, value)
...@@ -111,13 +131,26 @@ ...@@ -111,13 +131,26 @@
} }
for (const value of values) { for (const value of values) {
const label = findLabel(options.value, value.trim()) const text = findLabel(pageData.options, value.trim())
labels.push(label) labels.push(text)
} }
return labels.join(' / ') return labels ? labels.join(' / ') : ''
}
function handleChangeAddress(e) {
pageData.search.scope = e.value.join(',')
pageData.show.address = false
// 触发搜索
search()
} }
onNavigationBarButtonTap(() => {
pageData.search.scope = null
search()
})
onReachBottom(() => { onReachBottom(() => {
console.log('触底了') console.log('触底了')
if (pageData.total <= pageData.farmMachineList.length) return if (pageData.total <= pageData.farmMachineList.length) return
...@@ -131,8 +164,8 @@ ...@@ -131,8 +164,8 @@
<view class="codefun-flex-col group_2"> <view class="codefun-flex-col group_2">
<view class="codefun-flex-row codefun-justify-between section_2"> <view class="codefun-flex-row codefun-justify-between section_2">
<text class="font_2 text_2">服务区域</text> <text class="font_2 text_2">服务区域</text>
<view class="codefun-flex-row codefun-items-center"> <view class="codefun-flex-row codefun-items-center" @click="pageData.show.address = true">
<text class="font_2 text_3">选择市县乡镇</text> <text class="font_2 text_3">{{ getScope(pageData.search.scope) || '选择区域' }}</text>
<image <image
class="codefun-shrink-0 image_7 codefun-ml-4" class="codefun-shrink-0 image_7 codefun-ml-4"
src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png" src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png"
...@@ -316,6 +349,14 @@ ...@@ -316,6 +349,14 @@
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<fui-picker
:show="pageData.show.address"
:options="pageData.options"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="pageData.show.address = false"
/>
<ApplyDialog ref="applyDialogRef" /> <ApplyDialog ref="applyDialogRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论