|
|
|
// pages/customer/detail_owner_invitation8.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: ''
|
|
|
|
},
|
|
|
|
tableNum: 0,
|
|
|
|
detail: {},
|
|
|
|
staffinfo: {},
|
|
|
|
between: false,
|
|
|
|
chef: {},
|
|
|
|
marketing: {},
|
|
|
|
home: {},
|
|
|
|
reserve: {},
|
|
|
|
signboard: {},
|
|
|
|
store: {},
|
|
|
|
recharge_data: {},
|
|
|
|
coupon_dataList: [],
|
|
|
|
stringifyUse: '',
|
|
|
|
current: 0,
|
|
|
|
seller: {
|
|
|
|
name: '',
|
|
|
|
tablesText: '',
|
|
|
|
date: '',
|
|
|
|
addr: ''
|
|
|
|
},
|
|
|
|
priceInfo: '',
|
|
|
|
scoreInfo: '',
|
|
|
|
discount: '',
|
|
|
|
certificate: '',
|
|
|
|
dataStr: Date.now() * 1 / 1000,
|
|
|
|
swich_phone: '0',
|
|
|
|
is_comments: '0',
|
|
|
|
is_user_comments: false,
|
|
|
|
tableinfo: [],
|
|
|
|
StyleType: '',
|
|
|
|
showMoreTip: true,
|
|
|
|
themeColor: '',
|
|
|
|
screenHeight: '',
|
|
|
|
},
|
|
|
|
tablestr: '',
|
|
|
|
urlsValue: [],
|
|
|
|
screenHeight: '',
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
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, //渠道分析
|
|
|
|
});
|
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
|
this.screenHeight = systemInfo.windowHeight; // 获取屏幕高度
|
|
|
|
},
|
|
|
|
// 页面滚动事件
|
|
|
|
onPageScroll: function (event) {
|
|
|
|
const scrollTop = event.scrollTop * 1 + this.screenHeight - 80; // 获取滚动的距离
|
|
|
|
if (scrollTop < this.screenHeight) {
|
|
|
|
this.setData({
|
|
|
|
showMoreTip: true
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
showMoreTip: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 点击了解更多会员优惠政策
|
|
|
|
gotoFavourableList() {
|
|
|
|
let url = util.http_build_query({
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sellerid: this.data.seller.sid,
|
|
|
|
oid: this.data.detail.id,
|
|
|
|
types: '1'
|
|
|
|
}, '/pack-cookbook/pages/favourableList')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 去评价
|
|
|
|
evaluateFun() {
|
|
|
|
let url = util.http_build_query({
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sellerid: this.data.seller.sid,
|
|
|
|
oid: this.data.detail.id,
|
|
|
|
types: '1',
|
|
|
|
previousPage: '1',
|
|
|
|
}, '/pages/pinglun/createOpinion')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 监听用户点击分享到朋友圈按钮的操作
|
|
|
|
*/
|
|
|
|
onShareTimeline() {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.getDetail()
|
|
|
|
},
|
|
|
|
// 复制微信号
|
|
|
|
copyWeChat() {
|
|
|
|
if (this.data.staffinfo.wechat) {
|
|
|
|
wx.setClipboardData({
|
|
|
|
data: this.data.staffinfo.wechat,
|
|
|
|
success(res) {
|
|
|
|
wx.getClipboardData({
|
|
|
|
success(res) {
|
|
|
|
console.log(res.data) // data
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log('无微信号')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 拨打电话
|
|
|
|
call() {
|
|
|
|
wx.reportMonitor('1012', 1)
|
|
|
|
wx.makePhoneCall({
|
|
|
|
phoneNumber: this.data.staffinfo.phone
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 导航
|
|
|
|
looklocation: function () {
|
|
|
|
wx.reportMonitor('1015', 1)
|
|
|
|
wx.openLocation({
|
|
|
|
latitude: Number(this.data.seller.lat),
|
|
|
|
longitude: Number(this.data.seller.long),
|
|
|
|
scale: 17,
|
|
|
|
address: this.data.seller.addr,
|
|
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取包间图片列表
|
|
|
|
getroomimage(sellerid) {
|
|
|
|
App.Tables.GetTablesPhoto({
|
|
|
|
sellerid,
|
|
|
|
tableids: this.tablestr
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
this.setData({
|
|
|
|
roomimage: json.data
|
|
|
|
})
|
|
|
|
var urlsArr = [];
|
|
|
|
json.data.forEach((v, i) => {
|
|
|
|
urlsArr.push(v.url);
|
|
|
|
})
|
|
|
|
this.urlsValue = urlsArr;
|
|
|
|
console.log('urlsArr', urlsArr)
|
|
|
|
console.log('roomimage', json.data)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 预览包间图片
|
|
|
|
lookroom(e) {
|
|
|
|
const item = e.currentTarget.dataset['item'];
|
|
|
|
wx.previewImage({
|
|
|
|
current: item.url, // 当前显示图片的http链接
|
|
|
|
urls: this.urlsValue, // 需要预览的图片http链接列表
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取店铺详情
|
|
|
|
getDetail() {
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
let tablesText = '', //桌子信息
|
|
|
|
tableNum = 0;
|
|
|
|
let tableinfo = util.determine(res.data.tableinfo);
|
|
|
|
console.log('tableinfo', tableinfo);
|
|
|
|
res.data.tables.forEach((t, i) => {
|
|
|
|
tableNum += t.table_pnum * 1
|
|
|
|
tablesText += t.rname + t.name + (i == (res.data.tables.length - 1) ? '' : '、');
|
|
|
|
})
|
|
|
|
let tabaleids = [];
|
|
|
|
res.data.tables.forEach(t => {
|
|
|
|
tabaleids.push(t.id);
|
|
|
|
})
|
|
|
|
this.tablestr = tabaleids.toString();
|
|
|
|
let reserev = RS.reserve(res.data)
|
|
|
|
let dateSmart
|
|
|
|
if (res.data.type == 1) {
|
|
|
|
dateSmart = util.unixtoTime(reserev.ddate, 'YYYY年MM月DD日 星期WW')
|
|
|
|
if (res.data.is_set_ddate == 1) {
|
|
|
|
dateSmart += ' ' + util.unixtoTime(reserev.ddate, 'YYYY年MM月DD日 星期WW')
|
|
|
|
} else {
|
|
|
|
dateSmart += ' ' + reserev.soltName
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dateSmart = util.unixtoTime(reserev.ddate, 'YYYY年MM月DD日 星期WW')
|
|
|
|
}
|
|
|
|
console.log('dateSmart', dateSmart);
|
|
|
|
this.setData({
|
|
|
|
detail: this.formatDatail(reserev, dateSmart),
|
|
|
|
tableNum,
|
|
|
|
tableinfo,
|
|
|
|
is_user_comments: res.data.is_user_comments,
|
|
|
|
seller: {
|
|
|
|
name: reserev.seller.sellername,
|
|
|
|
sid: reserev.sid,
|
|
|
|
date: dateSmart,
|
|
|
|
tablesText,
|
|
|
|
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,
|
|
|
|
time: util.unixtoTime(reserev.ddate, '星期WW HH:II'),
|
|
|
|
lat: reserev.seller.lat,
|
|
|
|
long: reserev.seller.long,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('reserev reserev', reserev);
|
|
|
|
console.log('seller seller', this.data.seller);
|
|
|
|
console.log('detail detail', this.data.detail);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getSellerTemplateConfFun(reserev.sid);
|
|
|
|
this.getstaffinfo(res.data.uid)
|
|
|
|
this.getroomimage(reserev.sid)
|
|
|
|
}, 0);
|
|
|
|
}).catch(res => {
|
|
|
|
console.log(res, '详情请求失败');
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 客户经理获取基本信息
|
|
|
|
getstaffinfo(uid) {
|
|
|
|
console.log('sellerid', this.data.detail.seller.id);
|
|
|
|
App.Activity.GetCustomerActivityBaseinfo({
|
|
|
|
sellerid: this.data.detail.seller.id,
|
|
|
|
uid
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
console.log('staffinfostaffinfostaffinfo', json.data)
|
|
|
|
this.setData({
|
|
|
|
staffinfo: json.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 提前点餐
|
|
|
|
cookbook() {
|
|
|
|
if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
|
|
|
|
let data = {
|
|
|
|
rid: this.id,
|
|
|
|
oid: this.data.detail.order.id,
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sid: this.data.seller.sid,
|
|
|
|
identity: '1',
|
|
|
|
hasSuccess: '1',
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pack-cookbook/pages/success_new?hasSuccess=${data.hasSuccess}&identity=${data.identity}&oid=${data.oid}&rid=${data.rid}&sellerName=${data.sellerName}&sid=${data.sid}`,
|
|
|
|
})
|
|
|
|
} 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,
|
|
|
|
sid: res.data.sellerid,
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
identity: '1',
|
|
|
|
}, '/pack-cookbook/pages/index_new')
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 分享
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
console.log('seller_imageseller_imageseller_imageseller_imageseller_image', this.data.detail.seller.seller_image);
|
|
|
|
return {
|
|
|
|
title: '邀请您于' + this.data.seller.date + '一起共进' + this.data.seller.soltName + '。点击查看详情',
|
|
|
|
path: util.http_build_query(parmdata, '/pages/customer/index'),
|
|
|
|
imageUrl: this.data.detail.seller.seller_image,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 修改detail数据
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
// 获取商家设置营销信息
|
|
|
|
getSellerTemplateConfFun(sid) {
|
|
|
|
console.log(sid, 'sidsidsidsid');
|
|
|
|
App.Seller.GetSellerTemplateConf({
|
|
|
|
sid
|
|
|
|
}).then(res => {
|
|
|
|
let data = res.data
|
|
|
|
console.log('data', data);
|
|
|
|
let coupon_dataList = []
|
|
|
|
let themeColor, StyleType, home, chef, marketing, coupon, reserve, swich_phone, is_comments, signboard, store, priceInfo, certificate, scoreInfo, recharge_list, stringifyUse;
|
|
|
|
chef = util.determine(data.chef);
|
|
|
|
reserve = util.determine(data.reserve);
|
|
|
|
marketing = util.determine(data.marketing);
|
|
|
|
signboard = util.determine(data.signboard);
|
|
|
|
store = util.determine(data.store);
|
|
|
|
home = util.determine(data.home);
|
|
|
|
themeColor = data.lite_class;
|
|
|
|
StyleType = data.type;
|
|
|
|
swich_phone = reserve && reserve.swich_phone ? reserve.swich_phone : '';
|
|
|
|
if (marketing) {
|
|
|
|
is_comments = marketing.is_comments ? marketing.is_comments : '';
|
|
|
|
coupon = marketing.coupon_data ? util.determine(marketing.coupon_data) : '';
|
|
|
|
}
|
|
|
|
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
|
|
|
|
if (coupon && util.getType(coupon) == 'object') {
|
|
|
|
coupon.stringifyUse = JSON.stringify(coupon.use)
|
|
|
|
if (marketing.is_coupon == '1' && coupon && (!coupon.use.is_cash || coupon.use.is_cash == '1')) {
|
|
|
|
let cash = coupon.use.cash * 1;
|
|
|
|
let price = coupon.price * 1;
|
|
|
|
console.log('cash', cash + '---' + 'price', price + '---' + 'discount', ((price / cash) * 10).toFixed(1));
|
|
|
|
coupon.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
coupon_dataList.push(coupon);
|
|
|
|
}
|
|
|
|
if (coupon && util.getType(coupon) == 'array') {
|
|
|
|
if (coupon.length > 0) {
|
|
|
|
coupon.forEach(item => {
|
|
|
|
item.stringifyUse = JSON.stringify(item.use)
|
|
|
|
if ((!item.use.is_cash || item.use.is_cash == '1')) {
|
|
|
|
let cash = item.use.cash * 1;
|
|
|
|
let price = item.price * 1;
|
|
|
|
console.log('cash', cash + '---' + 'price', price + '---' + 'discount', ((price / cash) * 10).toFixed(1));
|
|
|
|
item.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
coupon_dataList = coupon;
|
|
|
|
}
|
|
|
|
let obj = {
|
|
|
|
chef,
|
|
|
|
reserve,
|
|
|
|
marketing,
|
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
home,
|
|
|
|
stringifyUse,
|
|
|
|
coupon,
|
|
|
|
coupon_dataList,
|
|
|
|
swich_phone,
|
|
|
|
is_comments,
|
|
|
|
StyleType,
|
|
|
|
themeColor,
|
|
|
|
}
|
|
|
|
console.log('获取数据', {
|
|
|
|
...obj
|
|
|
|
});
|
|
|
|
if (marketing && marketing.is_recharge == '1' && marketing.recharge_data) {
|
|
|
|
let recharge_data = marketing.recharge_data
|
|
|
|
recharge_list = marketing.recharge_data.recharge_list
|
|
|
|
if (recharge_list.is_price == '1') priceInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.price + '元余额';
|
|
|
|
if (recharge_list.is_score == '1') scoreInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.score + '积分';
|
|
|
|
if (recharge_list.is_coupons == '1' && recharge_data.recharge_list.coupons_names.length > 0) certificate = recharge_data.recharge_list.coupons_names.join('、');
|
|
|
|
console.log('scoreInfo', scoreInfo);
|
|
|
|
console.log('priceInfo', priceInfo);
|
|
|
|
this.setData({
|
|
|
|
recharge_data: marketing.recharge_data,
|
|
|
|
certificate
|
|
|
|
})
|
|
|
|
console.log('recharge_data', recharge_data);
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
stringifyUse
|
|
|
|
})
|
|
|
|
if (store && store.images.length > 0) store.images = util.determine(store.images);
|
|
|
|
if (signboard && signboard.images) signboard.images = util.determine(signboard.images);
|
|
|
|
if (marketing && marketing.is_online_book == '1' && marketing.is_transpond == '1') {
|
|
|
|
this.setData({
|
|
|
|
between: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
chef,
|
|
|
|
marketing,
|
|
|
|
home,
|
|
|
|
reserve,
|
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
priceInfo,
|
|
|
|
scoreInfo,
|
|
|
|
swich_phone,
|
|
|
|
is_comments,
|
|
|
|
StyleType,
|
|
|
|
themeColor,
|
|
|
|
})
|
|
|
|
}).catch(res => {
|
|
|
|
console.log('GetSellerTemplateConf请求失败');
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 再次预订
|
|
|
|
secondbook() {
|
|
|
|
wx.reportMonitor('1013', 1)
|
|
|
|
wx.redirectTo({
|
|
|
|
url: '../reserve/detail?id=' + this.data.detail.seller.id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|