|
@@ -1,15 +1,15 @@
|
|
|
-var coreServer = $("#coreServer").val();
|
|
|
-var isPC = ($(window).width()>768);
|
|
|
-var globalUserData = '';
|
|
|
-var GLOBAL_TOKEN = 'X-Token';
|
|
|
-var GLOBAL_USER_ID = 0; // 用户Id
|
|
|
-var GLOBAL_USER_IDENTITY = 0;//2-会员机构;3-供应商;4-普通机构
|
|
|
-var GLOBAL_SHOP_ID = 0; // 供应商Id
|
|
|
-var GLOBAL_VIP_FLAG = 0; // 超级会员标记
|
|
|
-var GLOBAL_CLUB_TYPE = 0; // 会员类型 1 医美机构 2 胜美机构
|
|
|
-var IDENTITY = 0; // 用户标记
|
|
|
-var isForbidTabs = true; //控制菜单
|
|
|
-var isShopIsOrder = false; //控制菜单
|
|
|
+const coreServer = $("#coreServer").val();
|
|
|
+const isPC = ($(window).width() > 768);
|
|
|
+let globalUserData = '';
|
|
|
+let GLOBAL_TOKEN = 'X-Token';
|
|
|
+let GLOBAL_USER_ID = 0; // 用户Id
|
|
|
+let GLOBAL_USER_IDENTITY = 0;//2-会员机构;3-供应商;4-普通机构
|
|
|
+let GLOBAL_SHOP_ID = 0; // 供应商Id
|
|
|
+let GLOBAL_VIP_FLAG = 0; // 超级会员标记
|
|
|
+let GLOBAL_CLUB_TYPE = 0; // 会员类型 1 医美机构 2 胜美机构
|
|
|
+let IDENTITY = 0; // 用户标记
|
|
|
+let isForbidTabs = true; //控制菜单
|
|
|
+let isShopIsOrder = false; //控制菜单
|
|
|
if(localStorage.getItem('userInfo')){
|
|
|
globalUserData = JSON.parse(localStorage.getItem('userInfo'));
|
|
|
GLOBAL_TOKEN = globalUserData.token;
|
|
@@ -32,28 +32,27 @@ if(localStorage.getItem('userInfo')){
|
|
|
if(globalUserData){
|
|
|
isShopIsOrder = globalUserData.shopIsOrder;
|
|
|
}
|
|
|
- console.log('isShopIsOrder',isShopIsOrder)
|
|
|
} else {
|
|
|
- var pathname = window.location.pathname;
|
|
|
- var weChatLoginFlag = (Number(getBaseCookie("weChatAutoLogin"))===1 || Number(getBaseCookie("weChatAutoLogin"))===2);
|
|
|
- if(pathname.indexOf('/product/auth/') === -1 && !weChatLoginFlag ){
|
|
|
- var userAgent = navigator.userAgent.toLowerCase();
|
|
|
- const isWechatLogin = window.location.href.indexOf('isDataBase') !== -1
|
|
|
- if (userAgent.match(/MicroMessenger/i) && !isWechatLogin) {
|
|
|
- // 微信浏览器自动授权登录
|
|
|
- var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
|
|
|
- $.get(coreServer+'/user/login/auth/link?mode=1&redirectUri='+urlForWeChat, function(r){
|
|
|
- if(r.code===0 && r.data){
|
|
|
- setBaseCookie("weChatAutoLogin", 1);
|
|
|
- setBeforeUrl();
|
|
|
- window.location.href = r.data;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ // const pathname = window.location.pathname;
|
|
|
+ // const weChatLoginFlag = (Number(getBaseCookie("weChatAutoLogin")) === 1 || Number(getBaseCookie("weChatAutoLogin")) === 2);
|
|
|
+ // if(pathname.indexOf('/product/auth/') === -1 && !weChatLoginFlag ){
|
|
|
+ // const userAgent = navigator.userAgent.toLowerCase();
|
|
|
+ // const isWechatLogin = window.location.href.indexOf('isDataBase') !== -1
|
|
|
+ // if (userAgent.match(/MicroMessenger/i) && !isWechatLogin) {
|
|
|
+ // // 微信浏览器自动授权登录
|
|
|
+ // var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
|
|
|
+ // $.get(coreServer+'/user/login/auth/link?mode=1&redirectUri='+urlForWeChat, function(r){
|
|
|
+ // if(r.code===0 && r.data){
|
|
|
+ // setBaseCookie("weChatAutoLogin", 1);
|
|
|
+ // setBeforeUrl();
|
|
|
+ // window.location.href = r.data;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
// 头部
|
|
|
-var globalHead = new Vue({
|
|
|
+const globalHead = new Vue({
|
|
|
el: '#globalHead',
|
|
|
data: {
|
|
|
loginStatus: false,
|
|
@@ -65,12 +64,12 @@ var globalHead = new Vue({
|
|
|
productCount: 0,
|
|
|
priceTotal: 0
|
|
|
},
|
|
|
- noticeNum:0,
|
|
|
- shopId:'',
|
|
|
- userIdentity:'',
|
|
|
+ noticeNum: 0,
|
|
|
+ shopId: '',
|
|
|
+ userIdentity: '',
|
|
|
articleType: '',
|
|
|
- isFiexd:false,
|
|
|
- classifyIndex:1,
|
|
|
+ isFiexd: false,
|
|
|
+ classifyIndex: 1,
|
|
|
supplierLinks: [
|
|
|
{
|
|
|
title: '美业参谋',
|
|
@@ -95,8 +94,8 @@ var globalHead = new Vue({
|
|
|
], // 供应商链接
|
|
|
activeLinks: [],
|
|
|
},
|
|
|
- watch:{
|
|
|
- isFiexd: function(nVal,oVal){
|
|
|
+ watch: {
|
|
|
+ isFiexd: function (nVal, oVal) {
|
|
|
// 防止跳动
|
|
|
// if(nVal && isPC){
|
|
|
// $("body").css('paddingTop', $("#globalHead").height() + "px");
|
|
@@ -117,111 +116,111 @@ var globalHead = new Vue({
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- changeClassify: function(value){
|
|
|
- this.classifyIndex=value;
|
|
|
+ changeClassify: function (value) {
|
|
|
+ this.classifyIndex = value;
|
|
|
},
|
|
|
// 初始化分类菜单效果
|
|
|
- initClassufyTab: function(){
|
|
|
- if(isPC){
|
|
|
- setTimeout(function(){
|
|
|
+ initClassufyTab: function () {
|
|
|
+ if (isPC) {
|
|
|
+ setTimeout(function () {
|
|
|
$('#mainClassify').slide({
|
|
|
- mainCell:".clsCon",
|
|
|
- titCell:".clsTab a",
|
|
|
+ mainCell: ".clsCon",
|
|
|
+ titCell: ".clsTab a",
|
|
|
trigger: "mouseover"
|
|
|
});
|
|
|
$('#mainClassify_1').slide({
|
|
|
- mainCell:".tabItem_right",
|
|
|
- titCell:".tabItem_lift a",
|
|
|
+ mainCell: ".tabItem_right",
|
|
|
+ titCell: ".tabItem_lift a",
|
|
|
trigger: "mouseover"
|
|
|
});
|
|
|
$('#mainClassify_2').slide({
|
|
|
- mainCell:".tabItem_right",
|
|
|
- titCell:".tabItem_lift a",
|
|
|
+ mainCell: ".tabItem_right",
|
|
|
+ titCell: ".tabItem_lift a",
|
|
|
trigger: "mouseover"
|
|
|
});
|
|
|
$("#mainClassify_2 .tabItem_lift a").eq(0).trigger("mouseover");
|
|
|
$("#mainClassify_1 .tabItem_lift a").eq(0).trigger("mouseover");
|
|
|
- },500);
|
|
|
- }else{
|
|
|
- setTimeout(function(){
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ setTimeout(function () {
|
|
|
$('#mainClassify').slide({
|
|
|
- mainCell:".clsCon",
|
|
|
- titCell:".clsTab a",
|
|
|
+ mainCell: ".clsCon",
|
|
|
+ titCell: ".clsTab a",
|
|
|
trigger: "click"
|
|
|
});
|
|
|
$('#mainClassify_1').slide({
|
|
|
- mainCell:".tabItem_right",
|
|
|
- titCell:".tabItem_lift a",
|
|
|
+ mainCell: ".tabItem_right",
|
|
|
+ titCell: ".tabItem_lift a",
|
|
|
trigger: "click"
|
|
|
});
|
|
|
$('#mainClassify_2').slide({
|
|
|
- mainCell:".tabItem_right",
|
|
|
- titCell:".tabItem_lift a",
|
|
|
+ mainCell: ".tabItem_right",
|
|
|
+ titCell: ".tabItem_lift a",
|
|
|
trigger: "click"
|
|
|
});
|
|
|
$("#mainClassify_2 .tabItem_lift a").eq(0).trigger("click");
|
|
|
$("#mainClassify_1 .tabItem_lift a").eq(0).trigger("click");
|
|
|
- },500);
|
|
|
+ }, 500);
|
|
|
}
|
|
|
},
|
|
|
// 头部购物车数据
|
|
|
- getHeadCart: function(userId) {
|
|
|
+ getHeadCart: function (userId) {
|
|
|
var _self = this;
|
|
|
- ShoppingApi.getHeaderCartList({userId: userId},function(response){
|
|
|
+ ShoppingApi.getHeaderCartList({userId: userId}, function (response) {
|
|
|
if (response.code === 0 && response.data) {
|
|
|
var data = response.data;
|
|
|
_self.headCart.cartList = data.list;
|
|
|
_self.headCart.cartCount = data.list.length;
|
|
|
_self.headCart.productCount = 0;
|
|
|
_self.headCart.priceTotal = 0;
|
|
|
- data.list.map(function(item){
|
|
|
+ data.list.map(function (item) {
|
|
|
_self.headCart.productCount += item.number;
|
|
|
- _self.headCart.priceTotal += item.number*item.price;
|
|
|
+ _self.headCart.priceTotal += item.number * item.price;
|
|
|
});
|
|
|
- }else if(r.code== -99){
|
|
|
+ } else if (r.code == -99) {
|
|
|
CAIMEI.Storage.clear();
|
|
|
location.href = "/login.html";
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getAuthClubCount:function (clubId) {
|
|
|
+ getAuthClubCount: function (clubId) {
|
|
|
var _self = this;
|
|
|
- PublicApi.getAuthClubCount({commonId: clubId},function(response){
|
|
|
+ PublicApi.getAuthClubCount({commonId: clubId}, function (response) {
|
|
|
if (response.code === 0 && response.data) {
|
|
|
var data = response.data;
|
|
|
- if(data.count>99){
|
|
|
+ if (data.count > 99) {
|
|
|
_self.noticeNum = '99+'
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_self.noticeNum = data.count
|
|
|
}
|
|
|
- console.log('noticeNum',_self.noticeNum)
|
|
|
- }else{
|
|
|
+ console.log('noticeNum', _self.noticeNum)
|
|
|
+ } else {
|
|
|
console.log('获取机构通知消息数量异常')
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getAuthShopCount:function (shopId) {
|
|
|
+ getAuthShopCount: function (shopId) {
|
|
|
var _self = this;
|
|
|
- PublicApi.getAuthShopCount({commonId: shopId},function(response){
|
|
|
+ PublicApi.getAuthShopCount({commonId: shopId}, function (response) {
|
|
|
if (response.code === 0 && response.data) {
|
|
|
var data = response.data;
|
|
|
- if(data.count>99){
|
|
|
+ if (data.count > 99) {
|
|
|
_self.noticeNum = '99+'
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_self.noticeNum = data.count
|
|
|
}
|
|
|
localStorage.setItem('noticeNum', _self.noticeNum)
|
|
|
- }else{
|
|
|
- console.log('获取供应商通知消息数量异常')
|
|
|
+ } else {
|
|
|
+ console.log('获取供应商通知消息数量异常')
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- goMsgLinkFn:function (url) {
|
|
|
+ goMsgLinkFn: function (url) {
|
|
|
var _self = this;
|
|
|
- if(_self.loginStatus){
|
|
|
- window.location.href= url;
|
|
|
- }else{
|
|
|
- window.location.href='/login.html';
|
|
|
+ if (_self.loginStatus) {
|
|
|
+ window.location.href = url;
|
|
|
+ } else {
|
|
|
+ window.location.href = '/login.html';
|
|
|
}
|
|
|
},
|
|
|
goSupplierLink() {
|
|
@@ -233,63 +232,63 @@ var globalHead = new Vue({
|
|
|
window.location.href = link
|
|
|
}
|
|
|
},
|
|
|
- goCartsLinkFn:function(){
|
|
|
+ goCartsLinkFn: function () {
|
|
|
var _self = this;
|
|
|
- if(_self.loginStatus){
|
|
|
- window.location.href='/shopping/cart.html';
|
|
|
- }else{
|
|
|
- window.location.href='/login.html';
|
|
|
+ if (_self.loginStatus) {
|
|
|
+ window.location.href = '/shopping/cart.html';
|
|
|
+ } else {
|
|
|
+ window.location.href = '/login.html';
|
|
|
}
|
|
|
},
|
|
|
- productDetailsFn:function(id){ // 跳转详情
|
|
|
- window.location.href='/product-'+id+'.html';
|
|
|
+ productDetailsFn: function (id) { // 跳转详情
|
|
|
+ window.location.href = '/product-' + id + '.html';
|
|
|
},
|
|
|
- DeleteCartProducts:function(skuId){ // 删除购物车
|
|
|
+ DeleteCartProducts: function (skuId) { // 删除购物车
|
|
|
const _self = this;
|
|
|
- ShoppingApi.DeleteCartProducts({userId: this.userData.userId, skuIds: skuId},function(response){
|
|
|
- if(response.code === 0){
|
|
|
+ ShoppingApi.DeleteCartProducts({userId: this.userData.userId, skuIds: skuId}, function (response) {
|
|
|
+ if (response.code === 0) {
|
|
|
_self.getHeadCart(_self.userData.userId);
|
|
|
- }else{
|
|
|
- CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ } else {
|
|
|
+ CAIMEI.Alert(response.msg, '确定', false);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- pageLinkSupplier: function(){//预览商品
|
|
|
- window.open('/supplier-'+this.shopId+'.html');
|
|
|
+ pageLinkSupplier: function () {//预览商品
|
|
|
+ window.open('/supplier-' + this.shopId + '.html');
|
|
|
},
|
|
|
// 退出登录
|
|
|
- userLogOut: function(){
|
|
|
+ userLogOut: function () {
|
|
|
localStorage.removeItem('userInfo');
|
|
|
delBaseCookie("loginBeforePath");
|
|
|
this.loginStatus = false;
|
|
|
window.location.href = "/index.html";
|
|
|
},
|
|
|
- showGlobalMenu: function(){
|
|
|
- if(!isPC){
|
|
|
+ showGlobalMenu: function () {
|
|
|
+ if (!isPC) {
|
|
|
$("#mGlobalMenu").show().find(".cShow").slideDown(500);
|
|
|
}
|
|
|
},
|
|
|
- hideGlobalMenu: function(){
|
|
|
- if(!isPC){
|
|
|
+ hideGlobalMenu: function () {
|
|
|
+ if (!isPC) {
|
|
|
$("#mGlobalMenu").hide().find(".cShow").hide();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// init auto-input complete
|
|
|
- initAuthInputComplete(){
|
|
|
+ initAuthInputComplete() {
|
|
|
new AutoComplete({
|
|
|
el: '.auto-input',
|
|
|
- callback: async function(keyword){
|
|
|
+ callback: async function (keyword) {
|
|
|
try {
|
|
|
const res = await PublicApi.fetchQueryKeywordList({keyword: keyword});
|
|
|
- if(!res.data) return [];
|
|
|
+ if (!res.data) return [];
|
|
|
return res.data.map(item => item.keyword);
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
}
|
|
|
},
|
|
|
itemClick: function (keyword) {
|
|
|
- window.location.href = '/product/list.html?keyword='+keyword + '&productFlag=1' + '&linkageFlag=1';
|
|
|
+ window.location.href = '/product/list.html?keyword=' + keyword + '&productFlag=1' + '&linkageFlag=1';
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -300,93 +299,93 @@ var globalHead = new Vue({
|
|
|
if (globalUserData.token) {
|
|
|
this.loginStatus = true;
|
|
|
this.userData = globalUserData;
|
|
|
- if(this.userData.userIdentity === 3){
|
|
|
+ if (this.userData.userIdentity === 3) {
|
|
|
// 获取头部通知消息数量
|
|
|
- setTimeout(function(){
|
|
|
+ setTimeout(function () {
|
|
|
_self.getAuthShopCount(_self.userData.shopId);
|
|
|
}, 1000);
|
|
|
// 获取头部通知消息数量
|
|
|
- var timerShopCount = setInterval(function(){
|
|
|
+ var timerShopCount = setInterval(function () {
|
|
|
_self.getAuthShopCount(_self.userData.shopId);
|
|
|
- }, 1000*120);
|
|
|
- }else{
|
|
|
- setTimeout(function(){
|
|
|
+ }, 1000 * 120);
|
|
|
+ } else {
|
|
|
+ setTimeout(function () {
|
|
|
// 获取头部购物车数据
|
|
|
_self.getHeadCart(_self.userData.userId);
|
|
|
_self.getAuthClubCount(_self.userData.clubId);
|
|
|
}, 1000);
|
|
|
// 获取头部通知消息数量
|
|
|
- var timerClubCount = setInterval(function(){
|
|
|
+ var timerClubCount = setInterval(function () {
|
|
|
_self.getAuthClubCount(_self.userData.clubId);
|
|
|
- }, 1000*120);
|
|
|
+ }, 1000 * 600);
|
|
|
}
|
|
|
}
|
|
|
// 信息中心
|
|
|
this.articleType = getUrlParam("type");
|
|
|
},
|
|
|
- mounted:function(){
|
|
|
+ mounted: function () {
|
|
|
var _self = this;
|
|
|
// 初始化分类菜单效果
|
|
|
this.initClassufyTab();
|
|
|
var userData = JSON.parse(window.localStorage.getItem('userInfo'));
|
|
|
- if(userData!=null) {
|
|
|
+ if (userData != null) {
|
|
|
this.userIdentity = userData.userIdentity;
|
|
|
this.shopId = userData.shopId;
|
|
|
}
|
|
|
- if($(window).height() > 750){
|
|
|
- $(window).on('scroll', function() {
|
|
|
+ if ($(window).height() > 750) {
|
|
|
+ $(window).on('scroll', function () {
|
|
|
var scrollTop = $(this).scrollTop();
|
|
|
- if(scrollTop>50){
|
|
|
+ if (scrollTop > 50) {
|
|
|
_self.isFiexd = true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_self.isFiexd = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// 判断导航菜单高亮-对比url
|
|
|
- setTimeout(function(){
|
|
|
+ setTimeout(function () {
|
|
|
var path = window.location.pathname;
|
|
|
var paramsArr = path.split(".")[0].split("-");
|
|
|
var key = paramsArr[0].split("/")[1];
|
|
|
- var pageId = paramsArr.length>=1 ? paramsArr[1] : '';
|
|
|
- if(key && key.length>0) {
|
|
|
+ var pageId = paramsArr.length >= 1 ? paramsArr[1] : '';
|
|
|
+ if (key && key.length > 0) {
|
|
|
$('.navBox li').each(function () {
|
|
|
var href = $(this).find('a').attr("href");
|
|
|
- if (href.indexOf(path)>=0){
|
|
|
+ if (href.indexOf(path) >= 0) {
|
|
|
$(this).find('a').addClass('on');
|
|
|
return false;
|
|
|
- } else if (key != 'product' && key != 'info' && href.indexOf('/'+key)>=0) {
|
|
|
+ } else if (key != 'product' && key != 'info' && href.indexOf('/' + key) >= 0) {
|
|
|
$(this).find('a').addClass('on');
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- },500);
|
|
|
+ }, 500);
|
|
|
this.initAuthInputComplete();
|
|
|
}
|
|
|
});
|
|
|
// 底部
|
|
|
-var globalFot = new Vue({
|
|
|
+const globalFot = new Vue({
|
|
|
el: '#globalFot',
|
|
|
mixins: [cmAiMixins],
|
|
|
data: {
|
|
|
isShowIcon: true,
|
|
|
},
|
|
|
- computed:{
|
|
|
- copyrightYear(){
|
|
|
+ computed: {
|
|
|
+ copyrightYear() {
|
|
|
let date = new Date()
|
|
|
return date.getFullYear()
|
|
|
}
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
goSupplierLink() {
|
|
|
window.location.href = '/supplier/attraction.html'
|
|
|
},
|
|
|
},
|
|
|
- mounted(){
|
|
|
+ mounted() {
|
|
|
|
|
|
}
|
|
|
-})
|
|
|
+});
|
|
|
// 初始化效果
|
|
|
$(function(){
|
|
|
// PC,H5切换时刷新
|
|
@@ -802,7 +801,7 @@ function setProductPrice(productList, productIds, userId, callback){
|
|
|
// 登录后返回登录前页面
|
|
|
function toBeforePath(){
|
|
|
var loginBeforePath = getBaseCookie("loginBeforePath");
|
|
|
- if (loginBeforePath && loginBeforePath!='undefined' && loginBeforePath.indexOf('.html')>0) {
|
|
|
+ if (loginBeforePath && loginBeforePath!=='undefined' && loginBeforePath.indexOf('.html')>0) {
|
|
|
delBaseCookie("loginBeforePath");
|
|
|
window.location.href = loginBeforePath;
|
|
|
}
|