ソースを参照

AI助手、微信登录调整

zhengjinyi 10 ヶ月 前
コミット
a2ba17045e

+ 93 - 93
src/main/java/com/caimei/www/controller/BaseController.java

@@ -1,93 +1,93 @@
-package com.caimei.www.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.caimei.www.pojo.page.BaseLink;
-import com.caimei.www.pojo.page.TopMenu;
-import com.caimei.www.service.page.BaseService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ModelAttribute;
-
-import java.util.List;
-
-/**
- * 页面全局变量
- *
- * @author : Charles
- * @date : 2020/6/18
- */
-@Controller
-public class BaseController {
-	@Value("${caimei.coreServer}")
-	private String coreServer;
-	@Value("${caimei.zplmDomain}")
-	private String zplmDomain;
-	@Value("${caimei.zplmServer}")
-	private String zplmServer;
-	@Value("${aliyunOss.ossBucket}")
-	private String ossBucket;
-    /** 打包时间 */
-    @Value("${caimei.siteEnv}")
-    private String siteEnv;
-    /** 打包时间 */
-    @Value("${spring.application.build-time}")
-    private String buildTime;
-    /** 错误页面 */
-	private static final String ERROR_PATH = "error/404";
-
-    public BaseService baseService;
-    @Autowired
-    public void setBaseService(BaseService baseService) {
-        this.baseService = baseService;
-    }
-
-	/**
-	 * 页面公共请求
-	 * @param model
-	 * @param request
-	 * @return
-	 */
-	@ModelAttribute
-	public Model init(final Model model, ServerHttpRequest request) {
-		// 环境变量,(2:正式环境,1:测试环境,0:开发环境)
-	    model.addAttribute("siteEnv", siteEnv);
-		// 判断请求设备
-		List<String> strings = request.getHeaders().get("User-Agent");
-		String agent = strings!=null ? strings.get(0) : "";
-		model.addAttribute("agent", agent);
-	    // 静态文件版本号
-	    model.addAttribute("version", buildTime);
-		// spi服务器地址
-		model.addAttribute("coreServer", coreServer);
-		// zplm服务器地址
-		model.addAttribute("zplmDomain", zplmDomain);
-		// zplm接口地址
-		model.addAttribute("zplmServer", zplmServer);
-		// 阿里云oss对象存储文件上传目录
-		model.addAttribute("ossBucket", ossBucket);
-		// 搜索热门关键字
-		List<String> searchHotWord = baseService.getSearchHotWord();
-		model.addAttribute("searchHotWord", searchHotWord);
-		// 头部菜单
-		List<TopMenu> menuList = baseService.getNavMenu();
-		model.addAttribute("topMenuList", menuList);
-		// 分类菜单
-		List<JSONObject> classifyList = baseService.getClassifyJson();
-		model.addAttribute("classifyJson", classifyList);
-		// 底部帮助页
-		List<BaseLink> helpPages = baseService.getHelpPages();
-		model.addAttribute("helpPages", helpPages);
-		// 友情链接
-		List<BaseLink> friendLinks = baseService.getFriendLinks();
-		model.addAttribute("friendLinks", friendLinks);
-
-		return model;
-	}
-
-	protected String errorPath(){
-		return ERROR_PATH;
-	}
-}
+package com.caimei.www.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.www.pojo.page.BaseLink;
+import com.caimei.www.pojo.page.TopMenu;
+import com.caimei.www.service.page.BaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+
+import java.util.List;
+
+/**
+ * 页面全局变量
+ *
+ * @author : Charles
+ * @date : 2020/6/18
+ */
+@Controller
+public class BaseController {
+	@Value("${caimei.coreServer}")
+	private String coreServer;
+	@Value("${caimei.zplmDomain}")
+	private String zplmDomain;
+	@Value("${caimei.zplmServer}")
+	private String zplmServer;
+	@Value("${aliyunOss.ossBucket}")
+	private String ossBucket;
+    /** 打包时间 */
+    @Value("${caimei.siteEnv}")
+    private String siteEnv;
+    /** 打包时间 */
+    @Value("${spring.application.build-time}")
+    private String buildTime;
+    /** 错误页面 */
+	private static final String ERROR_PATH = "error/404";
+
+    public BaseService baseService;
+    @Autowired
+    public void setBaseService(BaseService baseService) {
+        this.baseService = baseService;
+    }
+
+	/**
+	 * 页面公共请求
+	 * @param model
+	 * @param request
+	 * @return
+	 */
+	@ModelAttribute
+	public Model init(final Model model, ServerHttpRequest request) {
+		// 环境变量,(2:正式环境,1:测试环境,0:开发环境)
+	    model.addAttribute("siteEnv", siteEnv);
+		// 判断请求设备
+		List<String> strings = request.getHeaders().get("User-Agent");
+		String agent = strings!=null ? strings.get(0) : "";
+		model.addAttribute("agent", agent);
+	    // 静态文件版本号
+	    model.addAttribute("version", buildTime);
+		// spi服务器地址
+		model.addAttribute("coreServer", coreServer);
+		// zplm服务器地址
+		model.addAttribute("zplmDomain", zplmDomain);
+		// zplm接口地址
+		model.addAttribute("zplmServer", zplmServer);
+		// 阿里云oss对象存储文件上传目录
+		model.addAttribute("ossBucket", ossBucket);
+		// 搜索热门关键字
+		List<String> searchHotWord = baseService.getSearchHotWord();
+		model.addAttribute("searchHotWord", searchHotWord);
+		// 头部菜单
+		List<TopMenu> menuList = baseService.getNavMenu();
+		model.addAttribute("topMenuList", menuList);
+		// 分类菜单
+		List<JSONObject> classifyList = baseService.getClassifyJson();
+		model.addAttribute("classifyJson", classifyList);
+		// 底部帮助页
+		List<BaseLink> helpPages = baseService.getHelpPages();
+		model.addAttribute("helpPages", helpPages);
+		// 友情链接
+		List<BaseLink> friendLinks = baseService.getFriendLinks();
+		model.addAttribute("friendLinks", friendLinks);
+
+		return model;
+	}
+
+	protected String errorPath(){
+		return ERROR_PATH;
+	}
+}

+ 25 - 0
src/main/resources/static/js/anonymous/anonymous.js

@@ -0,0 +1,25 @@
+const siteEnv = $("#siteEnv").val();
+console.log('siteEnv',siteEnv)
+if(siteEnv === 2){
+    function onWindowResize() {
+        const width = window.innerWidth;
+        const height = window.innerHeight;
+        console.log('新的窗口宽度:', width, 'px')
+        console.log('新的窗口高度:', height, 'px')
+        debugger
+        window.location.href = 'about:blank';
+    }
+    window.addEventListener('resize', onWindowResize);
+    let resizeTimeout;
+    function onWindowResizeThrottled() {
+        if (resizeTimeout) {
+            clearTimeout(resizeTimeout);
+        }
+        resizeTimeout = setTimeout(function() {
+            onWindowResize();
+        }, 250);
+    }
+    window.removeEventListener('resize', onWindowResize)
+    window.addEventListener('resize', onWindowResizeThrottled)
+}
+

+ 113 - 113
src/main/resources/static/js/base.js

@@ -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;
@@ -52,7 +52,7 @@ if(localStorage.getItem('userInfo')){
     // }
 }
 // 头部
-var globalHead = new Vue({
+const globalHead = new Vue({
     el: '#globalHead',
     data: {
         loginStatus: false,
@@ -64,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: '美业参谋',
@@ -94,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");
@@ -116,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() {
@@ -232,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';
                 }
             });
         },
@@ -299,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*600);
+                }, 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切换时刷新
@@ -801,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;
     }

+ 1 - 0
src/main/resources/templates/components/foot-link.html

@@ -6,6 +6,7 @@
 <script charset="utf-8" type="text/javascript" src="/lib/vue2.6.12.min.js"></script>
 <script charset="utf-8" type="text/javascript" src="/lib/lazyload.js"></script>
 <script charset="utf-8" type="text/javascript" src="/lib/element-ui/element-ui.min.js"></script>
+<script charset="utf-8" type="text/javascript" th:src="@{/js/anonymous/anonymous.js(v=${version})}"></script>
 <script charset="utf-8" type="text/javascript" th:src="@{/js/common/ajax.service.js(v=${version})}"></script>
 <script charset="utf-8" type="text/javascript" th:src="@{/js/common/serviceapi/utils.service.js(v=${version})}"></script>
 <script charset="utf-8" type="text/javascript" th:src="@{/js/common/serviceapi/shopping.service.js(v=${version})}"></script>

+ 1 - 0
src/main/resources/templates/components/header.html

@@ -269,6 +269,7 @@
             </div>
         </div>
     </div>
+    <input type="hidden" th:value="${siteEnv}" id="siteEnv">
     <input type="hidden" th:value="${coreServer}" id="coreServer">
     <input type="hidden" th:value="${agent}" id="userAgent">
 </header>