TP5后端,VUE前端请求聚合数据天气接口

问题描述:
TP5 当后端
VUE 当前端
请求聚合数据天气接口

问题解决:
演示效果
TP5后端,VUE前端请求聚合数据天气接口

前端 VUE 代码:

<template>
    <div class="whether-tank">
        <!--
            根据城市查询生活指数 http://apis.juhe.cn/simpleWeather/life GET
            参数名	  类型	是否必填	说明
            city	string	是	    要查询的城市名称/id,城市名称如:温州、上海、北京,需要utf8 urlencode

            根据城市查询天气 http://apis.juhe.cn/simpleWeather/query    GET
            参数形式如上

            天气各类查询表
            http://apis.juhe.cn/simpleWeather/wids  GET      无需额外参数

            支持城市列表
            http://apis.juhe.cn/simpleWeather/cityList  GET  无需额外参数

            1: el-table 里面图片的遍历 (template 用法)
            2: v-for 双重循环
            3: 遍历 json 对象 [ 里面有数组,有对象 ]
         -->
        <el-card class="box-card">
            <div class="header">
                <el-row>
                    <el-button type="primary" round @click="showPanel(1)">查询天气</el-button>
                    <el-button type="success" round @click="showPanel(2)">天气类型</el-button>
                    <el-button type="warning" round @click="showPanel(3)">支持城市查看</el-button>
                </el-row>
                <div>
                    <hr class="hr" />
                </div>
            </div>

            <div class="bottom1" v-show="bottom1">

                <div class="cityShow" v-show="cityShow">
                    <el-select v-model="cityInitials" placeholder="城市首字母" @change="letterChange(cityInitials)">
                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>

                    <br /> <br />
                    <h3>请选择城市</h3>
                    <br /><br />
                    <p>
                        <span v-for="(c, index) in choosingCity" :key="index">
                            <span @click="potinCity(c)" class="cityNameChoose">{
  {c}}</span>
                            <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        </span>
                    </p>
                </div>

                <div class="weatherShow" v-show="weatherShow">
                    <p>
                        <span class="info info1">{
  { currentQueryCity }} </span>
                        <span class="info info2">{
  { realtimeWeather.temperature }}℃</span>
                        <span class="info info3">{
  { realtimeWeather.info }}</span>
                        <span class="info info4">{
  { realtimeWeather.direct }}</span>
                        <span class="info info5">湿度: {
  { realtimeWeather.humidity }}%</span>
                        <span class="info info6">空气质量: {
  { realtimeWeather.aqi }}</span>
                    </p>

                    <br /><br />

                    <h2>未来 5天天气</h2><br /><hr />

                    <div class="future5">
                        <div v-for="(fu, index) in futureWeather" :key="index">
                            <p>{
  { fu.date }}</p>
                            <p>{
  { fu.temperature }}</p>
                            <p>{
  { fu.weather }}</p>
                            <p>{
  { fu.direct }}</p>
                        </div>
                    </div>

                </div>
            </div>

            <div class="weatherType" v-show="bottom2">
                <el-table :data="tableData" class="elTable">
                    <el-table-column prop="wid" label="序号" width="" align="center"></el-table-column>
                    <el-table-column prop="weather" label="天气类型" width="" align="center"></el-table-column>
                    <el-table-column label="图标" align="center">
                        <template slot-scope="scope">
                            <img :src="scope.row.bgImg" width="60" />
                        </template>
                    </el-table-column>
                </el-table>
            </div>

            <div class="cities" v-show="bottom3">
                <div v-for="(item, index) in cityArr" :key="index" :class="'city' + { index }">
                    <h3>{
  { item.title }}</h3>
                    <br />
                    <p >
                        <span v-for="(city, index) in item.lists" :key="index">{
  { city }} &nbsp;&nbsp;&nbsp;&nbsp;</span>
                    </p>
                    <br /><hr /><br />
                </div>
            </div>

            <div class="errEle" v-show="errBtm">
                <h3>Sorry, 请求有问题</h3>
            </div>

        </el-card>

    </div>
</template>

<script>

export default {
     
    name: 'weather',
    mounted: function () {
     
        this.getWeatherType()
    }
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值