1、前端页面工具模块手机归属地、实时天气、预报天气功能实现
This commit is contained in:
parent
a88db36285
commit
3cddc54fad
|
|
@ -34,3 +34,33 @@ export function getIdCardQuery(idCard) {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取手机归属地信息
|
||||||
|
export function getMobileBelong(mobile) {
|
||||||
|
return request({
|
||||||
|
url: '/openapi/apitools/mobilebelong/'+mobile,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取实时天气信息
|
||||||
|
export function getNowWeather(city) {
|
||||||
|
return request({
|
||||||
|
url: '/openapi/apitools/nowweather/'+city,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取预报天气信息
|
||||||
|
export function getForecastWeather(city) {
|
||||||
|
return request({
|
||||||
|
url: '/openapi/apitools/forecastweather/'+city,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
v-loading="loading1"
|
v-loading="loading1"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
width="400"
|
width="400"
|
||||||
|
trigger="manual"
|
||||||
v-model="holidayVisible">
|
v-model="holidayVisible">
|
||||||
|
|
||||||
<div v-for="data in holidayData" v-loading="loading1">
|
<div v-for="data in holidayData" v-loading="loading1">
|
||||||
<span> {{ data.holidayName }} </span>
|
<span> {{ data.holidayName }} </span>
|
||||||
<span> ------ </span>
|
<span> ------ </span>
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
<span>还剩 <span style="color: red">{{ data.residueDays }}</span> 天</span>
|
<span>还剩 <span style="color: red">{{ data.residueDays }}</span> 天</span>
|
||||||
<el-divider><i class="el-icon-chat-round"></i></el-divider>
|
<el-divider><i class="el-icon-chat-round"></i></el-divider>
|
||||||
</div>
|
</div>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="getHoliday()" slot="reference">
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="getHoliday()" slot="reference">
|
||||||
搜索
|
搜索
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -44,12 +46,15 @@
|
||||||
v-loading="loading2"
|
v-loading="loading2"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
width="988"
|
width="988"
|
||||||
|
trigger="manual"
|
||||||
v-model="beautyPictureVisible">
|
v-model="beautyPictureVisible">
|
||||||
<el-image v-for="data in BeautyPictureData" v-loading="loading2"
|
<el-image v-for="data in BeautyPictureData" v-loading="loading2"
|
||||||
style="width: 192px; height: 108px"
|
style="width: 192px; height: 108px"
|
||||||
:src="data.imageUrl"
|
:src="data.imageUrl"
|
||||||
:preview-src-list="pictureList">
|
:preview-src-list="pictureList">
|
||||||
</el-image>
|
</el-image>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="getBeautyPicture()"
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="getBeautyPicture()"
|
||||||
slot="reference">搜索
|
slot="reference">搜索
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -67,6 +72,7 @@
|
||||||
v-loading="loading3"
|
v-loading="loading3"
|
||||||
placement="right"
|
placement="right"
|
||||||
width="400"
|
width="400"
|
||||||
|
trigger="manual"
|
||||||
v-model="historyTodayVisible">
|
v-model="historyTodayVisible">
|
||||||
|
|
||||||
<div v-for="data in historyTodayData" v-loading="loading3">
|
<div v-for="data in historyTodayData" v-loading="loading3">
|
||||||
|
|
@ -79,7 +85,8 @@
|
||||||
</span>
|
</span>
|
||||||
<el-divider><i class="el-icon-chat-round"></i></el-divider>
|
<el-divider><i class="el-icon-chat-round"></i></el-divider>
|
||||||
</div>
|
</div>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
<el-button type="primary" icon="el-icon-search" @click="getHistoryToday()" size="mini"
|
<el-button type="primary" icon="el-icon-search" @click="getHistoryToday()" size="mini"
|
||||||
slot="reference">搜索
|
slot="reference">搜索
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -98,9 +105,9 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-popover
|
<el-popover
|
||||||
v-loading="loading4"
|
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
width="300"
|
width="300"
|
||||||
|
trigger="manual"
|
||||||
v-model="idCardVisible">
|
v-model="idCardVisible">
|
||||||
<el-card shadow="hover" v-loading="loading4">
|
<el-card shadow="hover" v-loading="loading4">
|
||||||
<div style="font-size: 12px">
|
<div style="font-size: 12px">
|
||||||
|
|
@ -118,6 +125,8 @@
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
<el-button type="primary" @click="getIdCardQuery('idCardForm')" slot="reference">搜索</el-button>
|
<el-button type="primary" @click="getIdCardQuery('idCardForm')" slot="reference">搜索</el-button>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -137,36 +146,111 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<div class="table2_col">
|
<div class="table2_col">
|
||||||
|
|
||||||
<div class="table2_col_div">
|
<div class="table2_col_div">
|
||||||
<el-form :inline="true" class="">
|
<el-form :inline="true" :rules="rules" :model="mobileBelongForm" ref="mobileBelongForm">
|
||||||
<el-form-item label="手机归属地" label-width="100px">
|
<el-form-item label="手机归属地" label-width="100px" prop="mobile">
|
||||||
<el-input placeholder="请输入手机号码"></el-input>
|
<el-input v-model="mobileBelongForm.mobile" placeholder="请输入手机号码"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary">搜索</el-button>
|
<el-popover
|
||||||
|
placement="bottom"
|
||||||
|
width="220"
|
||||||
|
trigger="manual"
|
||||||
|
v-model="mobileBelongVisible">
|
||||||
|
<div v-loading="loading5">
|
||||||
|
<el-result icon="info" title="手机归属地" :subTitle="mobileBelongData.carrier">
|
||||||
|
</el-result>
|
||||||
|
</div>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
|
<el-button type="primary" slot="reference" @click="getMobileBelong('mobileBelongForm')">搜索</el-button>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table2_col_div">
|
<div class="table2_col_div">
|
||||||
<el-form :inline="true" class="">
|
<el-form :inline="true" :rules="rules" :model="nowWeatherForm" ref="nowWeatherForm">
|
||||||
<el-form-item label="实时天气" label-width="100px">
|
<el-form-item label="实时天气" label-width="100px" prop="city">
|
||||||
<el-input placeholder="请输入城市名称"></el-input>
|
<el-input v-model="nowWeatherForm.city" placeholder="请输入城市名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary">搜索</el-button>
|
<el-popover
|
||||||
|
placement="bottom"
|
||||||
|
width="250"
|
||||||
|
trigger="manual"
|
||||||
|
v-model="nowWeatherVisible">
|
||||||
|
<div v-loading="loading6">
|
||||||
|
<span>地理位置:{{ nowWeatherData.address }}</span><br>
|
||||||
|
<span>空气湿度:<span style="color: red">{{ nowWeatherData.humidity }}</span></span><br>
|
||||||
|
<span>实时温度:<span style="color: red">{{ nowWeatherData.temp }}</span></span><br>
|
||||||
|
<span>实时风力:{{ nowWeatherData.winddirection }} {{ nowWeatherData.windpower }}</span><br>
|
||||||
|
<span>
|
||||||
|
<img :src="weather"
|
||||||
|
style="width: 30px;height: 30px;float: left;">
|
||||||
|
<span style="margin-left:40px;float: left;width: 30px;height: 30px; line-height: 30px;color: red">{{
|
||||||
|
nowWeatherData.weather
|
||||||
|
}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
|
<el-button type="primary" slot="reference" @click="getNowWeather('nowWeatherForm')">搜索</el-button>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table2_col_div">
|
<div class="table2_col_div">
|
||||||
<el-form :inline="true" class="">
|
<el-form :inline="true" :rules="rules" :model="forecastWeatherForm" ref="forecastWeatherForm">
|
||||||
<el-form-item label="预报天气" label-width="100px">
|
<el-form-item label="预报天气" label-width="100px" prop="city">
|
||||||
<el-input placeholder="请输入城市名称"></el-input>
|
<el-input v-model="forecastWeatherForm.city" placeholder="请输入城市名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary">搜索</el-button>
|
<el-popover
|
||||||
|
placement="left"
|
||||||
|
width="300"
|
||||||
|
trigger="manual"
|
||||||
|
v-model="forecastWeatherVisible">
|
||||||
|
<div v-loading="loading7">
|
||||||
|
<el-card shadow="hover">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>{{ forecastWeatherData.address }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-for="(data,index) in forecastWeatherData.forecasts">
|
||||||
|
<ul style="margin: 0 0; padding: 0 0 0 10px; list-style-type: none">
|
||||||
|
<li>
|
||||||
|
<span v-if="index===0">
|
||||||
|
今天({{data.dayOfWeek}})
|
||||||
|
</span>
|
||||||
|
<span v-if="index===1">
|
||||||
|
明天({{data.dayOfWeek}})
|
||||||
|
</span>
|
||||||
|
<span v-if="index===2">
|
||||||
|
后天({{data.dayOfWeek}})
|
||||||
|
</span>
|
||||||
|
<span v-if="index===3">
|
||||||
|
大后({{data.dayOfWeek}})
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span style="color: red;margin-left: 10px;margin-right: 10px">
|
||||||
|
{{data.nighttemp}}~{{data.daytemp}}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{data.dayweather}}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
<el-button @click="close" icon="el-icon-close" circle plain size="mini"
|
||||||
|
style="float: right"></el-button>
|
||||||
|
<el-button type="primary" slot="reference"
|
||||||
|
@click="getForecastWeather('forecastWeatherForm')">搜索
|
||||||
|
</el-button>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -213,7 +297,17 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {getHoliday, getHistoryToday, getBeautyPicture, getIdCardQuery} from "@/api/business/openapi/apitools";
|
import {
|
||||||
|
getHoliday,
|
||||||
|
getHistoryToday,
|
||||||
|
getBeautyPicture,
|
||||||
|
getIdCardQuery,
|
||||||
|
getMobileBelong,
|
||||||
|
getNowWeather,
|
||||||
|
getForecastWeather,
|
||||||
|
} from "@/api/business/openapi/apitools";
|
||||||
|
|
||||||
|
import weather from "@/assets/icons/weather/天气.png"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Apitools",
|
name: "Apitools",
|
||||||
|
|
@ -226,12 +320,24 @@ export default {
|
||||||
pictureList: [], //单独存放图片路径
|
pictureList: [], //单独存放图片路径
|
||||||
historyTodayData: [],
|
historyTodayData: [],
|
||||||
idCardData: {},
|
idCardData: {},
|
||||||
|
mobileBelongData: {},
|
||||||
|
nowWeatherData: {},
|
||||||
|
forecastWeatherData: {},
|
||||||
|
|
||||||
|
|
||||||
//-------------input框数据-------------------
|
//-------------input框数据-------------------
|
||||||
idCardForm: {
|
idCardForm: {
|
||||||
idCard: ''
|
idCard: ''
|
||||||
},
|
},
|
||||||
|
mobileBelongForm: {
|
||||||
|
mobile: ''
|
||||||
|
},
|
||||||
|
nowWeatherForm: {
|
||||||
|
city: ''
|
||||||
|
},
|
||||||
|
forecastWeatherForm: {
|
||||||
|
city: ''
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
//------------控制弹出显示隐藏-----------------
|
//------------控制弹出显示隐藏-----------------
|
||||||
|
|
@ -239,6 +345,9 @@ export default {
|
||||||
beautyPictureVisible: false,
|
beautyPictureVisible: false,
|
||||||
historyTodayVisible: false,
|
historyTodayVisible: false,
|
||||||
idCardVisible: false,
|
idCardVisible: false,
|
||||||
|
mobileBelongVisible: false,
|
||||||
|
nowWeatherVisible: false,
|
||||||
|
forecastWeatherVisible: false,
|
||||||
|
|
||||||
|
|
||||||
//----------------遮罩层-------------------
|
//----------------遮罩层-------------------
|
||||||
|
|
@ -246,16 +355,33 @@ export default {
|
||||||
loading2: false,
|
loading2: false,
|
||||||
loading3: false,
|
loading3: false,
|
||||||
loading4: false,
|
loading4: false,
|
||||||
|
loading5: false,
|
||||||
|
loading6: false,
|
||||||
|
loading7: false,
|
||||||
|
loading8: false,
|
||||||
|
loading9: false,
|
||||||
|
loading10: false,
|
||||||
|
|
||||||
|
|
||||||
//---------------校验规则--------------------
|
//---------------校验规则--------------------
|
||||||
rules: {
|
rules: {
|
||||||
idCard: [
|
idCard: [
|
||||||
{required: true, message: '请输入身份证号!!!', trigger: 'blur'},
|
{required: true, message: '请输入身份证号!!!', trigger: 'blur'},
|
||||||
|
{required: true, validator: this.validatorIdNum, trigger: 'blur'},
|
||||||
],
|
],
|
||||||
}
|
mobile: [
|
||||||
|
{required: true, message: '请输入手机号码!!!', trigger: 'blur'},
|
||||||
|
{required: true, validator: this.validatorPhone, trigger: 'blur'},
|
||||||
|
],
|
||||||
|
city: [
|
||||||
|
{required: true, message: '请输入地名!!!', trigger: 'blur'},
|
||||||
|
]
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//----------------其他参数-------------------
|
||||||
|
weather,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -265,10 +391,105 @@ export default {
|
||||||
,
|
,
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
//获取预报天气信息
|
||||||
|
getForecastWeather(forecastWeatherForm) {
|
||||||
|
this.$refs[forecastWeatherForm].validate((valid) => {
|
||||||
|
this.forecastWeatherData = {}
|
||||||
|
if (valid) {
|
||||||
|
this.loading7 = true
|
||||||
|
getForecastWeather(this.forecastWeatherForm.city).then(res => {
|
||||||
|
this.loading7 = false
|
||||||
|
this.forecastWeatherVisible = true
|
||||||
|
this.forecastWeatherData = res.data
|
||||||
|
}).catch(err => {
|
||||||
|
this.loading7 = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
//获取实时天气信息
|
||||||
|
getNowWeather(nowWeatherForm) {
|
||||||
|
this.$refs[nowWeatherForm].validate((valid) => {
|
||||||
|
this.nowWeatherData = {}
|
||||||
|
if (valid) {
|
||||||
|
this.loading6 = true
|
||||||
|
getNowWeather(this.nowWeatherForm.city).then(res => {
|
||||||
|
this.loading6 = false
|
||||||
|
this.nowWeatherVisible = true
|
||||||
|
this.nowWeatherData = res.data
|
||||||
|
}).catch(err => {
|
||||||
|
this.loading6 = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//自定义rules校验方法:手机号校验
|
||||||
|
validatorPhone(rule, value, callback) {
|
||||||
|
if (value === '') {
|
||||||
|
callback(new Error('手机号不能为空'))
|
||||||
|
} else if (!/^1\d{10}$/.test(value)) {
|
||||||
|
callback(new Error('手机号格式错误'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//自定义rules校验方法:身份证校验
|
||||||
|
validatorIdNum(rule, value, callback) {
|
||||||
|
const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
|
||||||
|
if (!value) {
|
||||||
|
return callback(new Error('证件号码不能为空'))
|
||||||
|
} else if (!reg.test(value)) {
|
||||||
|
return callback(new Error('证件号码不正确'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
//关闭窗口
|
||||||
|
close() {
|
||||||
|
this.mobileBelongVisible = false;
|
||||||
|
this.idCardVisible = false;
|
||||||
|
this.historyTodayVisible = false;
|
||||||
|
this.beautyPictureVisible = false;
|
||||||
|
this.holidayVisible = false;
|
||||||
|
this.nowWeatherVisible = false;
|
||||||
|
this.forecastWeatherVisible = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
//获取手机归属地信息
|
||||||
|
getMobileBelong(mobileBelongForm) {
|
||||||
|
this.$refs[mobileBelongForm].validate((valid) => {
|
||||||
|
this.mobileBelongData = {}
|
||||||
|
if (valid) {
|
||||||
|
this.mobileBelongVisible = true
|
||||||
|
this.loading5 = true
|
||||||
|
getMobileBelong(this.mobileBelongForm.mobile).then(res => {
|
||||||
|
this.loading5 = false
|
||||||
|
this.mobileBelongData = res.data
|
||||||
|
}).catch(err => {
|
||||||
|
this.loading5 = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
//获取身份证信息
|
//获取身份证信息
|
||||||
getIdCardQuery(idCardForm) {
|
getIdCardQuery(idCardForm) {
|
||||||
this.$refs[idCardForm].validate((valid) => {
|
this.$refs[idCardForm].validate((valid) => {
|
||||||
|
this.idCardData = {}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
this.idCardVisible = true
|
||||||
this.loading4 = true
|
this.loading4 = true
|
||||||
getIdCardQuery(this.idCardForm.idCard).then(res => {
|
getIdCardQuery(this.idCardForm.idCard).then(res => {
|
||||||
this.loading4 = false
|
this.loading4 = false
|
||||||
|
|
@ -280,37 +501,37 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
//获取历史今天数据信息
|
//获取历史今天数据信息
|
||||||
getHistoryToday() {
|
getHistoryToday() {
|
||||||
this.loading3 = true
|
this.loading3 = true
|
||||||
|
this.historyTodayVisible = true
|
||||||
getHistoryToday().then(res => {
|
getHistoryToday().then(res => {
|
||||||
this.loading3 = false
|
this.loading3 = false
|
||||||
this.historyTodayData = res.data
|
this.historyTodayData = res.data
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.loading3 = false
|
this.loading3 = false
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
//获取节假日信息
|
//获取节假日信息
|
||||||
getHoliday() {
|
getHoliday() {
|
||||||
this.loading1 = true
|
this.loading1 = true
|
||||||
|
this.holidayVisible = true
|
||||||
getHoliday().then(res => {
|
getHoliday().then(res => {
|
||||||
this.loading1 = false
|
this.loading1 = false
|
||||||
this.holidayData = res.data
|
this.holidayData = res.data
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.loading3 = false
|
this.loading3 = false
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
//获取mm图片信息
|
//获取mm图片信息
|
||||||
getBeautyPicture() {
|
getBeautyPicture() {
|
||||||
this.loading2 = true
|
this.loading2 = true
|
||||||
this.pictureList = []
|
this.pictureList = []
|
||||||
|
this.beautyPictureVisible = true
|
||||||
getBeautyPicture().then(res => {
|
getBeautyPicture().then(res => {
|
||||||
this.loading2 = false
|
this.loading2 = false
|
||||||
this.BeautyPictureData = res.data
|
this.BeautyPictureData = res.data
|
||||||
|
|
@ -321,8 +542,7 @@ export default {
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.loading3 = false
|
this.loading3 = false
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.xjs.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 星期处理工具类
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-21
|
||||||
|
*/
|
||||||
|
public class WeekUtils {
|
||||||
|
|
||||||
|
public static String weekConvert(String week) {
|
||||||
|
switch (week) {
|
||||||
|
case "1":
|
||||||
|
week="周一";
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
week="周二";
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
week="周三";
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
week="周四";
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
week="周五";
|
||||||
|
break;
|
||||||
|
case "6":
|
||||||
|
week="周六";
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
|
week="周日";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return week;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -43,11 +43,11 @@ public class ApiToolsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("mobilebelong")
|
@GetMapping("mobilebelong/{mobile}")
|
||||||
@ApiOperation("获取手机归属地信息")
|
@ApiOperation("获取手机归属地信息")
|
||||||
@Log(title = "获取手机归属地")
|
@Log(title = "获取手机归属地")
|
||||||
@RequiresPermissions("open:apitools:mobilebelong")
|
@RequiresPermissions("open:apitools:mobilebelong")
|
||||||
public R<ApiMobileBelong> getMobileBelongApiData(@RequestParam(name = "mobile") String mobile) {
|
public R<ApiMobileBelong> getMobileBelongApiData(@PathVariable("mobile") String mobile) {
|
||||||
boolean matches = Pattern.matches(MOBILE_REGEX, mobile);
|
boolean matches = Pattern.matches(MOBILE_REGEX, mobile);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
return R.fail("请输入正确的手机号码!!!");
|
return R.fail("请输入正确的手机号码!!!");
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
import com.xjs.apitools.factory.impl.*;
|
import com.xjs.apitools.factory.impl.*;
|
||||||
import com.xjs.apitools.service.ApiToolsService;
|
import com.xjs.apitools.service.ApiToolsService;
|
||||||
import com.xjs.exception.ApiException;
|
import com.xjs.exception.ApiException;
|
||||||
|
import com.xjs.utils.WeekUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -18,7 +19,6 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,7 +33,7 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
/**
|
/**
|
||||||
* 文件单位
|
* 文件单位
|
||||||
*/
|
*/
|
||||||
public static final String KB= "KB";
|
public static final String KB = "KB";
|
||||||
|
|
||||||
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
||||||
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
||||||
|
|
@ -41,19 +41,19 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
private ApiToolsFactory<ApiForecastWeather, RequestBody> forecastWeatherFactory;
|
private ApiToolsFactory<ApiForecastWeather, RequestBody> forecastWeatherFactory;
|
||||||
private ApiToolsFactory<ApiGarbageSorting, RequestBody> garbageSortingFactory;
|
private ApiToolsFactory<ApiGarbageSorting, RequestBody> garbageSortingFactory;
|
||||||
private ApiToolsFactory<ApiBeautyPicture, Object> beautyPictureFactory;
|
private ApiToolsFactory<ApiBeautyPicture, Object> beautyPictureFactory;
|
||||||
private ApiToolsFactory<ApiHistoryToday,Object> historyTodayFactory;
|
private ApiToolsFactory<ApiHistoryToday, Object> historyTodayFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("rollSimpleComplexFactory")
|
@Qualifier("rollSimpleComplexFactory")
|
||||||
private ApiToolsFactory<ApiSimpleComplex,RequestBody> simpleComplexFactory;
|
private ApiToolsFactory<ApiSimpleComplex, RequestBody> simpleComplexFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("rollChineseDictFactory")
|
@Qualifier("rollChineseDictFactory")
|
||||||
private ApiToolsFactory<ApiChineseDict,RequestBody> chineseDictFactory;
|
private ApiToolsFactory<ApiChineseDict, RequestBody> chineseDictFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("rollIdcardQueryFactory")
|
@Qualifier("rollIdcardQueryFactory")
|
||||||
private ApiToolsFactory<ApiIdcardQuery,RequestBody> idcardQueryFactory;
|
private ApiToolsFactory<ApiIdcardQuery, RequestBody> idcardQueryFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setHolidayFactory(RollHolidayFactory rollHolidayFactory) {
|
public void setHolidayFactory(RollHolidayFactory rollHolidayFactory) {
|
||||||
|
|
@ -94,7 +94,9 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
@Override
|
@Override
|
||||||
public List<ApiHoliday> getApiHolidayList() {
|
public List<ApiHoliday> getApiHolidayList() {
|
||||||
List<ApiHoliday> apiHolidayList = holidayFactory.apiDataList();
|
List<ApiHoliday> apiHolidayList = holidayFactory.apiDataList();
|
||||||
Optional.ofNullable(apiHolidayList).orElseThrow(ApiException::new);
|
if (CollUtil.isEmpty(apiHolidayList)) {
|
||||||
|
throw new ApiException("获取的节假日数据为空");
|
||||||
|
}
|
||||||
List<ApiHoliday> collect = apiHolidayList.stream().map(holidayFactory -> {
|
List<ApiHoliday> collect = apiHolidayList.stream().map(holidayFactory -> {
|
||||||
if (holidayFactory.getResidueDays() >= 0) {
|
if (holidayFactory.getResidueDays() >= 0) {
|
||||||
if (holidayFactory.getLunarHoliday()) {
|
if (holidayFactory.getLunarHoliday()) {
|
||||||
|
|
@ -102,7 +104,7 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
DateTime lunarDate = DateUtil.parseDate(holidayFactory.getLunarDate());
|
DateTime lunarDate = DateUtil.parseDate(holidayFactory.getLunarDate());
|
||||||
ChineseDate chineseDate = new ChineseDate(lunarDate.toJdkDate());
|
ChineseDate chineseDate = new ChineseDate(lunarDate.toJdkDate());
|
||||||
holidayFactory.setReturnDate(chineseDate.toString());
|
holidayFactory.setReturnDate(chineseDate.toString());
|
||||||
}else {
|
} else {
|
||||||
holidayFactory.setReturnDate(holidayFactory.getDate());
|
holidayFactory.setReturnDate(holidayFactory.getDate());
|
||||||
}
|
}
|
||||||
return holidayFactory;
|
return holidayFactory;
|
||||||
|
|
@ -118,47 +120,65 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
public ApiMobileBelong getApiMobileBelong(String mobile) {
|
public ApiMobileBelong getApiMobileBelong(String mobile) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setMobile(mobile);
|
requestBody.setMobile(mobile);
|
||||||
return Optional.ofNullable(mobileBelongFactory.apiData(requestBody))
|
ApiMobileBelong apiMobileBelong = mobileBelongFactory.apiData(requestBody);
|
||||||
.orElseThrow(ApiException::new);
|
if (Objects.isNull(apiMobileBelong)) {
|
||||||
|
throw new ApiException("获取的手机归属地数据为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(apiMobileBelong.getCarrier())) {
|
||||||
|
apiMobileBelong.setCarrier("未找到,请重试");
|
||||||
|
}
|
||||||
|
return apiMobileBelong;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiNowWeather getNowWeather(String city) {
|
public ApiNowWeather getNowWeather(String city) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setCity(city);
|
requestBody.setCity(city);
|
||||||
return Optional.ofNullable(nowWeatherFactory.apiData(requestBody))
|
ApiNowWeather apiNowWeather = nowWeatherFactory.apiData(requestBody);
|
||||||
.orElseThrow(ApiException::new);
|
if (Objects.isNull(apiNowWeather)) {
|
||||||
|
throw new ApiException("获取的实时天气数据为空");
|
||||||
|
}
|
||||||
|
return apiNowWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiForecastWeather getForecastWeather(String city) {
|
public ApiForecastWeather getForecastWeather(String city) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setCity(city);
|
requestBody.setCity(city);
|
||||||
return Optional.ofNullable(forecastWeatherFactory.apiData(requestBody))
|
ApiForecastWeather forecastWeather = forecastWeatherFactory.apiData(requestBody);
|
||||||
.orElseThrow(ApiException::new);
|
if (Objects.isNull(forecastWeather)) {
|
||||||
|
throw new ApiException("获取的预报天气数据为空");
|
||||||
|
}
|
||||||
|
this.weekConvert(forecastWeather);
|
||||||
|
return forecastWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiGarbageSorting getGarbageSorting(String name) {
|
public ApiGarbageSorting getGarbageSorting(String name) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setName(name);
|
requestBody.setName(name);
|
||||||
return Optional.ofNullable(garbageSortingFactory.apiData(requestBody))
|
ApiGarbageSorting garbageSorting = garbageSortingFactory.apiData(requestBody);
|
||||||
.orElseThrow(ApiException::new);
|
if (Objects.isNull(garbageSorting)) {
|
||||||
|
throw new ApiException("获取的垃圾分类数据为空");
|
||||||
|
}
|
||||||
|
return garbageSorting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApiBeautyPicture> getBeautyPictureList() {
|
public List<ApiBeautyPicture> getBeautyPictureList() {
|
||||||
List<ApiBeautyPicture> beautyPictureList = Optional.ofNullable(beautyPictureFactory.apiDataList())
|
List<ApiBeautyPicture> apiBeautyPictureList = beautyPictureFactory.apiDataList();
|
||||||
.orElseThrow(ApiException::new);
|
if (CollUtil.isEmpty(apiBeautyPictureList)) {
|
||||||
beautyPictureList.forEach(bp ->{
|
throw new ApiException("获取的mm图片数据为空");
|
||||||
|
}
|
||||||
|
apiBeautyPictureList.forEach(bp -> {
|
||||||
String imageFileLength = bp.getImageFileLength();
|
String imageFileLength = bp.getImageFileLength();
|
||||||
if (StringUtils.isNotEmpty(imageFileLength)) {
|
if (StringUtils.isNotEmpty(imageFileLength)) {
|
||||||
BigDecimal decimal = new BigDecimal(imageFileLength);
|
BigDecimal decimal = new BigDecimal(imageFileLength);
|
||||||
BigDecimal divide = decimal.divide(new BigDecimal(1024), 0, RoundingMode.HALF_UP);
|
BigDecimal divide = decimal.divide(new BigDecimal(1024), 0, RoundingMode.HALF_UP);
|
||||||
bp.setImageFileLength(divide.toPlainString()+KB);
|
bp.setImageFileLength(divide.toPlainString() + KB);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return beautyPictureList;
|
return apiBeautyPictureList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -166,7 +186,7 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
List<ApiHistoryToday> historyTodayList = historyTodayFactory.apiDataList();
|
List<ApiHistoryToday> historyTodayList = historyTodayFactory.apiDataList();
|
||||||
if (CollUtil.isNotEmpty(historyTodayList)) {
|
if (CollUtil.isNotEmpty(historyTodayList)) {
|
||||||
return historyTodayList.stream().limit(7).collect(Collectors.toList());
|
return historyTodayList.stream().limit(7).collect(Collectors.toList());
|
||||||
}else {
|
} else {
|
||||||
throw new ApiException("获取历史上的今天api调用异常!!!");
|
throw new ApiException("获取历史上的今天api调用异常!!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,23 +195,47 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
public ApiSimpleComplex getSimpleComplex(String content) {
|
public ApiSimpleComplex getSimpleComplex(String content) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setContent(content);
|
requestBody.setContent(content);
|
||||||
return simpleComplexFactory.apiData(requestBody);
|
ApiSimpleComplex apiSimpleComplex = simpleComplexFactory.apiData(requestBody);
|
||||||
|
if (Objects.isNull(apiSimpleComplex)) {
|
||||||
|
throw new ApiException("获取的简繁转换数据为空");
|
||||||
|
}
|
||||||
|
return apiSimpleComplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiChineseDict getChineseDict(String content) {
|
public ApiChineseDict getChineseDict(String content) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setContent(content);
|
requestBody.setContent(content);
|
||||||
return chineseDictFactory.apiData(requestBody);
|
|
||||||
|
ApiChineseDict chineseDict = chineseDictFactory.apiData(requestBody);
|
||||||
|
if (Objects.isNull(chineseDict)) {
|
||||||
|
throw new ApiException("获取的汉语字典数据为空");
|
||||||
|
}
|
||||||
|
return chineseDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiIdcardQuery getIdcardQuery(String idcard) {
|
public ApiIdcardQuery getIdcardQuery(String idcard) {
|
||||||
RequestBody requestBody = new RequestBody();
|
RequestBody requestBody = new RequestBody();
|
||||||
requestBody.setIdcard(idcard);
|
requestBody.setIdcard(idcard);
|
||||||
return idcardQueryFactory.apiData(requestBody);
|
ApiIdcardQuery apiIdcardQuery = idcardQueryFactory.apiData(requestBody);
|
||||||
|
if (Objects.isNull(apiIdcardQuery)) {
|
||||||
|
throw new ApiException("获取的身份证数据为空");
|
||||||
|
}
|
||||||
|
return apiIdcardQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* week类型转换
|
||||||
|
*/
|
||||||
|
private void weekConvert(ApiForecastWeather weather) {
|
||||||
|
List<Forecasts> forecastsList = weather.getForecasts();
|
||||||
|
forecastsList.forEach(forecasts -> {
|
||||||
|
String week = WeekUtils.weekConvert(forecasts.getDayOfWeek());
|
||||||
|
forecasts.setDayOfWeek(week);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||||
|
import com.xjs.utils.WeekUtils;
|
||||||
|
import com.xjs.weather.domain.Casts;
|
||||||
import com.xjs.weather.domain.ForecastWeather;
|
import com.xjs.weather.domain.ForecastWeather;
|
||||||
import com.xjs.weather.domain.NowWeather;
|
import com.xjs.weather.domain.NowWeather;
|
||||||
import com.xjs.weather.service.WeatherService;
|
import com.xjs.weather.service.WeatherService;
|
||||||
|
|
@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,32 +67,11 @@ public class WeatherController {
|
||||||
* week类型转换
|
* week类型转换
|
||||||
*/
|
*/
|
||||||
private void weekConvert(ForecastWeather forecastWeather) {
|
private void weekConvert(ForecastWeather forecastWeather) {
|
||||||
forecastWeather.getCasts().forEach(cast -> {
|
List<Casts> casts = forecastWeather.getCasts();
|
||||||
switch (cast.getWeek()) {
|
casts.forEach(cast -> {
|
||||||
case "1":
|
String week = WeekUtils.weekConvert(cast.getWeek());
|
||||||
cast.setWeek("周一");
|
cast.setWeek(week);
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
cast.setWeek("周二");
|
|
||||||
break;
|
|
||||||
case "3":
|
|
||||||
cast.setWeek("周三");
|
|
||||||
break;
|
|
||||||
case "4":
|
|
||||||
cast.setWeek("周四");
|
|
||||||
break;
|
|
||||||
case "5":
|
|
||||||
cast.setWeek("周五");
|
|
||||||
break;
|
|
||||||
case "6":
|
|
||||||
cast.setWeek("周六");
|
|
||||||
break;
|
|
||||||
case "7":
|
|
||||||
cast.setWeek("周日");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue