-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcity.html
111 lines (102 loc) · 3.27 KB
/
city.html
1
2
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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>选择城市</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--标准mui.css-->
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/font-awesome.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/app.css" />
<script src="js/mui.min.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
</head>
<body>
<!--<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">选择城市</h1>
</header>-->
<div class="mui-content city" id="vue1">
<div class="mui-col-xs-12" v-if="pointCity != null">
<h5>GPS定位</h5>
<a class=" mui-col-xs-3 mui-pull-left mui-text-center" v-on:click="chooseCity(pointCity)">
<img :src="pointCity.pictures" class="img-responsive img-circle" />{{pointCity.name}}
</a>
<div class="mui-clearfix"></div>
</div>
<div class="mui-col-xs-12" v-for="country in countries">
<h5>{{country.name}}</h5>
<a class="mui-col-xs-3 mui-pull-left mui-text-center" v-on:click="chooseCity(city)" v-for="city in country.cities">
<img :src="city.pictures" class=" img-responsive img-circle" />{{city.name}}
</a>
<div class="mui-clearfix"></div>
</div>
</div>
<script src="js/mui.min.js"></script>
<script type="text/javascript">
var param = getRequest(); //得到url参数
var vue1 = new Vue({
el: '#vue1',
data: {
countries: [],
pointCity: null
},
updated: function() {
this.$nextTick(function() {})
},
methods: {
chooseCity: function(city) {
console.log(JSON.stringify(city))
console.log("设置城市");
myLocalStorage.setItem("city", city);
//wx.miniProgram.postMessage({ data: {city: cityName} })
wx.miniProgram.navigateTo({
url: '/pages/index/index'
});
//强制刷新首页
/*wx.miniProgram.reLaunch({
url:'/pages/index/index'
})*/
}
}
});
function loadCountryData() {
$.ajax({
dataType: "json",
type: "get",
url: basePath + "/services/allcities",
data: {},
success: function(result) {
if(result.status == 0) {
vue1.countries = result.result.countries;
var cities = result.result.cities
for(var i = 0; i < cities.length; i++) {
var city = cities[i];
if(param.cityName) {
if(param.cityName.indexOf(city.name) != -1) {
vue1.pointCity = city;
}
}
}
} else {
mui.toast(res.errmsg)
}
},
error: function(result) {
mui.toast("请求遇到问题!")
}
});
}
$(function() {
loadCountryData();
})
</script>
</body>
</html>