| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- var app = new Vue({
- 'el': '#app',
- 'data': {
- // 当前导航
- curNav: 'index',
- // 定位信息
- location: {
- city: '南宁市',
- address: '',
- info: {},
- lng: '',
- lat: ''
- },
- // 幻灯片列表
- advertList: [],
- id: 0,
- },
- created: function(){
- this.getAdvertList();
- },
- updated: function(){
- // 顶部轮播图
- var mySwiper = new Swiper ('.swiper-container', {
- // 如果需要分页器
- autoplay:true,
- pagination: {
- el: '.swiper-pagination'
- }
- });
- },
- mounted: function(){
- this.loadLocation();
- },
- methods: {
- // 搜索
- search: function(){
- var kw = $.trim($("#search").find('.keyword').val());
- location.href = '/weixin/shop/search?kw='+kw;
- },
- // 获取幻灯片,列表
- getAdvertList: function(){
- var _this = this;
- $.post('/weixin/index/getAdvertList', {}, function (res) {
- if (res.code == 'success') {
- _this.advertList = res.data
- }else if(res.code == 'login'){
- login(res.data.url);
- }
- }, "json");
- },
- // 初始化定位
- initPoint: function(){
- var lng = sessionStorage.getItem('point_lng');
- var lat = sessionStorage.getItem('point_lat');
- var city = sessionStorage.getItem('city');
- if(lng){
- this.params.lng = lng;
- }
- if(lat){
- this.params.lat = lat;
- }
- if(city){
- this.location.city = city;
- }
- },
- // 定位
- loadLocation: function () {
- var _this = this;
- var geolocation = new BMap.Geolocation();
- //$.showLoading('获取定位中...')
- geolocation.getCurrentPosition(function (r) {
- $.hideLoading();
- if (this.getStatus() == BMAP_STATUS_SUCCESS) {
- _this.location.lat = r.point.lat;
- _this.location.lat = r.point.lat;
- _this.location.info = r.address;
- _this.location.city = r.address.city;
- _this.location.address = r.address.province+' '+r.address.city +' '+r.address.district;
- sessionStorage.setItem('point_lng', r.point.lng)
- sessionStorage.setItem('point_lat', r.point.lat)
- sessionStorage.setItem('city', r.address.city)
- sessionStorage.setItem('address', _this.location.address)
- setTimeout(function(){
- $.toast.prototype.defaults.duration = 2000;
- $.toast('您的城市:'+_this.location.city,'text');
- }, 500)
- }
- else {
- $.toast('获取您的位置信息失败', 'text');
- }
- }, {enableHighAccuracy: true});
- },
- }
- })
|