diff --git a/resources/beike/shop/default/js/app.js b/resources/beike/shop/default/js/app.js index 6fe2d4a3..916101a6 100644 --- a/resources/beike/shop/default/js/app.js +++ b/resources/beike/shop/default/js/app.js @@ -3,8 +3,24 @@ import common from "./common"; window.bk = common; window.$http = http; +const token = document.querySelector('meta[name="csrf-token"]').content; +const base = document.querySelector('base').href; + import './product'; import './header' +$(document).ready(function ($) { + $.ajaxSetup({ + headers: {'X-CSRF-TOKEN': token}, + // beforeSend: function() { layer.load(2, {shade: [0.3,'#fff'] }); }, + // complete: function() { layer.closeAll('loading'); }, + error: function(xhr, ajaxOptions, thrownError) { + if (xhr.responseJSON.message) { + layer.msg(xhr.responseJSON.message,() => {}) + } + }, + }); +}); + bk.getCarts(); // 页面初始加载购物车数据 bk.slidingFixed(); \ No newline at end of file