master
李之实 2 years ago
parent 2f567f8c8a
commit acf6ceda9f

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

@ -0,0 +1,2 @@
// app.js
App({})

@ -0,0 +1,11 @@
{
"pages":[
"pages/weather/weather"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "天气预报",
"navigationBarTextStyle":"black"
}
}

@ -0,0 +1,10 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}

@ -0,0 +1,66 @@
//index.js
//这里只获取了实况天气信息,没有用预测信息
//获取应用实例
//定义城市、天气、温度、风级、图片、日期参数
var defaultcity,getweather,gettemp,getwind,getpic,getdate
const app = getApp()
Page({
data: {
adcode:'',
city:'',
humidity:'',
province:'',
reporttime:'',
temperature:'',
weather:'',
winddirection:'',
windpower:'',
},
bindKeyInput: function(e){
defaultcity = e.detail.value
},
search:function(){
var self = this;
wx.request({
url: 'https://restapi.amap.com/v3/weather/weatherInfo',
data:{
'key': '2660d0aefb159a4b773a6b684d0a9e14',
'city': defaultcity,
'extensions': 'base'
},
header:{
'content-type': 'application/json'
},
success:function(res){
console.log(res.data);
self.setData({
adcode: res.data.lives[0].adcode,
city: res.data.lives[0].city,
humidity: res.data.lives[0].humidity,
province: res.data.lives[0].province,
temperature: res.data.lives[0].temperature,
reporttime: res.data.lives[0].reporttime,
weather: res.data.lives[0].weather,
winddirection: res.data.lives[0].winddirection,
windpower: res.data.lives[0].windpower
})
}
})
}
})
// success: function(res) {
// console.log(res.data);
// getweather = res.data.request[0].weather_data[0].weather
// gettemp = res.data.request[0].weather_data[0].temperature
// getwind = res.data.request[0].weather_data[0].wind
// getpic = res.data.request[0].weather_data[0].dayPictureUrl
// getdate = res.data.request[0].weather_data[0].date
// that.setData({
// city: defaultcity, weather: getweather,
// temp: gettemp, wind: getwind,
// pic: getpic, date: getdate

@ -0,0 +1,22 @@
<view class="page">
<!-- top部分 -->
<view class="top">
<input placeholder="输入城市名进行搜索" bindinput="bindKeyInput"></input>
<view class="icon">
<icon type="search" size="25" bindtap="search" />
</view>
</view>
<!--index.wxml-->
<view class="content">
<view class="info"> 城市编码:{{adcode}}</view>
<view class="info"> 所在省份:{{province}}</view>
<view class="info"> 城市:{{city}}</view>
<view class="info">天气现象:{{weather}}</view>
<view class="info"> 实时气温:{{temperature}}℃</view>
<view class="info"> 风向:{{winddirection}}</view>
<view class="info"> 风力:{{windpower}}</view>
<view class="info"> 空气湿度:{{humidity}}%</view>
<view class="info"> 发布时间:{{reporttime}}</view>
</view>
</view>

@ -0,0 +1,79 @@
page {
background-color: #5a9cd8;
color: #fff;
}
.page {
margin: 50rpx;
}
.top {
display: flex;
padding: 20rpx;
flex-direction: row;
background-color: #efefef;
position: relative;
margin-bottom: 20rpx;
border-radius: 10rpx;
}
.input {
width: 80%;
font-size: 32rpx;
}
.icon {
width: 10%;
position: absolute;
right: 0;
bottom: 5rpx;
}
.body {
text-align: center;
display: flex;
flex-direction: column;
}
.city {
font-size: 80rpx;
}
.today {
font-size: 34rpx;
}
.bottom {
display: flex;
flex-direction: row;
align-items: center;
text-align: center;
}
.weather {
font-size: 38rpx;
width: 50%;
}
.right {
display: flex;
flex-direction: column;
}
.wind {
font-size: 40rpx;
}
.temp {
font-size: 40rpx;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
input {
color: #333;
}
.content{
text-align: center;
}

@ -0,0 +1,29 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"compileType": "miniprogram",
"libVersion": "2.4.0",
"appid": "touristappid",
"projectname": "weather",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
}

@ -0,0 +1,7 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "weather",
"setting": {
"compileHotReLoad": true
}
}

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
Loading…
Cancel
Save