Browse Source

Merge remote-tracking branch 'origin/developerB' into developerB

zhengjinyi 4 years ago
parent
commit
d26f213b16

+ 6 - 3
src/main/java/com/caimei/www/config/CustomExceptionHandler.java

@@ -1,7 +1,9 @@
 package com.caimei.www.config;
 
+import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
 import reactor.core.publisher.Mono;
 
 /**
@@ -10,17 +12,18 @@ import reactor.core.publisher.Mono;
  * @author : Charles
  * @date : 2020/8/7
  */
-@RestControllerAdvice
+@ControllerAdvice
 public class CustomExceptionHandler {
 
     @ExceptionHandler(Exception.class)
     public String convertExceptionMsg(Exception e) {
         //自定义逻辑,可返回其他值
         e.printStackTrace();
-        return "404";
+        return "error/404";
     }
 
     @ExceptionHandler(IllegalAccessException.class)
+    @ResponseBody
     public Mono<String> convertIllegalAccessError(Exception e) {
         //自定义逻辑,可返回其他值
         return Mono.just("illegal access");

+ 0 - 1
src/main/resources/static/css/user-center/setting/information.css

@@ -12,7 +12,6 @@ li{list-style:none}
 .subLine .btn-upgrade.none{border: 1px solid #E15616;background-color: #ffe6dc;box-shadow: 0px 3px 6px 0px rgba(249, 75, 75, 0.17);color: #e15616;}
 .subLine .btn-upgrade.disabled{background-color: #999999;}
 .formLine{width: 100%;float: left;margin-bottom: 10px;}
-.formLine .address textarea{margin-top: 0;}
 .formLine .form-upload{width: 128px;height: auto;float: left;margin-right: 20px;}
 .formLine .formLine-file{width: 128px;height: 90px;position: relative;}
 .formLine .form-upload-tips{width: 20px;height: 90px;float: left;position: relative;}

+ 18 - 26
src/main/resources/static/js/account/login.js

@@ -74,7 +74,6 @@ var loginPage = new Vue({
                 }else {
                     clearTimeout(timer); //清理定时任务
                     if(response.code == 0){
-                        var _userIdentity = response.data.userIdentity;
                         _self.userData = {
                             account: response.data.account,
                             email: response.data.email,
@@ -91,18 +90,15 @@ var loginPage = new Vue({
                         };
                         _self.setStorages( _self.userData);
                         // 登录成功页面跳转
-                        var forwardUrl = document.referrer;
-                        var getHrefUrl = $("#spiServer").val();
-                        if (forwardUrl && forwardUrl!=getHrefUrl){
-                            window.location.href = forwardUrl;
-                        }else{
-                            if(_userIdentity == 4 || _userIdentity ==2){
-                                window.location.href = '/user/dashboard.html';
-                            }else if(_userIdentity == 3){
-                                window.location.href = '/supplier/dashboard.html';
-                            }else{
-                                window.location.href="/index.html";
-                            }
+                        var loginBeforePath = getCookie("loginBeforePath");
+                        if (loginBeforePath) {
+                            window.location.href = loginBeforePath;
+                        } else if (_self.userData.userIdentity*1 === 3) {
+                            location.href = '/supplier/dashboard.html';
+                        } else if (_self.userData.userIdentity*1 === 2 || _self.userData.userIdentity*1 === 4) {
+                            location.href = '/user/dashboard.html';
+                        } else {
+                            location.href="/index.html";
                         }
                     }else if(response.code == -4){
                         window.location.href = '/bind.html';
@@ -139,7 +135,6 @@ var loginPage = new Vue({
                 UserApi.PostLoginAccount(params,function(response){
                     _self.loginLoading = false;
                     if(response.code === 0){
-                        var _userIdentity = response.data.userIdentity;
                         _self.userData = {
                             account: response.data.account,
                             email: response.data.email,
@@ -156,18 +151,15 @@ var loginPage = new Vue({
                         };
                         _self.setStorages( _self.userData);
                         // 登录成功页面跳转
-                        var forwardUrl = document.referrer;
-                        var getHrefUrl = $("#spiServer").val();
-                        if (forwardUrl && forwardUrl!=getHrefUrl){
-                            window.location.href = forwardUrl;
-                        }else{
-                            if(_userIdentity == 4 || _userIdentity ==2){
-                                window.location.href = '/user/dashboard.html';
-                            }else if(_userIdentity == 3){
-                                window.location.href = '/supplier/dashboard.html';
-                            }else{
-                                window.location.href="/index.html";
-                            }
+                        var loginBeforePath = getCookie("loginBeforePath");
+                        if (loginBeforePath) {
+                            window.location.href = loginBeforePath;
+                        } else if (_self.userData.userIdentity*1 === 3) {
+                            location.href = '/supplier/dashboard.html';
+                        } else if (_self.userData.userIdentity*1 === 2 || _self.userData.userIdentity*1 === 4) {
+                            location.href = '/user/dashboard.html';
+                        } else {
+                            location.href="/index.html";
                         }
                     } else {// 登录失败
                         CAIMEI.Alert(response.msg,'确定',false);

+ 40 - 15
src/main/resources/static/js/base.js

@@ -9,19 +9,22 @@ if(localStorage.getItem('userInfo')){
     globalUserData = JSON.parse(localStorage.getItem('userInfo'));
     GLOBAL_TOKEN = globalUserData.token;
     GLOBAL_USER_ID = globalUserData.userId;
-    GLOBAL_USER_IDENTITY = globalUserData.identity ? globalUserData.identity : globalUserData.userIdentity;
+    GLOBAL_USER_IDENTITY = globalUserData.userIdentity;
     GLOBAL_SHOP_ID = globalUserData.shopId;
 } else {
-    var userAgent = navigator.userAgent.toLowerCase();
-    if (userAgent.match(/MicroMessenger/i)) {
-        // 微信浏览器自动授权登录
-        var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
-        $.get(spiServer+'/user/authorizationLink?redirectUri='+urlForWeChat, function(r){
-            if(r.code===0 && r.data){
-                localStorage.setItem("loginBeforePath", window.location.href);
-                window.location.href = r.data;
-            }
-        });
+    if(!getCookie("weChatAutoLogin")){
+        var userAgent = navigator.userAgent.toLowerCase();
+        if (userAgent.match(/MicroMessenger/i)) {
+            // 微信浏览器自动授权登录
+            var urlForWeChat = 'https://www.caimei365.com/we_chat/redirect_uri.html';
+            $.get(spiServer+'/user/authorizationLink?redirectUri='+urlForWeChat, function(r){
+                if(r.code===0 && r.data){
+                    setCookie("loginBeforePath", window.location.href);
+                    setCookie("weChatAutoLogin", 1);
+                    window.location.href = r.data;
+                }
+            });
+        }
     }
 }
 // 头部
@@ -75,6 +78,8 @@ var globalHead = new Vue({
                 if (r.code === 0 && r.data) {
                     _self.headCart.cartList = r.data;
                     _self.headCart.cartCount = r.data.length;
+                    _self.headCart.productCount = 0;
+                    _self.headCart.priceTotal = 0;
                     r.data.map(function(item){
                         _self.headCart.productCount += item.number;
                         _self.headCart.priceTotal += item.number*item.price;
@@ -191,7 +196,7 @@ $(function(){
                     text: btnTxt,
                     btnClass: 'btn-confirm-login',
                     action: function(){
-                        localStorage.setItem("loginBeforePath", window.location.href);
+                        setCookie("loginBeforePath", window.location.href);
                         window.location.href = '/login.html';
                     }
                 },
@@ -205,7 +210,7 @@ $(function(){
     // 去登录弹窗
     $('body').on("click", '.toLogin',function () {
         //loginAert('<span>你还未登录</span><span>请登录后再进行购买</span>', '去登录');
-        localStorage.setItem("loginBeforePath", window.location.href);
+        setCookie("loginBeforePath", window.location.href);
         window.location.href = '/login.html';
     });
     // 退出登录
@@ -319,6 +324,25 @@ $(function(){
 
 });
 // 公共方法
+function setCookie(cname,cvalue,exdays){
+    if (exdays) {
+        var d = new Date();
+        d.setTime(d.getTime()+(exdays*24*60*60*1000));
+        var expires = "expires="+d.toGMTString();
+        document.cookie = cname+"="+cvalue+"; path=/; "+expires;
+    } else {
+        document.cookie = cname+"="+cvalue+"; path=/";
+    }
+}
+function getCookie(cname){
+    var name = cname + "=";
+    var ca = document.cookie.split(';');
+    for(var i=0; i<ca.length; i++) {
+        var c = ca[i].trim();
+        if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
+    }
+    return "";
+}
 function getDateStr(dd, addCount) {
     dd.setDate(dd.getDate() + addCount);//获取addCount天后的日期
     var y = dd.getFullYear();
@@ -533,14 +557,15 @@ function setProductPrice(productList, productIds, userId, callback){
 }
 // 登录后返回登录前页面
 function toBeforePath(){
-    var beforePath = localStorage.getItem("loginBeforePath");
+    var beforePath = getCookie("loginBeforePath");
     if (!beforePath) {
         beforePath = '/index.html';
     }
     window.location.href = beforePath;
 }
 function toLogin() {//去登录
-    window.location.href ='/login.html';
+    setCookie("loginBeforePath", window.location.href);
+    window.location.href = '/login.html';
 }
 function  upgrade () { //升级会员
     window.location.href='';

+ 3 - 4
src/main/resources/static/js/product/detail.js

@@ -3,7 +3,6 @@ var productDetail = new Vue({
     data: {
         productId: 0,
         userId: 0,
-        userIdentity: '', //2-会员机构;3-供应商;4-普通机构
         number: 0,
         productStock: 0,
         images: [],
@@ -18,7 +17,7 @@ var productDetail = new Vue({
             promotions: '',
             step: 1,
             supplierId: 0,
-            userIdentity: 0
+            userIdentity: 0 //2-会员机构;3-供应商;4-普通机构
         },
         ladderList:[],//阶梯价
         promotions:{},//促销活动信息
@@ -153,7 +152,8 @@ var productDetail = new Vue({
             }
         },
         toLogin: function() {
-            location.href ='/login.html';
+            setCookie("loginBeforePath", window.location.href);
+            window.location.href = '/login.html';
         },
 		addShopCart: function(){ //加入购物车
 		    var _self = this;
@@ -219,7 +219,6 @@ var productDetail = new Vue({
     },
     mounted: function () {
         this.userId = GLOBAL_USER_ID;
-        this.userIdentity = GLOBAL_USER_IDENTITY;
         this.getProductPrice();
         this.getParameters();
         this.getRecommends();

+ 24 - 8
src/main/resources/static/js/supplier-center/setting/information.js

@@ -23,6 +23,11 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
             nature:'',//公司性质
             turnover:'',//年营业额
         },
+        form:{
+            townID:'',
+            provinceID: '',//省id
+            cityID: '',
+        },
         params2:{
             userID:'',
             shopID:'',
@@ -123,6 +128,12 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
                     _this.params3.certificateHonor = shop.hygienicLicense;
                     _this.HonorImagesList = res.data.certificateHonor;
                     _this.productImagesList = res.data.productCertification;
+                    if(shop.cityID!=''&&shop.cityID!=null){
+                        _this.getcity()
+                    }
+                    if(shop.townID!=''&&shop.townID!=null){
+                        _this.getcTown();
+                    }
                 }
              })
          },
@@ -307,12 +318,14 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
          province:function () {
            var _this = this;
            _this.params.provinceID = event.target.value;
-            if(_this.params.provinceID==''){//省为请选择时市区初始化
+            if(_this.params.provinceID==0){//省为请选择时市区初始化
                 _this.cityArray=[];
                 _this.townArray=[];
-                _this.params.townID=''
+                _this.params.townID=0;
+                _this.params.cityID = 0;
             }else {
               _this.getcity();
+              _this.params.cityID = 0;
             }
         },
         getcity:function(event){//加载市
@@ -321,10 +334,12 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
                  if(response.code == 0 ){
                     _this.cityArray = response.data;
                      _this.params.cityID = event.target.value;
-                     if(_this.params.cityID==''){
+                     if(_this.params.cityID==0){
                            _this.townArray=[];
+                           _this.params.townID = 0;
                      }else {
                          _this.getcTown();
+                          _this.params.townID = 0;
                      }
                 }
             })
@@ -335,7 +350,6 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
                 if(response.code == 0 ){
                     _this.townArray = response.data;
                     _this.params.townID = event.target.value;
-                    console.log(_this.params.townID)
                 }else{
                     CAIMEI.Alert(response.msg, '确定', false);
                 }
@@ -349,11 +363,13 @@ jqMultipleShow("click", ".navList", ".tab", ".con");
             return newArr
         },
         setNewScope:function(arr){//回显处理主营内容
+            if (arr!=null){
             var newArr = [];
-            arr.split('/').forEach(function(item){
-                newArr.push(item);
-            });
-            return newArr
+                arr.split('/').forEach(function(item){
+                    newArr.push(item);
+                });
+                return newArr
+            }
         },
     },
     mounted:function () {

+ 2 - 1
src/main/resources/static/js/supplier-center/setting/password.js

@@ -219,5 +219,6 @@ var passwordPage = new Vue({
         var _self = this;
         $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
         $('.navLayout').find('.navList').eq(3).addClass("on").find('.con').show().find('a').eq(0).addClass("on");
-    }
+
+         }
 });

+ 1 - 20
src/main/resources/static/js/user-center/setting/upgrade.js

@@ -222,16 +222,7 @@ var upgradePage = new Vue({
                 }
             })
         },
-        GetProvinceFn: function(){//获取全部省份
-            var _self = this;
-            PublicApi.GetProvince({},function(response){
-                if(response.code == 0){
-                    _self.ProvinceList =response.data;
-                }else{
-                    CAIMEI.Alert(response.msg,'确定',false);
-                }
-            })
-        },
+
         ChangeProvince:function () {//选择省份
             var _self = this;
             _self.addressfrom.provinceID = event.target.value;
@@ -258,16 +249,6 @@ var upgradePage = new Vue({
             var _self = this;
             _self.clubUpgradeUser.townID = event.target.value;
         },
-        GetProvinceFn: function(){//获取全部省份
-            var _self = this;
-            PublicApi.GetProvince({},function(response){
-                if(response.code == 0){
-                    _self.ProvinceList =response.data;
-                }else{
-                    CAIMEI.Alert(response.msg,'确定',false);
-                }
-            })
-        },
         GetCtiyFn: function(){//获取市
             var _self = this;
             PublicApi.GetCity({ provinceId: _self.addressfrom.provinceID },function(response){

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

@@ -17,7 +17,8 @@
                 </div>
             </li>
             <li v-if="loginStatus" id="mGlobalMenu" @click="hideGlobalMenu()">
-                <a class="cTab" href="javascript:void(0);" v-text="userData.userName"></a>
+                <a class="cTab" href="javascript:void(0);" v-if="userIdentity == 3" v-text="userData.name"></a>
+                <a class="cTab" href="javascript:void(0);" v-else v-text="userData.userName"></a>
                 <div class="cShow" v-if="userIdentity == 4 || userIdentity == 2">
                     <a href="/user/dashboard.html">我的采美</a>
                     <a href="/user/setting/information.html">机构资料</a>

+ 1 - 1
src/main/resources/templates/index.html

@@ -75,7 +75,7 @@
                                             </div>
                                         </template>
                                         <template v-else>
-                                            <template v-if="p.priceFlag==0 || p.userIdentity==2 || (p.userIdentity==3 && p.supplierId==GLOBAL_SHOP_ID)">
+                                            <template v-if="p.priceFlag==0 && p.userIdentity==2 || (p.userIdentity==3 && p.supplierId==GLOBAL_SHOP_ID)">
                                                 <em class="p" v-text="'¥'+parseFloat(p.price).toFixed(2)"></em>
                                                 <span class="listTag" v-if="p.actStatus==1">{{p.promotions.name}}</span>
                                             </template>

+ 9 - 4
src/main/resources/templates/product/detail.html

@@ -71,7 +71,7 @@
                         </div>
                     </template>
                     <div class="row" v-if="priceObj.actStatus==1||priceObj.ladderPriceFlag==1" ><span class="l">促销</span><i>:</i>
-                        <template v-if="GLOBAL_USER_ID && GLOBAL_USER_ID>0">
+                        <template v-if="GLOBAL_USER_ID && GLOBAL_USER_ID>0 && (priceObj.priceFlag==0 || (priceObj.priceFlag==2 && priceObj.userIdentity==2) || (priceObj.userIdentity==3 && priceObj.supplierId==GLOBAL_SHOP_ID))">
                             <!-- 阶梯价 -->
                             <div v-if="priceObj.ladderPriceFlag==1" class="priceTag">
                                 <i class="tag icon mIcon" @click="toggleThisLadder($event)">阶梯价格</i>
@@ -120,11 +120,16 @@
                                 <i v-if="priceObj.ladderPriceFlag==1" class="tag icon mIcon" @click="toggleThisLadder($event)">阶梯价格</i>
                                 <i v-if="priceObj.actStatus==1" class="tag icon mIcon" @click="toggleThisLadder($event)" v-text="promotions?promotions.name:''"></i>
                                 <div class="promotion mFixed">
-                                    <div>
+                                    <div v-if="!GLOBAL_USER_ID">
                                         <p v-if="priceObj.ladderPriceFlag==1"><em @click="toLogin">登录</em>,享受阶梯价格优惠</p>
                                         <p v-if="priceObj.actStatus==1"><em @click="toLogin">登录</em>,参与促销活动</p>
                                         <p class="c"><a class="close" @click="hideThisLadder($event)" href="JavaScript:void(0);">了解</a></p>
                                     </div>
+                                    <div v-else>
+                                        <p v-if="priceObj.ladderPriceFlag==1"><em @click="toLogin">升级会员</em>,享受阶梯价格优惠</p>
+                                        <p v-if="priceObj.actStatus==1"><em @click="toLogin">升级会员</em>,参与促销活动</p>
+                                        <p class="c"><a class="close" @click="hideThisLadder($event)" href="JavaScript:void(0);">了解</a></p>
+                                    </div>
                                 </div>
                             </div>
                         </template>
@@ -150,10 +155,10 @@
                     </div>
                 </div>
                <template v-if="GLOBAL_USER_ID && GLOBAL_USER_ID>0">
-                   <div  class="btnBox" v-if="priceObj.priceFlag==2 && userIdentity!=2">
+                   <div  class="btnBox" v-if="priceObj.priceFlag==2 && priceObj.userIdentity!=2">
                       <a class="upgrade" href="/user/setting/upgrade.html">升级会员查看价格</a>
                    </div>
-                    <div class="btnBox" v-else-if="priceObj.priceFlag==0 || (priceObj.priceFlag==2 && userIdentity==2)">
+                    <div class="btnBox" v-else-if="priceObj.priceFlag==0 || (priceObj.priceFlag==2 && priceObj.userIdentity==2)">
                         <a href="javascript:void(0);" class="cart icon" @click='addShopCart()'>加入购物车</a>
                         <a href="javascript:void(0);" class="buy" @click="buyNowSubmit()">立即购买</a>
                     </div>

+ 6 - 6
src/main/resources/templates/supplier-center/setting/information.html

@@ -53,16 +53,16 @@
                             </div>
                             <div class="formLine" >
                                 <p><em>*</em>公司地址:</p>
-                                 <select name="provinceID" id="cProvince" @change="province">
-                                     <option value="">请选择</option>
+                                 <select name="provinceID" id="cProvince" @change="province" v-model="params.provinceID">
+                                     <option value="0">请选择</option>
                                      <option v-for="item in provinceArray" :value="item.provinceID">{{item.name}}</option>
                                  </select>
-                                 <select name="cityID" id="cityID" @change="getcity($event)">
-                                     <option value="">请选择</option>
+                                 <select name="cityID" id="cityID" @change="getcity($event)" v-model="params.cityID">
+                                     <option value="0"  selected="">请选择</option>
                                      <option v-for="(item ,index) in cityArray" :key="index" :value="item.cityID">{{item.name}}</option>
                                  </select>
-                                 <select name="townID" id="townID" @change="getcTown($event)">
-                                     <option value="">请选择</option>
+                                 <select name="townID" id="townID" @change="getcTown($event)" v-model="params.townID">
+                                     <option value="0">请选择</option>
                                      <option v-for="(item ,index) in townArray" :key="index" :value="item.townID" >{{item.name}}</option>
                                  </select>
                                  <textarea placeholder="建议您如实填写详细地址,例如:街道名称,门牌号码,楼层和房间号等信息"  v-model="params.address" maxlength="25"></textarea>

+ 1 - 1
src/main/resources/templates/supplier-center/setting/password.html

@@ -123,6 +123,6 @@
 <template th:replace="components/footer"></template>
 <template th:replace="components/foot-link"></template>
 <script charset="utf-8" type="text/javascript" th:src="@{/js/common/serviceapi/user.service.js(v=${version})}"></script>
-<script charset="utf-8" type="text/javascript" th:src="@{/js/user-center/setting/password.js(v=${version})}"></script>
+<script charset="utf-8" type="text/javascript" th:src="@{/js/supplier-center/setting/password.js(v=${version})}"></script>
 </body>
 </html>

+ 1 - 1
src/main/resources/templates/we_chat/redirect_uri.html

@@ -29,7 +29,7 @@
                 token: r.data.token
             };
             localStorage.setItem('userInfo',JSON.stringify(userData));
-            var loginBeforePath = sessionStorage.getItem("loginBeforePath");
+            var loginBeforePath = getCookie("loginBeforePath");
             if (loginBeforePath) {
                 window.location.href = loginBeforePath;
             } else if (userData.userIdentity*1 === 3) {