|
|
|
// pages/customer/detail_owner_invitation_new.js
|
|
|
|
var mta = require('mta-wechat-analysis')
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
import TP from '../../utils/tpls';
|
|
|
|
import RS from '../../utils/reserveStatus'
|
|
|
|
Page({
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
options: {
|
|
|
|
tplid: ''
|
|
|
|
},
|
|
|
|
between: false,
|
|
|
|
id: null,
|
|
|
|
msgTpl: '',
|
|
|
|
chef: {},
|
|
|
|
marketing: {},
|
|
|
|
home: {},
|
|
|
|
reserve: {},
|
|
|
|
signboard: {},
|
|
|
|
store: {},
|
|
|
|
homeColor: '',
|
|
|
|
current: 0,
|
|
|
|
theme: 'blackGold', //blue green blackGold
|
|
|
|
seller: {
|
|
|
|
name: '',
|
|
|
|
room: '',
|
|
|
|
date: '',
|
|
|
|
addr: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
this.id = options.id
|
|
|
|
let param = {
|
|
|
|
options: options,
|
|
|
|
hasOwner: options.hasSellerShare == 1, //是否为发起人
|
|
|
|
}
|
|
|
|
param.tpls = [TP.tpls(options.tplid)]
|
|
|
|
console.log(param);
|
|
|
|
console.log(options);
|
|
|
|
this.setData(param)
|
|
|
|
mta.Page.init({
|
|
|
|
"appID": "500667280",
|
|
|
|
"eventID": "500667287",
|
|
|
|
"statPullDownFresh": true,
|
|
|
|
"statShareApp": true,
|
|
|
|
"statReachBottom": true,
|
|
|
|
"lauchOpts": options, //渠道分析
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {},
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
onShareTimeline() {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.getSellerTemplateConf();
|
|
|
|
this.getDetail();
|
|
|
|
},
|
|
|
|
cli() {
|
|
|
|
wx.setClipboardData({
|
|
|
|
data: this.data.reserve.manager_wechat,
|
|
|
|
success(res) {
|
|
|
|
wx.getClipboardData({
|
|
|
|
success(res) {
|
|
|
|
console.log(res.data) // data
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
call() {
|
|
|
|
wx.reportMonitor('1012', 1)
|
|
|
|
wx.makePhoneCall({
|
|
|
|
phoneNumber: this.data.reserve.manager_phone
|
|
|
|
})
|
|
|
|
},
|
|
|
|
looklocation: function () {
|
|
|
|
wx.reportMonitor('1015', 1)
|
|
|
|
wx.openLocation({
|
|
|
|
latitude: Number(this.data.reserve.lat),
|
|
|
|
longitude: Number(this.data.reserve.long),
|
|
|
|
scale: 17,
|
|
|
|
address: this.data.reserve.address,
|
|
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getDetail() {
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
let tables = [], //桌子信息
|
|
|
|
regions = []; //区域名称
|
|
|
|
res.data.tables.forEach(t => {
|
|
|
|
tables.push(t.name);
|
|
|
|
if (regions.indexOf('t.rname') == -1) {
|
|
|
|
regions.push(t.rname);
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
let reserev = RS.reserve(res.data)
|
|
|
|
let dateSmart
|
|
|
|
if (res.data.type == 1) {
|
|
|
|
dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStrSmart[0])
|
|
|
|
if (res.data.is_set_ddate == 1) {
|
|
|
|
dateSmart += ' ' + util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStrSmart[1])
|
|
|
|
} else {
|
|
|
|
dateSmart += ' ' + reserev.soltName
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStr)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
detail: this.formatDatail(reserev, dateSmart),
|
|
|
|
seller: {
|
|
|
|
name: reserev.seller.sellername,
|
|
|
|
room: tables.join('、'),
|
|
|
|
date: dateSmart,
|
|
|
|
region: regions.join('、'),
|
|
|
|
addr: reserev.seller.real_address || reserev.seller.map_address,
|
|
|
|
image: reserev.image_url,
|
|
|
|
hasOwner: true,
|
|
|
|
type: reserev.type,
|
|
|
|
is_set_ddate: reserev.is_set_ddate,
|
|
|
|
hasUpTime: reserev.type == 1 && reserev.hasRunning && reserev.status != 2,
|
|
|
|
tel: reserev.seller.seller_tel.split(',')[0],
|
|
|
|
soltName: reserev.soltName
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log(this.data.detail);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
cookbook() {
|
|
|
|
if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({
|
|
|
|
rid: this.id,
|
|
|
|
oid: this.data.detail.order.id,
|
|
|
|
identity: 1
|
|
|
|
}, '/pack-cookbook/pages/success')
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
App.Advance.CreateOrder({
|
|
|
|
rid: this.id,
|
|
|
|
openid: getApp().openid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret != 200) {
|
|
|
|
return util.toast(res.msg, 'none')
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({
|
|
|
|
rid: this.id,
|
|
|
|
oid: res.data.id,
|
|
|
|
identity: 1,
|
|
|
|
sid: res.data.sellerid
|
|
|
|
}, '/pack-cookbook/pages/index')
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
noopen(e) {
|
|
|
|
let mark = e.currentTarget.dataset.mark;
|
|
|
|
wx.showToast({
|
|
|
|
title: '该商家未开通' + (mark == 'buy' ? '提前点餐' : '在线买单'),
|
|
|
|
duration: 2000,
|
|
|
|
mask: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sharesetting() {
|
|
|
|
wx.reportMonitor('1017', 1)
|
|
|
|
let parmdata = {
|
|
|
|
id: this.id,
|
|
|
|
fromid: getApp().openid,
|
|
|
|
hasInvitation: 1,
|
|
|
|
tplid: this.data.options.tplid,
|
|
|
|
}
|
|
|
|
if (this.data.options.uid) {
|
|
|
|
parmdata.uid = this.data.options.uid;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
title: this.data.tpls[0].shareTitle,
|
|
|
|
path: util.http_build_query(parmdata, '/pages/customer/index'),
|
|
|
|
imageUrl: this.data.tpls[0].shareImage,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
formatDatail(detail, dateSmart) {
|
|
|
|
detail.rdateStr = dateSmart;
|
|
|
|
detail.tableFirst = detail.tables[0].name;
|
|
|
|
if (detail.tables.length > 1) {
|
|
|
|
detail.tableSubInfo = '等' + (detail.tables.length) + '个' +
|
|
|
|
(detail.tables[0].tid == 2 ? '包间' : '');
|
|
|
|
}
|
|
|
|
if (detail.rname && 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 = '邀请您共进午餐';
|
|
|
|
}
|
|
|
|
return detail;
|
|
|
|
},
|
|
|
|
getSellerTemplateConf() {
|
|
|
|
App.Seller.GetSellerTemplateConf({
|
|
|
|
sid: '4352'
|
|
|
|
}).then(res => {
|
|
|
|
let home = JSON.parse(res.data.home)
|
|
|
|
let chef = JSON.parse(res.data.chef)
|
|
|
|
let marketing = JSON.parse(res.data.marketing)
|
|
|
|
let reserve = JSON.parse(res.data.reserve)
|
|
|
|
let signboard = JSON.parse(res.data.signboard)
|
|
|
|
let store = JSON.parse(res.data.store)
|
|
|
|
store.images = eval(store.images)
|
|
|
|
signboard.images = eval(signboard.images)
|
|
|
|
if (marketing.is_online && marketing.is_arrival && marketing.is_transpond) {
|
|
|
|
this.setData({
|
|
|
|
between: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
chef,
|
|
|
|
marketing,
|
|
|
|
home,
|
|
|
|
reserve,
|
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
homeColor: home.red + ',' + home.green + ',' + home.blue + ',' + home.alpha, //home主题颜色
|
|
|
|
})
|
|
|
|
if (home.red == '1' && home.green == '67' && home.blue == '163') {
|
|
|
|
this.setData({
|
|
|
|
theme: 'blue'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (home.red == '67' && home.green == '142' && home.blue == '147') {
|
|
|
|
this.setData({
|
|
|
|
theme: 'green'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (home.red == '12' && home.green == '15' && home.blue == '14') {
|
|
|
|
this.setData({
|
|
|
|
theme: 'blackGold'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log('chef', JSON.parse(res.data.chef));
|
|
|
|
console.log('home', JSON.parse(res.data.home));
|
|
|
|
console.log('marketing', JSON.parse(res.data.marketing));
|
|
|
|
console.log('reserve', JSON.parse(res.data.reserve));
|
|
|
|
console.log('signboard', JSON.parse(res.data.signboard));
|
|
|
|
console.log('store', store);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
secondbook() {
|
|
|
|
wx.reportMonitor('1013', 1)
|
|
|
|
if (this.data.list) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: './discount?sid=' + this.data.detail.seller.id + '&id=' + this.data.options.id
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
wx.redirectTo({
|
|
|
|
url: '../reserve/detail?id=' + this.data.detail.seller.id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|