Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
weather pages
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonxiang committed May 12, 2017
1 parent 56e2bff commit 5f1d243
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 69 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "node build/build.js"
},
"dependencies": {
"axios": "^0.16.1",
"fastclick": "^1.0.6",
"leaflet": "^1.0.2",
"leaflet.locatecontrol": "^0.60.0",
Expand Down
3 changes: 2 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<view-box ref="viewBox">
<x-header :left-options="{showBack: false}">
{{title}}
<a v-show="rightOption.show" slot="right" :href="'#/'+rightOption.link">{{rightOption.name}}</a>
<router-link v-if="rightOption.show" slot="right"
:to="rightOption.link">{{rightOption.name}}</router-link>
</x-header>
<transition :name="'vux-pop-' + (direction === 'forward' ? 'in' : 'out')">
<router-view class="router-view"></router-view>
Expand Down
4 changes: 4 additions & 0 deletions src/network/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const WEATHERKEY = '5wetuvenll5qucca'
export const AMAPKEY = 'ea889682997a181fd6678d9aaf23693a'
export const weatherhost = 'https://api.thinkpage.cn/v3/weather'
export const amaphost = 'https://restapi.amap.com/v3/geocode/regeo'
Empty file added src/network/getFutureWeather.js
Empty file.
2 changes: 2 additions & 0 deletions src/network/getNowWeather.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import {weatherhost} from './api'

36 changes: 4 additions & 32 deletions src/pages/Weather.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,12 @@
</template>

<script>
import { mapMutations } from 'vuex'
import { mapMutations, mapGetters} from 'vuex'
export default {
data() {
return {
now: {
cityName: 'Shenzhen',
text: 'Sunny',
temperature: 20,
},
future: [
{
day: '今日',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
{
day: '明天',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
{
day: '后天',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
]
}
computed:{
...mapGetters(['now', 'future'])
},
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ else {
}


const router = new VueRouter({ routes })
const router = new VueRouter({mode:'history', routes })

export default router
2 changes: 2 additions & 0 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export const deleteCity = makeAction(types.DELETE_CITY)
export const toggleCity = makeAction(types.TOGGLE_CITY)

export const updateDirction = makeAction(types.UPDATE_DIRECTION)

// export const getNowWeather =
6 changes: 5 additions & 1 deletion src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ export const selectedCities = (state) => state.cities.filter(city => state.map.

export const cities = state => state.cities

export const rightOption = state => state.rightOption
export const rightOption = state => state.rightOption

export const now = state => state.now

export const future = state => state.future
6 changes: 5 additions & 1 deletion src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export const UPDATE_DIRECTION = "UPDATE_DIRECTION"

export const SET_TITLE = "SET_TITLE"

export const SET_RIGHT_OPTION = 'SET_RIGHT_OPTION'
export const SET_RIGHT_OPTION = 'SET_RIGHT_OPTION'

export const SET_NOW_WEATHER = 'SET_NOW_WEATHER'

export const SET_FUTURE_WEATHER = 'SET_FUTURE_WEATHER'
8 changes: 8 additions & 0 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ export default {

[types.SET_RIGHT_OPTION](state, rightOption){
state.rightOption = rightOption
},

[types.SET_NOW_WEATHER](state, now){
state.now = now
},

[types.SET_FUTURE_WEATHER](state, future){
state.future = future
}
}
41 changes: 34 additions & 7 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import * as getters from './getters'
import * as actions from './actions'

const state = {
title:'地图',
title: '地图',
direction: 'forward',
map:{
map: {
cityName: 'Shenzhen',
coordinate: [22.5455537937, 114.0544373601],
selectedNames: ['Shenzhen', 'Beijing','Shanghai'],
selectedNames: ['Shenzhen', 'Beijing', 'Shanghai'],
},
rightOption:{
rightOption: {
show: true,
name:'城市',
link:'cities',
name: '城市',
link: 'cities',
},
cities: [
{ name: 'Shenzhen', coordinates: [22.5455537937, 114.0544373601] },
Expand All @@ -26,7 +26,34 @@ const state = {
{ name: 'Xian', coordinates: [34.3427473471, 108.9351962803] },
{ name: 'Wuhan', coordinates: [30.5951668577, 114.2998018195] }
],

now: {
cityName: 'Shenzhen',
text: 'Sunny',
temperature: 20,
},
future: [
{
day: '今日',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
{
day: '明天',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
{
day: '后天',
codeDay: '1',
codeNight: '2',
high: 25,
low: 20,
},
]
};

export default {
Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><title></title><meta name=format-detection content="telephone=no"><meta name=format-detection content="email=no"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black><link href=static/css/app.4b470795bb1a0aac2231ab236694e52d.css rel=stylesheet></head><body ontouchstart><div id=app></div><script type=text/javascript src=static/js/manifest.d4656fd9bedf3bc9ea40.js></script><script type=text/javascript src=static/js/vendor.bec7213b16d754ec4d4a.js></script><script type=text/javascript src=static/js/app.931a6ae2c3fcf70dd9f4.js></script></body></html>
<!DOCTYPE html><html><head><title></title><meta name=format-detection content="telephone=no"><meta name=format-detection content="email=no"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black><link href=static/css/app.c6cd963247f10bcd2bc803ef623e0506.css rel=stylesheet></head><body ontouchstart><div id=app></div><script type=text/javascript src=static/js/manifest.bfe82b42cf8a38e31fe7.js></script><script type=text/javascript src=static/js/vendor.e0d3a0d1c4d6e0fcae0e.js></script><script type=text/javascript src=static/js/app.39248fcefdfe65656f6a.js></script></body></html>

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file added www/static/img/5.7f39279.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions www/static/js/app.39248fcefdfe65656f6a.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions www/static/js/app.39248fcefdfe65656f6a.js.map

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions www/static/js/app.931a6ae2c3fcf70dd9f4.js

This file was deleted.

1 change: 0 additions & 1 deletion www/static/js/app.931a6ae2c3fcf70dd9f4.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion www/static/js/vendor.bec7213b16d754ec4d4a.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions www/static/js/vendor.e0d3a0d1c4d6e0fcae0e.js.map

Large diffs are not rendered by default.

0 comments on commit 5f1d243

Please sign in to comment.