|
|
require('../common');
|
|
|
|
|
|
var tip = require('../plugin/tip'),
|
|
|
IScroll = require('yoho-iscroll'),
|
|
|
diaLog = require('../plugin/dialog'),
|
...
|
...
|
@@ -25,780 +26,833 @@ if ($('#map').length > 0) { |
|
|
require('../../scss/activity/trend/map.css');
|
|
|
}
|
|
|
|
|
|
$(
|
|
|
function() {
|
|
|
// 地图初始化
|
|
|
if ($('#map').length > 0) {
|
|
|
var w_height = $(window).height();
|
|
|
var h_height = $('.yoho-header').height();
|
|
|
$('#map').css('height', (w_height - h_height) + 'px');
|
|
|
var mapPic = decodeURI(window.queryString.pic);
|
|
|
var mapName = decodeURI(window.queryString.name);
|
|
|
var napAdr = decodeURI(window.queryString.adr);
|
|
|
var mapIntro = decodeURI(window.queryString.intro);
|
|
|
var mapTel = decodeURI(window.queryString.tel);
|
|
|
var mapJD = decodeURI(window.queryString.jd);
|
|
|
var mapWD = decodeURI(window.queryString.wd);
|
|
|
|
|
|
// 百度地图API功能
|
|
|
var map = new BMap.Map('map');
|
|
|
var point = new BMap.Point(mapJD, mapWD); // 坐标点
|
|
|
map.centerAndZoom(point, 100); // 缩放比例
|
|
|
map.enableScrollWheelZoom();
|
|
|
var content = '<div style="margin:0;line-height:20px;padding:2px;font-size:12px;">' +
|
|
|
'<img src="' + mapPic + '" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' +
|
|
|
'地址:' + napAdr + '<br/>电话:' + mapTel + '<br/>简介:' + mapIntro +
|
|
|
'</div>';
|
|
|
function formatDate(time) {
|
|
|
var week = new Array('周一', '周二', '周三', '周四', '周五', '周六', '周日');
|
|
|
var time = new Date(time);
|
|
|
var year = time.getYear();
|
|
|
var month = time.getMonth() + 1;
|
|
|
var date = time.getDate();
|
|
|
var day = time.getDay();
|
|
|
var hour = time.getHours();
|
|
|
var minutes = time.getMinutes();
|
|
|
|
|
|
// 创建检索信息窗口对象
|
|
|
var searchInfoWindow = null;
|
|
|
searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
|
|
|
title: mapName, // 标题
|
|
|
width: 290, // 宽度
|
|
|
height: 105, // 高度
|
|
|
panel: 'panel', // 检索结果面板
|
|
|
enableAutoPan: true, // 自动平移
|
|
|
searchTypes:[
|
|
|
// BMAPLIB_TAB_SEARCH, // 周边检索
|
|
|
BMAPLIB_TAB_TO_HERE, // 到这里去
|
|
|
// BMAPLIB_TAB_FROM_HERE // 从这里出发
|
|
|
]
|
|
|
});
|
|
|
var marker = new BMap.Marker(point); // 创建marker对象
|
|
|
marker.enableDragging(); // marker可拖拽
|
|
|
marker.addEventListener('click', function(e){
|
|
|
searchInfoWindow.open(marker);
|
|
|
})
|
|
|
map.addOverlay(marker); // 在地图中添加marker
|
|
|
var label = new BMap.Label(mapName, {offset:new BMap.Size(30, -20)});
|
|
|
marker.setLabel(label);
|
|
|
var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT});// 左上角,添加比例尺
|
|
|
map.addControl(top_left_control);
|
|
|
var ctrl_nav = new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_LARGE});
|
|
|
map.addControl(ctrl_nav);
|
|
|
if (year < 1900) {
|
|
|
year = year + 1900;
|
|
|
}
|
|
|
|
|
|
// 批量设置isFront参数
|
|
|
if (window.queryString.isFront) {
|
|
|
window.setCookie('isFront', window.queryString.isFront);
|
|
|
} else {
|
|
|
window.setCookie('isFront', '1');
|
|
|
if (month < 10) {
|
|
|
month = '0' + month;
|
|
|
}
|
|
|
|
|
|
if ($('.travel').length > 0) {
|
|
|
window.setCookie('travelType', '3');
|
|
|
if (date < 10) {
|
|
|
date = '0' + date;
|
|
|
}
|
|
|
|
|
|
// 风格详情页图片点击放大
|
|
|
$('.pull-pic-list').on('click', function() {
|
|
|
var w_height = $(window).height();
|
|
|
$('.big-pic').show();
|
|
|
$('.swiper-slide img').each(
|
|
|
function() {
|
|
|
if ($(this).height() > w_height) {
|
|
|
$(this).css('height', '90%');
|
|
|
$(this).css('width', 'auto');
|
|
|
var newTop = (w_height - $(this).height()) / 2;
|
|
|
$(this).css('margin-top', newTop + 'px');
|
|
|
} else {
|
|
|
var newTop = (w_height - $(this).height()) / 2;
|
|
|
$(this).css('margin-top', newTop + 'px');
|
|
|
if (hour < 10) {
|
|
|
hour = '0' + hour;
|
|
|
}
|
|
|
if (minutes < 10) {
|
|
|
minutes = '0' + minutes;
|
|
|
}
|
|
|
);
|
|
|
$('.swiper-slide').on('click', function() {
|
|
|
$('.big-pic').hide();
|
|
|
});
|
|
|
});
|
|
|
return year + '年' + month + '月' + date + '日' + ' ' + week[day-1] + ' ' + hour + ':' + minutes;
|
|
|
}
|
|
|
|
|
|
// 瀑布流
|
|
|
if ($('.pull-pic-list').length > 0) {
|
|
|
setTimeout(function() {
|
|
|
var box = $('.pull-pic-list .box');
|
|
|
var boxWidth = box.eq(0).width();
|
|
|
var num = 2;
|
|
|
var boxArr = [];
|
|
|
var maxHeight = 0;
|
|
|
box.each(function(index, value) {
|
|
|
var boxHeight = box.eq(index).height();
|
|
|
if (index < num) {
|
|
|
boxArr[index] = boxHeight;
|
|
|
} else {
|
|
|
var minBoxHeight = Math.min.apply(null, boxArr);
|
|
|
var minBoxIndex = $.inArray(minBoxHeight, boxArr);
|
|
|
$(value).css({
|
|
|
'position': 'absolute',
|
|
|
'top': minBoxHeight,
|
|
|
'left': box.eq(minBoxIndex).position().left
|
|
|
});
|
|
|
boxArr[minBoxIndex] += box.eq(index).height();
|
|
|
var newHeight = $(this).position().top + box.eq(index).height();
|
|
|
if (newHeight > maxHeight) {
|
|
|
maxHeight = newHeight;
|
|
|
}
|
|
|
$('.pull-pic-list').css('height', maxHeight + 'px');
|
|
|
function autoScroll(thisPo) {
|
|
|
$navUl.find('.nav-item:eq(' + thisPo + ')').addClass('active').siblings('li').removeClass('active');
|
|
|
if (thisPo >= 2) {
|
|
|
|
|
|
// 倒数三个不触发效果
|
|
|
if ((sNum - thisPo) >= 3) {
|
|
|
myScroll.scrollTo((0 - (thisPo - 2) * sWidth), 0, 400);
|
|
|
}
|
|
|
});
|
|
|
}, 500);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($('.adviser-info').length > 0) {
|
|
|
window.setCookie('adviserId', window.queryString.id);
|
|
|
var swiper = new Swiper('.swiper-container', {
|
|
|
pagination: '.swiper-pagination',
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
paginationClickable: true,
|
|
|
|
|
|
// loop: true,
|
|
|
autoplay: 3000,
|
|
|
slidesPerView: 'auto',
|
|
|
centeredSlides: true,
|
|
|
observer: true,
|
|
|
observeParents: true,
|
|
|
paginationBulletRender: function(index, className) {
|
|
|
return '<span class="' + className + '">' + (index + 1) + '</span>';
|
|
|
}
|
|
|
if (window.cookie('limitPerson')) {
|
|
|
$('#num').attr('max', window.cookie('limitPerson'));
|
|
|
});
|
|
|
|
|
|
function getTimeList() {
|
|
|
var $date = $('.nav-ul').find('.active').attr('data');
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/getTimeList',
|
|
|
data: {
|
|
|
dateTime: $date,
|
|
|
storeId: window.queryString.storeId,
|
|
|
appointType: window.queryString.typeStatus || window.cookie('travelType'),
|
|
|
activityId: window.queryString.activityId || window.queryString.id || '',
|
|
|
travelId: window.cookie('travelId'),
|
|
|
userId: window.queryString.id
|
|
|
},
|
|
|
success: function(result) {
|
|
|
var timeList = '';
|
|
|
var timeStr = '';
|
|
|
|
|
|
$('.time-list').empty();
|
|
|
$('.date-list').empty();
|
|
|
if ($('.chosen-time').length > 0) {
|
|
|
window.setCookie('limitPerson', result.appointNum);
|
|
|
}
|
|
|
if ($('#num').attr('max') === '1') {
|
|
|
$('#num').next('.plus-btn').addClass('opacity');
|
|
|
for (var i = 0; i < result.getTimeList.length; i++) {
|
|
|
var useClass = 'use';
|
|
|
|
|
|
if (result.getTimeList[i].use === 2) {
|
|
|
var useClass = 'disable';
|
|
|
}
|
|
|
// 选择套餐优先级最高,改变套餐,其他选项要重新选择
|
|
|
$('.chosen-select .need').on('click', function() {
|
|
|
var $depend = $('.chosen-select').find('.depend');
|
|
|
var chosenAble = false;
|
|
|
$depend.each(
|
|
|
function() {
|
|
|
if ($(this).find('input').val() === '') {
|
|
|
var errText = $(this).closest('.depend').find('.label').text();
|
|
|
tip.show('请先选择' + errText);
|
|
|
chosenAble = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
chosenAble = true;
|
|
|
timeList = timeList + '<a date2="' + result.getTimeList[i].date2 + '" date="' + result.getTimeList[i].date + '" data="' + result.getTimeList[i].originTime + '" class="time-item ' + useClass + '">' + result.getTimeList[i].time + '</a>';
|
|
|
}
|
|
|
if ($('.time-list').length > 0) {
|
|
|
$('.time-list').append(timeList);
|
|
|
}
|
|
|
);
|
|
|
if (chosenAble) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
if ($('.date-list').length > 0) {
|
|
|
$('.date-list').append(timeList);
|
|
|
}
|
|
|
});
|
|
|
$('.time-list .time-item').on('click', function() {
|
|
|
if (!$(this).hasClass('disable')) {
|
|
|
$(this).addClass('chosen').siblings('.time-item').removeClass('chosen');
|
|
|
timeStr = $(this).attr('data');
|
|
|
window.setCookie('timeStr', timeStr);
|
|
|
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
} else {
|
|
|
if (!($('.chosen-style').val() && !$('.chosen-package').val())) {
|
|
|
clearCookieArr(1);
|
|
|
// 如果是从预约订单详情页过来
|
|
|
if (window.queryString.order == 'true') {
|
|
|
var detailtTimeStr = $(this).attr('date');
|
|
|
|
|
|
window.setCookie('detailtTimeStr', detailtTimeStr);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 限制文本框输入长度
|
|
|
$('#note').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
limitInp(obj, 200, true);
|
|
|
});
|
|
|
$('#name').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
limitInp(obj, 10, false);
|
|
|
});
|
|
|
$('#tel').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
limitInp(obj, 11, false);
|
|
|
});
|
|
|
$('#age').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
limitInp(obj, 2, false);
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('获取时间列表失败~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 默认勾选
|
|
|
if (window.queryString.chosenType === '4') {
|
|
|
$('.package-item').each(
|
|
|
function() {
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenPackage')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '3') {
|
|
|
$('.item').each(
|
|
|
function() {
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenAdviser')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '1') {
|
|
|
$('.style-ul:eq(0) li').each(
|
|
|
function() {
|
|
|
if (window.cookie('chosenStyle').indexOf($(this).text()) > -1) {
|
|
|
$(this).addClass('chosen');
|
|
|
styleNow ++;
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '5') {
|
|
|
$('.cutter-item').each(
|
|
|
function() {
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenCutter')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '2') {
|
|
|
var autoIndex = 0;
|
|
|
$('.nav-item').each(
|
|
|
function() {
|
|
|
if ($(this).find('p:first').text()) {
|
|
|
if (window.cookie('chosenTime').indexOf($(this).find('p:first').text()) > -1) {
|
|
|
autoIndex = $(this).index();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
setTimeout(function() {
|
|
|
$('.nav-ul .nav-item:eq(' + autoIndex + ')').click();
|
|
|
setTimeout(function() {
|
|
|
$('.time-item').each(
|
|
|
function() {
|
|
|
if (window.cookie('chosenTime').indexOf($(this).text()) > -1) {
|
|
|
$(this).addClass('chosen');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}, 100);
|
|
|
}, 100);
|
|
|
}
|
|
|
function orderSubmit() {
|
|
|
var type = 1;
|
|
|
var storeId = window.queryString.storeId;
|
|
|
var appointTime = parseInt(window.cookie('timeStr'));
|
|
|
var appointUserName = $('#name').val();
|
|
|
var appointMobile = parseInt($('#tel').val());
|
|
|
var uid = parseInt($('#uid').val());
|
|
|
var activityId = window.cookie('packageId') || window.cookie('adviserId') || window.cookie('travelId');
|
|
|
var userNote = $('#note').val();
|
|
|
var appointPersonNum = parseInt($('#num').val());
|
|
|
var age = parseInt($('#age').val()) || '';
|
|
|
var ageType = $('#age').parents('.chose-item').find('input:checked').next('label').text();
|
|
|
var styles = window.cookie('styleStr');
|
|
|
var sex = $('input[name=sex]:checked').next('label').attr('name') || '';
|
|
|
var appointContent = '{"name":"' + appointUserName + '","age":"' + age + ageType + '","sex":"' + sex + '","mobile":' + appointMobile + ',"num":' + appointPersonNum + ',"remark":"' + userNote + '"}';
|
|
|
|
|
|
// 发型师的套餐详情页
|
|
|
if (($('.package-detail').length > 0) && window.queryString.type === 'cutter') {
|
|
|
$('.foot-btn').attr('href', '//m.yohobuy.com/activity/trend/appointment?storeId=66&typeStatus=5')
|
|
|
if (!window.cookie('packageId') && !window.cookie('adviserId')) {
|
|
|
type = 2;
|
|
|
}
|
|
|
userNote = userNote.replace(/[\r\n]/g, ' ');
|
|
|
if (userNote === '添加备注(选填)') {
|
|
|
userNote = '';
|
|
|
}
|
|
|
|
|
|
// 将表单数据存入cookie
|
|
|
if ($('#detail-time').length > 0 && window.cookie('detailtTimeStr')) {
|
|
|
$('#detail-time').html(window.cookie('detailtTimeStr'));
|
|
|
|
|
|
// 修改预约时间
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/changeDate',
|
|
|
url: '/activity/trend/addOrder',
|
|
|
data: {
|
|
|
id: $('.chan-btn').attr('id'),
|
|
|
appointTimeStr: window.cookie('detailtTimeStr')
|
|
|
storeId: storeId,
|
|
|
appointTime: appointTime,
|
|
|
appointUserName: appointUserName,
|
|
|
appointMobile: appointMobile,
|
|
|
uid: uid,
|
|
|
activityId: activityId,
|
|
|
appointContent: appointContent,
|
|
|
userNote: userNote,
|
|
|
appointPersonNum: appointPersonNum,
|
|
|
styles: styles,
|
|
|
type: type
|
|
|
},
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
window.setCookie('detailtTimeStr', '');
|
|
|
window.location.href = window.location.href;
|
|
|
// tip.show('修改成功');
|
|
|
document.location.href = '//m.yohobuy.com/activity/trend/success?storeId=' + window.queryString.storeId + '&typeStatus=' + window.queryString.typeStatus;
|
|
|
} else {
|
|
|
// tip.show(result.message);
|
|
|
tip.show(result.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($('.chosen-select').length > 0) {
|
|
|
$('.chosen-package').val(window.cookie('chosenPackage'));
|
|
|
$('.chosen-style').val(window.cookie('chosenStyle'));
|
|
|
$('.chosen-style').attr('id', window.cookie('styleId'));
|
|
|
function diaHide() {
|
|
|
$('#dialog-wrapper').hide();
|
|
|
}
|
|
|
|
|
|
// 默认已勾选风格,根据后选套餐是否包含该风格,判断时候清空风格
|
|
|
if (window.cookie('packageStyle') && window.cookie('styleId')) {
|
|
|
var idArr = window.cookie('packageStyle').split(',');
|
|
|
var hasId = false;
|
|
|
for (var i = 0; i < idArr.length; i++) {
|
|
|
if (idArr[i] === $('.chosen-style').attr('id')) {
|
|
|
hasId = true;
|
|
|
|
|
|
function removeByValue(arr, val) {
|
|
|
for (var i=0; i<arr.length; i++) {
|
|
|
if (arr[i] == val) {
|
|
|
arr.splice(i, 1);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!hasId) {
|
|
|
$('.chosen-style').val('');
|
|
|
clearCookieArr(1);
|
|
|
}
|
|
|
window.setCookie('styleId', '');
|
|
|
}
|
|
|
|
|
|
function checkSubmit() {
|
|
|
var needNnow = $('.need-know').find('input:checked').length;
|
|
|
|
|
|
if (needNnow > 0) {
|
|
|
var $require = $('.require');
|
|
|
var checkSubmit = false;
|
|
|
|
|
|
$require.each(
|
|
|
function() {
|
|
|
if ($(this).val() === '') {
|
|
|
var errText = $(this).attr('label');
|
|
|
|
|
|
tip.show('请输入' + errText);
|
|
|
checkSubmit = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
var thisId = $(this).attr('id');
|
|
|
|
|
|
switch (thisId) {
|
|
|
case 'name' :
|
|
|
var reg = /^[\u4e00-\u9fa5]{1,10}$/;
|
|
|
var val = $(this).val();
|
|
|
|
|
|
if (!reg.test(val)) {
|
|
|
tip.show('姓名请输入10个以内汉字');
|
|
|
checkSubmit = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
checkSubmit = true;
|
|
|
}
|
|
|
$('.chosen-time').val(window.cookie('chosenTime'));
|
|
|
$('.chosen-cutter').val(window.cookie('chosenCutter'));
|
|
|
$('.chosen-adviser').val(window.cookie('chosenAdviser'));
|
|
|
$('.chosen-class').val(window.cookie('chosenClass'));
|
|
|
if (window.cookie('chosenClass')) {
|
|
|
var timeResult = getAbleTime();
|
|
|
if (timeResult.data) {
|
|
|
$('.chosen-time').val(_formatDay(new Date(timeResult.data * 1000))).addClass('disabled');
|
|
|
$('.chosen-time').parents('a').attr('href', 'javascript:void(0)');
|
|
|
window.setCookie('timeStr', timeResult.data);
|
|
|
break;
|
|
|
case 'tel' :
|
|
|
var reg = /^1[34578]\d{9}$/;
|
|
|
var val = $(this).val();
|
|
|
|
|
|
if (!reg.test(val)) {
|
|
|
tip.show('手机号请输入11位数字');
|
|
|
checkSubmit = false;
|
|
|
} else {
|
|
|
checkSubmit = true;
|
|
|
}
|
|
|
return false;
|
|
|
break;
|
|
|
default:
|
|
|
checkSubmit = true;
|
|
|
}
|
|
|
if (!window.cookie('chosenCutter') && window.cookie('chosenPackage')) {
|
|
|
$('.chosen-cutter').val('不预约发型师');
|
|
|
}
|
|
|
if (!window.cookie('chosenAdviser') && window.cookie('chosenTime')) {
|
|
|
$('.chosen-adviser').val('不预约潮流顾问');
|
|
|
}
|
|
|
if ($('.chosen-adviser').val() === '不预约潮流顾问') {
|
|
|
window.setCookie('adviserId', '');
|
|
|
);
|
|
|
if (checkSubmit) {
|
|
|
submitDia();
|
|
|
}
|
|
|
if (($('.chosen-select .chose-item:eq(0)').find('input').val() !== '') && window.cookie('chosenTime')) {
|
|
|
$('.chosen-select .chose-item:eq(0)').addClass('depend');
|
|
|
$('.chosen-select .chose-item:eq(1)').addClass('need');
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
} else {
|
|
|
clearCookieArr(1);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
tip.show('请先接受上述条款');
|
|
|
}
|
|
|
$cookie = $('.chosen-info').find('.cookie');
|
|
|
$cookie2 = $('.chosen-info').find('.cookie2');
|
|
|
}
|
|
|
|
|
|
// 修改表单存储cookie
|
|
|
$('.chosen').on('click', function() {
|
|
|
setCookieArr();
|
|
|
});
|
|
|
$('.chosen .cookie').on('keyup', function() {
|
|
|
setCookieArr();
|
|
|
function submitDia() {
|
|
|
diaLog.showDialog({
|
|
|
hasHeader: '温馨提示',
|
|
|
dialogText: '1、如需取消预约,可在预约时间前3天取消预约;<br />2、未取消的预约请按时到店。如未及时到店,我们将按爽约进行处理,一年中有3次爽约行为,本年内就无法再参与本店活动了哦。',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
diaHide();
|
|
|
orderSubmit();
|
|
|
});
|
|
|
if ($('.chosen-info').find('.cookie').length > 0) {
|
|
|
if (window.cookie('cookieArr') !== undefined && (window.cookie('cookieArr'))) {
|
|
|
var getCookie = window.cookie('cookieArr').split(',');
|
|
|
var inpNum = 0;
|
|
|
|
|
|
// 修改弹框样式
|
|
|
$('.tap-hightlight').css('color', '#007aff');
|
|
|
$('.dialog-content').css({'text-align': 'left', 'padding': '0 0.75rem 0.5rem'});
|
|
|
}
|
|
|
|
|
|
function setCookieArr() {
|
|
|
var cookieArr = new Array();
|
|
|
|
|
|
$cookie.each(
|
|
|
function() {
|
|
|
$(this).val(getCookie[inpNum]);
|
|
|
inpNum ++;
|
|
|
cookieArr.push($(this).val());
|
|
|
}
|
|
|
);
|
|
|
window.setCookie('cookieArr', cookieArr);
|
|
|
}
|
|
|
|
|
|
// 限制输入长度
|
|
|
function limitInp(obj, limit, show) {
|
|
|
var textLen = obj.val();
|
|
|
|
|
|
if (textLen.length > limit) {
|
|
|
if (show) {
|
|
|
tip.show('最多输入' + limit + '字');
|
|
|
}
|
|
|
textLen = textLen.substring(0, limit);
|
|
|
obj.val(textLen);
|
|
|
return false;
|
|
|
}
|
|
|
$('.cookie2').on('click', function() {
|
|
|
var radioIndex = $(this).index() === 2 ? 0 : 1;
|
|
|
window.setCookie('radio' + $(this).attr('name'), radioIndex);
|
|
|
});
|
|
|
if ($('.chosen-info').find('.cookie2').length > 0) {
|
|
|
$('.chose-item').find('.cookie2[name=sex]:eq(' + window.cookie('radiosex') + ')').attr('checked', 'checked');
|
|
|
$('.chose-item').find('.cookie2[name=birth]:eq(' + window.cookie('radiobirth') + ')').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($('.clearCookie').length > 0) {
|
|
|
clearCookieArr(3);
|
|
|
}
|
|
|
function getAbleTime() {
|
|
|
var timeResult = '';
|
|
|
|
|
|
if ($('.textarea textarea').val() === '添加备注(选填)') {
|
|
|
$('.textarea textarea').addClass('disabled');
|
|
|
$('.textarea textarea').on('focus', function() {
|
|
|
$(this).val('').removeClass('disabled');
|
|
|
});
|
|
|
};
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/getAbleTime',
|
|
|
data: {
|
|
|
activityType: window.queryString.typeStatus,
|
|
|
activityId: window.queryString.activityId || window.cookie('packageId') || window.cookie('travelId')
|
|
|
},
|
|
|
async: false,
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
timeResult = result;
|
|
|
} else {
|
|
|
|
|
|
// 默认选中菜单
|
|
|
if ($('.class-detail').length > 0) {
|
|
|
window.setCookie('chosenClass', $('.class-detail').find('.name').text());
|
|
|
window.setCookie('packageId', $('.class-detail').find('.name').attr('id'));
|
|
|
}
|
|
|
if ($('.adviser-info').find('.name').length > 0) {
|
|
|
window.setCookie('chosenCutter', $('.adviser-info').find('.name').text());
|
|
|
window.setCookie('chosenAdviser', $('.adviser-info').find('.name').text());
|
|
|
}
|
|
|
if ($('.style-detail').length > 0) {
|
|
|
window.setCookie('styleId', window.queryString.id);
|
|
|
window.setCookie('chosenStyle', ' ' + decodeURI(window.queryString.styleName) + ' ');
|
|
|
// tip.show(result.message);
|
|
|
}
|
|
|
if ($('.package-detail').length > 0) {
|
|
|
window.setCookie('chosenPackage', $('.package-detail').find('.name').text());
|
|
|
window.setCookie('packageLimit', $('.package-detail').find('.limit').val());
|
|
|
window.setCookie('packageStyle', $('.package-detail').find('.styleid').val());
|
|
|
window.setCookie('packageId', window.queryString.id);
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
return timeResult;
|
|
|
}
|
|
|
|
|
|
// 立即预约按钮
|
|
|
$('.chosen-btn').on('click', function() {
|
|
|
var $checkedItem = $(this).siblings('.side-main').find('input:checked');
|
|
|
var $chosenItem = $(this).siblings('.side-main').find('.chosen');
|
|
|
var checkedNum = $checkedItem.length;
|
|
|
var chosenNum = $chosenItem.length;
|
|
|
var chosenType = window.queryString.chosenType;
|
|
|
var tipMsg = '';
|
|
|
if ((checkedNum <= 0) && (chosenNum <= 0)) {
|
|
|
switch (chosenType) {
|
|
|
case '1' : tipMsg = '风格';
|
|
|
break;
|
|
|
case '2' : tipMsg = '时间';
|
|
|
break;
|
|
|
case '3' : tipMsg = '潮流顾问';
|
|
|
function _formatDay(day) {
|
|
|
return moment(day).format('MM月DD日 HH:mm');
|
|
|
}
|
|
|
|
|
|
// 清除cookie
|
|
|
function clearCookieArr(type) {
|
|
|
switch (type) {
|
|
|
case 1 :
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
break;
|
|
|
case '4' : tipMsg = '套餐';
|
|
|
case 2 :
|
|
|
window.setCookie('chosenPackage', '');
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
break;
|
|
|
case '5' : tipMsg = '发型师';
|
|
|
case 3 :
|
|
|
window.setCookie('chosenPackage', '');
|
|
|
window.setCookie('packageId', '');
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
window.setCookie('chosenAdviser', '');
|
|
|
window.setCookie('adviserId', '');
|
|
|
window.setCookie('chosenCutter', '');
|
|
|
window.setCookie('iscutter', '');
|
|
|
window.setCookie('styleStr', '');
|
|
|
window.setCookie('timeStr', '');
|
|
|
window.setCookie('detailtTimeStr', '');
|
|
|
window.setCookie('radiobirth', '');
|
|
|
window.setCookie('radiosex', '');
|
|
|
window.setCookie('cookieArr', '');
|
|
|
window.setCookie('limitPerson', '');
|
|
|
window.setCookie('packageLimit', '');
|
|
|
window.setCookie('packageStyle', '');
|
|
|
window.setCookie('chosenClass', '');
|
|
|
window.setCookie('styleId', '');
|
|
|
break;
|
|
|
}
|
|
|
tip.show('请选择' + tipMsg);
|
|
|
} else {
|
|
|
var chosenText = $checkedItem.attr('data') || $chosenItem.text();
|
|
|
var chosenText2 = $chosenItem.attr('date2');
|
|
|
var packageId = $checkedItem.attr('id');
|
|
|
switch (chosenType) {
|
|
|
case '4' :
|
|
|
window.setCookie('chosenPackage', chosenText);
|
|
|
window.setCookie('packageId', packageId);
|
|
|
window.setCookie('packageLimit', $checkedItem.attr('limit'));
|
|
|
window.setCookie('packageStyle', $checkedItem.attr('styleid'));
|
|
|
break;
|
|
|
case '1' :
|
|
|
window.setCookie('chosenStyle', chosenText);
|
|
|
break;
|
|
|
case '2' :
|
|
|
window.setCookie('chosenTime', chosenText2);
|
|
|
break;
|
|
|
case '3' :
|
|
|
window.setCookie('chosenAdviser', chosenText);
|
|
|
window.setCookie('adviserId', packageId);
|
|
|
break;
|
|
|
case '5' :
|
|
|
window.setCookie('chosenCutter', chosenText);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$(
|
|
|
function() {
|
|
|
|
|
|
// 地图初始化
|
|
|
if ($('#map').length > 0) {
|
|
|
var w_height = $(window).height();
|
|
|
var h_height = $('.yoho-header').height();
|
|
|
|
|
|
$('#map').css('height', (w_height - h_height) + 'px');
|
|
|
var mapPic = decodeURI(window.queryString.pic);
|
|
|
var mapName = decodeURI(window.queryString.name);
|
|
|
var napAdr = decodeURI(window.queryString.adr);
|
|
|
var mapIntro = decodeURI(window.queryString.intro);
|
|
|
var mapTel = decodeURI(window.queryString.tel);
|
|
|
var mapJD = decodeURI(window.queryString.jd);
|
|
|
var mapWD = decodeURI(window.queryString.wd);
|
|
|
var map = new BMap.Map('map');
|
|
|
var point = new BMap.Point(mapJD, mapWD); // 坐标点
|
|
|
var searchInfoWindow = null;
|
|
|
var content = '<div style="margin:0;line-height:20px;padding:2px;font-size:12px;">' +
|
|
|
'<img src="' + mapPic + '" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' +
|
|
|
'地址:' + napAdr + '<br/>电话:' + mapTel + '<br/>简介:' + mapIntro +
|
|
|
'</div>';
|
|
|
var marker = new BMap.Marker(point); // 创建marker对象
|
|
|
var label = new BMap.Label(mapName, {offset: new BMap.Size(30, -20)});
|
|
|
var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT});// 左上角,添加比例尺
|
|
|
var ctrl_nav = new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_LARGE});
|
|
|
|
|
|
// 百度地图API功能
|
|
|
map.centerAndZoom(point, 15); // 缩放比例
|
|
|
map.enableScrollWheelZoom();
|
|
|
|
|
|
// 创建检索信息窗口对象
|
|
|
searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
|
|
|
title: mapName, // 标题
|
|
|
width: 290, // 宽度
|
|
|
height: 105, // 高度
|
|
|
panel: 'panel', // 检索结果面板
|
|
|
enableAutoPan: true, // 自动平移
|
|
|
searchTypes: [
|
|
|
|
|
|
// BMAPLIB_TAB_SEARCH, // 周边检索
|
|
|
BMAPLIB_TAB_TO_HERE, // 到这里去
|
|
|
|
|
|
// BMAPLIB_TAB_FROM_HERE // 从这里出发
|
|
|
]
|
|
|
});
|
|
|
marker.enableDragging(); // marker可拖拽
|
|
|
marker.addEventListener('click', function(e) {
|
|
|
searchInfoWindow.open(marker);
|
|
|
});
|
|
|
map.addOverlay(marker); // 在地图中添加marker
|
|
|
marker.setLabel(label);
|
|
|
map.addControl(top_left_control);
|
|
|
map.addControl(ctrl_nav);
|
|
|
}
|
|
|
document.location.href = document.referrer;
|
|
|
|
|
|
// 批量设置isFront参数
|
|
|
if (window.queryString.isFront) {
|
|
|
window.setCookie('isFront', window.queryString.isFront);
|
|
|
} else {
|
|
|
window.setCookie('isFront', '1');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 取消订单
|
|
|
$('.order-btn a').on('click', function() {
|
|
|
diaLog.showDialog({
|
|
|
dialogText: '确认取消预约吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '我再想想',
|
|
|
rightBtnText: '确认取消'
|
|
|
if ($('.travel').length > 0) {
|
|
|
window.setCookie('travelType', '3');
|
|
|
}
|
|
|
},function() {
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/delOrder',
|
|
|
data: {
|
|
|
id: $('.order-btn a').attr('id')
|
|
|
},
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
document.location.href = '//m.yohobuy.com/activity/trend/order-list?storeId=' + window.queryString.storeId;
|
|
|
|
|
|
// 风格详情页图片点击放大
|
|
|
$('.pull-pic-list').on('click', function() {
|
|
|
var w_height = $(window).height();
|
|
|
|
|
|
$('.big-pic').show();
|
|
|
$('.swiper-slide img').each(
|
|
|
function() {
|
|
|
if ($(this).height() > w_height) {
|
|
|
$(this).css('height', '90%');
|
|
|
$(this).css('width', 'auto');
|
|
|
var newTop = (w_height - $(this).height()) / 2;
|
|
|
|
|
|
$(this).css('margin-top', newTop + 'px');
|
|
|
} else {
|
|
|
tip.show(result.message);
|
|
|
var newTop = (w_height - $(this).height()) / 2;
|
|
|
|
|
|
$(this).css('margin-top', newTop + 'px');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
);
|
|
|
$('.swiper-slide').on('click', function() {
|
|
|
$('.big-pic').hide();
|
|
|
});
|
|
|
});
|
|
|
// 修改弹框样式
|
|
|
$('.dialog-left-btn').css('color', '#999');
|
|
|
$('.dialog-right-btn').css('color', '#007aff');
|
|
|
});
|
|
|
|
|
|
// 加减人数按钮
|
|
|
$num.find('.plus-btn').on('click', function() {
|
|
|
if (!$('.chosen-time').val()) {
|
|
|
tip.show('请先选择预约时间');
|
|
|
// 瀑布流
|
|
|
if ($('.pull-pic-list').length > 0) {
|
|
|
setTimeout(function() {
|
|
|
var box = $('.pull-pic-list .box');
|
|
|
var boxWidth = box.eq(0).width();
|
|
|
var num = 2;
|
|
|
var boxArr = [];
|
|
|
var maxHeight = 0;
|
|
|
|
|
|
box.each(function(index, value) {
|
|
|
var boxHeight = box.eq(index).height();
|
|
|
|
|
|
if (index < num) {
|
|
|
boxArr[index] = boxHeight;
|
|
|
} else {
|
|
|
var limitNum = parseInt($num.find('input').attr('max'));
|
|
|
if (parseInt($num.find('input').val()) < limitNum) {
|
|
|
num = parseInt($num.find('input').val()) + 1;
|
|
|
$num.find('input').val(num);
|
|
|
var minBoxHeight = Math.min.apply(null, boxArr);
|
|
|
var minBoxIndex = $.inArray(minBoxHeight, boxArr);
|
|
|
|
|
|
$(value).css({
|
|
|
'position': 'absolute',
|
|
|
'top': minBoxHeight,
|
|
|
'left': box.eq(minBoxIndex).position().left
|
|
|
});
|
|
|
boxArr[minBoxIndex] += box.eq(index).height();
|
|
|
var newHeight = $(this).position().top + box.eq(index).height();
|
|
|
|
|
|
if (newHeight > maxHeight) {
|
|
|
maxHeight = newHeight;
|
|
|
}
|
|
|
$('.pull-pic-list').css('height', maxHeight + 'px');
|
|
|
}
|
|
|
});
|
|
|
}, 500);
|
|
|
}
|
|
|
|
|
|
if ($('.adviser-info').length > 0) {
|
|
|
window.setCookie('adviserId', window.queryString.id);
|
|
|
}
|
|
|
if (window.cookie('limitPerson')) {
|
|
|
$('#num').attr('max', window.cookie('limitPerson'));
|
|
|
}
|
|
|
if ($('#num').attr('max') === '1') {
|
|
|
$('#num').next('.plus-btn').addClass('opacity');
|
|
|
}
|
|
|
|
|
|
// 选择套餐优先级最高,改变套餐,其他选项要重新选择
|
|
|
$('.chosen-select .need').on('click', function() {
|
|
|
var $depend = $('.chosen-select').find('.depend');
|
|
|
var chosenAble = false;
|
|
|
|
|
|
$depend.each(
|
|
|
function() {
|
|
|
if ($(this).find('input').val() === '') {
|
|
|
var errText = $(this).closest('.depend').find('.label').text();
|
|
|
|
|
|
tip.show('请先选择' + errText);
|
|
|
chosenAble = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
tip.show('可预约人数已达上限');
|
|
|
chosenAble = true;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
$num.find('.minus-btn').on('click', function() {
|
|
|
if (parseInt($num.find('input').val()) > 1) {
|
|
|
num = parseInt($num.find('input').val()) - 1;
|
|
|
$num.find('input').val(num);
|
|
|
);
|
|
|
if (chosenAble) {
|
|
|
return true;
|
|
|
} else {
|
|
|
tip.show('人数不能小于1');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
sNum = $navUl.find('.nav-item').length;
|
|
|
sWidth = $navUl.find('.nav-item').width();
|
|
|
$navUl.width(sNum * sWidth);
|
|
|
|
|
|
if ($('.wrapper').length > 0) {
|
|
|
myScroll = new IScroll('.wrapper', {
|
|
|
scrollX: true,
|
|
|
scrollY: false,
|
|
|
preventDefault: false,
|
|
|
});
|
|
|
|
|
|
// 通过拖拽选择时间段
|
|
|
myScroll.on('scrollStart', function() {
|
|
|
$navUl.addClass('srolling');
|
|
|
return false;
|
|
|
});
|
|
|
myScroll.on('scrollEnd', function() {
|
|
|
if ($navUl.hasClass('srolling')) {
|
|
|
$navUl.removeClass('srolling');
|
|
|
var thisPo = Math.ceil((0 - myScroll.x) / sWidth + 1.5);
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 通过点击选择时间段
|
|
|
$navUl.find('.nav-item').on('click', function() {
|
|
|
if (!$(this).hasClass('disable')) {
|
|
|
var thisPo = $(this).index();
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
} else {
|
|
|
if (!($('.chosen-style').val() && !$('.chosen-package').val())) {
|
|
|
clearCookieArr(1);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.open-right').on('click', function() {
|
|
|
openId = $(this).attr('open-data');
|
|
|
$("#" + openId).removeClass('back');
|
|
|
$("#" + openId).addClass('active');
|
|
|
// 限制文本框输入长度
|
|
|
$('#note').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
limitInp(obj, 200, true);
|
|
|
});
|
|
|
$('#name').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
$('.dia-tip').on('click', function() {
|
|
|
checkSubmit();
|
|
|
})
|
|
|
limitInp(obj, 10, false);
|
|
|
});
|
|
|
$('#tel').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
$('.tab .tab-top span').on('click', function() {
|
|
|
var $this = $(this);
|
|
|
$this.addClass('active').siblings('span').removeClass('active');
|
|
|
var tabIndex = $this.index();
|
|
|
$this.parents('.tab').find('.tab-item:eq(' + tabIndex + ')').show().siblings('.tab-item').hide();
|
|
|
limitInp(obj, 11, false);
|
|
|
});
|
|
|
$('#age').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
$('.tab-item:first').show();
|
|
|
limitInp(obj, 2, false);
|
|
|
});
|
|
|
|
|
|
// 选择风格
|
|
|
if ($('.style-ul').length > 0) {
|
|
|
styleTotal = window.cookie('packageLimit');
|
|
|
if (window.cookie('packageStyle')) {
|
|
|
$('.style-ul:eq(0) li').each(
|
|
|
// 默认勾选
|
|
|
if (window.queryString.chosenType === '4') {
|
|
|
$('.package-item').each(
|
|
|
function() {
|
|
|
var $totalId = $(this).attr('id');
|
|
|
var $packageStyle = window.cookie('packageStyle').split(',');
|
|
|
for (var i = 0; i < $packageStyle.length; i++) {
|
|
|
if ($totalId == $packageStyle[i]) {
|
|
|
$(this).removeClass('disabled');
|
|
|
}
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenPackage')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
$('.style-tip .total').text(styleTotal);
|
|
|
$('.style-tip .now').text(styleNow);
|
|
|
if (window.queryString.chosenType === '3') {
|
|
|
$('.item').each(
|
|
|
function() {
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenAdviser')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
|
|
|
var styleStr = new Array();
|
|
|
$('.style-ul li').on('click', function() {
|
|
|
$(this).parents('.style-ul').siblings('.style-ul').find('li').removeClass('chosen');
|
|
|
var $this = $(this);
|
|
|
var $thisId = $(this).attr('id');
|
|
|
if (!$this.hasClass('disabled')) {
|
|
|
if ($this.hasClass('chosen')) {
|
|
|
$this.removeClass('chosen');
|
|
|
if (!$this.hasClass('not')) {
|
|
|
removeByValue(styleStr, $thisId);
|
|
|
styleNow --;
|
|
|
} else {
|
|
|
styleStr = [];
|
|
|
styleNow = 0;
|
|
|
}
|
|
|
} else {
|
|
|
if (!$this.hasClass('not')) {
|
|
|
var limitNum = $('.total').text();
|
|
|
if (styleNow >= limitNum) {
|
|
|
tip.show('超过最大可选风格数');
|
|
|
return false;
|
|
|
);
|
|
|
}
|
|
|
$this.addClass('chosen');
|
|
|
styleStr.push($thisId);
|
|
|
if (window.queryString.chosenType === '1') {
|
|
|
$('.style-ul:eq(0) li').each(
|
|
|
function() {
|
|
|
if (window.cookie('chosenStyle').indexOf($(this).text()) > -1) {
|
|
|
$(this).addClass('chosen');
|
|
|
styleNow ++;
|
|
|
} else {
|
|
|
$this.addClass('chosen');
|
|
|
styleStr = [];
|
|
|
styleNow = 0;
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
$('.style-tip .now').text(styleNow);
|
|
|
window.setCookie('styleStr', styleStr);
|
|
|
});
|
|
|
|
|
|
if ($('.time-nav').length > 0) {
|
|
|
$('.time-nav ul').find('.nav-item:eq(2)').addClass('active');
|
|
|
getTimeList();
|
|
|
if (window.queryString.chosenType === '5') {
|
|
|
$('.cutter-item').each(
|
|
|
function() {
|
|
|
if ($(this).find('.name').text() === window.cookie('chosenCutter')) {
|
|
|
$(this).find('input').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '2') {
|
|
|
var autoIndex = 0;
|
|
|
|
|
|
if ($('.order-item').length > 0) {
|
|
|
$('.order-item').each(
|
|
|
$('.nav-item').each(
|
|
|
function() {
|
|
|
var time = $(this).find('.time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
$(this).find('.time').html(weekTime);
|
|
|
if ($(this).find('p:first').text()) {
|
|
|
if (window.cookie('chosenTime').indexOf($(this).find('p:first').text()) > -1) {
|
|
|
autoIndex = $(this).index();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
setTimeout(function() {
|
|
|
$('.nav-ul .nav-item:eq(' + autoIndex + ')').click();
|
|
|
setTimeout(function() {
|
|
|
$('.time-item').each(
|
|
|
function() {
|
|
|
if (window.cookie('chosenTime').indexOf($(this).text()) > -1) {
|
|
|
$(this).addClass('chosen');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
}, 100);
|
|
|
}, 100);
|
|
|
}
|
|
|
|
|
|
if ($('#detail-time').length > 0) {
|
|
|
var time = $('#detail-time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
$('#detail-time').html(weekTime);
|
|
|
// 发型师的套餐详情页
|
|
|
if (($('.package-detail').length > 0) && window.queryString.type === 'cutter') {
|
|
|
$('.foot-btn').attr('href', '//m.yohobuy.com/activity/trend/appointment?storeId=66&typeStatus=5');
|
|
|
}
|
|
|
|
|
|
// 将表单数据存入cookie
|
|
|
if ($('#detail-time').length > 0 && window.cookie('detailtTimeStr')) {
|
|
|
$('#detail-time').html(window.cookie('detailtTimeStr'));
|
|
|
|
|
|
// 修改预约时间
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/changeDate',
|
|
|
data: {
|
|
|
id: $('.chan-btn').attr('id'),
|
|
|
appointTimeStr: window.cookie('detailtTimeStr')
|
|
|
},
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
window.setCookie('detailtTimeStr', '');
|
|
|
window.location.href = window.location.href;
|
|
|
|
|
|
// tip.show('修改成功');
|
|
|
} else {
|
|
|
|
|
|
// tip.show(result.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($('.chosen-select').length > 0) {
|
|
|
$('.chosen-package').val(window.cookie('chosenPackage'));
|
|
|
$('.chosen-style').val(window.cookie('chosenStyle'));
|
|
|
$('.chosen-style').attr('id', window.cookie('styleId'));
|
|
|
|
|
|
// 默认已勾选风格,根据后选套餐是否包含该风格,判断时候清空风格
|
|
|
if (window.cookie('packageStyle') && window.cookie('styleId')) {
|
|
|
var idArr = window.cookie('packageStyle').split(',');
|
|
|
var hasId = false;
|
|
|
|
|
|
for (var i = 0; i < idArr.length; i++) {
|
|
|
if (idArr[i] === $('.chosen-style').attr('id')) {
|
|
|
hasId = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!hasId) {
|
|
|
$('.chosen-style').val('');
|
|
|
clearCookieArr(1);
|
|
|
}
|
|
|
window.setCookie('styleId', '');
|
|
|
}
|
|
|
$('.chosen-time').val(window.cookie('chosenTime'));
|
|
|
$('.chosen-cutter').val(window.cookie('chosenCutter'));
|
|
|
$('.chosen-adviser').val(window.cookie('chosenAdviser'));
|
|
|
$('.chosen-class').val(window.cookie('chosenClass'));
|
|
|
if (window.cookie('chosenClass')) {
|
|
|
var timeResult = getAbleTime();
|
|
|
if (timeResult.data === '') {
|
|
|
$('.chan-btn').show();
|
|
|
|
|
|
if (timeResult.data) {
|
|
|
$('.chosen-time').val(_formatDay(new Date(timeResult.data * 1000))).addClass('disabled');
|
|
|
$('.chosen-time').parents('a').attr('href', 'javascript:void(0)');
|
|
|
window.setCookie('timeStr', timeResult.data);
|
|
|
}
|
|
|
}
|
|
|
if (!window.cookie('chosenCutter') && window.cookie('chosenPackage')) {
|
|
|
$('.chosen-cutter').val('不预约发型师');
|
|
|
}
|
|
|
if (!window.cookie('chosenAdviser') && window.cookie('chosenTime')) {
|
|
|
$('.chosen-adviser').val('不预约潮流顾问');
|
|
|
}
|
|
|
if ($('.chosen-adviser').val() === '不预约潮流顾问') {
|
|
|
window.setCookie('adviserId', '');
|
|
|
}
|
|
|
if (($('.chosen-select .chose-item:eq(0)').find('input').val() !== '') && window.cookie('chosenTime')) {
|
|
|
$('.chosen-select .chose-item:eq(0)').addClass('depend');
|
|
|
$('.chosen-select .chose-item:eq(1)').addClass('need');
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
} else {
|
|
|
clearCookieArr(1);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
$cookie = $('.chosen-info').find('.cookie');
|
|
|
$cookie2 = $('.chosen-info').find('.cookie2');
|
|
|
|
|
|
function formatDate(time) {
|
|
|
var week = new Array('周一', '周二', '周三', '周四', '周五', '周六', '周日');
|
|
|
var time = new Date(time);
|
|
|
var year = time.getYear();
|
|
|
if (year < 1900) {
|
|
|
year = year + 1900;
|
|
|
}
|
|
|
var month = time.getMonth() + 1;
|
|
|
if (month < 10) {
|
|
|
month = '0' + month;
|
|
|
}
|
|
|
var date = time.getDate();
|
|
|
if (date < 10) {
|
|
|
date = '0' + date;
|
|
|
// 修改表单存储cookie
|
|
|
$('.chosen').on('click', function() {
|
|
|
setCookieArr();
|
|
|
});
|
|
|
$('.chosen .cookie').on('keyup', function() {
|
|
|
setCookieArr();
|
|
|
});
|
|
|
if ($('.chosen-info').find('.cookie').length > 0) {
|
|
|
if (window.cookie('cookieArr') !== undefined && (window.cookie('cookieArr'))) {
|
|
|
var getCookie = window.cookie('cookieArr').split(',');
|
|
|
var inpNum = 0;
|
|
|
|
|
|
$cookie.each(
|
|
|
function() {
|
|
|
$(this).val(getCookie[inpNum]);
|
|
|
inpNum++;
|
|
|
}
|
|
|
var day = time.getDay();
|
|
|
var hour = time.getHours();
|
|
|
if (hour < 10) {
|
|
|
hour = '0' + hour;
|
|
|
);
|
|
|
}
|
|
|
var minutes = time.getMinutes();
|
|
|
if (minutes < 10) {
|
|
|
minutes = '0' + minutes;
|
|
|
}
|
|
|
return year + '年' + month + '月' + date + '日' + ' ' + week[day-1] + ' ' + hour + ':' + minutes;
|
|
|
}
|
|
|
$cookie2.on('click', function() {
|
|
|
var radioIndex = $(this).index() === 2 ? 0 : 1;
|
|
|
|
|
|
function autoScroll (thisPo) {
|
|
|
$navUl.find('.nav-item:eq(' + thisPo + ')').addClass('active').siblings('li').removeClass('active');
|
|
|
if (thisPo >= 2) {
|
|
|
// 倒数三个不触发效果
|
|
|
if ((sNum - thisPo) >= 3) {
|
|
|
myScroll.scrollTo((0 - (thisPo - 2) * sWidth), 0, 400);
|
|
|
}
|
|
|
window.setCookie('radio' + $(this).attr('name'), radioIndex);
|
|
|
});
|
|
|
if ($('.chosen-info').find('.cookie2').length > 0) {
|
|
|
$('.chose-item').find('.cookie2[name=sex]:eq(' + window.cookie('radiosex') + ')').attr('checked', 'checked');
|
|
|
$('.chose-item').find('.cookie2[name=birth]:eq(' + window.cookie('radiobirth') + ')').attr('checked', 'checked');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var swiper = new Swiper('.swiper-container', {
|
|
|
pagination: '.swiper-pagination',
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
paginationClickable: true,
|
|
|
// loop: true,
|
|
|
autoplay: 3000,
|
|
|
slidesPerView: 'auto',
|
|
|
centeredSlides: true,
|
|
|
observer: true,
|
|
|
observeParents: true,
|
|
|
paginationBulletRender: function(index, className) {
|
|
|
return '<span class="' + className + '">' + (index + 1) + '</span>';
|
|
|
if ($('.clearCookie').length > 0) {
|
|
|
clearCookieArr(3);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function getTimeList() {
|
|
|
var $date = $('.nav-ul').find('.active').attr('data');
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/getTimeList',
|
|
|
data: {
|
|
|
dateTime: $date,
|
|
|
storeId: window.queryString.storeId,
|
|
|
appointType: window.queryString.typeStatus || window.cookie('travelType'),
|
|
|
activityId: window.queryString.activityId || window.queryString.id || '',
|
|
|
travelId: window.cookie('travelId'),
|
|
|
userId: window.queryString.id
|
|
|
},
|
|
|
success: function(result) {
|
|
|
$('.time-list').empty();
|
|
|
$('.date-list').empty();
|
|
|
if ($('.chosen-time').length > 0) {
|
|
|
window.setCookie('limitPerson', result.appointNum);
|
|
|
if ($('.textarea textarea').val() === '添加备注(选填)') {
|
|
|
$('.textarea textarea').addClass('disabled');
|
|
|
}
|
|
|
let timeList = '';
|
|
|
for (var i = 0;i < result.getTimeList.length; i ++) {
|
|
|
var useClass = 'use';
|
|
|
if (result.getTimeList[i].use === 2) {
|
|
|
var useClass = 'disable';
|
|
|
$('.textarea textarea').on('focus', function() {
|
|
|
if ($('.textarea textarea').val() === '添加备注(选填)') {
|
|
|
$(this).val('').removeClass('disabled');
|
|
|
}
|
|
|
timeList = timeList + '<a date2="' + result.getTimeList[i].date2 + '" date="' + result.getTimeList[i].date + '" data="' + result.getTimeList[i].originTime + '" class="time-item ' + useClass + '">' + result.getTimeList[i].time + '</a>';
|
|
|
});
|
|
|
|
|
|
// 默认选中菜单
|
|
|
if ($('.class-detail').length > 0) {
|
|
|
window.setCookie('chosenClass', $('.class-detail').find('.name').text());
|
|
|
window.setCookie('packageId', $('.class-detail').find('.name').attr('id'));
|
|
|
}
|
|
|
if ($('.time-list').length > 0) {
|
|
|
$('.time-list').append(timeList);
|
|
|
if ($('.adviser-info').find('.name').length > 0) {
|
|
|
window.setCookie('chosenCutter', $('.adviser-info').find('.name').text());
|
|
|
window.setCookie('chosenAdviser', $('.adviser-info').find('.name').text());
|
|
|
}
|
|
|
if ($('.date-list').length > 0) {
|
|
|
$('.date-list').append(timeList);
|
|
|
if ($('.style-detail').length > 0) {
|
|
|
window.setCookie('styleId', window.queryString.id);
|
|
|
window.setCookie('chosenStyle', ' ' + decodeURI(window.queryString.styleName) + ' ');
|
|
|
}
|
|
|
var timeStr = '';
|
|
|
$('.time-list .time-item').on('click', function() {
|
|
|
if(!$(this).hasClass('disable')) {
|
|
|
$(this).addClass('chosen').siblings('.time-item').removeClass('chosen');
|
|
|
timeStr = $(this).attr('data');
|
|
|
window.setCookie('timeStr', timeStr);
|
|
|
// 如果是从预约订单详情页过来
|
|
|
if (window.queryString.order == 'true') {
|
|
|
var detailtTimeStr = $(this).attr("date");
|
|
|
window.setCookie('detailtTimeStr', detailtTimeStr);
|
|
|
if ($('.package-detail').length > 0) {
|
|
|
window.setCookie('chosenPackage', $('.package-detail').find('.name').text());
|
|
|
window.setCookie('packageLimit', $('.package-detail').find('.limit').val());
|
|
|
window.setCookie('packageStyle', $('.package-detail').find('.styleid').val());
|
|
|
window.setCookie('packageId', window.queryString.id);
|
|
|
}
|
|
|
|
|
|
// 立即预约按钮
|
|
|
$('.chosen-btn').on('click', function() {
|
|
|
var $checkedItem = $(this).siblings('.side-main').find('input:checked');
|
|
|
var $chosenItem = $(this).siblings('.side-main').find('.chosen');
|
|
|
var checkedNum = $checkedItem.length;
|
|
|
var chosenNum = $chosenItem.length;
|
|
|
var chosenType = window.queryString.chosenType;
|
|
|
var tipMsg = '';
|
|
|
|
|
|
if ((checkedNum <= 0) && (chosenNum <= 0)) {
|
|
|
switch (chosenType) {
|
|
|
case '1' : tipMsg = '风格';
|
|
|
break;
|
|
|
case '2' : tipMsg = '时间';
|
|
|
break;
|
|
|
case '3' : tipMsg = '潮流顾问';
|
|
|
break;
|
|
|
case '4' : tipMsg = '套餐';
|
|
|
break;
|
|
|
case '5' : tipMsg = '发型师';
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('获取时间列表失败~');
|
|
|
tip.show('请选择' + tipMsg);
|
|
|
} else {
|
|
|
var chosenText = $checkedItem.attr('data') || $chosenItem.text();
|
|
|
var chosenText2 = $chosenItem.attr('date2');
|
|
|
var packageId = $checkedItem.attr('id');
|
|
|
|
|
|
switch (chosenType) {
|
|
|
case '4' :
|
|
|
window.setCookie('chosenPackage', chosenText);
|
|
|
window.setCookie('packageId', packageId);
|
|
|
window.setCookie('packageLimit', $checkedItem.attr('limit'));
|
|
|
window.setCookie('packageStyle', $checkedItem.attr('styleid'));
|
|
|
break;
|
|
|
case '1' :
|
|
|
window.setCookie('chosenStyle', chosenText);
|
|
|
break;
|
|
|
case '2' :
|
|
|
window.setCookie('chosenTime', chosenText2);
|
|
|
break;
|
|
|
case '3' :
|
|
|
window.setCookie('chosenAdviser', chosenText);
|
|
|
window.setCookie('adviserId', packageId);
|
|
|
break;
|
|
|
case '5' :
|
|
|
window.setCookie('chosenCutter', chosenText);
|
|
|
break;
|
|
|
}
|
|
|
document.location.href = document.referrer;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function orderSubmit() {
|
|
|
var type = 1;
|
|
|
var storeId = window.queryString.storeId;
|
|
|
var appointTime = parseInt(window.cookie('timeStr'));
|
|
|
var appointUserName = $('#name').val();
|
|
|
var appointMobile = parseInt($('#tel').val());
|
|
|
var uid = parseInt($('#uid').val());
|
|
|
var activityId = window.cookie('packageId') || window.cookie('adviserId') || window.cookie('travelId');
|
|
|
if (!window.cookie('packageId') && !window.cookie('adviserId')) {
|
|
|
type = 2;
|
|
|
}
|
|
|
var userNote = $('#note').val();
|
|
|
userNote = userNote.replace(/[\r\n]/g, "");
|
|
|
if (userNote === '添加备注(选填)') {
|
|
|
userNote = '';
|
|
|
// 取消订单
|
|
|
$('.order-btn a').on('click', function() {
|
|
|
diaLog.showDialog({
|
|
|
dialogText: '确认取消预约吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '我再想想',
|
|
|
rightBtnText: '确认取消'
|
|
|
}
|
|
|
var appointPersonNum = parseInt($('#num').val());
|
|
|
var age = parseInt($('#age').val()) || '';
|
|
|
var ageType = $('#age').parents('.chose-item').find('input:checked').next('label').text();
|
|
|
var styles = window.cookie('styleStr');
|
|
|
var sex = $('input[name=sex]:checked').next('label').attr('name') || '';
|
|
|
var appointContent = '{"name":"' + appointUserName + '","age":"' + age + ageType + '","sex":"' + sex + '","mobile":' + appointMobile + ',"num":' + appointPersonNum + ',"remark":"' + userNote + '"}';
|
|
|
}, function() {
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/addOrder',
|
|
|
url: '/activity/trend/delOrder',
|
|
|
data: {
|
|
|
storeId: storeId,
|
|
|
appointTime: appointTime,
|
|
|
appointUserName: appointUserName,
|
|
|
appointMobile: appointMobile,
|
|
|
uid: uid,
|
|
|
activityId: activityId,
|
|
|
appointContent: appointContent,
|
|
|
userNote: userNote,
|
|
|
appointPersonNum: appointPersonNum,
|
|
|
styles: styles,
|
|
|
type: type
|
|
|
id: $('.order-btn a').attr('id')
|
|
|
},
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
document.location.href = '//m.yohobuy.com/activity/trend/success?storeId=' + window.queryString.storeId + '&typeStatus=' + window.queryString.typeStatus;
|
|
|
document.location.href = '//m.yohobuy.com/activity/trend/order-list?storeId=' + window.queryString.storeId;
|
|
|
} else {
|
|
|
tip.show(result.message);
|
|
|
}
|
...
|
...
|
@@ -807,172 +861,178 @@ function orderSubmit() { |
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 修改弹框样式
|
|
|
$('.dialog-left-btn').css('color', '#999');
|
|
|
$('.dialog-right-btn').css('color', '#007aff');
|
|
|
});
|
|
|
|
|
|
// 加减人数按钮
|
|
|
$num.find('.plus-btn').on('click', function() {
|
|
|
if (!$('.chosen-time').val()) {
|
|
|
tip.show('请先选择预约时间');
|
|
|
} else {
|
|
|
var limitNum = parseInt($num.find('input').attr('max'));
|
|
|
|
|
|
if (parseInt($num.find('input').val()) < limitNum) {
|
|
|
num = parseInt($num.find('input').val()) + 1;
|
|
|
$num.find('input').val(num);
|
|
|
} else {
|
|
|
tip.show('可预约人数已达上限');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
$num.find('.minus-btn').on('click', function() {
|
|
|
if (parseInt($num.find('input').val()) > 1) {
|
|
|
num = parseInt($num.find('input').val()) - 1;
|
|
|
$num.find('input').val(num);
|
|
|
} else {
|
|
|
tip.show('人数不能小于1');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function diaHide() {
|
|
|
$('#dialog-wrapper').hide();
|
|
|
}
|
|
|
sNum = $navUl.find('.nav-item').length;
|
|
|
sWidth = $navUl.find('.nav-item').width();
|
|
|
$navUl.width(sNum * sWidth);
|
|
|
|
|
|
if ($('.wrapper').length > 0) {
|
|
|
myScroll = new IScroll('.wrapper', {
|
|
|
scrollX: true,
|
|
|
scrollY: false,
|
|
|
preventDefault: false,
|
|
|
});
|
|
|
|
|
|
function removeByValue(arr, val) {
|
|
|
for (var i=0; i<arr.length; i++) {
|
|
|
if (arr[i] == val) {
|
|
|
arr.splice(i, 1);
|
|
|
break;
|
|
|
// 通过拖拽选择时间段
|
|
|
myScroll.on('scrollStart', function() {
|
|
|
$navUl.addClass('srolling');
|
|
|
return false;
|
|
|
});
|
|
|
myScroll.on('scrollEnd', function() {
|
|
|
if ($navUl.hasClass('srolling')) {
|
|
|
$navUl.removeClass('srolling');
|
|
|
var thisPo = Math.ceil((0 - myScroll.x) / sWidth + 1.5);
|
|
|
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function checkSubmit() {
|
|
|
var needNnow = $('.need-know').find('input:checked').length;
|
|
|
if (needNnow > 0) {
|
|
|
var $require = $('.require');
|
|
|
var checkSubmit = false;
|
|
|
$require.each(
|
|
|
function() {
|
|
|
if ($(this).val() === '') {
|
|
|
var errText = $(this).attr('label');
|
|
|
tip.show('请输入' + errText);
|
|
|
checkSubmit = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
var thisId = $(this).attr('id');
|
|
|
switch (thisId) {
|
|
|
case 'name' :
|
|
|
var reg = /^[\u4e00-\u9fa5]{1,10}$/;
|
|
|
var val = $(this).val();
|
|
|
if (!reg.test(val)) {
|
|
|
tip.show('姓名请输入10个以内汉字');
|
|
|
checkSubmit = false;
|
|
|
return false;
|
|
|
} else {
|
|
|
checkSubmit = true;
|
|
|
}
|
|
|
break;
|
|
|
case 'tel' :
|
|
|
var reg = /^1[34578]\d{9}$/;
|
|
|
var val = $(this).val();
|
|
|
if (!reg.test(val)) {
|
|
|
tip.show('手机号请输入11位数字');
|
|
|
checkSubmit = false;
|
|
|
} else {
|
|
|
checkSubmit = true;
|
|
|
// 通过点击选择时间段
|
|
|
$navUl.find('.nav-item').on('click', function() {
|
|
|
if (!$(this).hasClass('disable')) {
|
|
|
var thisPo = $(this).index();
|
|
|
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
}
|
|
|
return false;
|
|
|
break;
|
|
|
default:
|
|
|
checkSubmit = true;
|
|
|
});
|
|
|
|
|
|
$('.open-right').on('click', function() {
|
|
|
openId = $(this).attr('open-data');
|
|
|
$('#' + openId).removeClass('back');
|
|
|
$('#' + openId).addClass('active');
|
|
|
});
|
|
|
|
|
|
$('.dia-tip').on('click', function() {
|
|
|
checkSubmit();
|
|
|
});
|
|
|
|
|
|
$('.tab .tab-top span').on('click', function() {
|
|
|
var $this = $(this);
|
|
|
var tabIndex = $this.index();
|
|
|
|
|
|
$this.addClass('active').siblings('span').removeClass('active');
|
|
|
$this.parents('.tab').find('.tab-item:eq(' + tabIndex + ')').show().siblings('.tab-item').hide();
|
|
|
});
|
|
|
|
|
|
$('.tab-item:first').show();
|
|
|
|
|
|
// 选择风格
|
|
|
if ($('.style-ul').length > 0) {
|
|
|
styleTotal = window.cookie('packageLimit');
|
|
|
if (window.cookie('packageStyle')) {
|
|
|
$('.style-ul:eq(0) li').each(
|
|
|
function() {
|
|
|
var $totalId = $(this).attr('id');
|
|
|
var $packageStyle = window.cookie('packageStyle').split(',');
|
|
|
|
|
|
for (var i = 0; i < $packageStyle.length; i++) {
|
|
|
if ($totalId == $packageStyle[i]) {
|
|
|
$(this).removeClass('disabled');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
if (checkSubmit) {
|
|
|
submitDia();
|
|
|
}
|
|
|
} else {
|
|
|
tip.show('请先接受上述条款');
|
|
|
$('.style-tip .total').text(styleTotal);
|
|
|
$('.style-tip .now').text(styleNow);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function submitDia() {
|
|
|
diaLog.showDialog({
|
|
|
hasHeader: '温馨提示',
|
|
|
dialogText: '1、如需取消预约,可在预约时间前3天取消预约;<br />2、未取消的预约请按时到店。如未及时到店,我们将按爽约进行处理,一年中有3次爽约行为,本年内就无法再参与本店活动了哦。',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
diaHide();
|
|
|
orderSubmit();
|
|
|
});
|
|
|
// 修改弹框样式
|
|
|
$('.tap-hightlight').css('color', '#007aff');
|
|
|
$('.dialog-content').css({'text-align':'left', 'padding':'0 0.75rem 0.5rem'});
|
|
|
}
|
|
|
var styleStr = new Array();
|
|
|
$('.style-ul li').on('click', function() {
|
|
|
$(this).parents('.style-ul').siblings('.style-ul').find('li').removeClass('chosen');
|
|
|
var $this = $(this);
|
|
|
var $thisId = $(this).attr('id');
|
|
|
|
|
|
function setCookieArr() {
|
|
|
var cookieArr = new Array();
|
|
|
$cookie.each(
|
|
|
function() {
|
|
|
cookieArr.push($(this).val());
|
|
|
if (!$this.hasClass('disabled')) {
|
|
|
if ($this.hasClass('chosen')) {
|
|
|
$this.removeClass('chosen');
|
|
|
if (!$this.hasClass('not')) {
|
|
|
removeByValue(styleStr, $thisId);
|
|
|
styleNow--;
|
|
|
} else {
|
|
|
styleStr = [];
|
|
|
styleNow = 0;
|
|
|
}
|
|
|
);
|
|
|
window.setCookie('cookieArr', cookieArr);
|
|
|
}
|
|
|
} else {
|
|
|
if (!$this.hasClass('not')) {
|
|
|
var limitNum = $('.total').text();
|
|
|
|
|
|
// 限制输入长度
|
|
|
function limitInp (obj, limit, show) {
|
|
|
var textLen = obj.val();
|
|
|
if (textLen.length > limit) {
|
|
|
if (show) {
|
|
|
tip.show('最多输入' + limit + '字');
|
|
|
}
|
|
|
textLen = textLen.substring(0, limit);
|
|
|
obj.val(textLen);
|
|
|
if (styleNow >= limitNum) {
|
|
|
tip.show('超过最大可选风格数');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function getAbleTime() {
|
|
|
var timeResult = '';
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/getAbleTime',
|
|
|
data: {
|
|
|
activityType: window.queryString.typeStatus,
|
|
|
activityId: window.queryString.activityId || window.cookie('packageId') || window.cookie('travelId')
|
|
|
},
|
|
|
async: false,
|
|
|
success: function(result) {
|
|
|
if (result.code === 200) {
|
|
|
timeResult = result;
|
|
|
$this.addClass('chosen');
|
|
|
styleStr.push($thisId);
|
|
|
styleNow++;
|
|
|
} else {
|
|
|
// tip.show(result.message);
|
|
|
$this.addClass('chosen');
|
|
|
styleStr = [];
|
|
|
styleNow = 0;
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
}
|
|
|
$('.style-tip .now').text(styleNow);
|
|
|
window.setCookie('styleStr', styleStr);
|
|
|
});
|
|
|
return timeResult;
|
|
|
}
|
|
|
|
|
|
function _formatDay(day) {
|
|
|
return moment(day).format('MM月DD日 HH:mm');
|
|
|
};
|
|
|
if ($('.time-nav').length > 0) {
|
|
|
$('.time-nav ul').find('.nav-item:eq(2)').addClass('active');
|
|
|
getTimeList();
|
|
|
}
|
|
|
|
|
|
// 清除cookie
|
|
|
function clearCookieArr (type) {
|
|
|
switch (type) {
|
|
|
case 1 :
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
break;
|
|
|
case 2 :
|
|
|
window.setCookie('chosenPackage', '');
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
break;
|
|
|
case 3 :
|
|
|
window.setCookie('chosenPackage', '');
|
|
|
window.setCookie('packageId', '');
|
|
|
window.setCookie('chosenStyle', '');
|
|
|
window.setCookie('chosenTime', '');
|
|
|
window.setCookie('chosenAdviser', '');
|
|
|
window.setCookie('adviserId', '');
|
|
|
window.setCookie('chosenCutter', '');
|
|
|
window.setCookie('iscutter', '');
|
|
|
window.setCookie('styleStr', '');
|
|
|
window.setCookie('timeStr', '');
|
|
|
window.setCookie('detailtTimeStr', '');
|
|
|
window.setCookie('radiobirth', '');
|
|
|
window.setCookie('radiosex', '');
|
|
|
window.setCookie('cookieArr', '');
|
|
|
window.setCookie('limitPerson', '');
|
|
|
window.setCookie('packageLimit', '');
|
|
|
window.setCookie('packageStyle', '');
|
|
|
window.setCookie('chosenClass', '');
|
|
|
window.setCookie('styleId', '');
|
|
|
break;
|
|
|
if ($('.order-item').length > 0) {
|
|
|
$('.order-item').each(
|
|
|
function() {
|
|
|
var time = $(this).find('.time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
|
|
|
$(this).find('.time').html(weekTime);
|
|
|
}
|
|
|
} |
|
|
);
|
|
|
}
|
|
|
|
|
|
if ($('#detail-time').length > 0) {
|
|
|
var time = $('#detail-time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
var timeResult = getAbleTime();
|
|
|
|
|
|
$('#detail-time').html(weekTime);
|
|
|
if (timeResult.data === '') {
|
|
|
$('.chan-btn').show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
); |
|
|
\ No newline at end of file |
...
|
...
|
|