未登录情况下,加购物车会弹窗登录框

This commit is contained in:
pushuo 2022-08-29 16:16:02 +08:00
parent 623fed1af3
commit 8340fc781e
5 changed files with 54 additions and 11 deletions

View File

@ -2124,6 +2124,20 @@ __webpack_require__.r(__webpack_exports__);
quantity = _ref$quantity === void 0 ? 1 : _ref$quantity,
_ref$isBuyNow = _ref.isBuyNow,
isBuyNow = _ref$isBuyNow === void 0 ? false : _ref$isBuyNow;
if (!isLogin) {
layer.open({
type: 2,
title: '',
shadeClose: true,
shade: 0.8,
area: ['900px', '600px'],
content: 'login?iframe=true' //iframe的url
});
return;
}
var $btn = $(event);
var btnHtml = $btn.html();
var loadHtml = '<span class="spinner-border spinner-border-sm"></span>';
@ -2233,6 +2247,7 @@ __webpack_require__.r(__webpack_exports__);
// offcanvas-search-top
$(function () {
var myOffcanvas = document.getElementById('offcanvas-search-top');
if (!myOffcanvas) return;
myOffcanvas.addEventListener('shown.bs.offcanvas', function () {
$('#offcanvas-search-top input').focus();
$('#offcanvas-search-top input').keydown(function (e) {

View File

@ -24,6 +24,19 @@ export default {
* @return {*} 返回Promise
*/
addCart({sku_id, quantity = 1, isBuyNow = false}, event) {
if (!isLogin) {
layer.open({
type: 2,
title: '',
shadeClose: true,
shade: 0.8,
area: ['900px', '600px'],
content: 'login?iframe=true' //iframe的url
});
return;
}
const $btn = $(event);
const btnHtml = $btn.html();
const loadHtml = '<span class="spinner-border spinner-border-sm"></span>';

View File

@ -1,6 +1,8 @@
// offcanvas-search-top
$(function() {
var myOffcanvas = document.getElementById('offcanvas-search-top')
if (!myOffcanvas) return;
myOffcanvas.addEventListener('shown.bs.offcanvas', function () {
$('#offcanvas-search-top input').focus();
$('#offcanvas-search-top input').keydown(function (e) {

View File

@ -10,13 +10,14 @@
@section('content')
<div class="container" id="page-login" v-cloak>
<div class="{{ request('iframe') ? 'container-fluid mt-5' : 'container' }}" id="page-login" v-cloak>
@if (!request('iframe'))
<x-shop-breadcrumb type="static" value="login.index" />
<div class="hero-content pb-5 text-center"><h1 class="hero-heading">{{ __('shop/login.index') }}</h1></div>
@endif
<x-shop-breadcrumb type="static" value="login.index" />
<div class="hero-content pb-5 text-center"><h1 class="hero-heading">{{ __('shop/login.index') }}</h1></div>
<div class="justify-content-center row mb-5">
<div class="col-lg-5">
<div class="justify-content-center row {{ !request('iframe') ? 'mb-5' : '' }}">
<div class="col-lg-{{ request('iframe') ? '6' : '5' }} col-md-6 col-sm-12">
<div class="card">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules">
<div class="login-item-header card-header">
@ -46,7 +47,7 @@
</el-form>
</div>
</div>
<div class="col-lg-5">
<div class="col-lg-{{ request('iframe') ? '6' : '5' }} col-md-6 col-sm-12">
<div class="card">
<div class="login-item-header card-header">
<h6 class="text-uppercase mb-0">{{ __('shop/login.new') }}</h6>
@ -164,8 +165,16 @@
}
$http.post(url, _data).then((res) => {
this.$message.success(res.message);
location = "{{ shop_route('account.index') }}"
layer.msg(res.message)
@if (!request('iframe'))
location = "{{ shop_route('account.index') }}"
@else
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
setTimeout(() => {
parent.layer.close(index); //再执行关闭
parent.window.location.reload()
}, 400);
@endif
})
});
}

View File

@ -19,11 +19,15 @@
@stack('header')
</head>
<body class="@yield('body-class')">
@include('layout.header')
@if (!request('iframe'))
@include('layout.header')
@endif
@yield('content')
@include('layout.footer')
@if (!request('iframe'))
@include('layout.footer')
@endif
<script>
const isLogin = @json(current_customer());