|
@@ -1,5 +1,4 @@
|
|
|
var coreServer = $("#coreServer").val();
|
|
|
-var spiServer = $("#spiServer").val();
|
|
|
var isPC = ($(window).width()>768);
|
|
|
var globalUserData = '';
|
|
|
var GLOBAL_TOKEN = 'X-Token';
|
|
@@ -573,35 +572,6 @@ function updateUrlParam(params) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function tokenAjax(type, url, params, callback, errorBack){
|
|
|
- $.ajax({
|
|
|
- type: type,
|
|
|
- url: spiServer + url,
|
|
|
- xhrFields: {
|
|
|
- withCredentials: true
|
|
|
- },
|
|
|
- data: params,
|
|
|
- headers:{
|
|
|
- 'Content-Type': type=='post'?'application/x-www-form-urlencoded':'application/json;charset=utf8',
|
|
|
- 'X-Token':GLOBAL_TOKEN
|
|
|
- },
|
|
|
- success : function (res) {
|
|
|
- if(res.code === -99){
|
|
|
- localStorage.removeItem('userInfo');
|
|
|
- delBaseCookie("loginBeforePath");
|
|
|
- // window.location.href ='/login.html';
|
|
|
- }else{
|
|
|
- callback(res);
|
|
|
- }
|
|
|
- },
|
|
|
- error : function (res) {
|
|
|
- alertInfo("网络连接超时,请重试!",function (res) {
|
|
|
- console.log(res)
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
function setSearchProductList(list, userId, callback) {//处理搜索
|
|
|
var productIdArr = [];
|
|
|
var resultData = [];
|
|
@@ -790,43 +760,3 @@ function dialog(txt,callback) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-// 加入购物车
|
|
|
-function addShoppingCart(userId, productId, count, callback){
|
|
|
- tokenAjax("post", "/shoppingCart/addCart", {
|
|
|
- userID: userId,
|
|
|
- productID: productId,
|
|
|
- productCount: count
|
|
|
- },function (res) {
|
|
|
- if(res && res.code*1 === 0){
|
|
|
- globalHead.getHeadCart(userId);
|
|
|
- $.confirm({
|
|
|
- useBootstrap: false,
|
|
|
- boxWidth: (isPC?'338px':'74.6vw'),
|
|
|
- title: false,
|
|
|
- content:'<div class="cartAlert"><h6>商品已成功加入购物车!</h6><p>当前购物车共<em>'+res.data+'</em>种商品</p></div>',
|
|
|
- closeIcon: true,
|
|
|
- animation: 'opacity',
|
|
|
- closeAnimation: 'opacity',
|
|
|
- animateFromElement: false,
|
|
|
- scrollToPreviousElement: false,
|
|
|
- buttons: {
|
|
|
- login: {
|
|
|
- text: '去结算',
|
|
|
- btnClass: 'btn-to-cart',
|
|
|
- action: function(){
|
|
|
- window.location.href = '/shopping/cart.html';
|
|
|
- }
|
|
|
- },
|
|
|
- close: {
|
|
|
- text: '继续购物',
|
|
|
- btnClass: 'btn-to-goon',
|
|
|
- action: callback?callback():function(){}
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- dialog("加入购物车失败!");
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|