Browse Source

活动日历添加经纬度

master
nige 3 years ago
parent
commit
5c18912560
  1. 56
      pages/list/activitynew/index.js
  2. 1
      pages/list/scene/index.js

56
pages/list/activitynew/index.js

@ -34,7 +34,8 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
let d = new Date(); let d = new Date();
let month = d.getMonth() + 1,day = d.getDate(); let month = d.getMonth() + 1,
day = d.getDate();
month = month > 10 ? month : ("0" + month); month = month > 10 ? month : ("0" + month);
day = day > 10 ? day : ("0" + day); day = day > 10 ? day : ("0" + day);
this.setData({ this.setData({
@ -56,7 +57,20 @@ Page({
this.setData({ this.setData({
areas: res.data areas: res.data
}) })
this.getList() let that = this
wx.getLocation({
type: 'gcj02',
success: function (res) {
that.setData({
lat: res.latitude,
lon: res.longitude
})
that.getList()
},
fail: function () {
that.getList()
}
})
}) })
}, },
changeType: function (e) { changeType: function (e) {
@ -83,9 +97,12 @@ Page({
}, },
// 获取当前选择日期的一周日期范围 // 获取当前选择日期的一周日期范围
getWeekDay: function () { getWeekDay: function () {
var myDate = this.data.selectDay, daySecond = 24 * 60 * 60 * 1000,reslist=[]; var myDate = this.data.selectDay,
daySecond = 24 * 60 * 60 * 1000,
reslist = [];
for (let i = myDate - daySecond * 3; i <= myDate + daySecond * 3; i = i + daySecond) { for (let i = myDate - daySecond * 3; i <= myDate + daySecond * 3; i = i + daySecond) {
let day = new Date(i),putDate = day.getDate(); let day = new Date(i),
putDate = day.getDate();
putDate = putDate >= 10 ? putDate : '0' + putDate putDate = putDate >= 10 ? putDate : '0' + putDate
let item = { let item = {
times: i, times: i,
@ -119,6 +136,8 @@ Page({
category: this.data.types[this.data.type], category: this.data.types[this.data.type],
keywords: this.data.realKeywords, keywords: this.data.realKeywords,
area_key: this.data.areas[this.data.area].area_code, area_key: this.data.areas[this.data.area].area_code,
lon:this.data.lon,
lat:this.data.lat,
page_num: 10 page_num: 10
}).then(res => { }).then(res => {
this.setData({ this.setData({
@ -144,8 +163,10 @@ Page({
}, },
// 点击修改日期 // 点击修改日期
changeDate: function (e) { changeDate: function (e) {
let times = e.currentTarget.dataset.times,d = new Date(times); let times = e.currentTarget.dataset.times,
let month = d.getMonth()+1,day = d.getDate(); d = new Date(times);
let month = d.getMonth() + 1,
day = d.getDate();
month = month > 10 ? month : ('0' + month); month = month > 10 ? month : ('0' + month);
day = day > 10 ? day : ('0' + day); day = day > 10 ? day : ('0' + day);
this.setData({ this.setData({
@ -176,6 +197,8 @@ Page({
category: this.data.types[this.data.type], category: this.data.types[this.data.type],
keywords: this.data.realKeywords, keywords: this.data.realKeywords,
area_key: this.data.areas[this.data.area].area_code, area_key: this.data.areas[this.data.area].area_code,
lat: this.data.lat,
lon: this.data.lon,
page_num: 10 page_num: 10
}).then(res => { }).then(res => {
let now = new Date().getTime(); let now = new Date().getTime();
@ -188,8 +211,7 @@ Page({
end_date = new Date(end_date.replace(/-/g, '/')).getTime(); end_date = new Date(end_date.replace(/-/g, '/')).getTime();
if (end_date < now) { if (end_date < now) {
item.is_end = true; item.is_end = true;
} } else {
else {
item.is_end = false; item.is_end = false;
} }
} }
@ -236,8 +258,7 @@ Page({
if (item.distance || item.distance == 0) { if (item.distance || item.distance == 0) {
if (item.distance >= 1000) { if (item.distance >= 1000) {
item.distance = (item.distance / 1000).toFixed(2) + 'km'; item.distance = (item.distance / 1000).toFixed(2) + 'km';
} } else {
else {
item.distance = (item.distance).toFixed(2) + 'm'; item.distance = (item.distance).toFixed(2) + 'm';
} }
} }
@ -263,15 +284,13 @@ Page({
}) })
} }
}) })
} } else {
else {
commonApi._post('Cinema/' + service[this.data.movieType], data).then(res => { commonApi._post('Cinema/' + service[this.data.movieType], data).then(res => {
res.data.map(item => { res.data.map(item => {
if (item.distance || item.distance == 0) { if (item.distance || item.distance == 0) {
if (item.distance >= 1000) { if (item.distance >= 1000) {
item.distance = (item.distance / 1000).toFixed(2) + 'km'; item.distance = (item.distance / 1000).toFixed(2) + 'km';
} } else {
else {
item.distance = (item.distance).toFixed(2) + 'm'; item.distance = (item.distance).toFixed(2) + 'm';
} }
} }
@ -313,13 +332,11 @@ Page({
wx.navigateTo({ wx.navigateTo({
url: '/pages/list/movieticket/list/info/index?id=' + item.third_id url: '/pages/list/movieticket/list/info/index?id=' + item.third_id
}) })
} } else if (this.data.type == 4) {
else if(this.data.type==4){
wx.navigateTo({ wx.navigateTo({
url: '/pages/list/movieticket/list/cinema/index?id=' + item.third_id url: '/pages/list/movieticket/list/cinema/index?id=' + item.third_id
}) })
} } else {
else {
wx.navigateTo({ wx.navigateTo({
url: '/pages/info/activityInfo/index?id=' + item.id, url: '/pages/info/activityInfo/index?id=' + item.id,
}) })
@ -343,8 +360,7 @@ Page({
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function () {},
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示

1
pages/list/scene/index.js

@ -39,7 +39,6 @@ Page({
that.getList() that.getList()
} }
}) })
}, },
search:function(e){ search:function(e){
this.setData(e.detail); this.setData(e.detail);

Loading…
Cancel
Save