You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
276 lines
5.8 KiB
276 lines
5.8 KiB
5 years ago
|
// subpages/heart/pages/groupBuyDetail/groupBuyDetail.js
|
||
|
const api = require("../../utils/api")
|
||
|
const app = getApp()
|
||
|
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
nodata: false,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
infoCompleted: 0, //完善信息标志
|
||
|
noticeId: '',
|
||
|
details: {}, //团购详情
|
||
|
evaluateList: [], //评价列表
|
||
|
detailType: '', //团购详情,结束详情
|
||
|
dialogVisible: false, //提示框
|
||
|
dialogTitle: '', //提示内容
|
||
|
lock: false,
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.setData({
|
||
|
infoCompleted: app.globalData.infoCompleted,
|
||
|
noticeId: options.id,
|
||
|
detailType: options.type || '',
|
||
|
details: {}
|
||
|
})
|
||
|
this.getNoticeDetail()
|
||
|
this.getEvaluationList()
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
this.setData({
|
||
|
loadMoreVisible: true
|
||
|
})
|
||
|
if (this.data.loadMoreType === "loading") {
|
||
|
this.setData({
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
this.getEvaluationList()
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
// onShareAppMessage: function () {
|
||
|
|
||
|
// },
|
||
|
|
||
|
//列表照片的放大查看
|
||
|
previewImage (e) {
|
||
|
console.log(e.currentTarget.dataset)
|
||
|
wx.previewImage({
|
||
|
urls: e.currentTarget.dataset.imgarry,
|
||
|
current: e.currentTarget.dataset.src
|
||
|
})
|
||
|
},
|
||
|
|
||
|
getEvaluationList () {
|
||
|
const para = {
|
||
|
groupBuyId: this.data.noticeId,
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize
|
||
|
}
|
||
|
api.getEvaluationList(para).then(res => {
|
||
|
console.log(res)
|
||
|
this.setData({
|
||
|
evaluateList: [...this.data.evaluateList,...res.data],
|
||
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
||
|
loadMoreVisible: res.data.length === this.data.pageSize ? false : true,
|
||
|
nodata: false,
|
||
|
})
|
||
|
if (this.data.evaluateList.length == 0) {
|
||
|
this.setData({
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
}
|
||
|
}).catch(err => {
|
||
|
this.setData({
|
||
|
evaluateList: [],
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
console.log(err)
|
||
|
})
|
||
|
},
|
||
|
|
||
|
getNoticeDetail () {
|
||
|
wx.showLoading({
|
||
|
title: '加载中...'
|
||
|
})
|
||
|
api.getGroupBuyDetail(this.data.noticeId).then(res => {
|
||
|
// console.log(res.data)
|
||
|
wx.hideLoading()
|
||
|
this.setData({
|
||
|
details: res.data
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
callNumber () {
|
||
|
let mobile = this.data.details.groupBuyMobile
|
||
|
console.log('拨打电话', mobile)
|
||
|
let that = this
|
||
|
wx.showModal({
|
||
|
title: "拨打电话",
|
||
|
content: "",
|
||
|
cancelColor: "#29B9A5",
|
||
|
confirmColor: "#29B9A5",
|
||
|
success: (res) => {
|
||
|
if (res.confirm) {
|
||
|
console.log("用户点击确定")
|
||
|
that.countCall()
|
||
|
wx.makePhoneCall({
|
||
|
phoneNumber: mobile
|
||
|
})
|
||
|
} else if (res.cancel) {
|
||
|
console.log("用户点击取消")
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
countCall () {
|
||
|
api.groupBuyCall(this.data.noticeId).then(res => {
|
||
|
console.log(res.data)
|
||
|
})
|
||
|
},
|
||
|
|
||
|
//结束团购
|
||
|
submit () {
|
||
|
if (this.data.lock) {
|
||
|
return false
|
||
|
}
|
||
|
const para = {
|
||
|
id: this.data.noticeId,
|
||
|
status: '5'
|
||
|
}
|
||
|
this.setData({
|
||
|
lock: true
|
||
|
})
|
||
|
api.updateStatus(para).then(() => {
|
||
|
this.setData({
|
||
|
dialogVisible: true,
|
||
|
dialogTitle: '已结束团购',
|
||
|
lock: false
|
||
|
})
|
||
|
}).catch(err => {
|
||
|
this.setData({
|
||
|
lock: false
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
|
||
|
//报名 / 取消报名
|
||
|
signupCall (e) {
|
||
|
if (this.verifyCompleteInfo()) {
|
||
|
return false
|
||
|
}
|
||
|
if (this.data.lock) {
|
||
|
return false
|
||
|
}
|
||
|
//状态0:进行中 5:已结束 10:已取消
|
||
|
if (e.currentTarget.dataset.groupbuystatus != 0) {
|
||
|
return false
|
||
|
}
|
||
|
//提交 报名状态0:报名 10:取消报名
|
||
|
let status = 0
|
||
|
//当前 报名状态0:未报名 1:已报名 2:交易已确认
|
||
|
if (e.currentTarget.dataset.status == 1) {
|
||
|
status = 10
|
||
|
} else if (e.currentTarget.dataset.status == 2) {
|
||
|
return
|
||
|
}
|
||
|
const para = {
|
||
|
groupBuyId: this.data.noticeId,
|
||
|
status: status
|
||
|
}
|
||
|
this.setData({
|
||
|
lock: true
|
||
|
})
|
||
|
api.signUpOrCancel(para).then(res => {
|
||
|
let title = ''
|
||
|
if (status == 0) {
|
||
|
title = '报名成功'
|
||
|
} else {
|
||
|
title = '取消成功'
|
||
|
}
|
||
|
this.setData({
|
||
|
dialogVisible: true,
|
||
|
dialogTitle: title,
|
||
|
evaluateList: [],
|
||
|
pageIndex: 1
|
||
|
})
|
||
|
setTimeout(() => {
|
||
|
this.setData({
|
||
|
lock: false
|
||
|
})
|
||
|
}, 500);
|
||
|
this.getNoticeDetail()
|
||
|
this.getEvaluationList()
|
||
|
}).catch(err => {
|
||
|
this.setData({
|
||
|
lock: false
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
// 关闭弹框
|
||
|
closeDialog () {
|
||
|
this.setData({
|
||
|
dialogVisible: false
|
||
|
})
|
||
|
if (this.data.dialogTitle == "已结束团购") {
|
||
|
wx.navigateBack()
|
||
|
}
|
||
|
},
|
||
|
// 检查 是否完善信息
|
||
|
verifyCompleteInfo () {
|
||
|
if (this.data.infoCompleted == 0) {
|
||
|
this.setData({
|
||
|
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
|
||
|
})
|
||
|
return true
|
||
|
} else {
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
})
|