Browse Source

活动日历添加经纬度

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

406
pages/list/activitynew/index.js

@ -8,25 +8,25 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
isYL:false, isYL: false,
selectDay:new Date().getTime(), selectDay: new Date().getTime(),
days: ['日','一','二','三','四','五','六'], days: ['日', '一', '二', '三', '四', '五', '六'],
types:[null,'show','exhibition','scene','movie','lecture','other'], types: [null, 'show', 'exhibition', 'scene', 'movie', 'lecture', 'other'],
weeks:[], weeks: [],
pageNo:1, pageNo: 1,
sort:"", sort: "",
list:[], list: [],
date:null, date: null,
total:1, total: 1,
areas:['姑苏','吴江','苏州'], areas: ['姑苏', '吴江', '苏州'],
area:0, area: 0,
type:2, type: 2,
movieType:1, movieType: 1,
moreFlag:true, moreFlag: true,
lat:"", lat: "",
lon:"", lon: "",
keywords:"", keywords: "",
realKeywords:"" realKeywords: ""
}, },
/** /**
@ -34,317 +34,333 @@ 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,
month = month>10?month:("0"+month); day = d.getDate();
day = day>10?day:("0"+day); month = month > 10 ? month : ("0" + month);
day = day > 10 ? day : ("0" + day);
this.setData({ this.setData({
selectDay:d.getTime(), selectDay: d.getTime(),
date:d.getFullYear()+"-"+month+"-"+day date: d.getFullYear() + "-" + month + "-" + day
}) })
this.getWeekDay(); this.getWeekDay();
commonApi._post("pbservice/Other/getSuzhouAreas").then(res=>{ commonApi._post("pbservice/Other/getSuzhouAreas").then(res => {
res.data.unshift({ res.data.unshift({
area_code:"", area_code: "",
area_name:"苏州市" area_name: "苏州市"
}) })
if(options.area_code){ if (options.area_code) {
let index = res.data.findIndex(item=>item.area_code==options.area_code); let index = res.data.findIndex(item => item.area_code == options.area_code);
this.setData({ this.setData({
area:index area: index
}) })
} }
this.setData({ this.setData({
areas:res.data areas: res.data
})
let that = this
wx.getLocation({
type: 'gcj02',
success: function (res) {
that.setData({
lat: res.latitude,
lon: res.longitude
})
that.getList()
},
fail: function () {
that.getList()
}
}) })
this.getList()
}) })
}, },
changeType:function(e){ changeType: function (e) {
this.setData({ this.setData({
type:e.currentTarget.dataset.type, type: e.currentTarget.dataset.type,
list:[], list: [],
total:1, total: 1,
pageNo:1, pageNo: 1,
moreFlag:true, moreFlag: true,
keywords:"", keywords: "",
realKeywords:"" realKeywords: ""
}) })
this.getList(); this.getList();
}, },
changeArea:function(e){ changeArea: function (e) {
this.setData({ this.setData({
area:e.detail.value, area: e.detail.value,
list:[], list: [],
total:1, total: 1,
pageNo:1, pageNo: 1,
moreFlag:true moreFlag: true
}) })
this.getList() this.getList()
}, },
// 获取当前选择日期的一周日期范围 // 获取当前选择日期的一周日期范围
getWeekDay:function(){ getWeekDay: function () {
var myDate = this.data.selectDay, daySecond = 24 * 60 * 60 * 1000,reslist=[]; var myDate = this.data.selectDay,
for (let i = myDate - daySecond * 3; i <= myDate + daySecond * 3; i = i + daySecond){ daySecond = 24 * 60 * 60 * 1000,
let day = new Date(i),putDate = day.getDate(); reslist = [];
putDate = putDate>=10?putDate:'0'+putDate for (let i = myDate - daySecond * 3; i <= myDate + daySecond * 3; i = i + daySecond) {
let day = new Date(i),
putDate = day.getDate();
putDate = putDate >= 10 ? putDate : '0' + putDate
let item = { let item = {
times:i, times: i,
day:this.data.days[day.getDay()], day: this.data.days[day.getDay()],
date:putDate, date: putDate,
isSelect:i==myDate isSelect: i == myDate
}; };
reslist.push(item); reslist.push(item);
} }
this.setData({ this.setData({
weeks: reslist weeks: reslist
}) })
}, },
yulan:function(e){ yulan: function (e) {
let flag = e.currentTarget.dataset.flag; let flag = e.currentTarget.dataset.flag;
if(flag==0 && this.data.isYL || flag==1 && this.data.isYL==false) return; if (flag == 0 && this.data.isYL || flag == 1 && this.data.isYL == false) return;
this.setData({ this.setData({
isYL:flag==0, isYL: flag == 0,
list:[], list: [],
pageNo:1, pageNo: 1,
total:1, total: 1,
moreFlag:true, moreFlag: true,
selectDay:null selectDay: null
}) })
this.getList() this.getList()
}, },
getYL:function(){ getYL: function () {
let list = this.data.list; let list = this.data.list;
commonApi._post("pbservice/Actcalendar/getActPrevList",{ commonApi._post("pbservice/Actcalendar/getActPrevList", {
page_no:this.data.pageNo, page_no: this.data.pageNo,
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,
page_num:10 lon:this.data.lon,
}).then(res=>{ lat:this.data.lat,
page_num: 10
}).then(res => {
this.setData({ this.setData({
total:res.data.total, total: res.data.total,
list:list.concat(res.data.rows), list: list.concat(res.data.rows),
pageNo:this.data.pageNo+1 pageNo: this.data.pageNo + 1
}) })
}) })
}, },
// picker修改日期 // picker修改日期
bindDateChange:function(e){ bindDateChange: function (e) {
this.setData({ this.setData({
selectDay: new Date(e.detail.value).getTime(), selectDay: new Date(e.detail.value).getTime(),
list:[], list: [],
pageNo:1, pageNo: 1,
total:1, total: 1,
date:e.detail.value, date: e.detail.value,
moreFlag:true, moreFlag: true,
isYL:false isYL: false
}) })
this.getWeekDay(); this.getWeekDay();
this.getList(); this.getList();
}, },
// 点击修改日期 // 点击修改日期
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);
month = month>10?month:('0'+month); let month = d.getMonth() + 1,
day = day>10?day:('0'+day); day = d.getDate();
month = month > 10 ? month : ('0' + month);
day = day > 10 ? day : ('0' + day);
this.setData({ this.setData({
selectDay: times, selectDay: times,
date:d.getFullYear()+"-"+month+"-"+day, date: d.getFullYear() + "-" + month + "-" + day,
list:[], list: [],
pageNo:1, pageNo: 1,
total:1, total: 1,
moreFlag:true, moreFlag: true,
isYL:false isYL: false
}) })
this.getList(); this.getList();
}, },
getList:function(){ getList: function () {
let list = this.data.list; let list = this.data.list;
if(this.data.isYL){ if (this.data.isYL) {
this.getYL(); this.getYL();
return; return;
} }
if(this.data.type==4){ if (this.data.type == 4) {
this.getMovie(); this.getMovie();
return; return;
} }
if(list.length>=this.data.total) return; if (list.length >= this.data.total) return;
commonApi._post('pbservice/Actcalendar/getActList',{ commonApi._post('pbservice/Actcalendar/getActList', {
page_no:this.data.pageNo, page_no: this.data.pageNo,
date:this.data.date, date: this.data.date,
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,
page_num:10 lat: this.data.lat,
}).then(res=>{ lon: this.data.lon,
page_num: 10
}).then(res => {
let now = new Date().getTime(); let now = new Date().getTime();
res.data.rows.map(item=>{ res.data.rows.map(item => {
if(item.end_date){ if (item.end_date) {
let end_date = item.end_date; let end_date = item.end_date;
if(end_date.indexOf(":")==-1){ if (end_date.indexOf(":") == -1) {
end_date = end_date+" 23:59:59"; end_date = end_date + " 23:59:59";
} }
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;
} }
} }
}) })
this.setData({ this.setData({
total:res.data.total, total: res.data.total,
list:list.concat(res.data.rows), list: list.concat(res.data.rows),
pageNo:this.data.pageNo+1 pageNo: this.data.pageNo + 1
}) })
}) })
}, },
getMovie:function(e){ getMovie: function (e) {
if(!this.data.moreFlag) return; if (!this.data.moreFlag) return;
let service={ let service = {
1:"getHotMovieList", 1: "getHotMovieList",
2:"getCinemaList", 2: "getCinemaList",
3:'getSoonShowsList' 3: 'getSoonShowsList'
}; };
let data = { let data = {
page:this.data.pageNo, page: this.data.pageNo,
pageSize:10 pageSize: 10
}; };
if(this.data.movieType==2){ if (this.data.movieType == 2) {
data.lat = this.data.lat; data.lat = this.data.lat;
data.lon = this.data.lon; data.lon = this.data.lon;
data.is_price_sort = this.data.sort=='price'; data.is_price_sort = this.data.sort == 'price';
data.is_distance_sort = this.data.sort=='distance'; data.is_distance_sort = this.data.sort == 'distance';
} }
// if(this.data.movieType==1){ // if(this.data.movieType==1){
// data.queryDate = this.data.date // data.queryDate = this.data.date
// } // }
if(this.data.movieType==2 && !this.data.lon){ if (this.data.movieType == 2 && !this.data.lon) {
wx.getLocation({ wx.getLocation({
type: 'gcj02', type: 'gcj02',
success:(res)=>{ success: (res) => {
this.setData({ this.setData({
lat:res.latitude, lat: res.latitude,
lon:res.longitude lon: res.longitude
}) })
data.lat =res.latitude; data.lat = res.latitude;
data.lon =res.longitude; data.lon = res.longitude;
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';
} }
} }
}) })
this.setData({ this.setData({
list:this.data.list.concat(res.data), list: this.data.list.concat(res.data),
pageNo:this.data.pageNo+1, pageNo: this.data.pageNo + 1,
moreFlag:res.data.length<10?false:true moreFlag: res.data.length < 10 ? false : true
}) })
}) })
}, },
fail:()=>{ fail: () => {
wx.showToast({ wx.showToast({
title: '请打开位置授权', title: '请打开位置授权',
icon:'none' icon: 'none'
}) })
commonApi._post('Cinema/'+service[this.data.movieType],data).then(res=>{ commonApi._post('Cinema/' + service[this.data.movieType], data).then(res => {
this.setData({ this.setData({
list:this.data.list.concat(res.data), list: this.data.list.concat(res.data),
pageNo:this.data.pageNo+1, pageNo: this.data.pageNo + 1,
moreFlag:res.data.length<10?false:true moreFlag: res.data.length < 10 ? false : true
}) })
}) })
} }
}) })
} } 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 {
} item.distance = (item.distance).toFixed(2) + 'm';
else {
item.distance = (item.distance).toFixed(2)+'m';
} }
} }
}) })
this.setData({ this.setData({
list:this.data.list.concat(res.data), list: this.data.list.concat(res.data),
pageNo:this.data.pageNo+1, pageNo: this.data.pageNo + 1,
moreFlag:res.data.length<10?false:true moreFlag: res.data.length < 10 ? false : true
}) })
}) })
} }
}, },
setSort:function(e){ setSort: function (e) {
let sort = e.currentTarget.dataset.sort; let sort = e.currentTarget.dataset.sort;
if(this.data.sort==sort) sort=""; if (this.data.sort == sort) sort = "";
this.setData({ this.setData({
sort:sort, sort: sort,
list:[], list: [],
total:1, total: 1,
pageNo:1, pageNo: 1,
moreFlag:true moreFlag: true
}) })
this.getList(); this.getList();
}, },
changeMovieType:function(e){ changeMovieType: function (e) {
let type = e.currentTarget.dataset.type; let type = e.currentTarget.dataset.type;
this.setData({ this.setData({
movieType:type, movieType: type,
list:[], list: [],
pageNo:1, pageNo: 1,
total:1, total: 1,
moreFlag:true moreFlag: true
}) })
this.getList() this.getList()
}, },
gotoDetail:function(e){ gotoDetail: function (e) {
let item = e.currentTarget.dataset.item; let item = e.currentTarget.dataset.item;
if(this.data.type==4 && this.data.movieType!=2){ if (this.data.type == 4 && this.data.movieType != 2) {
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,
}) })
} }
}, },
changeKeywords:function(e){ changeKeywords: function (e) {
this.setData({ this.setData({
keywords:e.detail.value keywords: e.detail.value
}) })
}, },
search:function(){ search: function () {
this.setData({ this.setData({
realKeywords:this.data.keywords, realKeywords: this.data.keywords,
list:[], list: [],
pageNo:1, pageNo: 1,
total:1, total: 1,
moreFlag:true moreFlag: true
}) })
this.getList(); this.getList();
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
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