├── .gitignore ├── components ├── heartbeat │ ├── heartbeat.json │ ├── heartbeat.wxss │ ├── heartbeat.wxml │ └── heartbeat.js └── custom-navigation-bar │ ├── custom-navigation-bar.json │ ├── custom-navigation-bar.wxml │ ├── custom-navigation-bar.js │ └── custom-navigation-bar.wxss ├── pages ├── about │ ├── about.json │ ├── about.wxss │ ├── about.js │ └── about.wxml ├── setting │ ├── setting.json │ ├── setting.wxss │ ├── setting.wxml │ └── setting.js ├── citychoose │ ├── citychoose.json │ ├── citychoose.wxml │ ├── citychoose.js │ └── citychoose.wxss ├── systeminfo │ ├── systeminfo.json │ ├── systeminfo.wxml │ ├── systeminfo.wxss │ └── systeminfo.js └── index │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── img ├── qq.png ├── arrow.png ├── city.png ├── danger.png ├── down.png ├── email.png ├── github.png ├── info.png ├── menu.png ├── mobile.png ├── more.png ├── search.png ├── unlock.png ├── wechat.png ├── location.png ├── question.png ├── setting.png ├── up-arrow.png ├── weather.png ├── down-arrow.png ├── heartbeat.png ├── search_grey.png ├── share │ └── img1.png ├── lifestyle_ac.png ├── lifestyle_ag.png ├── lifestyle_air.png ├── lifestyle_cw.png ├── lifestyle_flu.png ├── lifestyle_fsh.png ├── lifestyle_gl.png ├── lifestyle_mu.png ├── lifestyle_spi.png ├── lifestyle_uv.png ├── location_s_w.png ├── share_circle.png ├── lifestyle_airc.png ├── lifestyle_comf.png ├── lifestyle_drsg.png ├── lifestyle_ptfc.png ├── lifestyle_sport.png ├── lifestyle_trav.png ├── beach-bird-birds-235787.jpg ├── aerial-climate-cold-296559.jpg ├── backlit-dawn-dusk-327466.jpg ├── beautiful-cold-dawn-547115.jpg ├── clouds-forest-idyllic-417102.jpg ├── asphalt-blue-sky-clouds-490411.jpg ├── fog-himalayas-landscape-38326.jpg └── accomplishment-adventure-clear-sky-585825.jpg ├── icon ├── iconfont.eot ├── iconfont.ttf ├── iconfont.woff ├── iconfont.woff2 ├── iconfont.wxss └── iconfont.svg ├── accountconfig.js ├── sitemap.json ├── app.wxss ├── cloudfunction ├── getHotCities │ ├── index.js │ └── package.json └── getBroadcast │ ├── index.js │ └── package.json ├── app.json ├── app.js ├── LICENSE ├── constant.js ├── project.config.json ├── README.md ├── utils └── utils.js └── data └── staticData.js /.gitignore: -------------------------------------------------------------------------------- 1 | cloudfunction/*/node_modules/ 2 | -------------------------------------------------------------------------------- /components/heartbeat/heartbeat.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } -------------------------------------------------------------------------------- /pages/about/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "关于" 3 | } -------------------------------------------------------------------------------- /pages/setting/setting.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "设置" 3 | } -------------------------------------------------------------------------------- /pages/citychoose/citychoose.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "选择城市" 3 | } -------------------------------------------------------------------------------- /pages/systeminfo/systeminfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "系统信息" 3 | } -------------------------------------------------------------------------------- /img/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/qq.png -------------------------------------------------------------------------------- /img/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/arrow.png -------------------------------------------------------------------------------- /img/city.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/city.png -------------------------------------------------------------------------------- /img/danger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/danger.png -------------------------------------------------------------------------------- /img/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/down.png -------------------------------------------------------------------------------- /img/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/email.png -------------------------------------------------------------------------------- /img/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/github.png -------------------------------------------------------------------------------- /img/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/info.png -------------------------------------------------------------------------------- /img/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/menu.png -------------------------------------------------------------------------------- /img/mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/mobile.png -------------------------------------------------------------------------------- /img/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/more.png -------------------------------------------------------------------------------- /img/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/search.png -------------------------------------------------------------------------------- /img/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/unlock.png -------------------------------------------------------------------------------- /img/wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/wechat.png -------------------------------------------------------------------------------- /img/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/location.png -------------------------------------------------------------------------------- /img/question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/question.png -------------------------------------------------------------------------------- /img/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/setting.png -------------------------------------------------------------------------------- /img/up-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/up-arrow.png -------------------------------------------------------------------------------- /img/weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/weather.png -------------------------------------------------------------------------------- /icon/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/icon/iconfont.eot -------------------------------------------------------------------------------- /icon/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/icon/iconfont.ttf -------------------------------------------------------------------------------- /icon/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/icon/iconfont.woff -------------------------------------------------------------------------------- /icon/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/icon/iconfont.woff2 -------------------------------------------------------------------------------- /img/down-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/down-arrow.png -------------------------------------------------------------------------------- /img/heartbeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/heartbeat.png -------------------------------------------------------------------------------- /img/search_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/search_grey.png -------------------------------------------------------------------------------- /img/share/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/share/img1.png -------------------------------------------------------------------------------- /img/lifestyle_ac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_ac.png -------------------------------------------------------------------------------- /img/lifestyle_ag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_ag.png -------------------------------------------------------------------------------- /img/lifestyle_air.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_air.png -------------------------------------------------------------------------------- /img/lifestyle_cw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_cw.png -------------------------------------------------------------------------------- /img/lifestyle_flu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_flu.png -------------------------------------------------------------------------------- /img/lifestyle_fsh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_fsh.png -------------------------------------------------------------------------------- /img/lifestyle_gl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_gl.png -------------------------------------------------------------------------------- /img/lifestyle_mu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_mu.png -------------------------------------------------------------------------------- /img/lifestyle_spi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_spi.png -------------------------------------------------------------------------------- /img/lifestyle_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_uv.png -------------------------------------------------------------------------------- /img/location_s_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/location_s_w.png -------------------------------------------------------------------------------- /img/share_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/share_circle.png -------------------------------------------------------------------------------- /img/lifestyle_airc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_airc.png -------------------------------------------------------------------------------- /img/lifestyle_comf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_comf.png -------------------------------------------------------------------------------- /img/lifestyle_drsg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_drsg.png -------------------------------------------------------------------------------- /img/lifestyle_ptfc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_ptfc.png -------------------------------------------------------------------------------- /img/lifestyle_sport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_sport.png -------------------------------------------------------------------------------- /img/lifestyle_trav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/lifestyle_trav.png -------------------------------------------------------------------------------- /components/custom-navigation-bar/custom-navigation-bar.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /img/beach-bird-birds-235787.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/beach-bird-birds-235787.jpg -------------------------------------------------------------------------------- /accountconfig.js: -------------------------------------------------------------------------------- 1 | // export const CloudEnvId = '云开发环境 id'; // 云开发环境 id 2 | export const HeWeatherKey = '和风天气 key 值'; // 和风天气 key 值 -------------------------------------------------------------------------------- /img/aerial-climate-cold-296559.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/aerial-climate-cold-296559.jpg -------------------------------------------------------------------------------- /img/backlit-dawn-dusk-327466.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/backlit-dawn-dusk-327466.jpg -------------------------------------------------------------------------------- /img/beautiful-cold-dawn-547115.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/beautiful-cold-dawn-547115.jpg -------------------------------------------------------------------------------- /img/clouds-forest-idyllic-417102.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/clouds-forest-idyllic-417102.jpg -------------------------------------------------------------------------------- /img/asphalt-blue-sky-clouds-490411.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/asphalt-blue-sky-clouds-490411.jpg -------------------------------------------------------------------------------- /img/fog-himalayas-landscape-38326.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/fog-himalayas-landscape-38326.jpg -------------------------------------------------------------------------------- /img/accomplishment-adventure-clear-sky-585825.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sijinglei/quietweather/master/img/accomplishment-adventure-clear-sky-585825.jpg -------------------------------------------------------------------------------- /components/heartbeat/heartbeat.wxss: -------------------------------------------------------------------------------- 1 | .heart { 2 | position: fixed; 3 | z-index: 999; 4 | top: -140rpx; 5 | left: -100rpx; 6 | width: 40rpx; 7 | height: 40rpx; 8 | } -------------------------------------------------------------------------------- /sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } 8 | -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "Quiet Weather", 3 | "enablePullDownRefresh": true, 4 | "usingComponents": { 5 | "heartbeat": "/components/heartbeat/heartbeat" 6 | } 7 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | @import "/icon/iconfont.wxss"; 2 | 3 | Page { 4 | background: #f4f6f9; 5 | } 6 | ::-webkit-scrollbar { 7 | display: none; 8 | } 9 | .iphonex-padding { 10 | padding-bottom: 68rpx; 11 | } -------------------------------------------------------------------------------- /cloudfunction/getHotCities/index.js: -------------------------------------------------------------------------------- 1 | const cloud = require('wx-server-sdk') 2 | cloud.init() 3 | const db = cloud.database() 4 | exports.main = async (event, context) => { 5 | return db.collection('hotCities') 6 | .get() 7 | } -------------------------------------------------------------------------------- /components/heartbeat/heartbeat.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cloudfunction/getBroadcast/index.js: -------------------------------------------------------------------------------- 1 | const cloud = require('wx-server-sdk') 2 | cloud.init() 3 | const db = cloud.database() 4 | exports.main = async (event, context) => { 5 | return db.collection('broadcast') 6 | .where({ 7 | hour: event.hour, 8 | }) 9 | .get() 10 | } -------------------------------------------------------------------------------- /cloudfunction/getHotCities/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getHotCities", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "wx-server-sdk": "latest" 13 | } 14 | } -------------------------------------------------------------------------------- /cloudfunction/getBroadcast/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getBroadcast", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "wx-server-sdk": "0.0.19" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pages/systeminfo/systeminfo.wxml: -------------------------------------------------------------------------------- 1 | 2 | 系统信息 3 | 4 | 5 | 6 | 7 | {{systeminfoObj.brand}} 8 | 9 | 10 | {{item.name}} 11 | {{systeminfoObj[item.key]}} 12 | 13 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/about/about", 5 | "pages/citychoose/citychoose", 6 | "pages/setting/setting", 7 | "pages/systeminfo/systeminfo" 8 | ], 9 | "window": { 10 | "backgroundTextStyle": "dark", 11 | "navigationBarBackgroundColor": "#40a7e7", 12 | "navigationStyle": "custom", 13 | "navigationBarTitleText": "Quiet Weather", 14 | "navigationBarTextStyle": "white" 15 | }, 16 | "permission": { 17 | "scope.userLocation": { 18 | "desc": "定位以获取当前位置天气信息" 19 | } 20 | }, 21 | "usingComponents": { 22 | "custom-navigation-bar": "/components/custom-navigation-bar/custom-navigation-bar" 23 | }, 24 | "style": "v2", 25 | "cloud": true, 26 | "sitemapLocation": "sitemap.json" 27 | } -------------------------------------------------------------------------------- /pages/systeminfo/systeminfo.wxss: -------------------------------------------------------------------------------- 1 | .systeminfo { 2 | padding: 0 30rpx 0 30rpx; 3 | background: #fff; 4 | margin-bottom: calc(constant(safe-area-inset-bottom)); 5 | margin-bottom: calc(env(safe-area-inset-bottom)); 6 | } 7 | .brand { 8 | font-family: DINCondensed-Bold; 9 | height: 300rpx; 10 | font-size: 100rpx; 11 | color: #40a7e7; 12 | display: flex; 13 | flex-direction: row; 14 | justify-content: center; 15 | align-items: center; 16 | } 17 | .brand image { 18 | width: 100rpx; 19 | height: 100rpx; 20 | margin-right: 20rpx; 21 | } 22 | .brand text { 23 | line-height: 1em; 24 | } 25 | .systeminfo .item { 26 | display: flex; 27 | flex-direction: column; 28 | justify-content: space-between; 29 | align-items: flex-start; 30 | font-size: 30rpx; 31 | color: #000; 32 | padding: 30rpx 15rpx; 33 | height: 62rpx; 34 | border-top: 1rpx solid #efefef; 35 | } 36 | .systeminfo .item:last-child { 37 | border-bottom: none; 38 | } 39 | .systeminfo .item .key { 40 | line-height: 1em; 41 | } 42 | .systeminfo .item .value { 43 | font-size: 24rpx; 44 | line-height: 1em; 45 | color: #777; 46 | } -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | import { CloudEnvId, HeWeatherKey, } from './accountconfig'; 2 | App({ 3 | onLaunch () { 4 | // wx.cloud.init({ 5 | // env: CloudEnvId, 6 | // traceUser: true, 7 | // }) 8 | this.globalData.platform = typeof tt !== 'undefined' ? 'tt' : 'wx'; 9 | wx.getSystemInfo({ 10 | success: (res) => { 11 | this.globalData.StatusBar = res.statusBarHeight; 12 | let custom = wx.getMenuButtonBoundingClientRect(); 13 | this.globalData.Custom = custom; 14 | this.globalData.CustomBar = custom.bottom + custom.top - res.statusBarHeight; 15 | 16 | this.globalData.systeminfo = res 17 | this.globalData.isIPhoneX = /iphonex/gi.test(res.model.replace(/\s+/, '')) 18 | }, 19 | }) 20 | }, 21 | globalData: { 22 | // keepscreenon:false, 23 | systeminfo: {}, 24 | isIPhoneX: false, 25 | key: HeWeatherKey, 26 | weatherIconUrl: 'https://cdn.heweather.com/cond_icon/', 27 | requestUrl: { 28 | weather: 'https://devapi.qweather.com/s6/weather', 29 | hourly: 'https://devapi.qweather.com/s6/weather/hourly', 30 | }, 31 | }, 32 | }) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present, myvin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /components/custom-navigation-bar/custom-navigation-bar.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /components/custom-navigation-bar/custom-navigation-bar.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Component({ 3 | /** 4 | * 组件的一些选项 5 | */ 6 | options: { 7 | addGlobalClass: true, 8 | multipleSlots: true 9 | }, 10 | /** 11 | * 组件的对外属性 12 | */ 13 | properties: { 14 | bgColor: { 15 | type: String, 16 | default: '' 17 | }, 18 | isCustom: { 19 | type: [Boolean, String], 20 | default: false 21 | }, 22 | isBack: { 23 | type: [Boolean, String], 24 | default: false 25 | }, 26 | isAvatar: { 27 | type: [Boolean, String], 28 | default: false 29 | }, 30 | bgImage: { 31 | type: String, 32 | default: '' 33 | }, 34 | titleLeft: { 35 | type: Boolean, 36 | default: false, 37 | }, 38 | }, 39 | /** 40 | * 组件的初始数据 41 | */ 42 | data: { 43 | StatusBar: app.globalData.StatusBar, 44 | CustomBar: app.globalData.CustomBar, 45 | Custom: app.globalData.Custom 46 | }, 47 | /** 48 | * 组件的方法列表 49 | */ 50 | methods: { 51 | BackPage() { 52 | wx.navigateBack({ 53 | delta: 1 54 | }); 55 | }, 56 | toHome(){ 57 | wx.reLaunch({ 58 | url: '/pages/home/home', 59 | }); 60 | // wx.switchTab({ 61 | // url: '/pages/home/home', 62 | // }); 63 | }, 64 | } 65 | }) -------------------------------------------------------------------------------- /pages/systeminfo/systeminfo.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | systeminfoObj: {}, 4 | systeminfoArr: [ 5 | { 6 | key: 'brand', 7 | name: '手机品牌', 8 | }, 9 | { 10 | key: 'model', 11 | name: '手机型号', 12 | }, 13 | { 14 | key: 'pixelRatio', 15 | name: '设备像素比', 16 | }, 17 | { 18 | key: 'screenWidth', 19 | name: '屏幕宽度', 20 | }, 21 | { 22 | key: 'screenHeight', 23 | name: '屏幕高度', 24 | }, 25 | { 26 | key: 'windowWidth', 27 | name: '可使用窗口宽度', 28 | }, 29 | { 30 | key: 'windowHeight', 31 | name: '可使用窗口高度', 32 | }, 33 | { 34 | key: 'statusBarHeight', 35 | name: '状态栏高度', 36 | }, 37 | { 38 | key: 'language', 39 | name: '微信设置的语言', 40 | }, 41 | { 42 | key: 'version', 43 | name: '微信版本号', 44 | }, 45 | { 46 | key: 'system', 47 | name: '操作系统版本', 48 | }, 49 | { 50 | key: 'platform', 51 | name: '客户端平台', 52 | }, 53 | { 54 | key: 'fontSizeSetting', 55 | name: '用户字体大小设置(px)', 56 | }, 57 | { 58 | key: 'SDKVersion', 59 | name: '客户端基础库版本', 60 | }, 61 | ], 62 | }, 63 | onShow () { 64 | this.setData({ 65 | systeminfoObj: getApp().globalData.systeminfo 66 | }) 67 | }, 68 | }) -------------------------------------------------------------------------------- /constant.js: -------------------------------------------------------------------------------- 1 | export const BackgroundImageList = [ 2 | { src: '/img/backlit-dawn-dusk-327466.jpg', topColor: '#2d2225' }, 3 | { src: '/img/beach-bird-birds-235787.jpg', topColor: '#393836' }, 4 | { src: '/img/clouds-forest-idyllic-417102.jpg', topColor: '#0085e5' }, 5 | { src: '/img/accomplishment-adventure-clear-sky-585825.jpg', topColor: '#004a89' }, 6 | { src: '/img/fog-himalayas-landscape-38326.jpg', topColor: '#b8bab9' }, 7 | { src: '/img/asphalt-blue-sky-clouds-490411.jpg', topColor: '#009ffe' }, 8 | { src: '/img/aerial-climate-cold-296559.jpg', topColor: '#d6d1e6' }, 9 | { src: '/img/beautiful-cold-dawn-547115.jpg', topColor: '#ffa5bc' } 10 | ]; 11 | 12 | export const LifeStyles = { 'comf': '舒适度指数', 'cw': '洗车指数', 'drsg': '穿衣指数', 'flu': '感冒指数', 'sport': '运动指数', 'trav': '旅游指数', 'uv': '紫外线指数', 'air': '空气污染扩散条件指数', 'ac': '空调开启指数', 'ag': '过敏指数', 'gl': '太阳镜指数', 'mu': '化妆指数', 'airc': '晾晒指数', 'ptfc': '交通指数', 'fsh': '钓鱼指数', 'spi': '防晒指数', }; 13 | 14 | export const EnvironmentVars = { tmp: '温度(℃)', fl: '体感温度(℃)', hum: '相对湿度(%)', pcpn: '降水量(mm)', wind_dir: '风向', wind_deg: '风向角度(deg)', wind_sc: '风力(级)', wind_spd: '风速(mk/h)', vis: '能见度(km)', pres: '气压(mb)', cloud: '云量', }; 15 | 16 | export const HotCities = ['北京市', '广州市', '深圳市', '上海市', '南京市', '杭州市', '武汉市']; 17 | 18 | export const BroadCastMessages = ['等忙完这一阵,就可以接着忙下一阵了', '世上无难事,只要肯放弃', '假如生活欺骗了你,不要悲伤,不要心急,反正明天也一样', '有时候你不努力一下,你都不知道什么叫绝望', '万事开头难,然后中间难,最后结尾难', '对今天解决不了的事,不必着急,因为明天还是解决不了', '只要你肯努力,没有什么是你不能搞砸的']; -------------------------------------------------------------------------------- /pages/about/about.wxss: -------------------------------------------------------------------------------- 1 | .about { 2 | font-size: 30rpx; 3 | color: #666; 4 | /* padding: 0 40rpx 40rpx; */ 5 | display: flex; 6 | flex-direction: column; 7 | justify-content: space-between; 8 | margin-bottom: calc(constant(safe-area-inset-bottom)); 9 | margin-bottom: calc(env(safe-area-inset-bottom)); 10 | } 11 | swiper { 12 | background: #fff; 13 | margin-bottom: 20rpx; 14 | } 15 | .info { 16 | display: flex; 17 | flex-direction: column; 18 | justify-content: center; 19 | align-items: center; 20 | font-size: 32rpx; 21 | color: #333; 22 | padding: 60rpx 40rpx; 23 | } 24 | .info image { 25 | width: 200rpx; 26 | height: 200rpx; 27 | border-radius: 50%; 28 | margin-bottom: 30rpx; 29 | } 30 | .item { 31 | line-height: 2.2em; 32 | padding: 0 40rpx; 33 | overflow: hidden; 34 | background: #fff; 35 | margin-bottom: 20rpx; 36 | } 37 | .item .title { 38 | font-size: 32rpx; 39 | color: #40a7e7; 40 | margin: 26rpx 0; 41 | } 42 | .item .i { 43 | display: flex; 44 | flex-direction: row; 45 | justify-content: flex-start; 46 | align-items: flex-start; 47 | position: relative; 48 | padding-bottom: 16rpx; 49 | } 50 | .i .icon { 51 | display: flex; 52 | justify-content: space-around; 53 | align-items: center; 54 | height: 2.2em; 55 | } 56 | .attention .i { 57 | margin-left: 0; 58 | } 59 | .i image { 60 | width: 32rpx; 61 | height: 32rpx; 62 | margin-right: 20rpx; 63 | } 64 | .feedback .text { 65 | position: relative; 66 | z-index: 1; 67 | } 68 | .feedback .btn { 69 | position: absolute; 70 | z-index: 2; 71 | width: 100%; 72 | height: 100%; 73 | top: 0; 74 | left: 1; 75 | opacity: 0; 76 | } 77 | .footer { 78 | display: flex; 79 | justify-content: space-around; 80 | align-items: center; 81 | height: 80rpx; 82 | font-size: 22rpx; 83 | color: #333; 84 | } 85 | -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": true, 6 | "enhance": true, 7 | "postcss": true, 8 | "preloadBackgroundData": false, 9 | "minified": true, 10 | "newFeature": true, 11 | "coverView": true, 12 | "nodeModules": false, 13 | "autoAudits": false, 14 | "showShadowRootInWxmlPanel": true, 15 | "scopeDataCheck": false, 16 | "uglifyFileName": false, 17 | "checkInvalidKey": true, 18 | "checkSiteMap": true, 19 | "uploadWithSourceMap": true, 20 | "compileHotReLoad": false, 21 | "lazyloadPlaceholderEnable": false, 22 | "useMultiFrameRuntime": true, 23 | "useApiHook": true, 24 | "useApiHostProcess": true, 25 | "babelSetting": { 26 | "ignore": [], 27 | "disablePlugins": [], 28 | "outputPath": "" 29 | }, 30 | "enableEngineNative": false, 31 | "useIsolateContext": true, 32 | "userConfirmedBundleSwitch": false, 33 | "packNpmManually": false, 34 | "packNpmRelationList": [], 35 | "minifyWXSS": true, 36 | "showES6CompileOption": false 37 | }, 38 | "cloudfunctionRoot": "cloudfunction/", 39 | "compileType": "miniprogram", 40 | "libVersion": "2.7.0", 41 | "appid": "wx7f0d40f5ed14c27d", 42 | "projectname": "weather", 43 | "simulatorType": "wechat", 44 | "simulatorPluginLibVersion": {}, 45 | "condition": { 46 | "search": { 47 | "list": [] 48 | }, 49 | "conversation": { 50 | "list": [] 51 | }, 52 | "plugin": { 53 | "list": [] 54 | }, 55 | "game": { 56 | "list": [] 57 | }, 58 | "miniprogram": { 59 | "list": [ 60 | { 61 | "id": -1, 62 | "name": "citychoose", 63 | "pathName": "pages/citychoose/citychoose" 64 | } 65 | ] 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /pages/about/about.js: -------------------------------------------------------------------------------- 1 | let utils = require('../../utils/utils') 2 | Page({ 3 | data: { 4 | projectAddress: 'https://github.com/myvin/quietweather', 5 | github: 'https://github.com/myvin', 6 | email: '851399101@qq.com', 7 | qq: '851399101', 8 | swiperHeight: 'auto', 9 | bannerImgList: [ 10 | { 11 | src: 'https://i.niupic.com/images/2021/09/30/9DC0.png', 12 | title: 'Quiet Weather', 13 | }, 14 | ], 15 | }, 16 | onLoad () { 17 | this.initSwiper() 18 | }, 19 | previewImages (e) { 20 | let index = e.currentTarget.dataset.index || 0 21 | let urls = this.data.bannerImgList 22 | let arr = [] 23 | urls.forEach(item => { 24 | arr.push(item.src) 25 | }) 26 | wx.previewImage({ 27 | current: arr[index], 28 | urls: arr, 29 | success: function (res) { }, 30 | fail: function (res) { 31 | console.error('previewImage fail: ', res) 32 | } 33 | }) 34 | }, 35 | initSwiper () { 36 | let systeminfo = getApp().globalData.systeminfo 37 | if (utils.isEmptyObject(systeminfo)) { 38 | wx.getSystemInfo({ 39 | success: (res) => { 40 | this.setSwiperHeight(res) 41 | }, 42 | }) 43 | } else { 44 | this.setSwiperHeight(systeminfo) 45 | } 46 | }, 47 | setSwiperHeight (res) { 48 | this.setData({ 49 | swiperHeight: `${(res.windowWidth || res.screenWidth) / 375 * 200}px` 50 | }) 51 | }, 52 | copy(e) { 53 | let dataset = (e.currentTarget || {}).dataset || {} 54 | let title = dataset.title || '' 55 | let content = dataset.content || '' 56 | wx.setClipboardData({ 57 | data: content, 58 | success () { 59 | wx.showToast({ 60 | title: `已复制${title}`, 61 | duration: 2000, 62 | }) 63 | }, 64 | }) 65 | }, 66 | }) -------------------------------------------------------------------------------- /pages/citychoose/citychoose.wxml: -------------------------------------------------------------------------------- 1 | 2 | 选择城市 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 清空 12 | 13 | 14 | 20 | 21 | 猜你想找 22 | 23 | 24 | 25 | 定位 26 | 27 | {{item}} 28 | 29 | 30 | 31 | 32 | 33 | {{index}} 34 | 35 | {{item.name}} 36 | 37 | 38 | 39 | 暂无城市可以选择 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuietWeather 2 | 一款天气应用微信小程序 3 |

4 | 5 |

6 | 7 | ## 截图 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | ## 数据来源 18 | 19 | 气象数据由 [和风天气](http://www.heweather.com/) 提供,需要注册账号获取 `key`;免费版只能获取三天的天气数据,若要获取七天的气象数据,可以申请**个人开发者认证**; 20 | 21 | ## 运行前准备 22 | > * [注册微信小程序](https://mp.weixin.qq.com/wxopen/waregister?action=step1),获取 `appid`,配置和风天气域名白名单(在小程序后台将使用到的 `API` 添加到域名白名单); 23 | > * 注册[和风天气](http://www.heweather.com/)账号,获取 'key`; 24 | > * 在 `accountconfig.js` 中修改 `HeWeatherKey` 变量为你的和风天气的 `key`; 25 | > * Run and Enjoy! 26 | 27 | ## 请喝咖啡 28 | 如果我的项目对你有帮助,可以请我喝杯咖啡噢~ 29 | 30 | ### 支付宝 31 | 32 | 33 | 34 | ### 微信 35 | 36 | 37 | 38 | ## License 39 | 40 | [MIT](http://opensource.org/licenses/MIT) 41 | 42 | Copyright (c) 2018-present, myvin 43 | -------------------------------------------------------------------------------- /utils/utils.js: -------------------------------------------------------------------------------- 1 | let formatDate = (nDate, date) => { 2 | if (isNaN(nDate.getTime())) { 3 | // 不是时间格式 4 | return '--' 5 | } 6 | let o = { 7 | 'M+': nDate.getMonth() + 1, 8 | 'd+': nDate.getDate(), 9 | 'h+': nDate.getHours(), 10 | 'm+': nDate.getMinutes(), 11 | 's+': nDate.getSeconds(), 12 | // 季度 13 | 'q+': Math.floor((nDate.getMonth() + 3) / 3), 14 | 'S': nDate.getMilliseconds() 15 | } 16 | if (/(y+)/.test(date)) { 17 | date = date.replace(RegExp.$1, (nDate.getFullYear() + '').substr(4 - RegExp.$1.length)) 18 | } 19 | for (let k in o) { 20 | if (new RegExp('(' + k + ')').test(date)) { 21 | date = date.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) 22 | } 23 | } 24 | return date 25 | } 26 | 27 | let isEmptyObject = (obj) => { 28 | for (let i in obj) { 29 | return false 30 | } 31 | return true 32 | } 33 | 34 | // let themeSetting = () => { 35 | // let bcgColor = '#40a7e7' 36 | // let hour = new Date().getHours() 37 | // if (hour >= 6 && hour <= 17) { 38 | // bcgColor = '#40a7e7' 39 | // } else { 40 | // bcgColor = '#384148' 41 | // } 42 | // wx.setNavigationBarColor({ 43 | // frontColor: '#ffffff', 44 | // backgroundColor: bcgColor, 45 | // }) 46 | // return bcgColor 47 | // } 48 | 49 | // 比较版本号:left > right 1, left < right -1, left == right 0 50 | // 用途:旧版本不执行写入、删除 日历操作 51 | let cmpVersion = (left, right) => { 52 | if (typeof left + typeof right !== 'stringstring') { 53 | return false 54 | } 55 | let a = left.split('.') 56 | let b = right.split('.') 57 | let i = 0 58 | let len = Math.max(a.length, b.length) 59 | for (; i < len; i++) { 60 | if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) { 61 | return 1 62 | } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) { 63 | return -1 64 | } 65 | } 66 | return 0 67 | } 68 | 69 | module.exports = { 70 | formatDate, 71 | isEmptyObject, 72 | // themeSetting, 73 | cmpVersion, 74 | } -------------------------------------------------------------------------------- /pages/setting/setting.wxss: -------------------------------------------------------------------------------- 1 | .setting { 2 | font-size: 28rpx; 3 | color: #666; 4 | margin-bottom: calc(20rpx + constant(safe-area-inset-bottom)); 5 | margin-bottom: calc(20rpx + env(safe-area-inset-bottom)); 6 | } 7 | .more { 8 | width: 32rpx; 9 | height: 32rpx; 10 | } 11 | .item { 12 | display: flex; 13 | justify-content: space-between; 14 | align-items: center; 15 | height: 100rpx; 16 | } 17 | .sub.content .item { 18 | padding-left: 20rpx; 19 | } 20 | .item .right { 21 | display: flex; 22 | justify-content: flex-end; 23 | align-items: center; 24 | } 25 | .item .tip { 26 | font-size: 22rpx; 27 | color: #999; 28 | display: flex; 29 | justify-content: flex-start; 30 | align-items: center; 31 | } 32 | .item .tip image { 33 | width: 24rpx; 34 | height: 24rpx; 35 | margin-right: 10rpx; 36 | } 37 | .item slider { 38 | width: 100%; 39 | margin: 0; 40 | } 41 | .title { 42 | font-size: 32rpx; 43 | color: #40a7e7; 44 | margin: 26rpx 0; 45 | } 46 | .subtitle { 47 | font-size: 28rpx; 48 | color: #40a7e7; 49 | } 50 | .toast .mask { 51 | position: fixed; 52 | z-index: 9; 53 | top: 0; 54 | right: 0; 55 | bottom: 0; 56 | left: 0; 57 | margin: auto; 58 | background: rgba(0, 0, 0, .5); 59 | } 60 | .toast .wrapper { 61 | position: fixed; 62 | z-index: 10; 63 | top: 0; 64 | right: 0; 65 | bottom: 0; 66 | left: 0; 67 | margin: auto; 68 | background: #fff; 69 | font-size: 24rpx; 70 | color: #333; 71 | width: 60%; 72 | height: 400rpx; 73 | border-radius: 14rpx; 74 | padding: 46rpx 28rpx; 75 | } 76 | .toast .box { 77 | height: 400rpx; 78 | overflow: scroll; 79 | } 80 | .t { 81 | overflow: hidden; 82 | padding: 0 40rpx; 83 | background: #fff; 84 | margin-bottom: 20rpx; 85 | } 86 | .toast .t { 87 | font-size: 28rpx; 88 | color: #40a7e7; 89 | margin: 20rpx 0; 90 | padding: 0; 91 | } 92 | .toast .content { 93 | line-height: 1.8em; 94 | text-align: justify; 95 | } 96 | .toast .content text { 97 | display: block; 98 | margin-bottom: 10rpx; 99 | } 100 | .wx-switch-input{width:84rpx !important;height:43rpx !important;} 101 | .wx-switch-input::before{width:82rpx !important;height: 38rpx !important;} 102 | .wx-switch-input::after{width: 38rpx !important;height: 38rpx !important;} -------------------------------------------------------------------------------- /components/heartbeat/heartbeat.js: -------------------------------------------------------------------------------- 1 | let utils = require('../../utils/utils') 2 | Component({ 3 | data: { 4 | windowWidth: 0, 5 | windowHeight: 0, 6 | arr: [], 7 | // 动画最长持续时间 8 | duration: 5000, 9 | animations: [], 10 | lefts: [], 11 | tops: [], 12 | widths: [], 13 | }, 14 | properties: { 15 | show: { 16 | type: Boolean, 17 | value: true 18 | }, 19 | }, 20 | ready () { 21 | let systeminfo = getApp().globalData.systeminfo 22 | if (utils.isEmptyObject(systeminfo)) { 23 | wx.getSystemInfo({ 24 | success: (res) => { 25 | this.setData({ 26 | windowWidth: res.windowWidth || res.screenWidth, 27 | windowHeight: res.windowHeight || res.screenHeight, 28 | }) 29 | }, 30 | }) 31 | } else { 32 | this.setData({ 33 | windowWidth: systeminfo.windowWidth || systeminfo.screenWidth, 34 | windowHeight: systeminfo.windowHeight || systeminfo.screenHeight, 35 | }) 36 | } 37 | let num = parseInt(Math.random() * 100) + 10 38 | let arr = Array.apply(null, { length: num }).map(function (value, index) { 39 | return index + 1; 40 | }) 41 | this.setData({ 42 | arr, 43 | }) 44 | }, 45 | methods: { 46 | dance (callback) { 47 | let windowWidth = this.data.windowWidth 48 | let windowHeight = this.data.windowHeight 49 | let duration = this.data.duration 50 | let animations = [] 51 | let lefts = [] 52 | let tops = [] 53 | let widths = [] 54 | let obj = {} 55 | for (let i = 0; i < this.data.arr.length; i++) { 56 | lefts.push(Math.random() * windowWidth) 57 | tops.push(-140) 58 | widths.push(Math.random() * 50 + 40) 59 | let animation = wx.createAnimation({ 60 | duration: Math.random() * (duration - 1000) + 1000 61 | }) 62 | animation.top(windowHeight).left(Math.random() * windowWidth).rotate(Math.random() * 960).step() 63 | animations.push(animation.export()) 64 | } 65 | this.setData({ 66 | lefts, 67 | tops, 68 | widths, 69 | }) 70 | let timer = setTimeout(() => { 71 | this.setData({ 72 | animations, 73 | }) 74 | clearTimeout(timer) 75 | }, 200) 76 | let end = setTimeout(() => { 77 | callback && callback() 78 | clearTimeout(end) 79 | }, duration) 80 | }, 81 | }, 82 | }) -------------------------------------------------------------------------------- /pages/about/about.wxml: -------------------------------------------------------------------------------- 1 | 2 | 关于 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{item.title}} 12 | 13 | 14 | 15 | 16 | 17 | 18 | 代码已开源 19 | 20 | 21 | 22 | 23 | 24 | 可随意 star 25 | {{projectAddress}} 26 | 27 | 28 | 29 | 30 | 联系开发者 31 | 32 | 33 | 34 | 35 | 36 | 通过 GitHub 反馈 37 | {{github}} 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 通过 Email 反馈 46 | {{email}} 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 通过 QQ 反馈 55 | {{qq}} 56 | 57 | 58 | 65 | 66 | 67 | 鸣谢 68 | 69 | 70 | 71 | 72 | 气象数据来源:和风天气 73 | 74 | 75 | 76 | 开发者 · myvin 77 | -------------------------------------------------------------------------------- /pages/citychoose/citychoose.js: -------------------------------------------------------------------------------- 1 | const { HotCities } = require('../../constant.js') 2 | let staticData = require('../../data/staticData.js') 3 | let utils = require('../../utils/utils.js') 4 | Page({ 5 | data: { 6 | alternative: null, 7 | cities: [], 8 | // 需要显示的城市 9 | showItems: null, 10 | inputText: '', 11 | hotCities: HotCities, 12 | }, 13 | cancel () { 14 | this.setData({ 15 | inputText: '', 16 | showItems: this.data.cities, 17 | }) 18 | }, 19 | inputFilter (e) { 20 | let alternative = {} 21 | let cities = this.data.cities 22 | let value = e.detail.value.replace(/\s+/g, '') 23 | if (value.length) { 24 | for (let i in cities) { 25 | let items = cities[i] 26 | for (let j = 0, len = items.length; j < len; j++) { 27 | let item = items[j] 28 | if (item.name.indexOf(value) !== -1) { 29 | if (utils.isEmptyObject(alternative[i])) { 30 | alternative[i] = [] 31 | } 32 | alternative[i].push(item) 33 | } 34 | } 35 | } 36 | if (utils.isEmptyObject(alternative)) { 37 | alternative = null 38 | } 39 | this.setData({ 40 | alternative, 41 | showItems: alternative, 42 | }) 43 | } else { 44 | this.setData({ 45 | alternative: null, 46 | showItems: cities, 47 | }) 48 | } 49 | }, 50 | // 按照字母顺序生成需要的数据格式 51 | getSortedAreaObj(areas) { 52 | // let areas = staticData.areas 53 | areas = areas.sort((a, b) => { 54 | if (a.letter > b.letter) { 55 | return 1 56 | } 57 | if (a.letter < b.letter) { 58 | return -1 59 | } 60 | return 0 61 | }) 62 | let obj = {} 63 | for (let i = 0, len = areas.length; i < len; i++) { 64 | let item = areas[i] 65 | delete item.districts 66 | let letter = item.letter 67 | if (!obj[letter]) { 68 | obj[letter] = [] 69 | } 70 | obj[letter].push(item) 71 | } 72 | // 返回一个对象,直接用 wx:for 来遍历对象,index 为 key,item 为 value,item 是一个数组 73 | return obj 74 | }, 75 | choose(e) { 76 | let name = e.currentTarget.dataset.name 77 | let pages = getCurrentPages() 78 | let len = pages.length 79 | let indexPage = pages[len - 2] 80 | if (name) { 81 | indexPage.search(name, () => { 82 | wx.navigateBack({}) 83 | }) 84 | } else { 85 | indexPage.init({}, () => { 86 | wx.navigateBack({}) 87 | }) 88 | } 89 | }, 90 | // getHotCities(callback) { 91 | // wx.cloud.callFunction({ 92 | // name: 'getHotCities', 93 | // data: {}, 94 | // }) 95 | // .then(res => { 96 | // let data = res.result.data 97 | // if (data) { 98 | // this.setData({ 99 | // hotCities: data 100 | // }) 101 | // } 102 | // }) 103 | // }, 104 | onLoad () { 105 | // this.getHotCities() 106 | let cities = this.getSortedAreaObj(staticData.cities || []) 107 | this.setData({ 108 | cities, 109 | showItems: cities, 110 | }) 111 | }, 112 | }) -------------------------------------------------------------------------------- /pages/citychoose/citychoose.wxss: -------------------------------------------------------------------------------- 1 | .container { 2 | min-height: 100vh; 3 | display: flex; 4 | flex-direction: column; 5 | margin-bottom: 20rpx; 6 | margin-bottom: calc(constant(safe-area-inset-bottom)); 7 | margin-bottom: calc(env(safe-area-inset-bottom)); 8 | } 9 | .wrapper { 10 | font-size: 0; 11 | background: #fff; 12 | padding: 30rpx; 13 | position: relative; 14 | height: 128rpx; 15 | box-sizing: border-box; 16 | } 17 | .wrapper .search { 18 | display: flex; 19 | justify-content: flex-start; 20 | align-items: center; 21 | } 22 | .inner { 23 | background: #f4f6f9; 24 | font-size: 30rpx; 25 | padding: 16rpx 0 16rpx 20rpx; 26 | box-sizing: border-box; 27 | border-radius: 8rpx; 28 | flex: 1; 29 | display: flex; 30 | align-items: center; 31 | } 32 | .inner input { 33 | background: #f4f6f9; 34 | font-size: 30rpx; 35 | height: 38rpx; 36 | /* 覆盖默认样式 min-height */ 37 | min-height: 38rpx; 38 | line-height: 38rpx; 39 | width: 100%; 40 | box-sizing: border-box; 41 | } 42 | .icon { 43 | width: 28rpx; 44 | height: 28rpx; 45 | margin-right: 10rpx; 46 | } 47 | .cancel { 48 | font-size: 30rpx; 49 | display: inline-block; 50 | color: #666; 51 | width: 2.5em; 52 | text-align: right; 53 | } 54 | .items { 55 | display: flex; 56 | flex-direction: row; 57 | justify-content: flex-start; 58 | flex-wrap: wrap; 59 | } 60 | .items .item { 61 | border: 1rpx solid rgb(242, 242, 242); 62 | background: #efefef; 63 | border-radius: 10rpx; 64 | padding: 8rpx 40rpx; 65 | margin-right: 30rpx; 66 | margin-bottom: 36rpx; 67 | } 68 | .top .title { 69 | margin-bottom: 30rpx; 70 | } 71 | .top { 72 | padding: 30rpx 96rpx 20rpx 30rpx; 73 | } 74 | .top, 75 | .bottom { 76 | font-size: 32rpx; 77 | color: #333; 78 | background: #fff; 79 | } 80 | .hot { 81 | background: #fff; 82 | margin-top: 10rpx; 83 | padding: 30rpx 30rpx 20rpx; 84 | } 85 | .hot .title { 86 | font-size: 32rpx; 87 | } 88 | .hot .cities { 89 | display: flex; 90 | align-items: center; 91 | flex-wrap: wrap; 92 | } 93 | .hot .item { 94 | display: flex; 95 | justify-content: center; 96 | align-items: center; 97 | width: 30%; 98 | height: 60rpx; 99 | background: #f4f6f9; 100 | border-radius: 8rpx; 101 | color: #333; 102 | font-size: 28rpx; 103 | margin-top: 20rpx; 104 | margin-left: 2.5%; 105 | margin-right: 2.5%; 106 | } 107 | .hot .item .icon { 108 | width: 24rpx; 109 | height: 24rpx; 110 | margin-right: 8rpx; 111 | } 112 | .hot .item.active { 113 | background: #40a7e7; 114 | color: #fff; 115 | } 116 | .hot .item:nth-child(3n+1) { 117 | margin-left: 0; 118 | } 119 | .hot .item:nth-child(3n) { 120 | margin-right: 0; 121 | } 122 | .bottom .key { 123 | background: #f4f6f9; 124 | height: 50rpx; 125 | display: flex; 126 | align-items: center; 127 | padding: 0 30rpx; 128 | } 129 | .bottom .values .value { 130 | border-bottom: 1rpx solid #efefef; 131 | height: 104rpx; 132 | display: flex; 133 | align-items: center; 134 | padding: 0 30rpx; 135 | } 136 | .bottom .values .value:last-child { 137 | border-bottom: none; 138 | } 139 | .hover { 140 | background: #f4f6f9; 141 | } 142 | .empty { 143 | margin-top: 100rpx; 144 | font-size: 30rpx; 145 | text-align: center; 146 | color: #666; 147 | } 148 | -------------------------------------------------------------------------------- /icon/iconfont.wxss: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "evfont"; /* Project id 2643907 */ 3 | src: url('iconfont.eot?t=1626591226887'); /* IE9 */ 4 | src: url('iconfont.eot?t=1626591226887#iefix') format('embedded-opentype'), /* IE6-IE8 */ 5 | url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAkEAAsAAAAAEBQAAAi0AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACEdgqQTI06ATYCJAM8CyAABCAFhFUHgS0bmw0jETaDk5Il+0dh3OYkpHCzIhSHAlUIgiD55zyd15zT3ZTttJ2+/78GEa2V1dOz84ygohgdu7AKKyBFoEhFkQxLBH07hJt2aT3BSgO0HugEJlRlVB060RQCFcMrk2TzZHNkKtWJ2wP9d17MFdzGbgapvAZE7P7HXN6GaVq2wxuhUOPEvu1x+GFqiUojWqKSRL1J2iNUUqHkjuVwxbwppk1Jb5F3eQ4ChFJNJ6a/pEoJOOtxUxeIwMLnC6TOsr5Vh4Og43TsRrQQ7HXUYy3yHw/MAfMUwDH3+/KNJAkCg6fwG02vLNaAm5+BH5Yq6ZMs0Xch5w3D9gbwAAXK71mmPNzOewA0sHInQms9LYcBJBN9/JDgj3wGfyz6TPZZ32cfffbN56Gfz/uc/GGp7wPTB38sTMEfm5OQLPSppOsy/4EHQQQTRjgRWEJwGEKJRPBQEAdE+L7/g/pI+AhUEoLgYzASfCFhIGGQk4CEQ04GEgEpA2Ih+8Dplx8BcZDfIAkGPvGTEAqfQpMQCZ/mJUHgE0l4vAsdkLxbdVHHZALZYE6DjgEeth0h7746xeC94kI+H8yI9cWFR0VEV7ooMlgQHC7g+7Hq/NhsUVJ8ACpkB8vYuFKAUaskNKqBcjuJLmp2UKJKXJ3ybbTwNGsAX/+BaiczoD16N2wQWPLavcm6Y/v2DnDohyeBtQkAeeoRwmWenIH8qdOPO7jMEDC384ZT7iq3Sz0FnprLKWcVowm+u0Zw8hpzg7pOX20HMD2FhhAksNc9lztxBcFVyryZLIjdNJe02WiHA4IqJQhjt5cc3rlkA6hhT8PUyNoml8YA5CA93AFGlDBD5OA6Xj7eUTrCDHXqJgA5epFaNgIZ2ATOWvQYcBxG0QhPkzDAdIpLGaJyd0eY9AfjM0ROWNpuaQMaFaIu5VmY9pBw5vh+8QWEceM9BELH4cEdAhViFzlFM507+ygIaaM8HtrlIt1uZny8mVLWMyJdrjZSMSq6QG6K0yekRMbntFBPmvxiXNJxUAm453aDPa6XrhR6AmoTRMOwaUuR4DjyILXziqkeT8PrAa3jKH0Y1di2g71DEyHE53HzkQdse/yZgJL76kOonXOJRq2uoZ25FN6643lgnCfnQCqyfdcVBKKfSltGxXtyr71qm864EXtI3jb8HFbRg+32YaXDs+jB2JMaHpjS5BAePXuLFyXtjEjntCEixiYSOVEEgSlEYBfKjyLsjJPSQL6Uw2YDhrQ7nQNSjc0Jo7QTRW0iVIjYhUKHgG2kddA2UkDYBUcuzGlFOWitD6A6+jZu19TriMbxZZs2lpUVc4tZB6RuuSk/EnaE+VZYbXP5rOez/Kcf9dXmDxxhDt39SNjR6bOeQerY6D26g+fo+TnsYSBJfPXfadmCH/nRcyL9guaxC837L0BKMmdVzPTXMbwwUXTMG9NjDr/sjZi8mNfTDxau4m/nD367+jHxoGLBR4Fyxd38Skg0b31fD9kGrf30IHZV8XTGU8VV4H+g8LKSWUB5vGFdqXkKCB+5HL7i3q4dotmVmprAvEB9TnDuo+Clf8T8sVHfjxh7O+J+8BebQjZ9ntWyk9nb7pn17nMkkXGc+xFvj0XElZMiJdsuVBh7kZHE6U/lxIFzLvoklD9nJ0Ulsc0fBFl61+Bt+gXGn5tZnl5WL22UzZ+ytlVQW15dIlZLtMK21U+QrR0g0nq9gpcMhaQHcWLYAbMha0tKFoZOktTQRQv6uZX82VFNkY35WQU5s/jCuGq6aOHK+1X5v331jmDaYH0+ZD/nZfKqmWzQnm0GIDXtYEmR1VK8wVxcbN1QbAma9ftYxkuyMnE809icmYGbpacZltPzZ+JeL66UNUh7tnHnyXmtecrchvnyhfFv71msD+c0zFDyWuW8+T1bG6Qq2Y6p1hp+WlvkjNx2Xb4rHq1PTVAlBUSVtZTG9CSRN72LbmkgHzlLHtFSn3xSP7M6oWzagl2BMz/ym8jfpl0LOvetuLlSVy4s17GNj93jxO9OBLOdgvcEz5ThteB9QYp6XWJetX4/zj2+XWaxXM3MTEu7AgIvUP6W1MADJclxaBsalyw7kBJI5aKKiT9n+XcY279JUZ/allqv2LRiNDUw9ucCvrNz2d7InAgxxxuRyyrfFxHiG0FDDPXfv/++t01qfU8iLuYORSrj4sQYZIIwjKfA/AIN0s3jNYpDJk0s4u6MLIydujRw+OVQ0KAZDOq27PjOz+aKqeaEOghEHzxxopK7I6ooOvrZIanuW4mkaO6imgBTSlBnvb9lp+XJQ9lwTwDA/8G80mh3tWe+J7UWANARn9/A/1FvK7eM7vbx1vyih5UFw1e+95RvoC2ktZozvdMAYM6bX2btqE81BgC66HMJugsF2322/kvbjmspMaELuTm/Bof9mVvwPpzs37PPFVO/usr8ign+ga0NC/j/WxzXQ5RlY9KVfZIpilX41xggVMyB/1tFsXy4PZVAtpkCR0ICQxBpoDhyNda/GDzCqGROqBZAKGV0nRxGHGvxRWwIUMouBkI4V8AQyW1Qwnmisf7PwCOR1+AI5xeEssjf5wyjUOrhQgOBmwgN1tyHtaq7u7Sy1AQTFtu+gdCZO3BD5jDbNREGY2t3F5YoT1g0lhJdhKH3EKNFl2QyaTGtobsTK2m4UUdHN9Zj6G4j1CZ5i8nUkxUfr60dKFd3dwKYPgwQ4JhMfA0YS+lLvgY13XSh7WoCZgWWQtPQVoeZDvDOYdURiTWhzoCR1uPVMWqopHpTUyq6CKPeNtsG0pF0ZAFpwdRQA910gjF4K6xDWJCHsbm+VRsEakzIWd1R00MWVfuzraQK+aNScza8rRkYB/fZKIiAgoFDQEJBw8DCwSMgRYbFDcf6RkNr213GaMrLMWpbp4n1dOS/b+3M2zpqiCa/p4sRvf3FjOp8kQaikVufHdcZ1ntTLd1zTWfNnW2YFT8WOTDv3rTzVLLVQsw9CQAAAA==') format('woff2'), 6 | url('iconfont.woff?t=1626591226887') format('woff'), 7 | url('iconfont.ttf?t=1626591226887') format('truetype'), 8 | url('iconfont.svg?t=1626591226887#evfont') format('svg'); 9 | } 10 | 11 | .evfont { 12 | font-family: "evfont" !important; 13 | font-size: 32rpx; 14 | line-height: 1; 15 | font-style: normal; 16 | -webkit-font-smoothing: antialiased; 17 | -moz-osx-font-smoothing: grayscale; 18 | } 19 | 20 | .ev-arrow-right:before { 21 | content: "\e75c"; 22 | } 23 | 24 | .ev-stack-fill:before { 25 | content: "\e6ec"; 26 | } 27 | 28 | .ev-play:before { 29 | content: "\f07e"; 30 | } 31 | 32 | .ev-image-default:before { 33 | content: "\e629"; 34 | } 35 | 36 | .ev-exit:before { 37 | content: "\e780"; 38 | } 39 | 40 | .ev-scan:before { 41 | content: "\e6e2"; 42 | } 43 | 44 | .ev-refresh:before { 45 | content: "\e600"; 46 | } 47 | 48 | .ev-group:before { 49 | content: "\e609"; 50 | } 51 | 52 | .ev-homefill:before { 53 | content: "\e679"; 54 | } 55 | 56 | .ev-back:before { 57 | content: "\e712"; 58 | } 59 | 60 | .ev-warn:before { 61 | content: "\e60a"; 62 | } 63 | 64 | .ev-arrowup:before { 65 | content: "\e626"; 66 | } 67 | 68 | .ev-arrowdown:before { 69 | content: "\e627"; 70 | } 71 | 72 | .ev-up:before { 73 | content: "\e713"; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /pages/setting/setting.wxml: -------------------------------------------------------------------------------- 1 | 2 | 设置 3 | 4 | 5 | 6 | 7 | 8 | 9 | 自定义 10 | 11 | 12 | 19 | 20 | 打开顶部城市天气快捷搜索 21 | 22 | 23 | 24 | 显示生活指数信息 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 检查更新 33 | 34 | 35 | 36 | 37 | 打开首页更新提醒 38 | 39 | 40 | 在首页检测到新版本,会提示更新 41 | 基础库版本需高于 1.9.90,当前基础库版本为 {{SDKVersion}} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 小工具 52 | 53 | 54 | NFC 55 | 56 | 检测是否支持NFC 57 | 58 | 59 | 60 | 61 | 屏幕亮度 62 | 63 | 64 | 当前屏幕亮度 65 | 范围0~100,0 最暗,100 最亮 66 | 67 | {{screenBrightness}} 68 | 69 | 70 | 71 | 设置屏幕亮度 72 | 73 | 74 | 75 | 76 | 83 | 84 | 85 | 系统信息 86 | 87 | 88 | 查看系统信息 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 清除数据 99 | 100 | 101 | 110 | 111 | 112 | 恢复初始化设置 113 | 114 | 115 | 所有设置信息都将被清除 116 | 117 | 118 | 119 | 120 | 121 | 122 | 清除所有本地数据 123 | 124 | 125 | 所有本地数据都将被清除 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 兼容性 139 | 由于小程序基础库从 1.9.90 开始支持 wx.getUpdateManager API,故基础库低于该版本的会忽略该设置。 140 | 启动机制 141 | 小程序启动会有两种情况,一种是「冷启动」,一种是「热启动」。 假如用户已经打开过某小程序,然后在一定时间内再次打开该小程序,此时无需重新启动,只需将后台的小程序切换到前台,这个过程就是热启动;冷启动指的是用户首次打开或小程序被微信主动销毁后再次打开的情况,此时小程序需要重新加载启动。 142 | 更新机制 143 | 小程序冷启动时如果发现有新版本,将会异步下载新版本的代码包,并同时用客户端本地的包进行启动,即新版本的小程序需要等下一次冷启动才会应用上。 144 | 运行机制 145 | 146 | 1、小程序没有重启的概念; 147 | 2、当小程序进入后台,客户端会维持一段时间的运行状态,超过一定时间后(目前是5分钟)会被微信主动销毁; 148 | 3、当短时间内(5s)连续收到两次以上系统内存告警,会进行小程序的销毁。 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /pages/setting/setting.js: -------------------------------------------------------------------------------- 1 | let utils = require('../../utils/utils') 2 | Page({ 3 | data: { 4 | setting: {}, 5 | show: false, 6 | screenBrightness: '获取中', 7 | // keepscreenon: false, 8 | SDKVersion: '', 9 | enableUpdate: true, 10 | indexPage: {}, 11 | }, 12 | switchChange(e) { 13 | let dataset = e.currentTarget.dataset 14 | let switchparam = dataset.switchparam 15 | let setting = this.data.setting 16 | if (switchparam === 'forceUpdate') { 17 | if (this.data.enableUpdate) { 18 | setting[switchparam] = (e.detail || {}).value 19 | } else { 20 | setting[switchparam] = false 21 | wx.showToast({ 22 | title: '基础库版本较低,无法使用该功能', 23 | icon: 'none', 24 | duration: 2000, 25 | }) 26 | } 27 | } else if (switchparam === 'keepscreenon') { 28 | this.setKeepScreenOn(!this.data.keepscreenon) 29 | getApp().globalData.keepscreenon = !this.data.keepscreenon 30 | } else { 31 | setting[switchparam] = !(e.detail || {}).value 32 | } 33 | this.setData({ 34 | setting, 35 | }) 36 | wx.setStorage({ 37 | key: 'setting', 38 | data: setting, 39 | success: () => { 40 | this.data.indexPage.reloadInitSetting() 41 | }, 42 | }) 43 | }, 44 | // defaultBcg () { 45 | // this.removeBcg(() => { 46 | // wx.showToast({ 47 | // title: '恢复默认背景', 48 | // duration: 1500, 49 | // }) 50 | // }) 51 | // }, 52 | // removeBcg (callback) { 53 | // wx.getSavedFileList({ 54 | // success: function (res) { 55 | // let fileList = res.fileList 56 | // let len = fileList.length 57 | // if (len > 0) { 58 | // for (let i = 0; i < len; i++) 59 | // (function (path) { 60 | // wx.removeSavedFile({ 61 | // filePath: path, 62 | // complete: function (res) { 63 | // if (i === len - 1) { 64 | // callback && callback() 65 | // } 66 | // } 67 | // }) 68 | // })(fileList[i].filePath) 69 | // } else { 70 | // callback && callback() 71 | // } 72 | // }, 73 | // fail: function () { 74 | // wx.showToast({ 75 | // title: '出错了,请稍后再试', 76 | // icon: 'none', 77 | // }) 78 | // }, 79 | // }) 80 | // }, 81 | // customBcg () { 82 | // wx.chooseImage({ 83 | // success: (res) => { 84 | // this.removeBcg(() => { 85 | // wx.saveFile({ 86 | // tempFilePath: res.tempFilePaths[0], 87 | // success: function (res) { 88 | // wx.navigateBack({}) 89 | // }, 90 | // }) 91 | // }) 92 | // }, 93 | // fail: function (res) { 94 | // let errMsg = res.errMsg 95 | // // 如果是取消操作,不提示 96 | // if (errMsg.indexOf('cancel') === -1) { 97 | // wx.showToast({ 98 | // title: '发生错误,请稍后再试', 99 | // icon: 'none', 100 | // }) 101 | // } 102 | // }, 103 | // }) 104 | // }, 105 | hide () { 106 | this.setData({ 107 | show: false, 108 | }) 109 | }, 110 | updateInstruc () { 111 | this.setData({ 112 | show: true, 113 | }) 114 | }, 115 | onShow () { 116 | let pages = getCurrentPages() 117 | let len = pages.length 118 | let indexPage = pages[len - 2] 119 | // 不能初始化到 data 里面!!!! 120 | this.setData({ 121 | keepscreenon: getApp().globalData.keepscreenon, 122 | indexPage, 123 | }) 124 | this.ifDisableUpdate() 125 | this.getScreenBrightness() 126 | wx.getStorage({ 127 | key: 'setting', 128 | success: (res) => { 129 | let setting = res.data 130 | this.setData({ 131 | setting, 132 | }) 133 | }, 134 | fail: (res) => { 135 | this.setData({ 136 | setting: {}, 137 | }) 138 | }, 139 | }) 140 | }, 141 | ifDisableUpdate () { 142 | let systeminfo = getApp().globalData.systeminfo 143 | let SDKVersion = systeminfo.SDKVersion 144 | let version = utils.cmpVersion(SDKVersion, '1.9.90') 145 | if (version >=0) { 146 | this.setData({ 147 | SDKVersion, 148 | enableUpdate: true, 149 | }) 150 | } else { 151 | this.setData({ 152 | SDKVersion, 153 | enableUpdate: false, 154 | }) 155 | } 156 | }, 157 | getHCEState () { 158 | wx.showLoading({ 159 | title: '检测中...', 160 | }) 161 | wx.getHCEState({ 162 | success: function (res) { 163 | wx.hideLoading() 164 | wx.showModal({ 165 | title: '检测结果', 166 | content: '该设备支持NFC功能', 167 | showCancel: false, 168 | confirmText: '朕知道了', 169 | confirmColor: '#40a7e7', 170 | }) 171 | }, 172 | fail: function (res) { 173 | wx.hideLoading() 174 | wx.showModal({ 175 | title: '检测结果', 176 | content: '该设备不支持NFC功能', 177 | showCancel: false, 178 | confirmText: '朕知道了', 179 | confirmColor: '#40a7e7', 180 | }) 181 | }, 182 | }) 183 | }, 184 | getScreenBrightness () { 185 | wx.getScreenBrightness({ 186 | success: (res) => { 187 | this.setData({ 188 | screenBrightness: Number(res.value * 100).toFixed(0), 189 | }) 190 | }, 191 | fail: (res) => { 192 | this.setData({ 193 | screenBrightness: '获取失败', 194 | }) 195 | }, 196 | }) 197 | }, 198 | screenBrightnessChanging (e) { 199 | this.setScreenBrightness(e.detail.value) 200 | }, 201 | setScreenBrightness (val) { 202 | wx.setScreenBrightness({ 203 | value: val / 100, 204 | success: (res) => { 205 | this.setData({ 206 | screenBrightness: val, 207 | }) 208 | }, 209 | }) 210 | }, 211 | setKeepScreenOn (b) { 212 | wx.setKeepScreenOn({ 213 | keepScreenOn: b, 214 | success: () => { 215 | this.setData({ 216 | keepscreenon: b, 217 | }) 218 | }, 219 | }) 220 | }, 221 | getsysteminfo () { 222 | wx.navigateTo({ 223 | url: '/pages/systeminfo/systeminfo', 224 | }) 225 | }, 226 | removeStorage (e) { 227 | let that = this 228 | let datatype = e.currentTarget.dataset.type 229 | if (datatype === 'setting') { 230 | wx.showModal({ 231 | title: '提示', 232 | content: '确认要初始化设置', 233 | cancelText: '容朕想想', 234 | confirmColor: '#40a7e7', 235 | success: (res) => { 236 | if (res.confirm) { 237 | wx.removeStorage({ 238 | key: 'setting', 239 | success: function (res) { 240 | wx.showToast({ 241 | title: '设置已初始化', 242 | }) 243 | that.setData({ 244 | setting: {}, 245 | }) 246 | that.data.indexPage.reloadInitSetting() 247 | }, 248 | }) 249 | } 250 | }, 251 | }) 252 | } else if (datatype === 'all') { 253 | wx.showModal({ 254 | title: '提示', 255 | content: '确认要删除', 256 | cancelText: '容朕想想', 257 | confirmColor: '#40a7e7', 258 | success (res) { 259 | if (res.confirm) { 260 | wx.clearStorage({ 261 | success: (res) => { 262 | wx.showToast({ 263 | title: '数据已清除', 264 | }) 265 | that.setData({ 266 | setting: {}, 267 | pos: {}, 268 | }) 269 | that.data.indexPage.reloadInitSetting() 270 | }, 271 | }) 272 | } 273 | }, 274 | }) 275 | } 276 | }, 277 | 278 | }) -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | Quiet Weather 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 更换背景 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {{cityDatas.basic.location || '定位中'}} 38 | 39 | 40 | {{cityDatas.updateTimeFormat}} 更新 41 | 42 | {{message}} 43 | {{cityDatas.now.tmp || '-'}} 44 | {{cityDatas.now.cond_txt || '--'}} 45 | 46 | 能见度 {{cityDatas.now.vis}} 47 | 48 | 49 | 50 | 7 天预报 51 | 52 | 53 | {{item.date}} 54 | {{item.tmp_max}}~{{item.tmp_min}}℃ 55 | 56 | {{item.cond_txt_d}} 57 | 58 | 59 | {{item.wind_dir}}{{item.wind_sc}}级 60 | 61 | 62 | 63 | 64 | 65 | {{environmentVars[item]}} 66 | {{cityDatas.now[item]}} 67 | 68 | 69 | 70 | 71 | 24 小时逐 3 小时预报 72 | 73 | 74 | 75 | 76 | 77 | 78 | 温度(℃) 79 | {{item.tmp}} 80 | 81 | 82 | 天气 83 | 84 | {{item.cond_txt}} 85 | 86 | 87 | 88 | 89 | 相对湿度(%) 90 | {{item.hum}} 91 | 92 | 93 | 露点温度(℃) 94 | {{item.dew}} 95 | 96 | 97 | 降水概率 98 | {{item.pop}} 99 | 100 | 101 | 风向 102 | {{item.wind_dir}} 103 | 104 | 105 | 风向角度(deg) 106 | {{item.wind_deg}} 107 | 108 | 109 | 风力(级) 110 | {{item.wind_sc}} 111 | 112 | 113 | 风速(mk/h) 114 | {{item.wind_spd}} 115 | 116 | 117 | 气压(mb) 118 | {{item.pres}} 119 | 120 | 121 | 云量 122 | {{item.cloud}} 123 | 124 | 125 | {{item.time}} 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | {{lifestyles[item.type]}} {{item.brf}} 137 | {{item.txt}} 138 | 139 | 140 | 141 | 142 | 146 | 147 | 开发者 · myvin 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | -webkit-font-smoothing: antialiased; 3 | font-family: "PingHei","Helvetica Neue","Helvetica","Arial","Verdana","sans-serif"; 4 | } 5 | .transparentClass { 6 | background-color: rgba(0,0,0,0) !important; 7 | } 8 | .num { 9 | font-weight: 300; 10 | } 11 | .container { 12 | display: flex; 13 | flex-direction: column; 14 | color: #fff; 15 | font-size: 30rpx; 16 | } 17 | .bcg { 18 | position: fixed; 19 | z-index: 2; 20 | height: 100%; 21 | width: 100%; 22 | top: 0; 23 | right: 0; 24 | bottom: 0; 25 | left: 0; 26 | /* background: #40a7e7; */ 27 | /* background: linear-gradient(to bottom, #73C6F1, #50B5EC); */ 28 | } 29 | .search { 30 | height: 90rpx; 31 | z-index: 10; 32 | } 33 | .search .wrapper { 34 | display: flex; 35 | flex-direction: row; 36 | justify-content: flex-start; 37 | align-items: center; 38 | font-size: 28rpx; 39 | height: 60rpx; 40 | margin: 15rpx 50rpx; 41 | padding: 0 15rpx; 42 | box-sizing: border-box; 43 | /* border-radius: 10rpx; */ 44 | /* border: 1rpx solid #999; */ 45 | border: none; 46 | border-bottom: 1rpx solid #fff; 47 | } 48 | .search image { 49 | width: 28rpx; 50 | height: 28rpx; 51 | margin-right: 16rpx; 52 | } 53 | .search input { 54 | flex: 1; 55 | } 56 | .placeholderClass { 57 | color: #fff; 58 | } 59 | .chooseBcg { 60 | display: flex; 61 | flex-direction: column; 62 | z-index: 100; 63 | width: 100%; 64 | font-size: 24rpx; 65 | color: #333; 66 | } 67 | .chooseBcg .top { 68 | box-sizing: border-box; 69 | padding: 20rpx 20rpx 50rpx; 70 | background: rgba(255, 255, 255, 0); 71 | color: #fff; 72 | } 73 | .chooseBcg .bcgs { 74 | display: flex; 75 | align-items: center; 76 | margin-top: 20rpx; 77 | overflow: scroll; 78 | } 79 | .chooseBcg .border { 80 | padding: 6rpx; 81 | margin-right: 14rpx; 82 | border: 1rpx solid rgba(255, 255, 255, 0); 83 | transition: .1s ease; 84 | } 85 | .chooseBcg .border:last-child { 86 | margin-right: 0; 87 | } 88 | .chooseBcg .border.active { 89 | border: 1rpx solid #40a7e7; 90 | transition: .1s ease; 91 | } 92 | .chooseBcg .bcgs image { 93 | width: 132rpx; 94 | height: 228rpx; 95 | } 96 | .chooseBcg .close { 97 | flex: 1; 98 | background: rgba(0, 0, 0, 0); 99 | padding: 20rpx 0; 100 | text-align: center; 101 | } 102 | .chooseBcg .close image { 103 | width: 64rpx; 104 | height: 64rpx; 105 | } 106 | .avatarInfo { 107 | display: flex; 108 | align-items: center; 109 | padding: 0 50rpx; 110 | } 111 | .avatarInfo .avatar { 112 | display: block; 113 | overflow: hidden; 114 | width: 60rpx; 115 | height: 60rpx; 116 | border-radius: 50%; 117 | } 118 | .avatarInfo .name { 119 | padding: 0 20rpx; 120 | font-size: 30rpx; 121 | } 122 | .avatarInfo .downArrow { 123 | width: 20rpx; 124 | height: 20rpx; 125 | } 126 | .container .content { 127 | flex: 2; 128 | transition: .3s ease; 129 | } 130 | .content { 131 | position: relative; 132 | z-index: 2; 133 | } 134 | .info { 135 | padding: 10rpx 0 50rpx; 136 | /* border-bottom: 1rpx solid rgba(240, 240, 240, .4); */ 137 | } 138 | .info .temp, 139 | .info .pm, 140 | .info .pm view, 141 | .info .weather { 142 | position: relative; 143 | width: 100%; 144 | display: flex; 145 | flex-direction: row; 146 | justify-content: center; 147 | align-items: center; 148 | } 149 | .info .weather { 150 | margin-bottom: 30rpx; 151 | } 152 | .info .pm text { 153 | font-size: 24rpx; 154 | height: 1em; 155 | line-height: 1em; 156 | padding: 10rpx 20rpx; 157 | border-radius: 20rpx; 158 | background: rgba(240, 240, 240, .2); 159 | } 160 | .city { 161 | display: flex; 162 | align-items: center; 163 | justify-content: space-between; 164 | position: relative; 165 | padding: 0 50rpx; 166 | font-size: 66rpx; 167 | } 168 | .city .name { 169 | display: flex; 170 | justify-content: center; 171 | align-items: center; 172 | } 173 | .city .name .val { 174 | max-width: 5em; 175 | display: -webkit-box; 176 | -webkit-box-orient: vertical; 177 | -webkit-line-clamp: 1; 178 | overflow: hidden; 179 | } 180 | .city .name .icon, 181 | .city .name .down { 182 | width: 30rpx; 183 | height: 30rpx; 184 | } 185 | .city .name .icon { 186 | margin-right: 20rpx; 187 | } 188 | .city .name .down { 189 | margin-left: 20rpx; 190 | } 191 | .city .time { 192 | display: block; 193 | text-align: right; 194 | font-size: 24rpx; 195 | } 196 | .message { 197 | font-size: 22rpx; 198 | color: #fff; 199 | padding: 30rpx 50rpx 0; 200 | box-sizing: border-box; 201 | } 202 | .temp { 203 | height: 360rpx; 204 | font-size: 200rpx; 205 | } 206 | .guide .guides { 207 | display: flex; 208 | flex-direction: row; 209 | justify-content: flex-start; 210 | align-items: flex-start; 211 | font-size: 24rpx; 212 | padding-top: 20rpx; 213 | /* border-bottom: 1rpx solid rgba(240, 240, 240, .4); */ 214 | background: rgba(0, 0, 0, .6); 215 | margin-bottom: 20rpx; 216 | overflow-x: scroll; 217 | } 218 | .guide .title, 219 | .hourly .title { 220 | border-bottom: 1rpx solid rgba(250, 250, 250, .2); 221 | background: rgba(0, 0, 0, .6); 222 | font-size: 24rpx; 223 | height: 80rpx; 224 | line-height: 80rpx; 225 | text-align: center; 226 | } 227 | .guide .item { 228 | display: flex; 229 | flex-direction: column; 230 | justify-content: flex-start; 231 | align-items: center; 232 | width: 170rpx; 233 | flex-shrink: 0; 234 | } 235 | .guide image { 236 | width: 44rpx; 237 | } 238 | .guide .i { 239 | padding-bottom: 20rpx; 240 | } 241 | .guide .i.weather, 242 | .hour .weather { 243 | display: flex; 244 | justify-content: center; 245 | align-items: center; 246 | } 247 | .guide .i image, 248 | .hour .weather image { 249 | width: 40rpx; 250 | margin-left: 4rpx; 251 | } 252 | .hourly { 253 | margin-bottom: 20rpx; 254 | } 255 | .hourly .hours { 256 | padding: 20rpx 10rpx 0; 257 | background: rgba(0, 0, 0, .6); 258 | } 259 | .hourly .hours .time { 260 | font-size: 22rpx; 261 | height: 60rpx; 262 | line-height: 60rpx; 263 | text-align: center; 264 | } 265 | .details { 266 | display: flex; 267 | align-items: center; 268 | flex-wrap: wrap; 269 | background:rgba(0, 0, 0, .6); 270 | margin-bottom:20rpx; 271 | font-size: 24rpx; 272 | } 273 | .hour { 274 | display: flex; 275 | align-items: center; 276 | flex-wrap: wrap; 277 | background: rgb(107, 102, 102); 278 | font-size: 24rpx; 279 | box-sizing: border-box; 280 | border-radius: 8rpx; 281 | } 282 | .hourly swiper-item { 283 | box-sizing: border-box; 284 | padding: 0 10rpx; 285 | background: rgba(0, 0, 0, 0); 286 | } 287 | .details .detail, 288 | .hour .detail { 289 | display: flex; 290 | flex-direction: column; 291 | justify-content: space-around; 292 | align-items: center; 293 | padding: 10rpx 0; 294 | height: 100rpx; 295 | width: 25%; 296 | border-right: 1rpx solid rgba(250, 250, 250, 0.2); 297 | border-bottom: 1rpx solid rgba(250, 250, 250, 0.2); 298 | box-sizing: border-box; 299 | } 300 | .details .detail:nth-child(4n), 301 | .hour .detail:nth-child(4n) { 302 | border-right: none; 303 | } 304 | .details .detail:nth-child(n+9), 305 | .hour .detail:nth-child(n+9) { 306 | border-bottom: none; 307 | } 308 | .livingIndex { 309 | /* border-bottom: 1rpx solid rgba(240, 240, 240, .4); */ 310 | background: rgba(0, 0, 0, .6); 311 | margin-bottom: 20rpx; 312 | } 313 | .livingIndex .item { 314 | display: flex; 315 | flex-direction: row; 316 | justify-content: flex-start; 317 | align-items: center; 318 | border-bottom: 1rpx solid rgba(250, 250, 250, .2); 319 | padding: 20rpx 0; 320 | margin: 0 30rpx; 321 | } 322 | .livingIndex .item:last-child { 323 | border-bottom: none; 324 | } 325 | .livingIndex .item .right { 326 | display: flex; 327 | flex-direction: column; 328 | justify-content: space-between; 329 | align-items: flex-start; 330 | flex: 1; 331 | } 332 | .livingIndex .item .value { 333 | margin-top: 10rpx; 334 | font-size: 24rpx; 335 | } 336 | .livingIndex .icon { 337 | width: 80rpx; 338 | height: 80rpx; 339 | padding: 0 24rpx; 340 | } 341 | .menus .menu, 342 | .menus .share { 343 | height: 40px; 344 | width: 40px; 345 | border-radius: 50%; 346 | position: fixed; 347 | z-index: 100; 348 | bottom: 150rpx; 349 | right: 70rpx; 350 | opacity: 0; 351 | } 352 | .menus .share { 353 | background: rgba(0, 0, 0, 0); 354 | } 355 | .menus .main { 356 | opacity: 1; 357 | } 358 | /* 打开设置页面 button */ 359 | .openSettingButton { 360 | position: fixed; 361 | z-index: 102; 362 | width: 100%; 363 | height: 100%; 364 | top: 0; 365 | left: 0; 366 | right: 0; 367 | bottom: 0; 368 | background: rgba(0, 0, 0, .5); 369 | display: flex; 370 | flex-direction: row; 371 | justify-content: center; 372 | align-items: center; 373 | } 374 | .openSettingButton image { 375 | position: relative; 376 | width: 128rpx; 377 | height: 128rpx; 378 | z-index: 2; 379 | } 380 | .openSettingButton button { 381 | position: absolute; 382 | width: 100%; 383 | height: 100%; 384 | top: 0; 385 | left: 0; 386 | opacity: 0; 387 | z-index: 3; 388 | } 389 | .footer { 390 | display: flex; 391 | justify-content: space-around; 392 | align-items: center; 393 | height: 60rpx; 394 | font-size: 22rpx; 395 | color: #fff; 396 | } 397 | .footer .feedback { 398 | position: relative; 399 | } 400 | .footer .feedback button { 401 | opacity: 0; 402 | position: absolute; 403 | top: 0; 404 | right: 0; 405 | bottom: 0; 406 | left: 0; 407 | } -------------------------------------------------------------------------------- /components/custom-navigation-bar/custom-navigation-bar.wxss: -------------------------------------------------------------------------------- 1 | .cu-custom view { 2 | box-sizing: border-box; 3 | } 4 | .cu-custom .ev-back { 5 | font-size: 36rpx; 6 | } 7 | .cu-custom .content { 8 | font-size: 32rpx; 9 | } 10 | .navigation-bar-default-background-color { 11 | background-color: #40a7e7; 12 | color: #ffffff; 13 | } 14 | 15 | .cu-bar { 16 | display: flex; 17 | position: relative; 18 | align-items: center; 19 | min-height: 100rpx; 20 | justify-content: space-between; 21 | } 22 | 23 | .cu-bar .action { 24 | display: flex; 25 | align-items: center; 26 | height: 100%; 27 | justify-content: center; 28 | max-width: 100%; 29 | } 30 | 31 | .cu-bar .action.border-title { 32 | position: relative; 33 | top: -10rpx; 34 | } 35 | 36 | .cu-bar .action.border-title text[class*="bg-"]:last-child { 37 | position: absolute; 38 | bottom: -0.5rem; 39 | min-width: 2rem; 40 | height: 6rpx; 41 | left: 0; 42 | } 43 | 44 | .cu-bar .action.sub-title { 45 | position: relative; 46 | top: -0.2rem; 47 | } 48 | 49 | .cu-bar .action.sub-title text { 50 | position: relative; 51 | z-index: 1; 52 | } 53 | 54 | .cu-bar .action.sub-title text[class*="bg-"]:last-child { 55 | position: absolute; 56 | display: inline-block; 57 | bottom: -0.2rem; 58 | border-radius: 6rpx; 59 | width: 100%; 60 | height: 0.6rem; 61 | left: 0.6rem; 62 | opacity: 0.3; 63 | z-index: 0; 64 | } 65 | 66 | .cu-bar .action.sub-title text[class*="text-"]:last-child { 67 | position: absolute; 68 | display: inline-block; 69 | bottom: -0.7rem; 70 | left: 0.5rem; 71 | opacity: 0.2; 72 | z-index: 0; 73 | text-align: right; 74 | font-weight: 900; 75 | font-size: 36rpx; 76 | } 77 | 78 | .cu-bar.justify-center .action.border-title text:last-child, 79 | .cu-bar.justify-center .action.sub-title text:last-child { 80 | left: 0; 81 | right: 0; 82 | margin: auto; 83 | text-align: center; 84 | } 85 | 86 | .cu-bar .action:first-child, 87 | .cu-bar .action.avatar { 88 | margin-left: 30rpx; 89 | font-size: 30rpx; 90 | } 91 | .cu-bar .action.avatar .base-info { 92 | display: flex; 93 | justify-content: flex-start; 94 | align-items: center; 95 | background-color: transparent; 96 | } 97 | .cu-bar .action.avatar .avatar { 98 | width: 50rpx; 99 | height: 50rpx; 100 | border-radius: 50%; 101 | overflow: hidden; 102 | } 103 | 104 | .cu-bar .action text.text-cut { 105 | text-align: left; 106 | width: 100%; 107 | } 108 | 109 | .cu-bar .cu-avatar:first-child { 110 | margin-left: 20rpx; 111 | } 112 | 113 | .cu-bar .action:first-child>text[class*="cuIcon-"] { 114 | margin-left: -0.3em; 115 | margin-right: 0.3em; 116 | } 117 | 118 | .cu-bar .action:last-child { 119 | margin-right: 30rpx; 120 | } 121 | 122 | .cu-bar .action>text[class*="cuIcon-"], 123 | .cu-bar .action>view[class*="cuIcon-"] { 124 | font-size: 36rpx; 125 | } 126 | 127 | .cu-bar .action>text[class*="cuIcon-"]+text[class*="cuIcon-"] { 128 | margin-left: 0.5em; 129 | } 130 | 131 | .cu-bar .content { 132 | position: absolute; 133 | text-align: center; 134 | width: calc(100% - 340rpx); 135 | left: 0; 136 | right: 0; 137 | bottom: 0; 138 | top: 0; 139 | margin: auto; 140 | height: 60rpx; 141 | font-size: 32rpx; 142 | line-height: 60rpx; 143 | cursor: none; 144 | pointer-events: none; 145 | text-overflow: ellipsis; 146 | white-space: nowrap; 147 | overflow: hidden; 148 | } 149 | 150 | .cu-bar .content.left { 151 | text-align: left; 152 | margin-left: 30rpx; 153 | } 154 | 155 | .cu-bar.ios .content { 156 | bottom: 7px; 157 | height: 30px; 158 | font-size: 32rpx; 159 | line-height: 30px; 160 | } 161 | 162 | .cu-bar.btn-group { 163 | justify-content: space-around; 164 | } 165 | 166 | .cu-bar.btn-group button { 167 | padding: 20rpx 32rpx; 168 | } 169 | 170 | .cu-bar.btn-group button { 171 | flex: 1; 172 | margin: 0 20rpx; 173 | max-width: 50%; 174 | } 175 | 176 | .cu-bar .search-form { 177 | background-color: #f5f5f5; 178 | line-height: 64rpx; 179 | height: 64rpx; 180 | font-size: 24rpx; 181 | color: #000000; 182 | flex: 1; 183 | display: flex; 184 | align-items: center; 185 | margin: 0 30rpx; 186 | } 187 | 188 | .cu-bar .search-form+.action { 189 | margin-right: 30rpx; 190 | } 191 | 192 | .cu-bar .search-form input { 193 | flex: 1; 194 | padding-right: 30rpx; 195 | height: 64rpx; 196 | line-height: 64rpx; 197 | font-size: 26rpx; 198 | background-color: transparent; 199 | } 200 | 201 | .cu-bar .search-form [class*="cuIcon-"] { 202 | margin: 0 0.5em 0 0.8em; 203 | } 204 | 205 | .cu-bar .search-form [class*="cuIcon-"]::before { 206 | top: 0rpx; 207 | } 208 | 209 | .cu-bar.fixed, 210 | .nav.fixed { 211 | position: fixed; 212 | width: 100%; 213 | top: 0; 214 | z-index: 1024; 215 | box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0.1); 216 | } 217 | 218 | .cu-bar.foot { 219 | position: fixed; 220 | width: 100%; 221 | bottom: 0; 222 | z-index: 1024; 223 | box-shadow: 0 -1rpx 6rpx rgba(0, 0, 0, 0.1); 224 | } 225 | 226 | .cu-bar.tabbar { 227 | padding: 0; 228 | height: calc(100rpx + env(safe-area-inset-bottom) / 2); 229 | padding-bottom: calc(env(safe-area-inset-bottom) / 2); 230 | } 231 | 232 | .cu-tabbar-height { 233 | min-height: 100rpx; 234 | height: calc(100rpx + env(safe-area-inset-bottom) / 2); 235 | } 236 | 237 | .cu-bar.tabbar.shadow { 238 | box-shadow: 0 -1rpx 6rpx rgba(0, 0, 0, 0.1); 239 | } 240 | 241 | .cu-bar.tabbar .action { 242 | font-size: 22rpx; 243 | position: relative; 244 | flex: 1; 245 | text-align: center; 246 | padding: 0; 247 | display: block; 248 | height: auto; 249 | line-height: 1; 250 | margin: 0; 251 | overflow: initial; 252 | } 253 | 254 | .cu-bar.tabbar.shop .action { 255 | width: 140rpx; 256 | flex: initial; 257 | } 258 | 259 | .cu-bar.tabbar .action.add-action { 260 | position: relative; 261 | z-index: 2; 262 | padding-top: 50rpx; 263 | background-color: inherit; 264 | } 265 | 266 | .cu-bar.tabbar .action.add-action [class*="cuIcon-"] { 267 | position: absolute; 268 | width: 70rpx; 269 | z-index: 2; 270 | height: 70rpx; 271 | border-radius: 50%; 272 | line-height: 70rpx; 273 | font-size: 50rpx; 274 | top: -35rpx; 275 | left: 0; 276 | right: 0; 277 | margin: auto; 278 | padding: 0; 279 | } 280 | 281 | .cu-bar.tabbar .action.add-action::after { 282 | content: ""; 283 | position: absolute; 284 | width: 100rpx; 285 | height: 100rpx; 286 | top: -50rpx; 287 | left: 0; 288 | right: 0; 289 | margin: auto; 290 | box-shadow: 0 -3rpx 8rpx rgba(0, 0, 0, 0.08); 291 | border-radius: 50rpx; 292 | background-color: inherit; 293 | z-index: 0; 294 | } 295 | 296 | .cu-bar.tabbar .action.add-action::before { 297 | content: ""; 298 | position: absolute; 299 | width: 100rpx; 300 | height: 30rpx; 301 | bottom: 30rpx; 302 | left: 0; 303 | right: 0; 304 | margin: auto; 305 | background-color: inherit; 306 | z-index: 1; 307 | } 308 | 309 | .cu-bar.tabbar .btn-group { 310 | flex: 1; 311 | display: flex; 312 | justify-content: space-around; 313 | align-items: center; 314 | padding: 0 10rpx; 315 | } 316 | 317 | .cu-bar.tabbar button.action::after { 318 | border: 0; 319 | } 320 | 321 | .cu-bar.tabbar .action [class*="cuIcon-"] { 322 | width: 100rpx; 323 | position: relative; 324 | display: block; 325 | height: auto; 326 | margin: 0 auto 10rpx; 327 | text-align: center; 328 | font-size: 40rpx; 329 | } 330 | 331 | .cu-bar.tabbar .action .cuIcon-cu-image { 332 | margin: 0 auto; 333 | } 334 | 335 | .cu-bar.tabbar .action .cuIcon-cu-image image { 336 | width: 50rpx; 337 | height: 50rpx; 338 | display: inline-block; 339 | } 340 | 341 | .cu-bar.tabbar .submit { 342 | align-items: center; 343 | display: flex; 344 | justify-content: center; 345 | text-align: center; 346 | position: relative; 347 | flex: 2; 348 | align-self: stretch; 349 | } 350 | 351 | .cu-bar.tabbar .submit:last-child { 352 | flex: 2.6; 353 | } 354 | 355 | .cu-bar.tabbar .submit+.submit { 356 | flex: 2; 357 | } 358 | 359 | .cu-bar.tabbar.border .action::before { 360 | content: " "; 361 | width: 200%; 362 | height: 200%; 363 | position: absolute; 364 | top: 0; 365 | left: 0; 366 | transform: scale(0.5); 367 | transform-origin: 0 0; 368 | border-right: 1rpx solid rgba(0, 0, 0, 0.1); 369 | z-index: 3; 370 | } 371 | 372 | .cu-bar.tabbar.border .action:last-child:before { 373 | display: none; 374 | } 375 | 376 | .cu-bar.input { 377 | padding-right: 20rpx; 378 | background-color: #ffffff; 379 | } 380 | 381 | .cu-bar.input input { 382 | overflow: initial; 383 | line-height: 64rpx; 384 | height: 64rpx; 385 | min-height: 64rpx; 386 | flex: 1; 387 | font-size: 30rpx; 388 | margin: 0 20rpx; 389 | } 390 | 391 | .cu-bar.input .action { 392 | margin-left: 20rpx; 393 | } 394 | 395 | .cu-bar.input .action [class*="cuIcon-"] { 396 | font-size: 48rpx; 397 | } 398 | 399 | .cu-bar.input input+.action { 400 | margin-right: 20rpx; 401 | margin-left: 0rpx; 402 | } 403 | 404 | .cu-bar.input .action:first-child [class*="cuIcon-"] { 405 | margin-left: 0rpx; 406 | } 407 | 408 | .cu-custom { 409 | display: block; 410 | position: relative; 411 | } 412 | 413 | .cu-custom .cu-bar .content { 414 | width: calc(100% - 440rpx); 415 | } 416 | 417 | 418 | .cu-custom .cu-bar .content image { 419 | height: 60rpx; 420 | width: 240rpx; 421 | } 422 | 423 | .cu-custom .cu-bar { 424 | min-height: 0px; 425 | padding-right: 220rpx; 426 | box-shadow: 0rpx 0rpx 0rpx; 427 | z-index: 9999; 428 | } 429 | 430 | .cu-custom .cu-bar .border-custom { 431 | position: relative; 432 | background: rgba(0, 0, 0, 0.15); 433 | border-radius: 1000rpx; 434 | height: 30px; 435 | } 436 | 437 | .cu-custom .cu-bar .border-custom::after { 438 | content: " "; 439 | width: 200%; 440 | height: 200%; 441 | position: absolute; 442 | top: 0; 443 | left: 0; 444 | border-radius: inherit; 445 | transform: scale(0.5); 446 | transform-origin: 0 0; 447 | pointer-events: none; 448 | box-sizing: border-box; 449 | border: 1rpx solid #ffffff; 450 | opacity: 0.5; 451 | } 452 | 453 | .cu-custom .cu-bar .border-custom::before { 454 | content: " "; 455 | width: 1rpx; 456 | height: 110%; 457 | position: absolute; 458 | top: 22.5%; 459 | left: 0; 460 | right: 0; 461 | margin: auto; 462 | transform: scale(0.5); 463 | transform-origin: 0 0; 464 | pointer-events: none; 465 | box-sizing: border-box; 466 | opacity: 0.6; 467 | background-color: #ffffff; 468 | } 469 | 470 | .cu-custom .cu-bar .border-custom text { 471 | display: block; 472 | flex: 1; 473 | margin: auto !important; 474 | text-align: center; 475 | font-size: 34rpx; 476 | } -------------------------------------------------------------------------------- /icon/iconfont.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by iconfont 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /data/staticData.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | cities: [{ "letter": "B", "name": "北京市" }, { "letter": "T", "name": "天津市" }, { "letter": "S", "name": "石家庄市" }, { "letter": "T", "name": "唐山市" }, { "letter": "Q", "name": "秦皇岛市" }, { "letter": "H", "name": "邯郸市" }, { "letter": "X", "name": "邢台市" }, { "letter": "B", "name": "保定市" }, { "letter": "Z", "name": "张家口市" }, { "letter": "C", "name": "承德市" }, { "letter": "C", "name": "沧州市" }, { "letter": "L", "name": "廊坊市" }, { "letter": "H", "name": "衡水市" }, { "letter": "T", "name": "太原市" }, { "letter": "D", "name": "大同市" }, { "letter": "Y", "name": "阳泉市" }, { "letter": "C", "name": "长治市" }, { "letter": "J", "name": "晋城市" }, { "letter": "S", "name": "朔州市" }, { "letter": "J", "name": "晋中市" }, { "letter": "Y", "name": "运城市" }, { "letter": "X", "name": "忻州市" }, { "letter": "L", "name": "临汾市" }, { "letter": "L", "name": "吕梁市" }, { "letter": "H", "name": "呼和浩特市" }, { "letter": "B", "name": "包头市" }, { "letter": "W", "name": "乌海市" }, { "letter": "C", "name": "赤峰市" }, { "letter": "T", "name": "通辽市" }, { "letter": "E", "name": "鄂尔多斯市" }, { "letter": "H", "name": "呼伦贝尔市" }, { "letter": "B", "name": "巴彦淖尔市" }, { "letter": "W", "name": "乌兰察布市" }, { "letter": "X", "name": "兴安盟" }, { "letter": "X", "name": "锡林郭勒盟" }, { "letter": "A", "name": "阿拉善盟" }, { "letter": "S", "name": "沈阳市" }, { "letter": "D", "name": "大连市" }, { "letter": "A", "name": "鞍山市" }, { "letter": "F", "name": "抚顺市" }, { "letter": "B", "name": "本溪市" }, { "letter": "D", "name": "丹东市" }, { "letter": "J", "name": "锦州市" }, { "letter": "Y", "name": "营口市" }, { "letter": "F", "name": "阜新市" }, { "letter": "L", "name": "辽阳市" }, { "letter": "P", "name": "盘锦市" }, { "letter": "T", "name": "铁岭市" }, { "letter": "C", "name": "朝阳市" }, { "letter": "H", "name": "葫芦岛市" }, { "letter": "Z", "name": "长春市" }, { "letter": "J", "name": "吉林市" }, { "letter": "S", "name": "四平市" }, { "letter": "L", "name": "辽源市" }, { "letter": "T", "name": "通化市" }, { "letter": "B", "name": "白山市" }, { "letter": "S", "name": "松原市" }, { "letter": "B", "name": "白城市" }, { "letter": "Y", "name": "延边朝鲜族自治州" }, { "letter": "H", "name": "哈尔滨市" }, { "letter": "Q", "name": "齐齐哈尔市" }, { "letter": "J", "name": "鸡西市" }, { "letter": "H", "name": "鹤岗市" }, { "letter": "S", "name": "双鸭山市" }, { "letter": "D", "name": "大庆市" }, { "letter": "Y", "name": "伊春市" }, { "letter": "J", "name": "佳木斯市" }, { "letter": "Q", "name": "七台河市" }, { "letter": "M", "name": "牡丹江市" }, { "letter": "H", "name": "黑河市" }, { "letter": "S", "name": "绥化市" }, { "letter": "D", "name": "大兴安岭地区" }, { "letter": "S", "name": "上海市" }, { "letter": "N", "name": "南京市" }, { "letter": "W", "name": "无锡市" }, { "letter": "X", "name": "徐州市" }, { "letter": "C", "name": "常州市" }, { "letter": "S", "name": "苏州市" }, { "letter": "N", "name": "南通市" }, { "letter": "L", "name": "连云港市" }, { "letter": "H", "name": "淮安市" }, { "letter": "Y", "name": "盐城市" }, { "letter": "Y", "name": "扬州市" }, { "letter": "Z", "name": "镇江市" }, { "letter": "T", "name": "泰州市" }, { "letter": "S", "name": "宿迁市" }, { "letter": "H", "name": "杭州市" }, { "letter": "N", "name": "宁波市" }, { "letter": "W", "name": "温州市" }, { "letter": "J", "name": "嘉兴市" }, { "letter": "H", "name": "湖州市" }, { "letter": "S", "name": "绍兴市" }, { "letter": "J", "name": "金华市" }, { "letter": "Q", "name": "衢州市" }, { "letter": "Z", "name": "舟山市" }, { "letter": "T", "name": "台州市" }, { "letter": "L", "name": "丽水市" }, { "letter": "H", "name": "合肥市" }, { "letter": "W", "name": "芜湖市" }, { "letter": "B", "name": "蚌埠市" }, { "letter": "H", "name": "淮南市" }, { "letter": "M", "name": "马鞍山市" }, { "letter": "H", "name": "淮北市" }, { "letter": "T", "name": "铜陵市" }, { "letter": "A", "name": "安庆市" }, { "letter": "H", "name": "黄山市" }, { "letter": "C", "name": "滁州市" }, { "letter": "F", "name": "阜阳市" }, { "letter": "S", "name": "宿州市" }, { "letter": "L", "name": "六安市" }, { "letter": "B", "name": "亳州市" }, { "letter": "C", "name": "池州市" }, { "letter": "X", "name": "宣城市" }, { "letter": "F", "name": "福州市" }, { "letter": "S", "name": "厦门市" }, { "letter": "P", "name": "莆田市" }, { "letter": "S", "name": "三明市" }, { "letter": "Q", "name": "泉州市" }, { "letter": "Z", "name": "漳州市" }, { "letter": "N", "name": "南平市" }, { "letter": "L", "name": "龙岩市" }, { "letter": "N", "name": "宁德市" }, { "letter": "N", "name": "南昌市" }, { "letter": "J", "name": "景德镇市" }, { "letter": "P", "name": "萍乡市" }, { "letter": "J", "name": "九江市" }, { "letter": "X", "name": "新余市" }, { "letter": "Y", "name": "鹰潭市" }, { "letter": "G", "name": "赣州市" }, { "letter": "J", "name": "吉安市" }, { "letter": "Y", "name": "宜春市" }, { "letter": "F", "name": "抚州市" }, { "letter": "S", "name": "上饶市" }, { "letter": "J", "name": "济南市" }, { "letter": "Q", "name": "青岛市" }, { "letter": "Z", "name": "淄博市" }, { "letter": "Z", "name": "枣庄市" }, { "letter": "D", "name": "东营市" }, { "letter": "Y", "name": "烟台市" }, { "letter": "W", "name": "潍坊市" }, { "letter": "J", "name": "济宁市" }, { "letter": "T", "name": "泰安市" }, { "letter": "W", "name": "威海市" }, { "letter": "R", "name": "日照市" }, { "letter": "L", "name": "莱芜市" }, { "letter": "L", "name": "临沂市" }, { "letter": "D", "name": "德州市" }, { "letter": "L", "name": "聊城市" }, { "letter": "B", "name": "滨州市" }, { "letter": "H", "name": "菏泽市" }, { "letter": "Z", "name": "郑州市" }, { "letter": "K", "name": "开封市" }, { "letter": "L", "name": "洛阳市" }, { "letter": "P", "name": "平顶山市" }, { "letter": "A", "name": "安阳市" }, { "letter": "H", "name": "鹤壁市" }, { "letter": "X", "name": "新乡市" }, { "letter": "J", "name": "焦作市" }, { "letter": "P", "name": "濮阳市" }, { "letter": "X", "name": "许昌市" }, { "letter": "L", "name": "漯河市" }, { "letter": "S", "name": "三门峡市" }, { "letter": "N", "name": "南阳市" }, { "letter": "S", "name": "商丘市" }, { "letter": "X", "name": "信阳市" }, { "letter": "Z", "name": "周口市" }, { "letter": "Z", "name": "驻马店市" }, { "letter": "J", "name": "济源市" }, { "letter": "W", "name": "武汉市" }, { "letter": "H", "name": "黄石市" }, { "letter": "S", "name": "十堰市" }, { "letter": "Y", "name": "宜昌市" }, { "letter": "X", "name": "襄阳市" }, { "letter": "E", "name": "鄂州市" }, { "letter": "J", "name": "荆门市" }, { "letter": "X", "name": "孝感市" }, { "letter": "J", "name": "荆州市" }, { "letter": "H", "name": "黄冈市" }, { "letter": "X", "name": "咸宁市" }, { "letter": "S", "name": "随州市" }, { "letter": "E", "name": "恩施土家族苗族自治州" }, { "letter": "X", "name": "仙桃市" }, { "letter": "Q", "name": "潜江市" }, { "letter": "T", "name": "天门市" }, { "letter": "S", "name": "神农架林区" }, { "letter": "C", "name": "长沙市" }, { "letter": "Z", "name": "株洲市" }, { "letter": "X", "name": "湘潭市" }, { "letter": "H", "name": "衡阳市" }, { "letter": "S", "name": "邵阳市" }, { "letter": "Y", "name": "岳阳市" }, { "letter": "C", "name": "常德市" }, { "letter": "Z", "name": "张家界市" }, { "letter": "Y", "name": "益阳市" }, { "letter": "C", "name": "郴州市" }, { "letter": "Y", "name": "永州市" }, { "letter": "H", "name": "怀化市" }, { "letter": "L", "name": "娄底市" }, { "letter": "X", "name": "湘西土家族苗族自治州" }, { "letter": "G", "name": "广州市" }, { "letter": "S", "name": "韶关市" }, { "letter": "S", "name": "深圳市" }, { "letter": "Z", "name": "珠海市" }, { "letter": "S", "name": "汕头市" }, { "letter": "F", "name": "佛山市" }, { "letter": "J", "name": "江门市" }, { "letter": "Z", "name": "湛江市" }, { "letter": "M", "name": "茂名市" }, { "letter": "Z", "name": "肇庆市" }, { "letter": "H", "name": "惠州市" }, { "letter": "M", "name": "梅州市" }, { "letter": "S", "name": "汕尾市" }, { "letter": "H", "name": "河源市" }, { "letter": "Y", "name": "阳江市" }, { "letter": "Q", "name": "清远市" }, { "letter": "D", "name": "东莞市" }, { "letter": "Z", "name": "中山市" }, { "letter": "C", "name": "潮州市" }, { "letter": "J", "name": "揭阳市" }, { "letter": "Y", "name": "云浮市" }, { "letter": "N", "name": "南宁市" }, { "letter": "L", "name": "柳州市" }, { "letter": "G", "name": "桂林市" }, { "letter": "W", "name": "梧州市" }, { "letter": "B", "name": "北海市" }, { "letter": "F", "name": "防城港市" }, { "letter": "Q", "name": "钦州市" }, { "letter": "G", "name": "贵港市" }, { "letter": "Y", "name": "玉林市" }, { "letter": "B", "name": "百色市" }, { "letter": "H", "name": "贺州市" }, { "letter": "H", "name": "河池市" }, { "letter": "L", "name": "来宾市" }, { "letter": "C", "name": "崇左市" }, { "letter": "H", "name": "海口市" }, { "letter": "S", "name": "三亚市" }, { "letter": "S", "name": "三沙市" }, { "letter": "D", "name": "儋州市" }, { "letter": "W", "name": "五指山市" }, { "letter": "Q", "name": "琼海市" }, { "letter": "W", "name": "文昌市" }, { "letter": "W", "name": "万宁市" }, { "letter": "D", "name": "东方市" }, { "letter": "D", "name": "定安县" }, { "letter": "T", "name": "屯昌县" }, { "letter": "C", "name": "澄迈县" }, { "letter": "L", "name": "临高县" }, { "letter": "B", "name": "白沙黎族自治县" }, { "letter": "C", "name": "昌江黎族自治县" }, { "letter": "L", "name": "乐东黎族自治县" }, { "letter": "L", "name": "陵水黎族自治县" }, { "letter": "B", "name": "保亭黎族苗族自治县" }, { "letter": "Q", "name": "琼中黎族苗族自治县" }, { "letter": "C", "name": "重庆市" }, { "letter": "C", "name": "成都市" }, { "letter": "Z", "name": "自贡市" }, { "letter": "P", "name": "攀枝花市" }, { "letter": "L", "name": "泸州市" }, { "letter": "D", "name": "德阳市" }, { "letter": "M", "name": "绵阳市" }, { "letter": "G", "name": "广元市" }, { "letter": "S", "name": "遂宁市" }, { "letter": "N", "name": "内江市" }, { "letter": "L", "name": "乐山市" }, { "letter": "N", "name": "南充市" }, { "letter": "M", "name": "眉山市" }, { "letter": "Y", "name": "宜宾市" }, { "letter": "G", "name": "广安市" }, { "letter": "D", "name": "达州市" }, { "letter": "Y", "name": "雅安市" }, { "letter": "B", "name": "巴中市" }, { "letter": "Z", "name": "资阳市" }, { "letter": "A", "name": "阿坝藏族羌族自治州" }, { "letter": "G", "name": "甘孜藏族自治州" }, { "letter": "L", "name": "凉山彝族自治州" }, { "letter": "G", "name": "贵阳市" }, { "letter": "L", "name": "六盘水市" }, { "letter": "Z", "name": "遵义市" }, { "letter": "A", "name": "安顺市" }, { "letter": "B", "name": "毕节市" }, { "letter": "T", "name": "铜仁市" }, { "letter": "Q", "name": "黔西南布依族苗族自治州" }, { "letter": "Q", "name": "黔东南苗族侗族自治州" }, { "letter": "Q", "name": "黔南布依族苗族自治州" }, { "letter": "K", "name": "昆明市" }, { "letter": "Q", "name": "曲靖市" }, { "letter": "Y", "name": "玉溪市" }, { "letter": "B", "name": "保山市" }, { "letter": "Z", "name": "昭通市" }, { "letter": "L", "name": "丽江市" }, { "letter": "P", "name": "普洱市" }, { "letter": "L", "name": "临沧市" }, { "letter": "C", "name": "楚雄彝族自治州" }, { "letter": "H", "name": "红河哈尼族彝族自治州" }, { "letter": "W", "name": "文山壮族苗族自治州" }, { "letter": "X", "name": "西双版纳傣族自治州" }, { "letter": "D", "name": "大理白族自治州" }, { "letter": "D", "name": "德宏傣族景颇族自治州" }, { "letter": "N", "name": "怒江傈僳族自治州" }, { "letter": "D", "name": "迪庆藏族自治州" }, { "letter": "L", "name": "拉萨市" }, { "letter": "R", "name": "日喀则市" }, { "letter": "C", "name": "昌都市" }, { "letter": "L", "name": "林芝市" }, { "letter": "S", "name": "山南市" }, { "letter": "N", "name": "那曲地区" }, { "letter": "A", "name": "阿里地区" }, { "letter": "X", "name": "西安市" }, { "letter": "T", "name": "铜川市" }, { "letter": "B", "name": "宝鸡市" }, { "letter": "X", "name": "咸阳市" }, { "letter": "W", "name": "渭南市" }, { "letter": "Y", "name": "延安市" }, { "letter": "H", "name": "汉中市" }, { "letter": "Y", "name": "榆林市" }, { "letter": "A", "name": "安康市" }, { "letter": "S", "name": "商洛市" }, { "letter": "L", "name": "兰州市" }, { "letter": "J", "name": "嘉峪关市" }, { "letter": "J", "name": "金昌市" }, { "letter": "B", "name": "白银市" }, { "letter": "T", "name": "天水市" }, { "letter": "W", "name": "武威市" }, { "letter": "Z", "name": "张掖市" }, { "letter": "P", "name": "平凉市" }, { "letter": "J", "name": "酒泉市" }, { "letter": "Q", "name": "庆阳市" }, { "letter": "D", "name": "定西市" }, { "letter": "L", "name": "陇南市" }, { "letter": "L", "name": "临夏回族自治州" }, { "letter": "G", "name": "甘南藏族自治州" }, { "letter": "X", "name": "西宁市" }, { "letter": "H", "name": "海东市" }, { "letter": "H", "name": "海北藏族自治州" }, { "letter": "H", "name": "黄南藏族自治州" }, { "letter": "H", "name": "海南藏族自治州" }, { "letter": "G", "name": "果洛藏族自治州" }, { "letter": "Y", "name": "玉树藏族自治州" }, { "letter": "H", "name": "海西蒙古族藏族自治州" }, { "letter": "Y", "name": "银川市" }, { "letter": "S", "name": "石嘴山市" }, { "letter": "W", "name": "吴忠市" }, { "letter": "G", "name": "固原市" }, { "letter": "Z", "name": "中卫市" }, { "letter": "W", "name": "乌鲁木齐市" }, { "letter": "K", "name": "克拉玛依市" }, { "letter": "T", "name": "吐鲁番市" }, { "letter": "H", "name": "哈密市" }, { "letter": "C", "name": "昌吉回族自治州" }, { "letter": "B", "name": "博尔塔拉蒙古自治州" }, { "letter": "B", "name": "巴音郭楞蒙古自治州" }, { "letter": "A", "name": "阿克苏地区" }, { "letter": "K", "name": "克孜勒苏柯尔克孜自治州" }, { "letter": "K", "name": "喀什地区" }, { "letter": "H", "name": "和田地区" }, { "letter": "Y", "name": "伊犁哈萨克自治州" }, { "letter": "T", "name": "塔城地区" }, { "letter": "A", "name": "阿勒泰地区" }, { "letter": "S", "name": "石河子市" }, { "letter": "A", "name": "阿拉尔市" }, { "letter": "T", "name": "图木舒克市" }, { "letter": "W", "name": "五家渠市" }, { "letter": "B", "name": "北屯市" }, { "letter": "S", "name": "双河市" }, { "letter": "K", "name": "可克达拉市" }] 3 | } 4 | -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | import { BackgroundImageList, EnvironmentVars, LifeStyles, BroadCastMessages } from '../../constant'; 2 | 3 | let utils = require('../../utils/utils') 4 | let globalData = getApp().globalData 5 | const key = globalData.key 6 | let SYSTEMINFO = globalData.systeminfo 7 | let rewardedVideoAd = null; 8 | Page({ 9 | data: { 10 | transparentClass: 'transparentClass', 11 | isIPhoneX: globalData.isIPhoneX, 12 | message: '', 13 | cityDatas: {}, 14 | hourlyDatas: [], 15 | weatherIconUrl: globalData.weatherIconUrl, 16 | EnvironmentVars: { 17 | key: ['tmp', 'fl', 'hum', 'pcpn', 'wind_dir', 'wind_deg', 'wind_sc', 'wind_spd', 'vis', 'pres', 'cloud', ''], 18 | val: EnvironmentVars, 19 | }, 20 | lifestyles: LifeStyles, 21 | // 用来清空 input 22 | searchText: '', 23 | // 是否已经弹出 24 | hasPopped: false, 25 | animationMain: {}, 26 | animationOne: {}, 27 | animationTwo: {}, 28 | animationThree: {}, 29 | // 是否切换了城市 30 | located: true, 31 | // 需要查询的城市 32 | searchCity: '', 33 | setting: {}, 34 | bcgImgList: BackgroundImageList, 35 | bcgImgIndex: 0, 36 | bcgImg: '', 37 | bcgImgAreaShow: false, 38 | bcgColor: '#2d2225', 39 | // 粗暴直接:移除后再创建,达到初始化组件的作用 40 | showHeartbeat: true, 41 | // heartbeat 时禁止搜索,防止动画执行 42 | enableSearch: true, 43 | openSettingButtonShow: false, 44 | shareInfo: {}, 45 | pageShowCount: 0, 46 | isWx: getApp().globalData.platform === 'wx', 47 | }, 48 | success (data, location) { 49 | this.setData({ 50 | openSettingButtonShow: false, 51 | searchCity: location, 52 | }) 53 | wx.stopPullDownRefresh() 54 | let now = new Date() 55 | // 存下来源数据 56 | data.updateTime = now.getTime() 57 | data.updateTimeFormat = utils.formatDate(now, "MM-dd hh:mm") 58 | wx.setStorage({ 59 | key: 'cityDatas', 60 | data, 61 | }) 62 | this.setData({ 63 | cityDatas: data, 64 | }) 65 | }, 66 | fail(res) { 67 | wx.stopPullDownRefresh() 68 | let errMsg = res.errMsg || '' 69 | // 拒绝授权地理位置权限 70 | if (errMsg.indexOf('deny') !== -1 || errMsg.indexOf('denied') !== -1) { 71 | wx.showToast({ 72 | title: '需要开启地理位置权限', 73 | icon: 'none', 74 | duration: 2500, 75 | success: (res) => { 76 | if (this.canUseOpenSettingApi()) { 77 | let timer = setTimeout(() => { 78 | clearTimeout(timer) 79 | wx.openSetting({}) 80 | }, 2500) 81 | } else { 82 | this.setData({ 83 | openSettingButtonShow: true, 84 | }) 85 | } 86 | }, 87 | }) 88 | } else { 89 | wx.showToast({ 90 | title: '网络不给力,请稍后再试', 91 | icon: 'none', 92 | }) 93 | } 94 | }, 95 | initRewardedVideo () { 96 | rewardedVideoAd = wx.createRewardedVideoAd({ 97 | adUnitId: 'adunit-5598044ee112a568' 98 | }); 99 | rewardedVideoAd.onLoad(() => {}); 100 | rewardedVideoAd.onError((err) => {}); 101 | rewardedVideoAd.onClose((res) => {}); 102 | }, 103 | showRewardedVideo () { 104 | rewardedVideoAd.show().catch(() => { 105 | rewardedVideoAd.load() 106 | .then(() => rewardedVideoAd.show()) 107 | .catch(err => { 108 | console.log('激励视频 广告显示失败') 109 | }) 110 | }); 111 | }, 112 | showInterstitialAd () { 113 | // 在页面中定义插屏广告 114 | let interstitialAd = null 115 | 116 | // 在页面onLoad回调事件中创建插屏广告实例 117 | if (wx.createInterstitialAd) { 118 | interstitialAd = wx.createInterstitialAd({ 119 | adUnitId: 'adunit-c83634ff3bc695cd' 120 | }) 121 | interstitialAd.onLoad(() => { }) 122 | interstitialAd.onError((err) => { }) 123 | interstitialAd.onClose(() => { }) 124 | } 125 | 126 | // 在适合的场景显示插屏广告 127 | if (interstitialAd) { 128 | interstitialAd.show().catch((err) => { 129 | console.error(err) 130 | }) 131 | } 132 | }, 133 | commitSearch (res) { 134 | this.showInterstitialAd() 135 | let val = ((res.detail || {}).value || '').replace(/\s+/g, '') 136 | this.search(val) 137 | }, 138 | dance() { 139 | this.setData({ 140 | enableSearch: false, 141 | }) 142 | let heartbeat = this.selectComponent('#heartbeat') 143 | heartbeat.dance(() => { 144 | this.setData({ 145 | showHeartbeat: false, 146 | enableSearch: true, 147 | }) 148 | this.setData({ 149 | showHeartbeat: true, 150 | }) 151 | }) 152 | }, 153 | clearInput () { 154 | this.setData({ 155 | searchText: '', 156 | }) 157 | }, 158 | search (val, callback) { 159 | if (val === '520' || val === '521') { 160 | this.clearInput() 161 | this.dance() 162 | return 163 | } 164 | wx.pageScrollTo({ 165 | scrollTop: 0, 166 | duration: 300, 167 | }) 168 | if (val) { 169 | this.setData({ 170 | located: false, 171 | }) 172 | this.getWeather(val) 173 | this.getHourly(val) 174 | } 175 | callback && callback() 176 | }, 177 | // wx.openSetting 要废弃,button open-type openSetting 2.0.7 后支持 178 | // 使用 wx.canIUse('openSetting') 都会返回 true,这里判断版本号区分 179 | canUseOpenSettingApi () { 180 | let systeminfo = getApp().globalData.systeminfo 181 | let SDKVersion = systeminfo.SDKVersion 182 | let version = utils.cmpVersion(SDKVersion, '2.0.7') 183 | if (version < 0) { 184 | return true 185 | } else { 186 | return false 187 | } 188 | }, 189 | init(params, callback) { 190 | this.setData({ 191 | located: true, 192 | }) 193 | wx.getLocation({ 194 | type: 'gcj02', // qq 必须 195 | success: (res) => { 196 | this.getWeather(`${res.latitude},${res.longitude}`) 197 | this.getHourly(`${res.latitude},${res.longitude}`) 198 | callback && callback() 199 | }, 200 | fail: (res) => { 201 | this.fail(res) 202 | } 203 | }) 204 | }, 205 | getWeather (location) { 206 | wx.request({ 207 | url: `${globalData.requestUrl.weather}`, 208 | data: { 209 | location, 210 | key, 211 | }, 212 | success: (res) => { 213 | if (res.statusCode === 200) { 214 | let data = res.data.HeWeather6[0] 215 | if (data.status === 'ok') { 216 | this.clearInput() 217 | this.success(data, location) 218 | } else { 219 | wx.showToast({ 220 | title: '查询失败', 221 | icon: 'none', 222 | }) 223 | } 224 | } 225 | }, 226 | fail: () => { 227 | wx.showToast({ 228 | title: '查询失败', 229 | icon: 'none', 230 | }) 231 | }, 232 | }) 233 | }, 234 | getHourly(location) { 235 | wx.request({ 236 | url: `${globalData.requestUrl.hourly}`, 237 | data: { 238 | location, 239 | key, 240 | }, 241 | success: (res) => { 242 | if (res.statusCode === 200) { 243 | let data = res.data.HeWeather6[0] 244 | if (data.status === 'ok') { 245 | this.setData({ 246 | hourlyDatas: data.hourly || [] 247 | }) 248 | } 249 | } 250 | }, 251 | fail: () => { 252 | wx.showToast({ 253 | title: '查询失败', 254 | icon: 'none', 255 | }) 256 | }, 257 | }) 258 | }, 259 | onPullDownRefresh (res) { 260 | this.reloadWeather() 261 | }, 262 | getCityDatas() { 263 | let cityDatas = wx.getStorage({ 264 | key: 'cityDatas', 265 | success: (res) => { 266 | this.setData({ 267 | cityDatas: res.data, 268 | }) 269 | }, 270 | }) 271 | }, 272 | setBcgImg (index) { 273 | if (index !== undefined) { 274 | this.setData({ 275 | bcgImgIndex: index, 276 | bcgImg: this.data.bcgImgList[index].src, 277 | bcgColor: this.data.bcgImgList[index].topColor, 278 | }) 279 | this.setNavigationBarColor() 280 | return 281 | } 282 | wx.getStorage({ 283 | key: 'bcgImgIndex', 284 | success: (res) => { 285 | let bcgImgIndex = res.data || 0 286 | this.setData({ 287 | bcgImgIndex, 288 | bcgImg: this.data.bcgImgList[bcgImgIndex].src, 289 | bcgColor: this.data.bcgImgList[bcgImgIndex].topColor, 290 | }) 291 | this.setNavigationBarColor() 292 | }, 293 | fail: () => { 294 | this.setData({ 295 | bcgImgIndex: 0, 296 | bcgImg: this.data.bcgImgList[0].src, 297 | bcgColor: this.data.bcgImgList[0].topColor, 298 | }) 299 | this.setNavigationBarColor() 300 | }, 301 | }) 302 | }, 303 | setNavigationBarColor (color) { 304 | let bcgColor = color || this.data.bcgColor 305 | wx.setNavigationBarColor({ 306 | frontColor: '#ffffff', 307 | backgroundColor: this.data.bcgColor, 308 | }) 309 | }, 310 | // getBroadcast (callback) { 311 | // wx.cloud.callFunction({ 312 | // name: 'getBroadcast', 313 | // data: { 314 | // hour: new Date().getHours(), 315 | // }, 316 | // }) 317 | // .then(res => { 318 | // let data = res.result.data 319 | // if (data) { 320 | // callback && callback(data[0].message) 321 | // } 322 | // }) 323 | // }, 324 | reloadGetBroadcast () { 325 | // this.getBroadcast((message) => { 326 | // this.setData({ 327 | // message, 328 | // }) 329 | // }) 330 | const len = BroadCastMessages.length; 331 | const index = Math.floor(Math.random() * len); 332 | this.setData({ 333 | message: BroadCastMessages[index], 334 | }); 335 | }, 336 | reloadWeather () { 337 | if (this.data.located) { 338 | this.init({}) 339 | } else { 340 | this.search(this.data.searchCity) 341 | this.setData({ 342 | searchCity: '', 343 | }) 344 | } 345 | }, 346 | onShow() { 347 | this.setData({ 348 | pageShowCount: ++this.data.pageShowCount, 349 | }) 350 | // 注意:这里是测试广告的,上线后请注释掉 351 | if (this.data.pageShowCount === 3) { 352 | this.showRewardedVideo() 353 | } else { 354 | if (this.data.pageShowCount > 1) { 355 | this.showInterstitialAd() 356 | } 357 | } 358 | }, 359 | onLoad () { 360 | this.setBcgImg() 361 | this.getCityDatas() 362 | this.reloadInitSetting() 363 | this.reloadGetBroadcast() 364 | this.reloadWeather(); 365 | 366 | this.initRewardedVideo() 367 | }, 368 | checkUpdate (setting) { 369 | // 兼容低版本 370 | if (!setting.forceUpdate || !wx.getUpdateManager) { 371 | return 372 | } 373 | let updateManager = wx.getUpdateManager() 374 | updateManager.onCheckForUpdate((res) => { 375 | console.error(res) 376 | }) 377 | updateManager.onUpdateReady(function () { 378 | wx.showModal({ 379 | title: '更新提示', 380 | content: '新版本已下载完成,是否重启应用?', 381 | success: function (res) { 382 | if (res.confirm) { 383 | updateManager.applyUpdate() 384 | } 385 | } 386 | }) 387 | }) 388 | }, 389 | showBcgImgArea () { 390 | this.setData({ 391 | bcgImgAreaShow: true, 392 | }) 393 | }, 394 | hideBcgImgArea () { 395 | this.setData({ 396 | bcgImgAreaShow: false, 397 | }) 398 | }, 399 | chooseBcg (e) { 400 | let dataset = e.currentTarget.dataset 401 | let src = dataset.src 402 | let index = dataset.index 403 | this.setBcgImg(index) 404 | wx.setStorage({ 405 | key: 'bcgImgIndex', 406 | data: index, 407 | }) 408 | }, 409 | toCitychoose () { 410 | wx.navigateTo({ 411 | url: '/pages/citychoose/citychoose', 412 | }) 413 | }, 414 | initSetting (successFunc) { 415 | wx.getStorage({ 416 | key: 'setting', 417 | success: (res) => { 418 | let setting = res.data || {} 419 | this.setData({ 420 | setting, 421 | }) 422 | successFunc && successFunc(setting) 423 | }, 424 | fail: () => { 425 | this.setData({ 426 | setting: {}, 427 | }) 428 | }, 429 | }) 430 | }, 431 | reloadInitSetting () { 432 | this.initSetting((setting) => { 433 | this.checkUpdate(setting) 434 | }) 435 | }, 436 | onShareAppMessage () { 437 | return { 438 | title: '出行天气早知道', 439 | path: '/pages/index/index', 440 | imageUrl: '/img/share/img1.png', 441 | } 442 | }, 443 | onShareTimeline () { 444 | return { 445 | title: '出现天气早知道', 446 | } 447 | }, 448 | menuHide () { 449 | if (this.data.hasPopped) { 450 | this.takeback() 451 | this.setData({ 452 | hasPopped: false, 453 | }) 454 | } 455 | }, 456 | menuMain () { 457 | if (!this.data.hasPopped) { 458 | this.popp() 459 | this.setData({ 460 | hasPopped: true, 461 | }) 462 | } else { 463 | this.takeback() 464 | this.setData({ 465 | hasPopped: false, 466 | }) 467 | } 468 | }, 469 | menuToCitychoose () { 470 | this.menuMain() 471 | wx.navigateTo({ 472 | url: '/pages/citychoose/citychoose', 473 | }) 474 | }, 475 | menuToSetting () { 476 | this.menuMain() 477 | wx.navigateTo({ 478 | url: '/pages/setting/setting', 479 | }) 480 | }, 481 | menuToAbout () { 482 | this.menuMain() 483 | wx.navigateTo({ 484 | url: '/pages/about/about', 485 | }) 486 | }, 487 | popp() { 488 | let animationMain = wx.createAnimation({ 489 | duration: 200, 490 | timingFunction: 'ease-out' 491 | }) 492 | let animationOne = wx.createAnimation({ 493 | duration: 200, 494 | timingFunction: 'ease-out' 495 | }) 496 | let animationTwo = wx.createAnimation({ 497 | duration: 200, 498 | timingFunction: 'ease-out' 499 | }) 500 | let animationThree = wx.createAnimation({ 501 | duration: 200, 502 | timingFunction: 'ease-out' 503 | }) 504 | let animationFour = wx.createAnimation({ 505 | duration: 200, 506 | timingFunction: 'ease-out' 507 | }) 508 | animationMain.rotateZ(180).step() 509 | animationOne.translate(0, -60).rotateZ(360).opacity(1).step() 510 | animationTwo.translate(-Math.sqrt(3600 - 400), -30).rotateZ(360).opacity(1).step() 511 | animationThree.translate(-Math.sqrt(3600 - 400), 30).rotateZ(360).opacity(1).step() 512 | animationFour.translate(0, 60).rotateZ(360).opacity(1).step() 513 | this.setData({ 514 | animationMain: animationMain.export(), 515 | animationOne: animationOne.export(), 516 | animationTwo: animationTwo.export(), 517 | animationThree: animationThree.export(), 518 | animationFour: animationFour.export(), 519 | }) 520 | }, 521 | takeback() { 522 | let animationMain = wx.createAnimation({ 523 | duration: 200, 524 | timingFunction: 'ease-out' 525 | }) 526 | let animationOne = wx.createAnimation({ 527 | duration: 200, 528 | timingFunction: 'ease-out' 529 | }) 530 | let animationTwo = wx.createAnimation({ 531 | duration: 200, 532 | timingFunction: 'ease-out' 533 | }) 534 | let animationThree = wx.createAnimation({ 535 | duration: 200, 536 | timingFunction: 'ease-out' 537 | }) 538 | let animationFour = wx.createAnimation({ 539 | duration: 200, 540 | timingFunction: 'ease-out' 541 | }) 542 | animationMain.rotateZ(0).step(); 543 | animationOne.translate(0, 0).rotateZ(0).opacity(0).step() 544 | animationTwo.translate(0, 0).rotateZ(0).opacity(0).step() 545 | animationThree.translate(0, 0).rotateZ(0).opacity(0).step() 546 | animationFour.translate(0, 0).rotateZ(0).opacity(0).step() 547 | this.setData({ 548 | animationMain: animationMain.export(), 549 | animationOne: animationOne.export(), 550 | animationTwo: animationTwo.export(), 551 | animationThree: animationThree.export(), 552 | animationFour: animationFour.export(), 553 | }) 554 | }, 555 | }) --------------------------------------------------------------------------------