|
|
require('../common');
|
|
|
|
|
|
var tip = require('../plugin/tip'),
|
|
|
IScroll = require('yoho-iscroll'),
|
|
|
diaLog = require('../plugin/dialog'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
moment = require('moment');
|
|
|
diaLog = require('../plugin/dialog');
|
|
|
|
|
|
var $num = $('.num'),
|
|
|
$navUl = $('.nav-ul');
|
|
|
$navUl = $('.nav-ul'),
|
|
|
idArr = '',
|
|
|
hasId = false,
|
|
|
timeResult = '',
|
|
|
time = 0,
|
|
|
weekTime = '';
|
|
|
|
|
|
var num = 1,
|
|
|
openId = '',
|
...
|
...
|
@@ -17,42 +18,22 @@ var num = 1, |
|
|
$cookie,
|
|
|
$cookie2,
|
|
|
styleTotal = 0,
|
|
|
styleNow = 0;
|
|
|
styleNow = 0,
|
|
|
autoIndex = 0,
|
|
|
i = 0,
|
|
|
getCookie = '',
|
|
|
inpNum = 0,
|
|
|
styleStr = [];
|
|
|
|
|
|
require('../../scss/activity/trend/trend.page.css');
|
|
|
require('../activity/trend/share.js');
|
|
|
var indexAct = require('activity/trend/index');
|
|
|
|
|
|
require('../common');
|
|
|
require('activity/trend/trend.page.css');
|
|
|
require('activity/trend/share');
|
|
|
if ($('#map').length > 0) {
|
|
|
require('../../scss/activity/trend/map.css');
|
|
|
require('activity/trend/map');
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
|
if (year < 1900) {
|
|
|
year = year + 1900;
|
|
|
}
|
|
|
if (month < 10) {
|
|
|
month = '0' + month;
|
|
|
}
|
|
|
if (date < 10) {
|
|
|
date = '0' + date;
|
|
|
}
|
|
|
if (hour < 10) {
|
|
|
hour = '0' + hour;
|
|
|
}
|
|
|
if (minutes < 10) {
|
|
|
minutes = '0' + minutes;
|
|
|
}
|
|
|
return year + '年' + month + '月' + date + '日' + ' ' + week[day-1] + ' ' + hour + ':' + minutes;
|
|
|
}
|
|
|
|
|
|
function autoScroll(thisPo) {
|
|
|
$navUl.find('.nav-item:eq(' + thisPo + ')').addClass('active').siblings('li').removeClass('active');
|
...
|
...
|
@@ -65,367 +46,9 @@ function autoScroll(thisPo) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
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>';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
for (var i = 0; i < result.getTimeList.length; i++) {
|
|
|
var useClass = 'use';
|
|
|
|
|
|
if (result.getTimeList[i].use === 2) {
|
|
|
var useClass = 'disable';
|
|
|
}
|
|
|
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 ($('.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);
|
|
|
|
|
|
// 如果是从预约订单详情页过来
|
|
|
if (window.queryString.order == 'true') {
|
|
|
var detailtTimeStr = $(this).attr('date');
|
|
|
|
|
|
window.setCookie('detailtTimeStr', detailtTimeStr);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('获取时间列表失败~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
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 (!window.cookie('packageId') && !window.cookie('adviserId')) {
|
|
|
type = 2;
|
|
|
}
|
|
|
userNote = userNote.replace(/[\r\n]/g, ' ');
|
|
|
if (userNote === '添加备注(选填)') {
|
|
|
userNote = '';
|
|
|
}
|
|
|
$.ajax({
|
|
|
url: '/activity/trend/addOrder',
|
|
|
data: {
|
|
|
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) {
|
|
|
document.location.href = '//m.yohobuy.com/activity/trend/success?storeId=' + window.queryString.storeId + '&typeStatus=' + window.queryString.typeStatus;
|
|
|
} else {
|
|
|
tip.show(result.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function diaHide() {
|
|
|
$('#dialog-wrapper').hide();
|
|
|
}
|
|
|
|
|
|
|
|
|
function removeByValue(arr, val) {
|
|
|
for (var i=0; i<arr.length; i++) {
|
|
|
if (arr[i] == val) {
|
|
|
arr.splice(i, 1);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
return false;
|
|
|
break;
|
|
|
default:
|
|
|
checkSubmit = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
if (checkSubmit) {
|
|
|
submitDia();
|
|
|
}
|
|
|
} else {
|
|
|
tip.show('请先接受上述条款');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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'});
|
|
|
}
|
|
|
|
|
|
function setCookieArr() {
|
|
|
var cookieArr = new Array();
|
|
|
|
|
|
$cookie.each(
|
|
|
function() {
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
} else {
|
|
|
|
|
|
// tip.show(result.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
return timeResult;
|
|
|
}
|
|
|
|
|
|
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 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
// 批量设置isFront参数
|
|
|
if (window.queryString.isFront) {
|
|
|
window.setCookie('isFront', window.queryString.isFront);
|
...
|
...
|
@@ -439,62 +62,12 @@ $( |
|
|
|
|
|
// 风格详情页图片点击放大
|
|
|
$('.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');
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
$('.swiper-slide').on('click', function() {
|
|
|
$('.big-pic').hide();
|
|
|
});
|
|
|
indexAct.pullPicBig();
|
|
|
});
|
|
|
|
|
|
// 瀑布流
|
|
|
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');
|
|
|
}
|
|
|
});
|
|
|
}, 500);
|
|
|
indexAct.pullPic();
|
|
|
}
|
|
|
|
|
|
if ($('.adviser-info').length > 0) {
|
...
|
...
|
@@ -514,9 +87,10 @@ $( |
|
|
|
|
|
$depend.each(
|
|
|
function() {
|
|
|
if ($(this).find('input').val() === '') {
|
|
|
var errText = $(this).closest('.depend').find('.label').text();
|
|
|
var errText = '';
|
|
|
|
|
|
if ($(this).find('input').val() === '') {
|
|
|
errText = $(this).closest('.depend').find('.label').text();
|
|
|
tip.show('请先选择' + errText);
|
|
|
chosenAble = false;
|
|
|
return false;
|
...
|
...
|
@@ -534,10 +108,10 @@ $( |
|
|
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
indexAct.clearCookieArr(2);
|
|
|
} else {
|
|
|
if (!($('.chosen-style').val() && !$('.chosen-package').val())) {
|
|
|
clearCookieArr(1);
|
|
|
indexAct.clearCookieArr(1);
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -546,22 +120,22 @@ $( |
|
|
$('#note').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
limitInp(obj, 200, true);
|
|
|
indexAct.limitInp(obj, 200, true);
|
|
|
});
|
|
|
$('#name').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
limitInp(obj, 10, false);
|
|
|
indexAct.limitInp(obj, 10, false);
|
|
|
});
|
|
|
$('#tel').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
limitInp(obj, 11, false);
|
|
|
indexAct.limitInp(obj, 11, false);
|
|
|
});
|
|
|
$('#age').on('keyup', function() {
|
|
|
var obj = $(this);
|
|
|
|
|
|
limitInp(obj, 2, false);
|
|
|
indexAct.limitInp(obj, 2, false);
|
|
|
});
|
|
|
|
|
|
// 默认勾选
|
...
|
...
|
@@ -588,7 +162,7 @@ $( |
|
|
function() {
|
|
|
if (window.cookie('chosenStyle').indexOf($(this).text()) > -1) {
|
|
|
$(this).addClass('chosen');
|
|
|
styleNow ++;
|
|
|
styleNow++;
|
|
|
}
|
|
|
}
|
|
|
);
|
...
|
...
|
@@ -603,8 +177,6 @@ $( |
|
|
);
|
|
|
}
|
|
|
if (window.queryString.chosenType === '2') {
|
|
|
var autoIndex = 0;
|
|
|
|
|
|
$('.nav-item').each(
|
|
|
function() {
|
|
|
if ($(this).find('p:first').text()) {
|
...
|
...
|
@@ -668,10 +240,10 @@ $( |
|
|
|
|
|
// 默认已勾选风格,根据后选套餐是否包含该风格,判断时候清空风格
|
|
|
if (window.cookie('packageStyle') && window.cookie('styleId')) {
|
|
|
var idArr = window.cookie('packageStyle').split(',');
|
|
|
var hasId = false;
|
|
|
idArr = window.cookie('packageStyle').split(',');
|
|
|
hasId = false;
|
|
|
|
|
|
for (var i = 0; i < idArr.length; i++) {
|
|
|
for (i = 0; i < idArr.length; i++) {
|
|
|
if (idArr[i] === $('.chosen-style').attr('id')) {
|
|
|
hasId = true;
|
|
|
break;
|
...
|
...
|
@@ -679,7 +251,7 @@ $( |
|
|
}
|
|
|
if (!hasId) {
|
|
|
$('.chosen-style').val('');
|
|
|
clearCookieArr(1);
|
|
|
indexAct.clearCookieArr(1);
|
|
|
}
|
|
|
window.setCookie('styleId', '');
|
|
|
}
|
...
|
...
|
@@ -688,10 +260,10 @@ $( |
|
|
$('.chosen-adviser').val(window.cookie('chosenAdviser'));
|
|
|
$('.chosen-class').val(window.cookie('chosenClass'));
|
|
|
if (window.cookie('chosenClass')) {
|
|
|
var timeResult = getAbleTime();
|
|
|
timeResult = indexAct.getAbleTime();
|
|
|
|
|
|
if (timeResult.data) {
|
|
|
$('.chosen-time').val(_formatDay(new Date(timeResult.data * 1000))).addClass('disabled');
|
|
|
$('.chosen-time').val(indexAct._formatDay(new Date(timeResult.data * 1000))).addClass('disabled');
|
|
|
$('.chosen-time').parents('a').attr('href', 'javascript:void(0)');
|
|
|
window.setCookie('timeStr', timeResult.data);
|
|
|
}
|
...
|
...
|
@@ -710,9 +282,9 @@ $( |
|
|
$('.chosen-select .chose-item:eq(1)').addClass('need');
|
|
|
$('.chosen-select .depend').on('click', function() {
|
|
|
if ($(this).find('.chosen-cutter').length > 0) {
|
|
|
clearCookieArr(2);
|
|
|
indexAct.clearCookieArr(2);
|
|
|
} else {
|
|
|
clearCookieArr(1);
|
|
|
indexAct.clearCookieArr(1);
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -722,15 +294,15 @@ $( |
|
|
|
|
|
// 修改表单存储cookie
|
|
|
$('.chosen').on('click', function() {
|
|
|
setCookieArr();
|
|
|
indexAct.setCookieArr();
|
|
|
});
|
|
|
$('.chosen .cookie').on('keyup', function() {
|
|
|
setCookieArr();
|
|
|
indexAct.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;
|
|
|
getCookie = window.cookie('cookieArr').split(',');
|
|
|
inpNum = 0;
|
|
|
|
|
|
$cookie.each(
|
|
|
function() {
|
...
|
...
|
@@ -746,14 +318,15 @@ $( |
|
|
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');
|
|
|
$('.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);
|
|
|
indexAct.clearCookieArr(3);
|
|
|
}
|
|
|
|
|
|
if ($('.textarea textarea').val() === '添加备注(选填)') {
|
|
|
$('.textarea textarea').addClass('disabled');
|
|
|
}
|
...
|
...
|
@@ -764,24 +337,7 @@ $( |
|
|
});
|
|
|
|
|
|
// 默认选中菜单
|
|
|
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) + ' ');
|
|
|
}
|
|
|
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);
|
|
|
}
|
|
|
indexAct.chosenDefault();
|
|
|
|
|
|
// 立即预约按钮
|
|
|
$('.chosen-btn').on('click', function() {
|
...
|
...
|
@@ -791,7 +347,13 @@ $( |
|
|
var chosenNum = $chosenItem.length;
|
|
|
var chosenType = window.queryString.chosenType;
|
|
|
var tipMsg = '';
|
|
|
var chosenText = '';
|
|
|
var chosenText2 = '';
|
|
|
var packageId = '';
|
|
|
|
|
|
if ($(this).hasClass('full')) {
|
|
|
return false;
|
|
|
}
|
|
|
if ((checkedNum <= 0) && (chosenNum <= 0)) {
|
|
|
switch (chosenType) {
|
|
|
case '1' : tipMsg = '风格';
|
...
|
...
|
@@ -804,12 +366,14 @@ $( |
|
|
break;
|
|
|
case '5' : tipMsg = '发型师';
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
tip.show('请选择' + tipMsg);
|
|
|
} else {
|
|
|
var chosenText = $checkedItem.attr('data') || $chosenItem.text();
|
|
|
var chosenText2 = $chosenItem.attr('date2');
|
|
|
var packageId = $checkedItem.attr('id');
|
|
|
chosenText = $checkedItem.attr('data') || $chosenItem.text();
|
|
|
chosenText2 = $chosenItem.attr('date2');
|
|
|
packageId = $checkedItem.attr('id');
|
|
|
|
|
|
switch (chosenType) {
|
|
|
case '4' :
|
...
|
...
|
@@ -830,6 +394,9 @@ $( |
|
|
break;
|
|
|
case '5' :
|
|
|
window.setCookie('chosenCutter', chosenText);
|
|
|
window.setCookie('cutterId', packageId);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
document.location.href = document.referrer;
|
...
|
...
|
@@ -838,45 +405,19 @@ $( |
|
|
|
|
|
// 取消订单
|
|
|
$('.order-btn a').on('click', function() {
|
|
|
diaLog.showDialog({
|
|
|
dialogText: '确认取消预约吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '我再想想',
|
|
|
rightBtnText: '确认取消'
|
|
|
}
|
|
|
}, 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;
|
|
|
} else {
|
|
|
tip.show(result.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开了~~~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 修改弹框样式
|
|
|
$('.dialog-left-btn').css('color', '#999');
|
|
|
$('.dialog-right-btn').css('color', '#007aff');
|
|
|
indexAct.cancelOrder();
|
|
|
});
|
|
|
|
|
|
// 加减人数按钮
|
|
|
$num.find('.plus-btn').on('click', function() {
|
|
|
var limitNum = 0;
|
|
|
|
|
|
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;
|
|
|
limitNum = parseInt($num.find('input').attr('max'), 10);
|
|
|
if (parseInt($num.find('input').val(), 10) < limitNum) {
|
|
|
num = parseInt($num.find('input').val(), 10) + 1;
|
|
|
$num.find('input').val(num);
|
|
|
} else {
|
|
|
tip.show('可预约人数已达上限');
|
...
|
...
|
@@ -884,8 +425,8 @@ $( |
|
|
}
|
|
|
});
|
|
|
$num.find('.minus-btn').on('click', function() {
|
|
|
if (parseInt($num.find('input').val()) > 1) {
|
|
|
num = parseInt($num.find('input').val()) - 1;
|
|
|
if (parseInt($num.find('input').val(), 10) > 1) {
|
|
|
num = parseInt($num.find('input').val(), 10) - 1;
|
|
|
$num.find('input').val(num);
|
|
|
} else {
|
|
|
tip.show('人数不能小于1');
|
...
|
...
|
@@ -909,23 +450,25 @@ $( |
|
|
return false;
|
|
|
});
|
|
|
myScroll.on('scrollEnd', function() {
|
|
|
var thisPo = 0;
|
|
|
|
|
|
if ($navUl.hasClass('srolling')) {
|
|
|
$navUl.removeClass('srolling');
|
|
|
var thisPo = Math.ceil((0 - myScroll.x) / sWidth + 1.5);
|
|
|
|
|
|
thisPo = Math.ceil((0 - myScroll.x) / sWidth + 1.5);
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
indexAct.getTimeList();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 通过点击选择时间段
|
|
|
$navUl.find('.nav-item').on('click', function() {
|
|
|
if (!$(this).hasClass('disable')) {
|
|
|
var thisPo = $(this).index();
|
|
|
var thisPo = 0;
|
|
|
|
|
|
if (!$(this).hasClass('disable')) {
|
|
|
thisPo = $(this).index();
|
|
|
autoScroll(thisPo);
|
|
|
getTimeList();
|
|
|
indexAct.getTimeList();
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -936,7 +479,7 @@ $( |
|
|
});
|
|
|
|
|
|
$('.dia-tip').on('click', function() {
|
|
|
checkSubmit();
|
|
|
indexAct.checkSubmit();
|
|
|
});
|
|
|
|
|
|
$('.tab .tab-top span').on('click', function() {
|
...
|
...
|
@@ -958,29 +501,48 @@ $( |
|
|
var $totalId = $(this).attr('id');
|
|
|
var $packageStyle = window.cookie('packageStyle').split(',');
|
|
|
|
|
|
for (var i = 0; i < $packageStyle.length; i++) {
|
|
|
if ($totalId == $packageStyle[i]) {
|
|
|
for (i = 0; i < $packageStyle.length; i++) {
|
|
|
if ($totalId === $packageStyle[i]) {
|
|
|
$(this).removeClass('disabled');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
} else if (!window.cookie('chosenPackage')) {
|
|
|
$('.style-ul:eq(0) li').each(
|
|
|
function() {
|
|
|
$('.top').find('.text').text('请先选择套餐');
|
|
|
$(this).removeClass('disabled');
|
|
|
styleTotal = $('.style-ul:eq(0) li').length;
|
|
|
$('.foot-btn').addClass('full').removeClass('ok');
|
|
|
$('.style-tip').hide();
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
$('.style-tip .total').text(styleTotal);
|
|
|
$('.style-tip .now').text(styleNow);
|
|
|
}
|
|
|
|
|
|
var styleStr = new Array();
|
|
|
// 不选套餐进入时间选择页
|
|
|
if ($('.time-tag').length > 0) {
|
|
|
if (!window.cookie('packageId') && ((window.queryString.typeStatus === '4') ||
|
|
|
(window.queryString.typeStatus === '5'))) {
|
|
|
$('.date-tip').find('.text').text('请先选择套餐');
|
|
|
$('.foot-btn').addClass('full').removeClass('ok');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$('.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');
|
|
|
var limitNum = 0;
|
|
|
|
|
|
$(this).parents('.style-ul').siblings('.style-ul').find('li').removeClass('chosen');
|
|
|
if (!$this.hasClass('disabled')) {
|
|
|
if ($this.hasClass('chosen')) {
|
|
|
$this.removeClass('chosen');
|
|
|
if (!$this.hasClass('not')) {
|
|
|
removeByValue(styleStr, $thisId);
|
|
|
indexAct.removeByValue(styleStr, $thisId);
|
|
|
styleNow--;
|
|
|
} else {
|
|
|
styleStr = [];
|
...
|
...
|
@@ -988,7 +550,7 @@ $( |
|
|
}
|
|
|
} else {
|
|
|
if (!$this.hasClass('not')) {
|
|
|
var limitNum = $('.total').text();
|
|
|
limitNum = $('.total').text();
|
|
|
|
|
|
if (styleNow >= limitNum) {
|
|
|
tip.show('超过最大可选风格数');
|
...
|
...
|
@@ -1010,14 +572,14 @@ $( |
|
|
|
|
|
if ($('.time-nav').length > 0) {
|
|
|
$('.time-nav ul').find('.nav-item:eq(2)').addClass('active');
|
|
|
getTimeList();
|
|
|
indexAct.getTimeList();
|
|
|
}
|
|
|
|
|
|
if ($('.order-item').length > 0) {
|
|
|
$('.order-item').each(
|
|
|
function() {
|
|
|
var time = $(this).find('.time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
time = $(this).find('.time').attr('date') * 1000;
|
|
|
weekTime = indexAct.formatDate(time);
|
|
|
|
|
|
$(this).find('.time').html(weekTime);
|
|
|
}
|
...
|
...
|
@@ -1025,9 +587,9 @@ $( |
|
|
}
|
|
|
|
|
|
if ($('#detail-time').length > 0) {
|
|
|
var time = $('#detail-time').attr('date') * 1000;
|
|
|
var weekTime = formatDate(time);
|
|
|
var timeResult = getAbleTime();
|
|
|
time = $('#detail-time').attr('date') * 1000;
|
|
|
weekTime = indexAct.formatDate(time);
|
|
|
timeResult = indexAct.getAbleTime();
|
|
|
|
|
|
$('#detail-time').html(weekTime);
|
|
|
if (timeResult.data === '') {
|
...
|
...
|
@@ -1035,4 +597,4 @@ $( |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
); |
|
|
\ No newline at end of file |
|
|
); |
...
|
...
|
|