|
|
|
// pages/customer/detail_owner.js
|
|
|
|
var mta=require('mta-wechat-analysis')
|
|
|
|
var mta = require('mta-wechat-analysis')
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
import TP from '../../utils/tpls';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
detail:null,
|
|
|
|
invite_name:''
|
|
|
|
},
|
|
|
|
id:null,
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.id=options.id;
|
|
|
|
let invite_names=wx.getStorageSync('invite_names') ||{};
|
|
|
|
let invite_name=invite_names[options.id];
|
|
|
|
if(invite_name){
|
|
|
|
this.setData({
|
|
|
|
invite_name:invite_name
|
|
|
|
})
|
|
|
|
}
|
|
|
|
mta.Page.init({
|
|
|
|
"appID":"500667280",
|
|
|
|
"eventID":"500667287",
|
|
|
|
"statPullDownFresh":true,
|
|
|
|
"statShareApp":true,
|
|
|
|
"statReachBottom":true,
|
|
|
|
"lauchOpts":options, //渠道分析
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
detail: null,
|
|
|
|
height: 667,
|
|
|
|
current: 0,
|
|
|
|
tpls: [],
|
|
|
|
seller: {
|
|
|
|
name: '',
|
|
|
|
room: '',
|
|
|
|
date: '',
|
|
|
|
addr: ''
|
|
|
|
},
|
|
|
|
options: {tplid: ''},
|
|
|
|
hasOwner: false,//是否为发起人
|
|
|
|
animation: 'animation',
|
|
|
|
},
|
|
|
|
id: null,
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.id = options.id;
|
|
|
|
let param={
|
|
|
|
options:options,
|
|
|
|
hasOwner:options.hasSellerShare==1,//是否为发起人
|
|
|
|
}
|
|
|
|
param.tpls=[TP.tpls(options.tplid)]
|
|
|
|
this.setData(param)
|
|
|
|
mta.Page.init({
|
|
|
|
"appID": "500667280",
|
|
|
|
"eventID": "500667287",
|
|
|
|
"statPullDownFresh": true,
|
|
|
|
"statShareApp": true,
|
|
|
|
"statReachBottom": true,
|
|
|
|
"lauchOpts": options, //渠道分析
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.getDetail();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.getDetail();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return this.shareSetting();
|
|
|
|
},
|
|
|
|
getDetail(fouce=false){
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.id
|
|
|
|
},fouce).then(res => {
|
|
|
|
this.setData({
|
|
|
|
detail:this.formatDatail(res.data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
formatDatail(detail){
|
|
|
|
detail.rdateStr=util.unixtoTime(detail.ddate,'YYYY/MM/DD 星期WW HH:II');
|
|
|
|
detail.tableFirst=detail.tables[0].name;
|
|
|
|
if(detail.tables.length>1){
|
|
|
|
detail.tableSubInfo='等'+(detail.tables.length)+'个'
|
|
|
|
+(detail.tables[0].tid==2?'包间':'');
|
|
|
|
}
|
|
|
|
if(detail.sex!=3){
|
|
|
|
detail.rnameStr=detail.rname.substr(0,1)+(detail.sex==1?'先生':'女士')
|
|
|
|
}else{
|
|
|
|
detail.rnameStr=detail.rname
|
|
|
|
}
|
|
|
|
detail.eatStr='邀请您共进晚餐';
|
|
|
|
let hi=util.unixtoTime(detail.ddate,'HHII');
|
|
|
|
if(hi<'10:00'){
|
|
|
|
detail.eatStr='邀请您共进早餐';
|
|
|
|
}else if(hi<'15:00'){
|
|
|
|
detail.eatStr='邀请您共进午餐';
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return this.shareSetting();
|
|
|
|
},
|
|
|
|
getDetail(fouce = false){
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.id
|
|
|
|
}, fouce).then(res => {
|
|
|
|
let tables=[];
|
|
|
|
res.data.tables.forEach(t=>{
|
|
|
|
tables.push(t.name);
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
detail: this.formatDatail(res.data),
|
|
|
|
seller:{
|
|
|
|
name:res.data.seller.sellername,
|
|
|
|
room:tables.join('、'),
|
|
|
|
date:util.unixtoTime(res.data.ddate,this.data.tpls[this.data.current].timeStr),
|
|
|
|
addr:res.data.seller.real_address||res.data.seller.map_address,
|
|
|
|
image:res.data.image_url,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
formatDatail(detail){
|
|
|
|
detail.rdateStr = util.unixtoTime(detail.ddate, 'YYYY/MM/DD 星期WW HH:II');
|
|
|
|
detail.tableFirst = detail.tables[0].name;
|
|
|
|
if (detail.tables.length > 1) {
|
|
|
|
detail.tableSubInfo = '等' + (detail.tables.length) + '个'
|
|
|
|
+ (detail.tables[0].tid == 2 ? '包间' : '');
|
|
|
|
}
|
|
|
|
if (detail.sex != 3) {
|
|
|
|
detail.rnameStr = detail.rname.substr(0, 1) + (detail.sex == 1 ? '先生' : '女士')
|
|
|
|
} else {
|
|
|
|
detail.rnameStr = detail.rname
|
|
|
|
}
|
|
|
|
detail.eatStr = '邀请您共进晚餐';
|
|
|
|
let hi = util.unixtoTime(detail.ddate, 'HHII');
|
|
|
|
if (hi < '10:00') {
|
|
|
|
detail.eatStr = '邀请您共进早餐';
|
|
|
|
} else if (hi < '15:00') {
|
|
|
|
detail.eatStr = '邀请您共进午餐';
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(!detail.cusman){
|
|
|
|
// detail.cusman='vking';
|
|
|
|
// detail.cusman_phone='15877556369';
|
|
|
|
// detail.cusman_account='wx:vking';
|
|
|
|
// }
|
|
|
|
detail.hasCanSuccess=false;
|
|
|
|
if(detail.customers.length>0){
|
|
|
|
let openid=getApp().openid;
|
|
|
|
detail.customers.forEach(item=>{
|
|
|
|
if(openid==item.openid){
|
|
|
|
detail.hasCanSuccess=true;
|
|
|
|
detail.remindtime=item.remind_date;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return detail;
|
|
|
|
},
|
|
|
|
showManager(){
|
|
|
|
if(this.data.detail.cusman_phone || this.data.detail.cusman_account){
|
|
|
|
this.selectComponent('#manager').show();
|
|
|
|
// if(!detail.cusman){
|
|
|
|
// detail.cusman='vking';
|
|
|
|
// detail.cusman_phone='15877556369';
|
|
|
|
// detail.cusman_account='wx:vking';
|
|
|
|
// }
|
|
|
|
detail.hasCanSuccess = false;
|
|
|
|
if (detail.customers.length > 0) {
|
|
|
|
let openid = getApp().openid;
|
|
|
|
detail.customers.forEach(item => {
|
|
|
|
if (openid == item.openid) {
|
|
|
|
detail.hasCanSuccess = true;
|
|
|
|
detail.remindtime = item.remind_date;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return detail;
|
|
|
|
},
|
|
|
|
showManager(){
|
|
|
|
if (this.data.detail.cusman_phone || this.data.detail.cusman_account) {
|
|
|
|
this.selectComponent('#manager').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
lookLocation:function(){
|
|
|
|
wx.openLocation({
|
|
|
|
latitude:Number(this.data.detail.seller.lat),
|
|
|
|
longitude:Number(this.data.detail.seller.long),
|
|
|
|
scale:17,
|
|
|
|
address:this.data.detail.seller.map_address,
|
|
|
|
success:function (res) {
|
|
|
|
console.log(res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
userinfo(){
|
|
|
|
if(!this.data.detail.hasCanSuccess){
|
|
|
|
let userInfo=util.cache('userInfo');
|
|
|
|
if(userInfo){
|
|
|
|
userInfo=JSON.stringify({
|
|
|
|
openid: getApp().openid,
|
|
|
|
avatar: userInfo.avatarUrl,
|
|
|
|
nickname: userInfo.nickName,
|
|
|
|
gender: userInfo.gender
|
|
|
|
})
|
|
|
|
}
|
|
|
|
App.Reserve.SetRelaSuccess({
|
|
|
|
rid:this.id,
|
|
|
|
openid:getApp().openid,
|
|
|
|
is_agree:1,
|
|
|
|
userinfo:userInfo
|
|
|
|
}).then(res=>{
|
|
|
|
this.setData({
|
|
|
|
[`detail.hasCanSuccess`]:true
|
|
|
|
})
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.id
|
|
|
|
},'clear')
|
|
|
|
util.toast('赴约成功','none')
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
util.toast('赴约成功','none')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setUserInfoSuccess(){
|
|
|
|
util.toast('授权成功,可以继续转发','none');
|
|
|
|
},
|
|
|
|
reserveCancel(){
|
|
|
|
},
|
|
|
|
lookLocation: function () {
|
|
|
|
wx.openLocation({
|
|
|
|
latitude: Number(this.data.detail.seller.lat),
|
|
|
|
longitude: Number(this.data.detail.seller.long),
|
|
|
|
scale: 17,
|
|
|
|
address: this.data.detail.seller.map_address,
|
|
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
userinfo(){
|
|
|
|
if (!this.data.detail.hasCanSuccess) {
|
|
|
|
let userInfo = util.cache('userInfo');
|
|
|
|
if (userInfo) {
|
|
|
|
userInfo = JSON.stringify({
|
|
...
|
...
|
@@ -180,30 +170,63 @@ Page({ |
|
|
|
App.Reserve.SetRelaSuccess({
|
|
|
|
rid: this.id,
|
|
|
|
openid: getApp().openid,
|
|
|
|
cancel: 'cancel',
|
|
|
|
is_agree: 0,
|
|
|
|
is_agree: 1,
|
|
|
|
userinfo: userInfo
|
|
|
|
}).then(res => {
|
|
|
|
this.getDetail(true);
|
|
|
|
this.setData({
|
|
|
|
[`detail.hasCanSuccess`]: true
|
|
|
|
})
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.id
|
|
|
|
}, 'clear')
|
|
|
|
util.toast('赴约成功', 'none')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
shareSetting(){
|
|
|
|
console.log('this.topicVal',this.topicVal)
|
|
|
|
if(this.topicVal && this.data.detail.openid==getApp().openid){
|
|
|
|
App.Reserve.SetTopicFromShare({
|
|
|
|
rid:this.id,
|
|
|
|
topic:this.topicVal
|
|
|
|
})
|
|
|
|
}
|
|
|
|
let nickname="";
|
|
|
|
try{
|
|
|
|
nickname=util.cache('userInfo').nickName;
|
|
|
|
}catch(e){}
|
|
|
|
return {
|
|
|
|
//title: (nickname||'')+'给你发了一个邀请,点击查看',
|
|
|
|
title: '你收到一个邀请函,点击查看',
|
|
|
|
path: '/pages/customer/index?id='+this.id+'&fromid='+getApp().openid+'&invite_name='+nickname+'&hasInvitation=1',
|
|
|
|
imageUrl:util.cgi('App.Reserve.MakePic&rid=')+this.id,
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
util.toast('赴约成功', 'none')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setUserInfoSuccess(){
|
|
|
|
util.toast('授权成功,可以继续转发', 'none');
|
|
|
|
},
|
|
|
|
reserveCancel(){
|
|
|
|
let userInfo = util.cache('userInfo');
|
|
|
|
if (userInfo) {
|
|
|
|
userInfo = JSON.stringify({
|
|
|
|
openid: getApp().openid,
|
|
|
|
avatar: userInfo.avatarUrl,
|
|
|
|
nickname: userInfo.nickName,
|
|
|
|
gender: userInfo.gender
|
|
|
|
})
|
|
|
|
}
|
|
|
|
App.Reserve.SetRelaSuccess({
|
|
|
|
rid: this.id,
|
|
|
|
openid: getApp().openid,
|
|
|
|
cancel: 'cancel',
|
|
|
|
is_agree: 0,
|
|
|
|
userinfo: userInfo
|
|
|
|
}).then(res => {
|
|
|
|
this.getDetail(true);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
shareSetting(){
|
|
|
|
console.log('this.topicVal', this.topicVal)
|
|
|
|
if (this.topicVal && this.data.detail.openid == getApp().openid) {
|
|
|
|
App.Reserve.SetTopicFromShare({
|
|
|
|
rid: this.id,
|
|
|
|
topic: this.topicVal
|
|
|
|
})
|
|
|
|
}
|
|
|
|
let nickname = "";
|
|
|
|
try {
|
|
|
|
nickname = util.cache('userInfo').nickName;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
//title: (nickname||'')+'给你发了一个邀请,点击查看',
|
|
|
|
title: '你收到一个邀请函,点击查看',
|
|
|
|
path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname + '&hasInvitation=1',
|
|
|
|
imageUrl: util.cgi('App.Reserve.MakePic&rid=') + this.id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}) |
...
|
...
|
|