...
|
...
|
@@ -8,28 +8,99 @@ Page({ |
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
current_swiper:0,
|
|
|
current_swiper: 0,
|
|
|
slide: [],
|
|
|
peopleList: [],
|
|
|
num:1,
|
|
|
num: 1,
|
|
|
actEndTimeList: [],
|
|
|
is_zan:false,
|
|
|
is_zan: false,
|
|
|
display:false,
|
|
|
content:'',
|
|
|
is_ask:false,
|
|
|
is_reply:false,
|
|
|
placeholder:'输入您的留言',
|
|
|
is_showRelease_modal:false,
|
|
|
|
|
|
},
|
|
|
//查看我的订单
|
|
|
goMyOrder() {
|
|
|
wx.redirectTo({url:'/pages/order/order-detail/order-detail?id=' + this.data.order_id})
|
|
|
},
|
|
|
//完成按钮
|
|
|
goBack() {
|
|
|
wx.redirectTo({url:'/pages/spell-list/spell-list?current=' + 1})
|
|
|
},
|
|
|
disableScroll() {
|
|
|
},
|
|
|
handleBackground() {
|
|
|
console.log('dianji');
|
|
|
this.setData({is_showRelease_modal:false,})
|
|
|
},
|
|
|
// 问一问
|
|
|
ask(e) {
|
|
|
wx.navigateTo({url:'/pages/comment/comment?activity_id=' + this.data.detail_id
|
|
|
+ '&common_id=' + 0
|
|
|
})
|
|
|
console.log('前问一问-display', this.data.display);
|
|
|
this.setData({
|
|
|
display: !this.data.display,
|
|
|
is_ask:true,is_reply:false,
|
|
|
content:'' ,
|
|
|
placeholder:'输入您的留言',
|
|
|
});
|
|
|
console.log('后问一问-display', this.data.display);
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/comment/comment?activity_id=' + this.data.detail_id
|
|
|
// + '&common_id=' + 0
|
|
|
// })
|
|
|
// console.log('问',e.detail.value);
|
|
|
// this.setData({focus:true})
|
|
|
},
|
|
|
//输入评论内容
|
|
|
inputComment(e) {
|
|
|
this.setData({ content: e.detail.value });
|
|
|
},
|
|
|
//发送评论/回复
|
|
|
clickComment() {
|
|
|
this.setData({ display: false });
|
|
|
if(this.data.content === '' ) {
|
|
|
wx.showToast({title:'请输入内容',icon:'none'})
|
|
|
}else {
|
|
|
let url = '/portal/Active/common';
|
|
|
let params = {
|
|
|
token:wx.getStorageSync('token'),
|
|
|
activeId:this.data.detail_id,
|
|
|
commonId: this.data.is_ask?0:this.data.commet_id,
|
|
|
content:this.data.content,
|
|
|
};
|
|
|
app.post(url,params,{}).then((res)=>{
|
|
|
console.log('提交评论',res);
|
|
|
if(+res.code === 1) {
|
|
|
wx.showToast({title:this.data.is_ask?'留言成功':'回复成功',icon:'none',});
|
|
|
this.getDetail();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
//评论input失去焦点
|
|
|
blur() {
|
|
|
this.setData({ display: false });
|
|
|
},
|
|
|
//点击键盘上的完成
|
|
|
confirm() {
|
|
|
this.setData({ display: false });
|
|
|
this.clickComment();
|
|
|
},
|
|
|
//回复
|
|
|
reply(e) {
|
|
|
const id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({url:'/pages/comment/comment?is_reply=' + true
|
|
|
+ '&activity_id=' + this.data.detail_id + '&common_id=' + id
|
|
|
})
|
|
|
this.setData({
|
|
|
display: !this.data.display,
|
|
|
is_ask:false,is_reply:true,
|
|
|
commet_id:id,content:'' ,
|
|
|
placeholder:'输入您的回复'
|
|
|
});
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/comment/comment?is_reply=' + true
|
|
|
// + '&activity_id=' + this.data.detail_id + '&common_id=' + id
|
|
|
// })
|
|
|
},
|
|
|
//收藏/取消收藏
|
|
|
collect() {
|
...
|
...
|
@@ -44,21 +115,21 @@ Page({ |
|
|
token: wx.getStorageSync('token'),
|
|
|
activeId: self.data.detail_id,
|
|
|
};
|
|
|
if(self.data.is_collect) {
|
|
|
if (self.data.is_collect) {
|
|
|
app.post(url_del, params, header).then((res) => {
|
|
|
console.log('取消收藏',res);
|
|
|
if(+res.code === 1) {
|
|
|
wx.showToast({title:res.message,icon:'none'});
|
|
|
console.log('取消收藏', res);
|
|
|
if (+res.code === 1) {
|
|
|
wx.showToast({title: res.message, icon: 'none'});
|
|
|
self.setData({
|
|
|
is_collect: 0
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
}else {
|
|
|
} else {
|
|
|
app.post(url, params, header).then((res) => {
|
|
|
console.log('收藏',res);
|
|
|
if(+res.code === 1) {
|
|
|
wx.showToast({title:res.message,icon:'none'});
|
|
|
console.log('收藏', res);
|
|
|
if (+res.code === 1) {
|
|
|
wx.showToast({title: res.message, icon: 'none'});
|
|
|
self.setData({
|
|
|
is_collect: 1
|
|
|
});
|
...
|
...
|
@@ -83,10 +154,10 @@ Page({ |
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('点赞', res);
|
|
|
if (+res.code === 1) { //
|
|
|
wx.showToast({title:res.message,icon:'none'});
|
|
|
wx.showToast({title: res.message, icon: 'none'});
|
|
|
self.setData({
|
|
|
[`commentList[${index}].is_prefect`]: true,
|
|
|
[`commentList[${index}].prefect`]: +self.data.commentList[index].prefect +1,
|
|
|
[`commentList[${index}].prefect`]: res.message == '该评论已赞'?+self.data.commentList[index].prefect:+self.data.commentList[index].prefect + 1,
|
|
|
});
|
|
|
// console.log('paise_user', paise_user);
|
|
|
}
|
...
|
...
|
@@ -98,10 +169,10 @@ Page({ |
|
|
},
|
|
|
onPageScroll(e) {
|
|
|
// console.log('页面滚动', e);
|
|
|
if(e.scrollTop > 140) {
|
|
|
this.setData({hidden_top:true})
|
|
|
}else if(e.scrollTop <=140){
|
|
|
this.setData({hidden_top:false})
|
|
|
if (e.scrollTop > 140) {
|
|
|
this.setData({hidden_top: true})
|
|
|
} else if (e.scrollTop <= 140) {
|
|
|
this.setData({hidden_top: false})
|
|
|
}
|
|
|
},
|
|
|
// 增加数量
|
...
|
...
|
@@ -112,7 +183,7 @@ Page({ |
|
|
// let num = cartslist[k].children[t].num;
|
|
|
// let product_id = cartslist[k].children[t].product_id;
|
|
|
let num = this.data.num;
|
|
|
num ++;
|
|
|
num++;
|
|
|
this.setData({
|
|
|
num: num
|
|
|
});
|
...
|
...
|
@@ -123,7 +194,7 @@ Page({ |
|
|
if (num <= 1) {
|
|
|
return false;
|
|
|
}
|
|
|
num --;
|
|
|
num--;
|
|
|
this.setData({
|
|
|
num: num
|
|
|
});
|
...
|
...
|
@@ -131,33 +202,34 @@ Page({ |
|
|
//获取详情
|
|
|
getDetail() {
|
|
|
const self = this;
|
|
|
console.log('city',self.data.city);
|
|
|
console.log('city', self.data.city);
|
|
|
let url = '/portal/Active/activeDetail';
|
|
|
let params = {
|
|
|
activeId: self.data.detail_id,
|
|
|
token:wx.getStorageSync('token'),
|
|
|
token: wx.getStorageSync('token'),
|
|
|
};
|
|
|
let header = {
|
|
|
"token": wx.getStorageSync('token')
|
|
|
};
|
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('获取详情', res);
|
|
|
console.log('获取详情', res, app.initTime(res.data.active.surplus));
|
|
|
if (+res.code === 1) {
|
|
|
self.setData({
|
|
|
detail: res.data.active,
|
|
|
'detail.time': app.initTime(res.data.active.surplus),
|
|
|
end_time: res.data.active.time,
|
|
|
over_hours:res.data.active.over_time,//几小时截止
|
|
|
over_hours: res.data.active.over_time,//几小时截止
|
|
|
join_people: res.data.son,
|
|
|
commentList:res.data.common,
|
|
|
is_collect:res.data.is_collect,
|
|
|
count:res.data.count, // 留言板
|
|
|
commentList: res.data.common,
|
|
|
is_collect: res.data.is_collect,
|
|
|
count: res.data.count, // 留言板
|
|
|
});
|
|
|
// (0全部,2待处理,4已拼成,5已取消,6已完成
|
|
|
// (0全部,2待处理,4已拼成,5已取消,6已完成
|
|
|
const status = res.data.active.status;
|
|
|
if(status ===2 || status ===4 || status ===6 || status ===7) {
|
|
|
if (status === 2 || status === 4 || status === 6 || status === 7) {
|
|
|
console.log('调用倒计时');
|
|
|
self.countDown();
|
|
|
}else {
|
|
|
} else {
|
|
|
console.log('不调用倒计时');
|
|
|
let countDownArr = [];
|
|
|
let obj = null;
|
...
|
...
|
@@ -180,43 +252,41 @@ Page({ |
|
|
timeFormat(param) { //小于10的格式化函数
|
|
|
return param < 10 ? '0' + param : param;
|
|
|
},
|
|
|
|
|
|
time() {
|
|
|
const self = this;
|
|
|
self.data.detail.surplus--;
|
|
|
//定時器,每秒重新計算
|
|
|
// setTimeout(function () {
|
|
|
// self.time();
|
|
|
// },1000)
|
|
|
},
|
|
|
countDown() { //倒计时函数
|
|
|
// 获取当前时间,同时得到活动结束时间数组
|
|
|
t = setTimeout(this.countDown, 1000);
|
|
|
let newTime = new Date().getTime();//当前时间戳
|
|
|
let end_time = app.nextTime(this.data.end_time, this.data.over_hours);//截止时间
|
|
|
let endTime = new Date(end_time).getTime(); //截止时间戳
|
|
|
let countDownArr = [];
|
|
|
// 对结束时间进行处理渲染到页面
|
|
|
let obj = null;
|
|
|
// 如果活动未结束,对时间进行处理
|
|
|
if (endTime - newTime > 0) {
|
|
|
let time = (endTime - newTime) / 1000;
|
|
|
// 获取天、时、分、秒
|
|
|
let day = parseInt(time / (60 * 60 * 24));
|
|
|
let hou = parseInt(time % (60 * 60 * 24) / 3600);
|
|
|
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
|
|
|
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
|
|
|
obj = {
|
|
|
day: this.timeFormat(day),
|
|
|
hou: this.timeFormat(hou),
|
|
|
min: this.timeFormat(min),
|
|
|
sec: this.timeFormat(sec)
|
|
|
};
|
|
|
t;
|
|
|
|
|
|
} else { //活动已结束,全部设置为'00'
|
|
|
obj = {
|
|
|
day: '00',
|
|
|
hou: '00',
|
|
|
min: '00',
|
|
|
sec: '00'
|
|
|
};
|
|
|
clearTimeout(t);
|
|
|
this.end()
|
|
|
}
|
|
|
countDownArr.push(obj);
|
|
|
let obj = null;
|
|
|
if (this.data.detail.surplus > 0) { //未结束
|
|
|
this.time();
|
|
|
// console.log('surplus', this.data.detail.surplus);
|
|
|
// t = setTimeout(this.countDown, 1000);
|
|
|
const time = app.initTime(this.data.detail.surplus);
|
|
|
// console.log('time', time);
|
|
|
obj = {
|
|
|
hou: time[0].hou,
|
|
|
min: time[0].min,
|
|
|
sec: time[0].sec
|
|
|
};
|
|
|
t;
|
|
|
} else {
|
|
|
obj = {
|
|
|
day: '00',
|
|
|
hou: '00',
|
|
|
min: '00',
|
|
|
sec: '00'
|
|
|
};
|
|
|
clearTimeout(t);
|
|
|
this.end();
|
|
|
}
|
|
|
countDownArr.push(obj);
|
|
|
// 渲染,然后每隔一秒执行一次倒计时函数
|
|
|
this.setData({
|
|
|
// countDownList: countDownArr,
|
...
|
...
|
@@ -245,7 +315,7 @@ Page({ |
|
|
getNavigate() {
|
|
|
const self = this;
|
|
|
const arr = self.data.detail.latng.split(',');
|
|
|
console.log('arr',arr,arr[0],arr[1]);
|
|
|
console.log('arr', arr, arr[0], arr[1]);
|
|
|
wx.openLocation({//使用微信内置地图查看位置。
|
|
|
latitude: +arr[1],//要去的纬度-地址
|
|
|
longitude: +arr[0],//要去的经度-地址
|
...
|
...
|
@@ -258,37 +328,38 @@ Page({ |
|
|
//确认拼活动
|
|
|
confirmJoin(e) {
|
|
|
const self = this;
|
|
|
let url = '/portal/Active/join';
|
|
|
let params = {
|
|
|
token: wx.getStorageSync('token'),
|
|
|
number: self.data.num,
|
|
|
activeId: self.data.detail_id,
|
|
|
formId: e.detail.formId,
|
|
|
};
|
|
|
let header = {
|
|
|
"token": wx.getStorageSync('token')
|
|
|
};
|
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('确认拼餐', res);
|
|
|
if (+res.code === 1) {
|
|
|
wx.showToast({title:'拼餐成功',icon:'success'})
|
|
|
// self.setData({
|
|
|
// detail: res.data.active,
|
|
|
// end_time: res.data.active.time,
|
|
|
// over_hours:res.data.active.over_time,//几小时截止
|
|
|
// join_people: res.data.son,
|
|
|
// commenList:res.data.common
|
|
|
// });
|
|
|
// self.countDown();
|
|
|
}
|
|
|
})
|
|
|
console.log('已参与人数',self.data.join_people.length);
|
|
|
if(self.data.join_people.length + self.data.num > self.data.detail.max) {
|
|
|
wx.showToast({title:'参加人数已超过剩余名额',icon:'none'})
|
|
|
}else if(self.data.join_people.length + self.data.num == self.data.detail.max){
|
|
|
wx.showToast({title:'名额已满',icon:'none'})
|
|
|
} else {
|
|
|
let url = '/portal/Active/join';
|
|
|
let params = {
|
|
|
token: wx.getStorageSync('token'),
|
|
|
number: self.data.num,
|
|
|
activeId: self.data.detail_id,
|
|
|
formId: e.detail.formId,
|
|
|
};
|
|
|
let header = {
|
|
|
"token": wx.getStorageSync('token')
|
|
|
};
|
|
|
app.post(url, params, {}).then((res) => {
|
|
|
console.log('确认拼餐', res);
|
|
|
if (+res.code === 1) {
|
|
|
// wx.showToast({title: '拼餐成功', icon: 'success'});
|
|
|
self.setData({is_showRelease_modal:true,order_id:+res.data.orderId});
|
|
|
self.getDetail();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
console.log('详情options', options);
|
|
|
this.setData({detail_id:+options.id?+options.id:''});
|
|
|
this.setData({detail_id: +options.id ? +options.id : ''});
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -336,17 +407,18 @@ Page({ |
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
onShareAppMessage: function () {
|
|
|
let self = this;
|
|
|
// 设置菜单中的转发按钮触发转发事件时的转发内容
|
|
|
var shareObj = {
|
|
|
title: '火柴西路', // 默认是小程序的名称(可以写slogan等)
|
|
|
path: '', // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
|
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
|
|
|
success: function(res) {
|
|
|
if (res.errMsg == 'shareAppMessage:ok') {}
|
|
|
success: function (res) {
|
|
|
if (res.errMsg == 'shareAppMessage:ok') {
|
|
|
}
|
|
|
},
|
|
|
fail: function() {
|
|
|
fail: function () {
|
|
|
// 转发失败之后的回调
|
|
|
if (res.errMsg == 'shareAppMessage:fail cancel') {
|
|
|
// 用户取消转发
|
...
|
...
|
@@ -354,7 +426,7 @@ Page({ |
|
|
// 转发失败,其中 detail message 为详细失败信息
|
|
|
}
|
|
|
},
|
|
|
complete: function() {
|
|
|
complete: function () {
|
|
|
// 转发结束之后的回调(转发成不成功都会执行)
|
|
|
}
|
|
|
}
|
...
|
...
|
|