|
|
/**
|
|
|
* 潮流之旅
|
|
|
* <jing.li@yoho.cn>
|
|
|
* 2017/1/3
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const service = global.yoho.ServiceAPI;
|
|
|
const moment = require('moment');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
// 格式年月日
|
|
|
const _formatDay = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('YYYY年MM月DD日');
|
|
|
};
|
|
|
|
|
|
// 格式年月日
|
|
|
const _originDay = (day) => {
|
|
|
return moment(day, 'YYYY年MM月DD日 HH:mm').format('YYYY/MM/DD HH:mm');
|
|
|
};
|
|
|
|
|
|
// 所有时间
|
|
|
const _MYDHm = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('YYYY年MM月DD日 HH:mm');
|
|
|
};
|
|
|
|
|
|
// 月日时分
|
|
|
const _MDHm = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('MM月DD日 HH:mm');
|
|
|
};
|
|
|
|
|
|
// 格式年月日2
|
|
|
const _formatDay2 = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('YY年MM月DD日');
|
|
|
};
|
|
|
|
|
|
// 只要月日
|
|
|
const _MD = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('MM月DD日');
|
|
|
};
|
|
|
|
|
|
// 只要月日
|
|
|
const _D = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('DD日');
|
|
|
};
|
|
|
|
|
|
// 只要时分
|
|
|
const _HM = (day) => {
|
|
|
return moment(day, 'YYYY/MM/DD').format('HH:mm');
|
|
|
};
|
|
|
|
|
|
// 资讯列表
|
|
|
const info = (params) => {
|
|
|
return service.get('InformationController/getFrontAllList', {
|
|
|
storeId: params.storeId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 店铺信息
|
|
|
const storeInfo = (params) => {
|
|
|
return service.get('StoreController/getStoreInfoExtById', {
|
|
|
storeId: params.storeId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 店铺可预约项目
|
|
|
const storeSon = (params) => {
|
|
|
return service.get('MenuConfigController/getChildrenNodeById', {
|
|
|
storeId: params.storeId,
|
|
|
id: 0,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 店铺
|
|
|
const store = (params) => {
|
|
|
return Promise.all([
|
|
|
info(params),
|
|
|
storeInfo(params),
|
|
|
storeSon(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
infos: [],
|
|
|
detail: {},
|
|
|
storeSon: []
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
resu.infos = result[0].data;
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data) {
|
|
|
resu.detail = result[1].data;
|
|
|
}
|
|
|
|
|
|
if (result[2] && result[2].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[2].data.forEach(val => {
|
|
|
build.push({
|
|
|
img: val.thumbnailUrl,
|
|
|
href: val.url
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.storeSon = build;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 文章详情
|
|
|
const articleDetail = (params) => {
|
|
|
return service.get('InformationController/getFrontContentById', {
|
|
|
informationId: params.informationId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
let resu = {};
|
|
|
|
|
|
if (result && result.data) {
|
|
|
resu = result.data;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 店铺文章列表
|
|
|
const articleList = (params) => {
|
|
|
return service.get('InformationController/getFrontAllList', {
|
|
|
storeId: params.storeId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
let resu = {
|
|
|
infos: []
|
|
|
};
|
|
|
|
|
|
if (result && result.data) {
|
|
|
resu.infos = result.data;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 文章详情
|
|
|
const useList = (params) => {
|
|
|
return service.get('ActivityConfigController/getActivityNowList', {
|
|
|
storeId: params.storeId,
|
|
|
activityType: params.activityType,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 文章详情-过期
|
|
|
const oldList = (params) => {
|
|
|
return service.get('ActivityConfigController/getActivityEndList', {
|
|
|
storeId: params.storeId,
|
|
|
activityType: params.activityType,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
let resu = [];
|
|
|
|
|
|
if (result && result.data) {
|
|
|
resu = result.data;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流课堂,活动列表
|
|
|
const classActList = (params) => {
|
|
|
return Promise.all([
|
|
|
useList(params),
|
|
|
oldList(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
list: [],
|
|
|
oldList: []
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[0].data.forEach(val => {
|
|
|
|
|
|
let endDate = '';
|
|
|
|
|
|
let status = 0;// 0:已过期 ,1:可预约,2:已约满,3:免预约
|
|
|
|
|
|
if (val.isAppointment === 0) {
|
|
|
status = 3;
|
|
|
} else {
|
|
|
if (val.appointStatus === 1) {
|
|
|
status = 1;
|
|
|
} else {
|
|
|
status = 2;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (val.activityStartDate.split('/')[0] === val.activityEndDate.split('/')[0]) {
|
|
|
endDate = _MD(val.activityEndDate);
|
|
|
if (val.activityStartDate.split('/')[1] === val.activityEndDate.split('/')[1]) {
|
|
|
endDate = _D(val.activityEndDate);
|
|
|
}
|
|
|
} else {
|
|
|
endDate = _formatDay2(val.activityEndDate);
|
|
|
}
|
|
|
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
image: val.image.split(',')[0],
|
|
|
startDate: _formatDay(val.activityStartDate),
|
|
|
endDate: endDate,
|
|
|
startTime: val.activityDayStartTime,
|
|
|
endTime: val.activityDayEndTime,
|
|
|
free: val.isFree === 1,
|
|
|
price: helpers.round(val.price, 0),
|
|
|
needApo: val.isAppointment === 1,
|
|
|
apoStatus: val.appointStatus === 1,
|
|
|
id: val.id,
|
|
|
status: status,
|
|
|
storeId: params.storeId
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.list = build;
|
|
|
}
|
|
|
|
|
|
if (result && result[1]) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
let status = 0;
|
|
|
|
|
|
result[1].forEach(val => {
|
|
|
|
|
|
let endDate = '';
|
|
|
|
|
|
if (val.activityStartDate.split('/')[0] === val.activityEndDate.split('/')[0]) {
|
|
|
endDate = _MD(val.activityEndDate);
|
|
|
if (val.activityStartDate.split('/')[1] === val.activityEndDate.split('/')[1]) {
|
|
|
endDate = _D(val.activityEndDate);
|
|
|
}
|
|
|
} else {
|
|
|
endDate = _formatDay2(val.activityEndDate);
|
|
|
}
|
|
|
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
image: val.image.split(',')[0],
|
|
|
startDate: _formatDay(val.activityStartDate),
|
|
|
endDate: endDate,
|
|
|
startTime: val.activityDayStartTime,
|
|
|
endTime: val.activityDayEndTime,
|
|
|
end: true,
|
|
|
free: true,
|
|
|
id: val.id,
|
|
|
status: status,
|
|
|
storeId: params.storeId
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.oldList = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流课堂,活动详情
|
|
|
const classActDetail = (params) => {
|
|
|
return service.get('ActivityConfigController/getFrontDetailById', {
|
|
|
activityId: params.activityId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
let resu = {};
|
|
|
if (result && result.data) {
|
|
|
resu = {
|
|
|
content: result.data.detail,
|
|
|
name: params.name,
|
|
|
price: params.price,
|
|
|
startDate: params.startDate,
|
|
|
endDate: params.endDate,
|
|
|
startTime: params.startTime,
|
|
|
endTime: params.endTime,
|
|
|
status: params.status || '0',
|
|
|
storeId: params.storeId,
|
|
|
activityType: params.activityType,
|
|
|
id: params.activityId,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流之旅详情
|
|
|
const travelDetail = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMainTour', {
|
|
|
storeId: params.storeId,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
let resu = '';
|
|
|
Object.assign(params, {hairStylistId: result.data.id});
|
|
|
return Promise.all([
|
|
|
adviserList(params),
|
|
|
getDate2(params)
|
|
|
]).then(newResult => {
|
|
|
resu = Object.assign(result.data, {advisersList: newResult[0].data});
|
|
|
resu = Object.assign(result.data, {dateList: newResult[1].data});
|
|
|
return resu;
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流顾问,发型师套餐列表
|
|
|
const adviserList = (params) => {
|
|
|
return service.get('ActivityConfigController/getActivityList', {
|
|
|
storeId: params.storeId,
|
|
|
activityType: params.activityType,
|
|
|
id: params.id || '',
|
|
|
hairStylistId: 8 || '',
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流之旅
|
|
|
const travel = (params) => {
|
|
|
return Promise.all([
|
|
|
travelDetail(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
content: '',
|
|
|
adviser: [],
|
|
|
dateList: [],
|
|
|
storeId: params.storeId,
|
|
|
travelId: ''
|
|
|
};
|
|
|
|
|
|
if (result && result[0]) {
|
|
|
resu.travelId = result[0].id;
|
|
|
resu.content = result[0].tourDetail;
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[0].advisersList.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
summary: val.summary,
|
|
|
image: val.image,
|
|
|
id: val.id,
|
|
|
typeStatus: params.activityType,
|
|
|
storeId: params.storeId
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.adviser = build;
|
|
|
|
|
|
let build2 = [];
|
|
|
|
|
|
for(let item in result[0].dateList){
|
|
|
build2.push({
|
|
|
date: _MD(item),
|
|
|
week: result[0].dateList[item],
|
|
|
dateOrigin: item,
|
|
|
dateParse: Date.parse(item) / 1000
|
|
|
});
|
|
|
}
|
|
|
resu.dateList = build2;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流顾问,摄影,发型师,套餐详情
|
|
|
const adviserDetail = (params) => {
|
|
|
return service.get('ActivityConfigController/getFrontActivityInfoById', {
|
|
|
activityId: params.id,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮流顾问详情
|
|
|
const adviser = (params) => {
|
|
|
return Promise.all([
|
|
|
adviserDetail(params),
|
|
|
getDate(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
detail: {},
|
|
|
content: {},
|
|
|
dateList: [],
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
resu.detail = {
|
|
|
name: result[0].data.activityName,
|
|
|
summary: result[0].data.summary,
|
|
|
image: result[0].data.image,
|
|
|
};
|
|
|
|
|
|
resu.content = result[0].data.detail;
|
|
|
}
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
if (result && result[1] && result[1].data) {
|
|
|
|
|
|
for(let item in result[1].data){
|
|
|
build.push({
|
|
|
date: _MD(item),
|
|
|
week: result[1].data[item],
|
|
|
dateOrigin: item,
|
|
|
dateParse: Date.parse(item) / 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
resu.dateList = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 摄影详情
|
|
|
const photographyDetail = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMenuById', {
|
|
|
id: params.id,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取风格
|
|
|
const getStyle = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMenuPhotoStyle', {
|
|
|
storeId: params.storeId,
|
|
|
id: params.styleId || '',
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取日期,星期
|
|
|
const getDate = (params) => {
|
|
|
if (!params.activityId) {
|
|
|
params.activityId = params.travelId;
|
|
|
params.activityType = 6;
|
|
|
}
|
|
|
return service.get('ActivityConfigController/getAppointInfoById', {
|
|
|
activityId: params.activityId,
|
|
|
activityType: params.activityType,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取日期,星期(所有潮流顾问, 发型师详情页)
|
|
|
const getDate2 = (params) => {
|
|
|
return service.get('ActivityConfigController/getAppointDateForTour', {
|
|
|
storeId: params.storeId,
|
|
|
activityType: params.activityType,
|
|
|
hairStylistId: params.id || '',
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取风格热推
|
|
|
const getStylePush = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMenuPhotoStyle', {
|
|
|
storeId: params.storeId,
|
|
|
isPush: 1,
|
|
|
isFront: params.isFront
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取时间列表
|
|
|
const getTimeList = (params) => {
|
|
|
if (!params.activityId) {
|
|
|
params.activityId = params.travelId;
|
|
|
params.appointType = 6;
|
|
|
}
|
|
|
|
|
|
let ajaxUrl = '';
|
|
|
if (params.userId) {
|
|
|
ajaxUrl = 'ActivityConfigController/getAppointTimeForTour';
|
|
|
} else {
|
|
|
ajaxUrl = 'AppointmentController/getAppointTime';
|
|
|
}
|
|
|
|
|
|
return service.get(ajaxUrl, {
|
|
|
storeId: params.storeId,
|
|
|
activityId: params.activityId,
|
|
|
appointType: params.appointType,
|
|
|
activityType: params.appointType,
|
|
|
hairStylistId: params.userId,
|
|
|
dateTime: params.dateTime,
|
|
|
isFront: params.isFront,
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
getTimeList: [],
|
|
|
appointNum: 0
|
|
|
};
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
if (result && result.data && result.data.timeMap) {
|
|
|
for(let item in result.data.timeMap){
|
|
|
build.push({
|
|
|
time: _HM(new Date(item * 1000)),
|
|
|
originTime: item,
|
|
|
use: result.data.timeMap[item],
|
|
|
date2: _MDHm(new Date(item * 1000)),
|
|
|
date: _MYDHm(new Date(item * 1000)),
|
|
|
});
|
|
|
}
|
|
|
resu.appointNum = result.data.appointNum;
|
|
|
resu.getTimeList = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 摄影
|
|
|
const photography = (params) => {
|
|
|
return Promise.all([
|
|
|
photographyDetail(params),
|
|
|
getStyle(params),
|
|
|
adviserList(params),
|
|
|
getStylePush(params),
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
content: '',
|
|
|
detail: {},
|
|
|
styleList: [],
|
|
|
packageList: [],
|
|
|
swiper: [],
|
|
|
storeId: params.storeId
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
resu.detail = {
|
|
|
bigPic: result[0].data.mainPushUrl
|
|
|
};
|
|
|
resu.content = result[0].data.detail;
|
|
|
}
|
|
|
if (result[1] && result[1].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[1].data.forEach(val => {
|
|
|
|
|
|
build.push({
|
|
|
img: val.styleImage,
|
|
|
id: val.id,
|
|
|
name: val.styleName
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.styleList = build;
|
|
|
}
|
|
|
if (result[2] && result[2].data) {
|
|
|
let build = [];
|
|
|
|
|
|
result[2].data.forEach(val => {
|
|
|
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
free: val.isFree === 1,
|
|
|
price: val.price,
|
|
|
summary: val.summary,
|
|
|
id: val.id
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.packageList = build;
|
|
|
}
|
|
|
if (result[3] && result[3].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[3].data.forEach(val => {
|
|
|
|
|
|
build.push({
|
|
|
pic: val.styleImage,
|
|
|
name: val.styleName,
|
|
|
introduction: val.introduction,
|
|
|
id: val.id,
|
|
|
storeId: params.storeId
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.swiper = build;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 套餐详情
|
|
|
const packageDetail = (params) => {
|
|
|
return Promise.all([
|
|
|
adviserDetail(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
detail: {},
|
|
|
content: {},
|
|
|
isAppointment: false
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
resu.detail = {
|
|
|
name: result[0].data.activityName,
|
|
|
summary: result[0].data.summary,
|
|
|
free: result[0].data.isFree === 1,
|
|
|
price: result[0].data.price,
|
|
|
img: result[0].data.image,
|
|
|
limit: result[0].data.styleNumber,
|
|
|
styleId: result[0].data.styleList
|
|
|
};
|
|
|
resu.isAppointment = result[0].data.isAppointment === 1;
|
|
|
resu.content = result[0].data.detail;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 风格详情
|
|
|
const styleDetail = (params) => {
|
|
|
return Promise.all([
|
|
|
getStyle(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
introduction: '',
|
|
|
picList: []
|
|
|
};
|
|
|
|
|
|
let bulid = [];
|
|
|
|
|
|
if (result && result[0] && result[0].data && result[0].data[0]) {
|
|
|
resu.introduction = result[0].data[0].introduction;
|
|
|
resu.picList = result[0].data[0].styleDemo.split(',');
|
|
|
resu.picList.forEach(val => {
|
|
|
bulid.push({
|
|
|
imgSrc: val
|
|
|
});
|
|
|
});
|
|
|
resu.picList = bulid;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 预约
|
|
|
const appointment = (params) => {
|
|
|
return Promise.all([
|
|
|
storeInfo(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
storeInfo: {},
|
|
|
storeId: params.storeId,
|
|
|
typeStatus: params.activityType,
|
|
|
uid: params.uid,
|
|
|
cutterChosen: params.activityType === '5',
|
|
|
styleChosen: params.activityType === '4',
|
|
|
adviserChosen: params.activityType === '3',
|
|
|
packageChosen: params.activityType === '4' || params.activityType === '5',
|
|
|
sexInp: params.activityType === '4' || params.activityType === '5',
|
|
|
ageInp: params.activityType === '4' || params.activityType === '5',
|
|
|
babyName: params.activityType === '4' || params.activityType === '5',
|
|
|
classChosen: params.activityType === '1',
|
|
|
actChosen: params.activityType === '2',
|
|
|
hideChosen: params.activityType === '3' ? false : true,
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
resu.storeInfo = {
|
|
|
name: result[0].data.storeName,
|
|
|
adr: result[0].data.address,
|
|
|
telephone: result[0].data.telephone,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 选择套餐
|
|
|
const chosenPackage = (params) => {
|
|
|
return Promise.all([
|
|
|
adviserList(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
packageChosen: []
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
summary: val.summary,
|
|
|
free: val.isFree === 1,
|
|
|
price: val.price,
|
|
|
id: val.id,
|
|
|
foot: true,
|
|
|
limit: val.styleNumber,
|
|
|
styleId: val.styleList
|
|
|
});
|
|
|
|
|
|
resu.packageChosen = build;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 选择风格
|
|
|
const chosenStyle = (params) => {
|
|
|
return Promise.all([
|
|
|
getStyle(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
styleList: [],
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.styleName,
|
|
|
id: val.id
|
|
|
});
|
|
|
resu.styleList = build;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 选择时间
|
|
|
const chosenTime = (params) => {
|
|
|
return Promise.all([
|
|
|
getDate(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
dateList: [],
|
|
|
needAdv: params.activityType === '3',
|
|
|
hide: params.activityType === '1',
|
|
|
};
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
for(let item in result[0].data){
|
|
|
build.push({
|
|
|
date: _MD(item),
|
|
|
week: result[0].data[item],
|
|
|
dateOrigin: item,
|
|
|
dateParse: Date.parse(item) / 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
resu.dateList = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 选择发型师
|
|
|
const chosenCutter = (params) => {
|
|
|
return Promise.all([
|
|
|
cutterList(params),
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {};
|
|
|
|
|
|
if (result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.stylistName,
|
|
|
level: val.stylistLevelStr,
|
|
|
price: val.minPrice,
|
|
|
img: val.stylistPhoto,
|
|
|
radio: true,
|
|
|
arr: false,
|
|
|
free: val.minPrice === -1,
|
|
|
noPackage: val.minPrice === null
|
|
|
});
|
|
|
});
|
|
|
resu.cutterList = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 选择潮流顾问
|
|
|
const chosenAdviser = (params) => {
|
|
|
return Promise.all([
|
|
|
adviserList(params),
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
adviser: []
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.consultantName,
|
|
|
summary: val.summary,
|
|
|
image: val.image,
|
|
|
id: val.id
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.adviser = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 提交预约
|
|
|
const addOrder = (params) => {
|
|
|
return service.get('AppointmentController/addAppointmentRecord', {
|
|
|
storeId: params.storeId,
|
|
|
appointTime: params.appointTime,
|
|
|
appointUserName: params.appointUserName,
|
|
|
appointMobile: params.appointMobile,
|
|
|
uid: params.uid,
|
|
|
activityId: params.activityId,
|
|
|
appointContent: params.appointContent,
|
|
|
userNote: params.userNote,
|
|
|
appointPersonNum: params.appointPersonNum,
|
|
|
styles: params.styles,
|
|
|
appointStatus: 1,
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 我的预约列表,详情
|
|
|
const orderList1 = (params) => {
|
|
|
return service.get('AppointmentController/getMyAppointmentList', {
|
|
|
storeId: params.storeId,
|
|
|
uid: params.uid,
|
|
|
statusList: params.statusList,
|
|
|
id: params.id || ''
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 我的预约
|
|
|
const orderList = (params) => {
|
|
|
|
|
|
let params1 = params;
|
|
|
|
|
|
let params2 = params;
|
|
|
|
|
|
return Promise.all([
|
|
|
orderList1(Object.assign(params1, {statusList: '1,2'})),
|
|
|
orderList1(Object.assign(params2, {statusList: '3,4'}))
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
list1: [],
|
|
|
list2: [],
|
|
|
noOrder: false
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
console.log(result[0].data);
|
|
|
let build = [];
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
status: val.appointStatusStr,
|
|
|
createTime: _MYDHm(new Date(val.appointTime * 1000)),
|
|
|
originTime: val.appointTime,
|
|
|
id: val.id,
|
|
|
storeId: params.storeId,
|
|
|
typeStatus: val.activityType,
|
|
|
activityId: val.activityId
|
|
|
});
|
|
|
});
|
|
|
resu.list1 = build;
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[1].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
status: val.appointStatusStr,
|
|
|
createTime: _MYDHm(new Date(val.appointTime * 1000)),
|
|
|
originTime: val.appointTime,
|
|
|
id: val.id,
|
|
|
storeId: params.storeId
|
|
|
});
|
|
|
});
|
|
|
resu.list2 = build;
|
|
|
}
|
|
|
|
|
|
if (!result[0].data && !result[1].data) {
|
|
|
resu.noOrder = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 我的预约
|
|
|
const orderDetail = (params) => {
|
|
|
return Promise.all([
|
|
|
orderList1(params),
|
|
|
storeInfo(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
storeInfo: {},
|
|
|
userInfo: {},
|
|
|
storeId: params.storeId,
|
|
|
id: params.id
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[1] && result[1].data) {
|
|
|
resu.storeInfo = {
|
|
|
name: result[1].data.storeName,
|
|
|
adr: result[1].data.address,
|
|
|
telephone: result[1].data.telephone,
|
|
|
storeId: result[1].data.storeId,
|
|
|
longitude: result[1].data.longitude,
|
|
|
latitude: result[1].data.latitude,
|
|
|
storeName: result[1].data.storeName,
|
|
|
address: result[1].data.address,
|
|
|
telephone: result[1].data.telephone,
|
|
|
introduction: result[1].data.introduction,
|
|
|
pictureUrl: result[1].data.pictureUrl
|
|
|
};
|
|
|
}
|
|
|
if (result[0] && result[0].data) {
|
|
|
let appointContent = JSON.parse(result[0].data[0].appointContent);
|
|
|
resu.userInfo = {
|
|
|
babyName: appointContent.name,
|
|
|
babyAge: appointContent.age === 'NaN' ? '' : appointContent.age,
|
|
|
babySex: appointContent.sex === 'undefined' ? '' : appointContent.sex,
|
|
|
userNote: result[0].data[0].userNote,
|
|
|
appointMobile: result[0].data[0].appointMobile,
|
|
|
appointTime: _MYDHm(new Date(result[0].data[0].appointTime * 1000)),
|
|
|
originTime: result[0].data[0].appointTime,
|
|
|
storeId: params.storeId,
|
|
|
activityId: result[0].data[0].activityId,
|
|
|
stylesName: result[0].data[0].stylesName,
|
|
|
typeStatus: result[0].data[0].activityType,
|
|
|
status: result[0].data[0].appointStatusStr,
|
|
|
id: result[0].data[0].id,
|
|
|
showBtn: params.showBtn === 'true',
|
|
|
originUrl: result[0].data[0].url,
|
|
|
personName: result[0].data[0].personName,
|
|
|
personId: result[0].data[0].personId,
|
|
|
num: result[0].data[0].appointPersonNum
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let newNarams = '';
|
|
|
if (result[0] && result[0].data) {
|
|
|
newNarams = {
|
|
|
id: result[0].data[0].activityId,
|
|
|
isFront: params.isFront
|
|
|
};
|
|
|
}
|
|
|
return adviserDetail(newNarams).then(newResult => {
|
|
|
|
|
|
let adviserDetail= '';
|
|
|
if (newResult && newResult.data) {
|
|
|
adviserDetail = {
|
|
|
name: newResult.data.activityName,
|
|
|
summary: newResult.data.summary,
|
|
|
free: newResult.data.isFree === 1,
|
|
|
price: newResult.data.price,
|
|
|
id: newResult.data.id,
|
|
|
kidStyle: newResult.data.activityType === 5,
|
|
|
photography: newResult.data.activityType === 4,
|
|
|
adviser: newResult.data.activityType === 3,
|
|
|
act: newResult.data.activityType === 2,
|
|
|
class: newResult.data.activityType === 1,
|
|
|
activityType: newResult.data.activityType,
|
|
|
storeId: params.storeId,
|
|
|
startDate: newResult.data.activityStartDate,
|
|
|
endDate: newResult.data.activityEndDate,
|
|
|
startTime: newResult.data.activityDayStartTime,
|
|
|
endTime: newResult.data.activityDayEndTime
|
|
|
};
|
|
|
}
|
|
|
resu = Object.assign(resu, {adviserDetail: adviserDetail});
|
|
|
return resu;
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 发型师列表
|
|
|
const cutterList = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMenuStylist', {
|
|
|
storeId: params.storeId,
|
|
|
id: params.id || '',
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
const cutterList2 = (params) => {
|
|
|
return service.get('MenuConfigController/getFrontMenuStylist', {
|
|
|
storeId: params.storeId,
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 儿童造型
|
|
|
const kidStyle = (params) => {
|
|
|
return Promise.all([
|
|
|
cutterList2(params),
|
|
|
adviserList(params),
|
|
|
photographyDetail(params),
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
cutterList: [],
|
|
|
storeId: params.storeId,
|
|
|
detail: {},
|
|
|
content: ''
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
name: val.stylistName,
|
|
|
level: val.stylistLevelStr,
|
|
|
price: val.minPrice,
|
|
|
img: val.stylistPhoto,
|
|
|
id: val.id,
|
|
|
radio: false,
|
|
|
arr: true,
|
|
|
storeId: params.storeId,
|
|
|
free: val.minPrice === -1,
|
|
|
noPackage: val.minPrice === null
|
|
|
});
|
|
|
});
|
|
|
resu.cutterList = build;
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
result[1].data.forEach(val => {
|
|
|
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
free: val.isFree === 1,
|
|
|
price: val.price,
|
|
|
summary: val.summary,
|
|
|
id: val.id
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.packageList = build;
|
|
|
}
|
|
|
|
|
|
if (result[2] && result[2].data) {
|
|
|
resu.detail = {
|
|
|
bigPic: result[2].data.mainPushUrl
|
|
|
};
|
|
|
resu.content = result[2].data.detail;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 潮童造型
|
|
|
const kids = (params) => {
|
|
|
return Promise.all([
|
|
|
storeSon(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
storeSon: []
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[0].data.forEach(val => {
|
|
|
build.push({
|
|
|
img: val.thumbnailUrl,
|
|
|
href: val.url
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.storeSon = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 发型师
|
|
|
const cutter = (params) => {
|
|
|
return Promise.all([
|
|
|
cutterList(params),
|
|
|
adviserList(params),
|
|
|
getDate2(params)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
|
|
packageList: [],
|
|
|
stylist: [],
|
|
|
dateList: [],
|
|
|
showBtn: ''
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
|
|
|
let val = result[0].data[0];
|
|
|
resu = {
|
|
|
image: val.stylistPhoto,
|
|
|
name: val.stylistName,
|
|
|
summary: val.stylistLevelStr,
|
|
|
intro: val.introduction,
|
|
|
};
|
|
|
resu.showBtn = val.isAppointment ===1;
|
|
|
resu.stylist = val.stylistWorks.split(',');
|
|
|
}
|
|
|
if (result[1] && result[1].data) {
|
|
|
|
|
|
let build = [];
|
|
|
result[1].data.forEach(val => {
|
|
|
|
|
|
build.push({
|
|
|
name: val.activityName,
|
|
|
free: val.isFree === 1,
|
|
|
price: val.price,
|
|
|
summary: val.summary,
|
|
|
id: val.id
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.packageList = build;
|
|
|
}
|
|
|
if (result[2] && result[2].data) {
|
|
|
|
|
|
let build = [];
|
|
|
|
|
|
if (result && result[2] && result[2].data) {
|
|
|
|
|
|
for(let item in result[2].data){
|
|
|
build.push({
|
|
|
date: _MD(item),
|
|
|
week: result[2].data[item],
|
|
|
dateOrigin: item,
|
|
|
dateParse: Date.parse(item) / 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
resu.dateList = build;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 删除预约订单
|
|
|
const delOrder = (params) => {
|
|
|
return service.get('AppointmentController/frontCancelAppoint', {
|
|
|
id: params.id,
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 修改预约时间
|
|
|
const changeDate = (params) => {
|
|
|
|
|
|
let appointTimeStr = _originDay(params.appointTimeStr);
|
|
|
return service.get('AppointmentController/updateFrontAppointTime', {
|
|
|
id: params.id,
|
|
|
appointTimeStr: appointTimeStr,
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 获取可用时间
|
|
|
const getAbleTime = (params) => {
|
|
|
return service.get('ActivityConfigController/getAppointTime4Activity', {
|
|
|
activityType: params.activityType,
|
|
|
activityId: params.activityId,
|
|
|
isFront: params.isFront
|
|
|
}).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
store,
|
|
|
articleDetail,
|
|
|
articleList,
|
|
|
classActList,
|
|
|
classActDetail,
|
|
|
travel,
|
|
|
adviser,
|
|
|
photography,
|
|
|
packageDetail,
|
|
|
styleDetail,
|
|
|
appointment,
|
|
|
chosenPackage,
|
|
|
chosenStyle,
|
|
|
chosenTime,
|
|
|
getTimeList,
|
|
|
addOrder,
|
|
|
orderList,
|
|
|
orderDetail,
|
|
|
kidStyle,
|
|
|
chosenCutter,
|
|
|
chosenAdviser,
|
|
|
cutter,
|
|
|
delOrder,
|
|
|
changeDate,
|
|
|
kids,
|
|
|
getAbleTime
|
|
|
}; |
...
|
...
|
|