170 lines
4.9 KiB
JavaScript
170 lines
4.9 KiB
JavaScript
AOS.init();
|
|
var bodyWidth = 0;
|
|
var userInfo = null;
|
|
var baseApi = 'http://message-api.ahjzk.com';
|
|
$(function () {
|
|
if (window.localStorage.getItem('_HEATUserInfo')) {
|
|
userInfo = JSON.parse(window.localStorage.getItem('_HEATUserInfo'))
|
|
if (userInfo.header_url) {
|
|
$('.user-avatar').attr('src', baseApi + userInfo.header_url)
|
|
}
|
|
$('.register, .login').hide()
|
|
$('.user-info').show()
|
|
} else {
|
|
$('.register, .login').show()
|
|
$('.user-info').hide()
|
|
}
|
|
console.log(userInfo)
|
|
bodyWidth = $(window).width()
|
|
new Swiper('.swiper', {
|
|
direction: 'horizontal',
|
|
loop: true,
|
|
// autoplay: {
|
|
// pauseOnMouseEnter: true,
|
|
// disableOnInteraction: false
|
|
// }
|
|
})
|
|
new Swiper('.swiper-hzhb-pc', {
|
|
direction: 'horizontal',
|
|
loop: true,
|
|
slidesPerView: 3,
|
|
pagination: {
|
|
el: '.swiper-pagination'
|
|
}
|
|
// autoplay: {
|
|
// pauseOnMouseEnter: true,
|
|
// disableOnInteraction: false
|
|
// }
|
|
})
|
|
new Swiper('.swiper-hzhb-m', {
|
|
direction: 'horizontal',
|
|
loop: true
|
|
// autoplay: {
|
|
// pauseOnMouseEnter: true,
|
|
// disableOnInteraction: false
|
|
// }
|
|
})
|
|
new Swiper('.swiper-food', {
|
|
direction: 'horizontal',
|
|
loop: true,
|
|
slidesPerView: 'auto',
|
|
pagination: {
|
|
el: '.swiper-pagination'
|
|
}
|
|
// autoplay: {
|
|
// pauseOnMouseEnter: true,
|
|
// disableOnInteraction: false
|
|
// }
|
|
})
|
|
})
|
|
$(window).resize(function () {
|
|
bodyWidth = $('body').width()
|
|
})
|
|
function getParamsFromHref() {
|
|
var parameters = window.location.search.substr(1);
|
|
var array = parameters.split('&');
|
|
var object = new Object();
|
|
for (var i = 0; i < array.length; i++) {
|
|
var index = array[i].indexOf('=');
|
|
object[array[i].substring(0, index)] = array[i]
|
|
.substring(index + 1);
|
|
}
|
|
return object;
|
|
};
|
|
$('.find-left a').hover(function () {
|
|
var _index = $(this).index()
|
|
if (_index === 0) {
|
|
if (bodyWidth > 1024) {
|
|
$('.find-3').width(290)
|
|
}
|
|
if (bodyWidth < 1024 && bodyWidth > 768) {
|
|
$('.find-3').width(180)
|
|
}
|
|
$('.find-right').show()
|
|
} else {
|
|
if (bodyWidth > 1024) {
|
|
$('.find-3').width(145)
|
|
}
|
|
if (bodyWidth < 1024 && bodyWidth > 768) {
|
|
$('.find-3').width(90)
|
|
}
|
|
$('.find-right').hide()
|
|
}
|
|
});
|
|
$('.box-type .box-type-item').hover(function () {
|
|
var _name = $(this).data('name')
|
|
var _index = $(this).index()
|
|
$(this).addClass('box-type-on').siblings('.box-type-item').removeClass('box-type-on')
|
|
$('.box-type .box-type-item').each(function (index, element) {
|
|
var _name = $(element).data('name')
|
|
$(element).find('img').attr('src', './images/' + _name + '.svg')
|
|
});
|
|
$(this).find('img').attr('src', './images/' + _name + '-on.svg')
|
|
$('.box-list .box-item').eq(_index).css('display', 'flex').siblings('.box-item').hide()
|
|
})
|
|
function workOrder() {
|
|
layer.open({
|
|
type: 2,
|
|
skin: 'update-box update-order',
|
|
title: '请输入您的问题',
|
|
content: './work-order.html'
|
|
});
|
|
}
|
|
$('.food-type span').hover(function () {
|
|
var _index = $(this).index()
|
|
$(this).addClass('food-on').siblings('span').removeClass('food-on')
|
|
$('.food-cell .food-list').eq(_index).css('display', 'flex').siblings('.food-list').hide()
|
|
})
|
|
|
|
function ajax(url, params, callback, flag = true) {
|
|
$.ajax({
|
|
url: baseApi + url,
|
|
type: "POST",
|
|
async: flag,
|
|
cache: false,
|
|
dataType: "json",
|
|
timeout: 30000,
|
|
contentType: "application/x-www-form-urlencoded",
|
|
data: params,
|
|
success: function (data) {
|
|
if (data.error_code === 0) {
|
|
callback(data)
|
|
} else {
|
|
layer.closeAll('loading')
|
|
layer.msg(data.error_msg)
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
function upload(formData, callback, flag = true) {
|
|
$.ajax({
|
|
url: baseApi + '/upload/upload',
|
|
type: "POST",
|
|
async: flag,
|
|
cache: false,
|
|
timeout: 30000,
|
|
contentType: false,
|
|
processData: false,
|
|
data: formData,
|
|
success: function (data) {
|
|
if (data.error_code === 0) {
|
|
callback(data)
|
|
} else {
|
|
layer.closeAll('loading')
|
|
layer.msg(data.error_msg)
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
function sendMess(tel) {
|
|
ajax('/SendMess/sendSms', { tel }, function (data) {
|
|
layer.msg('发送成功')
|
|
})
|
|
}
|
|
|
|
function logout() {
|
|
window.localStorage.removeItem('_HEATUserInfo')
|
|
window.open('../login.html', '_self')
|
|
} |