// pages/info/groupOrderInfo/index.js import commonApi from "../../../utils/https/common" let timer = null Page({ /** * 页面的初始数据 */ data: { info:null, keywords:"", id:null, img:null, restTime:null, countdown:0, codeImg:null, showShareMask:false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ id:options.id }) // 获取二维码 commonApi.user_post("team_order/get_qrcode",{ url:'https://m.cloud.sz-trip.com/TeamForm?team_id='+this.data.id }).then(res=>{ this.setData({ codeImg:res.data }) }) if(options.from=='order'){ wx.showModal({ title:"提示", content:"团体预约发起后请前往个人中心团体预约订单中查看订单详情和组团详情。", success:function(){ } }) } }, showShare(){ this.setData({ showShareMask:!this.data.showShareMask }) }, edit:function(e){ let item = e.currentTarget.dataset.item wx.navigateTo({ url: '/pages/order/joinOrder/index?id='+item.team_id+'&mid='+item.id+'&oid='+this.data.id }) }, delItem:function(e){ // 删除团员 let item = e.currentTarget.dataset.item,index = e.currentTarget.dataset.index,info = this.data.info,that = this wx.showModal({ title:"提示", content:"确定删除该团员吗?", success:function(res){ if(res.confirm){ commonApi.user_post("team_order/del",{ team_id:item.team_id, member_id:item.id }).then(res=>{ if(res.code==1){ wx.showToast({ title: '删除成功', icon:'success' }) info.list.members.splice(index,1) that.setData({ info:info }) } }) } } }) }, changeKeywords:function(e){ this.setData({ keywords:e.detail.value }) }, search:function(e){ commonApi.user_post("team_order/get_team_detail",{ order_id:this.data.id, name:this.data.keywords }).then(res=>{ if(res.code==1){ this.setData({ info:res.data }) } }) }, order:function(){ commonApi.user_post("team_order/create",{ team_id:this.data.info.list.id }).then(res=>{ if(res.code==1){ this.onShow() } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { commonApi.user_post("team_order/get_team_detail",{ order_id:this.data.id }).then(res=>{ if(res.code==1){ res.data.list.order_info = res.data.list.order_info?JSON.parse(res.data.list.order_info):null; res.data.list.members.reverse() this.setData({ info:res.data, countdown:Number(res.data.list.countdown) }) this.setTime() commonApi._post("scene/detail_for_venue",{ id:res.data.list.scene_id }).then(res=>{ this.setData({ img:res.data.headimg }) this.onShareAppMessage() }) } }) }, setTime(){ if(this.data.countdown && this.data.countdown>0){ let countdown = this.data.countdown; this.setTimeText(countdown) timer = setInterval(()=>{ countdown--; this.setTimeText(countdown) },1000) } }, setTimeText(countdown){ let h = Math.floor(countdown / (60 * 60)); countdown = countdown - h * 3600 h = h<10?'0'+h:h let m = Math.floor(countdown / 60); countdown = countdown - m * 60 m = m<10?'0'+m:m let s = countdown<10?'0'+countdown:countdown this.setData({ restTime:h+':'+m+':'+s }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { if(timer){ clearInterval(timer) timer = null } }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { if(this.data.info){ return { title:"加入我的旅游团", path:"/pages/order/joinOrder/index?id="+this.data.info.list.id+'&uid='+this.data.info.list.user_id+'&oid='+this.data.id, imageUrl:this.data.img } } } })