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

Commit 041fc84

Browse files
committed
new discovery
1 parent c0fa970 commit 041fc84

28 files changed

+289
-124
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"axios": "^0.16.1",
1313
"fastclick": "^1.0.6",
14+
"jsonp": "^0.2.1",
1415
"leaflet": "^1.0.2",
1516
"leaflet.locatecontrol": "^0.60.0",
1617
"object-assign": "^4.1.1",

src/components/GridLink.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<card :header="{title:'更多服务'}">
3+
<grid slot="content">
4+
<grid-item v-for="item in items" :label="item.label" :link="item.link">
5+
<img slot="icon" :src="item.img">
6+
</grid-item>
7+
</grid>
8+
</card>
9+
</template>
10+
11+
<script>
12+
import { mapMutations } from 'vuex'
13+
import { Grid, GridItem, Card } from 'vux'
14+
15+
export default {
16+
data() {
17+
return {
18+
items: [{
19+
label: "百度",
20+
link: "https://www.baidu.com",
21+
img: require("../assets/vux_logo.png"),
22+
}, {
23+
label: "滴滴",
24+
link: "https://common.diditaxi.com.cn/general/webEntry?code=031RcUHP1bDB5717NpHP1U6KHP1RcUHV&state=123#/",
25+
img: require("../assets/vux_logo.png"),
26+
}, {
27+
label: "美团外卖",
28+
link: "https://takeaway.dianping.com/waimai/wxwallet#!index/source=redir",
29+
img: require("../assets/vux_logo.png"),
30+
}]
31+
}
32+
},
33+
34+
components: {
35+
Grid,
36+
GridItem,
37+
Card
38+
},
39+
40+
mounted() {
41+
this.SET_TITLE(this.$t('Discovery'))
42+
this.SET_RIGHT_OPTION({show:false})
43+
},
44+
45+
methods: {
46+
...mapMutations(['SET_TITLE','SET_RIGHT_OPTION'])
47+
}
48+
}
49+
</script>

src/network/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const WEATHERUID = 'U4B4E3B9B9'
12
export const WEATHERKEY = '5wetuvenll5qucca'
23
export const AMAPKEY = 'ea889682997a181fd6678d9aaf23693a'
34
export const weatherhost = 'https://api.thinkpage.cn/v3/weather'

src/network/getFutureWeather.js

Whitespace-only changes.

src/network/getNowWeather.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/network/getWeather.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import axios from 'axios'
2+
import { weatherhost } from './api'
3+
4+
export const getFutureWeather = (params) => axios.get(weatherhost + '/daily.json', {params})
5+
6+
export const getNowWeather = (params) => axios.get(weatherhost + '/now.json', {params})

src/network/jsonp.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import jsonp from 'jsonp'
2+
import querystring from 'querystring'
3+
4+
export default function(url, data, params) {
5+
return new Promise((resolve, reject) => {
6+
if (data) url += "?" + querystring.stringify(data)
7+
params = params || {timeout: 15000}
8+
if (!params.timeout) params.timeout = 15000
9+
jsonp(url, params, (err, data) => {
10+
if (err) {
11+
reject(err)
12+
} else {
13+
resolve(data)
14+
}
15+
})
16+
})
17+
}

src/pages/Discovery.vue

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
<template>
2-
<grid>
3-
<grid-item v-for="item in items" :label="item.label" :link="item.link">
4-
<img slot="icon" :src="item.img">
5-
</grid-item>
6-
</grid>
2+
<panel header="我的博客" :footer="footer" :list="list" :type="type"></panel>
73
</template>
84

95
<script>
10-
import {mapMutations} from 'vuex'
11-
import { Grid, GridItem } from 'vux'
6+
import {Panel} from 'vux'
7+
8+
export default {
9+
components:{
10+
Panel,
11+
},
1212
13-
export default {
14-
data() {
15-
return {
16-
items: [{
17-
label: "百度",
18-
link: "https://www.baidu.com",
19-
img: require("../assets/vux_logo.png"),
20-
}, {
21-
label: "滴滴",
22-
link: "https://common.diditaxi.com.cn/general/webEntry?code=031RcUHP1bDB5717NpHP1U6KHP1RcUHV&state=123#/",
23-
img: require("../assets/vux_logo.png"),
24-
}, {
25-
label: "美团外卖",
26-
link: "https://takeaway.dianping.com/waimai/wxwallet#!index/source=redir",
27-
img: require("../assets/vux_logo.png"),
28-
}]
13+
data(){
14+
return {
15+
type:'1',
16+
list: [{
17+
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
18+
title: '标题一',
19+
desc: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。',
20+
url: '/component/cell'
21+
}, {
22+
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
23+
title: '标题二',
24+
desc: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。',
25+
url: {
26+
path: '/component/radio',
27+
replace: false
28+
}
29+
}],
30+
footer: {
31+
title: '查看更多',
32+
url: 'http://vux.li'
33+
}
34+
}
35+
}
2936
}
30-
},
31-
32-
components: {
33-
Grid,
34-
GridItem,
35-
},
36-
37-
mounted() {
38-
this.SET_TITLE(this.$t('Discovery'))
39-
this.SET_RIGHT_OPTION({show:false})
40-
},
41-
42-
methods: {
43-
...mapMutations(['SET_TITLE','SET_RIGHT_OPTION'])
44-
}
45-
}
4637
</script>

src/pages/Setting.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@
99
<popup-picker :title="$t('Language')" :data="langs" v-model="currentLang" @on-change="onChange"></popup-picker>
1010
<cell :title="$t('About')" link="/about" is-link></cell>
1111
</group>
12+
<grid-link></grid-link>
1213
</div>
1314
</template>
1415

1516
<script>
1617
import { mapMutations } from 'vuex'
1718
import { Group, Cell, Blur, PopupPicker } from 'vux'
19+
import GridLink from '../components/GridLink'
1820
1921
export default {
2022
components: {
2123
Group,
2224
Cell,
2325
Blur,
2426
PopupPicker,
27+
GridLink,
2528
},
2629
2730
computed: {

src/pages/Weather.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<div class="vux-1px-t vux-1px-b future-box" v-for="item in future">
1010
<span class="future-text">{{item.day}}</span>
1111
<span class="future-text">日</span>
12-
<img class="future-img" :src="require(`../assets/weather/${item.codeDay}.png`)">
12+
<img class="future-img" :src="require(`../assets/weather/${item.code_day}.png`)">
1313
<span class="future-text">夜</span>
14-
<img class="future-img" :src="require(`../assets/weather/${item.codeNight}.png`)">
14+
<img class="future-img" :src="require(`../assets/weather/${item.code_night}.png`)">
1515
<span class="future-text">{{item.high}}</span>
1616
<span class="future-text">{{item.low}}</span>
1717
</div>
@@ -20,21 +20,28 @@
2020
</template>
2121

2222
<script>
23-
import { mapMutations, mapGetters} from 'vuex'
23+
24+
import { mapMutations, mapGetters, mapActions} from 'vuex'
2425
2526
export default {
2627
2728
computed:{
2829
...mapGetters(['now', 'future'])
2930
},
3031
32+
created(){
33+
const fetch = [this.loadNowWeather(), this.loadDailyWeather()]
34+
Promise.all(fetch)
35+
},
36+
3137
mounted() {
3238
this.SET_TITLE('天气')
3339
this.SET_RIGHT_OPTION({show:true,name:'城市',link:'cities'})
3440
},
3541
3642
methods: {
37-
...mapMutations(['SET_TITLE','SET_RIGHT_OPTION'])
43+
...mapMutations(['SET_TITLE','SET_RIGHT_OPTION']),
44+
...mapActions(['loadNowWeather','loadDailyWeather'])
3845
}
3946
}
4047
</script>

0 commit comments

Comments
 (0)