Bläddra i källkod

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

zhengjinyi 4 år sedan
förälder
incheckning
1a214fc4cc

+ 1 - 0
src/main/resources/static/css/base/init.css

@@ -21,6 +21,7 @@ table,td,th{border: 1px solid #EBECEF;}
 .fl{float: left;}
 .fr{float: right;}
 .shadow{box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.07);}
+.cartAlert{text-align:left;}
 /* checkbox */
 input[type=checkbox]{width:16px;height:16px;text-align:center;outline:none;cursor:copy;}
 input[type=checkbox]:focus{outline:none}

+ 23 - 3
src/main/resources/static/css/product/list.css

@@ -22,6 +22,14 @@ li{list-style:none}
     .productList{width:1200px;margin:0 auto;box-sizing:border-box}
     .productList .productItem{margin-bottom:16px}
     .login-btn{font-size: 12px}
+    .listTitle{width:1184px;margin:0 auto 16px auto;box-sizing:border-box;padding:16px 30px;border-radius:0 0 2px 2px;background:#fc5331 url(/img/cart/promotions.png) no-repeat right;background-size:auto 100%;color:#FFF}
+    .listTitle h1{font-size:20px;line-height:42px;font-weight:normal;margin-bottom:16px}
+    .listTitle p{text-indent:1em;line-height:36px;font-size:16px}
+    .listTitle p em{color:#e15616;font-style:normal;display:inline-block;height:24px;line-height:24px;padding:0 10px;background:#FFF}
+
+
+
+
 }
 /**
 * 移动端
@@ -44,8 +52,20 @@ li{list-style:none}
     .empty img{width:40vw;height:40vw;}
     .empty a{color:#E15616;}
     .productList{width:96.6vw;margin:1.3vw auto;box-sizing:border-box}
-    .original-price{
-    text-decoration:line-through;
-}
+    .original-price{text-decoration:line-through}
+    .listTitle{width:100%;min-height:3.2vw;box-sizing:border-box;padding:3.3vw;background:#fc5331 url(/img/cart/promotions.png) no-repeat right;background-size:auto 100%;color:#FFF}
+    .listTitle h1{font-size:4vw;line-height:8vw;font-weight:normal}
+    .listTitle p{text-indent:1em;line-height:7vw;font-size:3.2vw}
+    .listTitle p em{color:#e15616;font-style:normal;display:inline-block;height:4.8vw;line-height:4.8vw;padding:0 1.5vw;background:#FFF}
+
+
+
+
+
+
+
+
+
+
 }
 

+ 1 - 0
src/main/resources/static/css/shopping/shopping.css

@@ -89,6 +89,7 @@ li{list-style:none}
     .summaryWrap .summary .right .item{position:relative;text-align:right}
     .summaryWrap .summary .right .item em{color:#f55c5c}
     .summaryWrap .summary .submit{display:inline-block;width:232px;height:50px;line-height:50px;text-align:center;background-color:#e15616;border-radius:2px;color:#FFF}
+    .summaryWrap .summary .submit.dis{background:#999;}
     .summaryWrap.fixed{position:fixed;bottom:0;left:0;margin:0;z-index:99999;box-shadow:20px 20px 102px rgba(0,0,0,0.1)}
     .summaryWrap .summary .item .del{position:absolute;right:0;top:-20px;cursor:pointer;height:24px;font-size:14px}
     .summaryWrap .summary .item .del em{position:absolute;top:-12px;height:24px;white-space:nowrap;right:0;background:#ff4500;line-height:24px;color:#FFF;padding:0 12px;border-radius:2px}

BIN
src/main/resources/static/img/cart/promotions.png


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

@@ -371,7 +371,7 @@ function updateUrlParam(params) {
     }
 }
 
-function tokenAjax(type, url, params, callback){
+function tokenAjax(type, url, params, callback, errorBack){
     $.ajax({
         type: type,
         url: spiServer + url,
@@ -392,7 +392,7 @@ function tokenAjax(type, url, params, callback){
             }
         },
         error : function (res) {
-           alertInfo("网络连接超时,请重试!")
+           alertInfo("网络连接超时,请重试!",errorBack);
         }
     });
 }

+ 3 - 5
src/main/resources/static/js/common/ajax.service.js

@@ -47,11 +47,9 @@ var Http = {
                     def.resolve(res);
                 }
             }, function(error) {
-                if(error.status == 500 || error.status == 504){
-                    CAIMEI.Alert('网络请求超时,请重试~','确定',true,function () {
-                        window.location.reload();
-                    });
-                }
+                CAIMEI.Alert('网络请求超时,请重试~','确定',true,function () {
+                    window.location.reload();
+                });
                 def.reject(error);
             });
             return def;

+ 3 - 1
src/main/resources/static/js/index.js

@@ -93,7 +93,9 @@ var homeData = new Vue({
                                 productIdArr.push(item.id)
                             }
                         });
-                        setProductPrice(_self.recommends, productIdArr.join(","), _self.userId, function () {});
+                        setProductPrice(_self.recommends, productIdArr.join(","), _self.userId, function () {
+                            _self.$forceUpdate();
+                        });
                         console.log(_self.recommends)
                     // }
                 }

+ 145 - 0
src/main/resources/static/js/product/promotions.js

@@ -0,0 +1,145 @@
+var promotionsList = new Vue({
+    el: "#promotionsList",
+    data: {
+        userId: 0,
+        listLoading: true,
+        requestFlag: true,
+        noMore: false,
+        params: {
+            id: 0,
+            size: 0,
+            num: 0
+        },
+        promotions: {},
+        listData: [],
+        listRecord: 0,
+        pageInput: '1',
+        userIdentity: '',
+        userToken: ''
+    },
+    computed: {
+        pageTotal: function () {
+            var total = Math.ceil(this.listRecord / this.params.size);
+            return total > 0 ? total : 1;
+        },
+        showPageBtn: function () {
+            var total = Math.ceil(this.listRecord / this.params.size);
+            total = total > 0 ? total : 1;
+            var index = this.params.num, arr = [];
+            if (total <= 6) {
+                for (var i = 1; i <= total; i++) {
+                    arr.push(i);
+                }
+                return arr;
+            }
+            if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
+            if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
+            return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
+        }
+    },
+    methods: {
+        toPagination: function (pageNum) {
+            if (pageNum <= this.pageTotal) {
+                var params = {pageNum: pageNum};
+                window.location.href = updateUrlParam(params);
+            }
+        },
+        checkNum: function () {
+            if (this.pageInput > this.pageTotal) {
+                this.pageInput = this.pageTotal;
+            } else if (this.pageInput < 1) {
+                this.pageInput = 1;
+            }
+        },
+        getPromotions: function(){
+            var _self = this;
+            $.getJSON(spiServer+"/product/promotion/info?promotionsId="+this.params.id, function (r) {
+                if (r.code === 0 && r.data) {
+                    _self.promotions = r.data;
+                    _self.getProductsByPromotions();
+                }else{
+                    CAIMEI.Alert("该促销活动已过期或不存在!", '确定', true, function(){
+                        window.location.href="/";
+                    });
+                }
+            })
+        },
+        getProductsByPromotions: function () {
+            var _self = this;
+            $.getJSON(spiServer+"/product/promotion/products",{
+                promotionsId: this.params.id,
+                pageSize: this.params.size,
+                pageNum: this.params.num
+            },function (r) {
+                if (r.code === 0 && r.data) {
+                    _self.listRecord = r.data.total;
+                    var resultData = r.data.list;
+                    var productIdArr = [];
+                    resultData.map(function (item) {
+                        productIdArr.push(item.id)
+                    });
+                    setProductPrice(resultData, productIdArr.join(","), _self.userId, function () {
+                        _self.$forceUpdate();
+                    });
+                    if(isPC){
+                        _self.listData = resultData;
+                    }else{
+                        _self.listData = _self.listData.concat(resultData);
+                    }
+                    console.log(_self.listData)
+                }
+                _self.listLoading = false;
+                _self.requestFlag = true;
+            })
+        }
+    },
+    created: function () {
+        if(isPC){
+            this.params.size = getUrlParam("pageSize") ? getUrlParam("pageSize") * 1 : 20;
+            this.params.num = getUrlParam("pageNum") ? getUrlParam("pageNum") * 1 : 1;
+        }else{
+            this.params.size = 10;
+            this.params.num = 1;
+        }
+        this.params.id = getUrlParam("id") ? getUrlParam("id") : 0;
+        // 搜索框赋值
+        $('#topSearch').find('[data-select]').attr("data-select", 0).text("产品");
+        $('#topSearch').find('.jqSelect').find('select').val(0);
+        $('#topSearch').find('.keyword').val(getUrlParam("keyword"));
+        if(globalUserData){
+            this.userId = globalUserData.userId;
+            this.userIdentity = globalUserData.identity;
+            this.userToken = globalUserData.token;
+        }
+        // 获取页面数据
+        this.getPromotions();
+    },
+    mounted: function () {
+        var _self = this;
+        if(!isPC){
+            $('footer').addClass("noneImportant");
+            //移动端上垃加载更多
+            $(window).on('scroll', function(){
+                var scrollTop = $(this).scrollTop();
+                var scrollHeight = $(document).height();
+                var windowHeight = window.innerHeight;
+                if (scrollTop + windowHeight >= scrollHeight) {
+                    //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
+                    var totalPage = Math.ceil(_self.listRecord / _self.params.size)?Math.ceil(_self.listRecord / _self.params.size):1;
+                    var next = _self.params.num+1;
+                    if(next <= totalPage){
+                        if (_self.requestFlag){
+                            _self.params.num = next;
+                            _self.getPromotions();
+                        }
+                        _self.requestFlag = false;
+                    }else{
+                        //到底了
+                        _self.noMore = true;
+                        $('footer').removeClass("noneImportant");
+                    }
+                }
+            });
+        }
+    }
+});

+ 15 - 7
src/main/resources/static/js/shopping/confirm.js

@@ -10,6 +10,7 @@ var shoppingConfirm = new Vue({
         kindCount: 0,
         totalCount: 0,
         totalPrice: 0,
+        reducedPrice: 0,
         address: {
             id: '',
             townId: '',
@@ -54,9 +55,9 @@ var shoppingConfirm = new Vue({
         },
         payInfo: {
             clauseId: 0,         //条款(暂时保留)
-            orderShouldPayFee: 0,//提交的总价
+            orderShouldPayFee: 0.00,//提交的总价
             balancePayFlag: 0,   //余额抵扣的状态 0不使用,1使用
-            freight: 0,          //邮费
+            freight: 0.00,          //邮费
             freePostFlag:-1      // 0包邮 -1到付 1 有运费
         },
         invoice: {
@@ -100,6 +101,7 @@ var shoppingConfirm = new Vue({
                 if (r.code === 0 && r.data) {
                     _self.listData = r.data.list;
                     _self.totalPrice =  r.data.totalPrice;
+                    _self.reducedPrice = r.data.reducedPrice;
                     _self.totalCount =  r.data.totalCount;
                     _self.kindCount = r.data.kindCount;
                     _self.balance.userMoney = r.data.userMoney;
@@ -416,7 +418,7 @@ var shoppingConfirm = new Vue({
                 clubUserId: this.userId,   // 机构用户ID
                 addressId: this.address.id,// 地址ID
                 orderInfo: [],             // 商品信息
-                payInfo: this.payInfo,     // 订单信息
+                payInfo: {},     // 订单信息
                 orderInvoice: {type: 0}    // 默认不开发票
             };
             // 发票信息
@@ -456,8 +458,13 @@ var shoppingConfirm = new Vue({
                     productInfo: productInfo
                 }
             });
-            params.payInfo.freight = toFloat(this.payInfo.freight);
-            params.payInfo.orderShouldPayFee = toFloat(this.payInfo.orderShouldPayFee);
+            params.payInfo = {
+                clauseId: 0,
+                orderShouldPayFee: toFloat(this.payInfo.orderShouldPayFee),
+                balancePayFlag: this.payInfo.balancePayFlag,
+                freight: toFloat(this.payInfo.freight),
+                freePostFlag: this.payInfo.freePostFlag
+            };
             console.log(params);
             this.submitLoading = true;
             OrderApi.ConfirmOrder({'params':JSON.stringify(params)},function (r) {
@@ -477,9 +484,10 @@ var shoppingConfirm = new Vue({
                     CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:data}));
                     window.location.href = '/pay/caimei-paycash.html?type=confirm&orderID='+r.data.orderID;
                 }else{
-                    CAIMEI.Alert(r.msg,'确定',false);
+                    CAIMEI.Alert(r.msg,'确定',true, function(){
+                        _self.submitLoading = false;
+                    });
                 }
-                _self.submitLoading = false;
             });
         }
     },

+ 3 - 1
src/main/resources/static/js/supplier/index.js

@@ -78,7 +78,9 @@ var supplierHome = new Vue({
                                 productIdArr.push(item.id)
                             }
                         });
-                        setProductPrice(r.data, productIdArr.join(","), _self.userId, function () {});
+                        setProductPrice(r.data, productIdArr.join(","), _self.userId, function () {
+                            _self.$forceUpdate();
+                        });
                     }
                     _self.mainProducts = r.data;
                 }

+ 2 - 2
src/main/resources/static/js/supplier/list.js

@@ -62,8 +62,8 @@ var supplierList = new Vue({
                     result.items.map(function (su) {
                         if(su.products && su.products.length>0) {
                             var productList = setSearchProductList(su.products, 0, function(){
-                            _self.$forceUpdate();
-                        });
+                                _self.$forceUpdate();
+                            });
                         }
                         resultData.push({
                             id: su.s_id,

+ 78 - 9
src/main/resources/templates/product/promotions.html

@@ -11,16 +11,85 @@
 <template th:replace="components/header"></template>
 
 <!-- 商品列表 -->
-<div id="promotionsList">
-    <!-- 面包屑 -->
-    <div v-else class="crumbs">
-        <a href="/">首页</a>
-        <span>&gt;</span>
-        <span>凑单商品</span>
+<div id="promotionsList" v-cloak>
+    <div class="listTitle">
+        <h1>【{{promotions.name}}】 {{promotions.description}}</h1>
+        <p><span>促销时间:</span>
+            <em v-if="promotions.status==1">不限时</em>
+            <em v-else>{{promotions.beginTime.substr(0,10)+' ~ '+promotions.endTime.substr(0,10)}}</em>
+        </p>
+        <p>下面为参与本次凑单活动的全部商品:</p>
     </div>
-    <!-- 列表数据 -->
-    <div>
-        <h1>促单满减商品</h1>
+    <!--loading-->
+    <div v-if="listLoading" class="loading">
+        <img src="/img/base/loading.gif">
+    </div>
+    <!--数据为空-->
+    <div v-else-if="!listLoading && (!listData || listData.length==0)" class="empty">
+        <img src="/img/common/empty.png">
+        <div class="msg">
+            <p>暂未找到促单的商品,去<a href="/">商城</a>,逛逛吧~</p>
+        </div>
+    </div>
+    <template v-else>
+        <!--商品列表-->
+        <ul class="productList clear mfw">
+            <li class="productItem mfc" v-for="p in listData">
+                <div class="item">
+                    <a class="image" :href="'/product-'+p.id+'.html'" target="_blank">
+                        <img :src="p.image" :alt="p.name">
+                    </a>
+                    <a class="name" :href="'/product-'+p.id+'.html'" target="_blank">
+                        <span v-html="p.name"></span>
+                    </a>
+                    <div class="price mfhc">
+                        <template v-if="GLOBAL_USER_ID && GLOBAL_USER_ID>0">
+                            <!--用户身份 0、个人 1、协销 2、会员机构 3、供应商 4,普通机构-->
+                            <template v-if="p.priceFlag==1">
+                                <em>¥价格未公开</em>
+                                <div class="btnBox">
+                                    <a href="javascript:void(0)" class="btn cat">价格未公开,请联系 0755-22907771</a>
+                                </div>
+                            </template>
+                            <template v-else>
+                                <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>
+                                <template v-else-if="p.priceFlag==2 && p.userIdentity!=2">
+                                    <em>¥会员可见</em>
+                                    <div class="btnBox">
+                                        <a href="/upgrade.html" class="btn">升级会员查看价格</a>
+                                    </div>
+                                </template>
+                                <template v-else>
+                                    <em>¥<i :class="'icon mIcon i'+p.priceGrade"></i></em>
+                                </template>
+                            </template>
+                        </template>
+                        <template v-else>
+                            <em>¥<i :class="'icon mIcon i'+p.priceGrade"></i></em>
+                            <div class="btnBox"><a href="javascript:void(0)" class="btn add toLogin">登录查看价格</a></div>
+                        </template>
+                    </div>
+                </div>
+            </li>
+        </ul>
+    </template>
+    <!--分页-->
+    <div v-if="(!isPC) && noMore" class="noMore">---- 没有更多了 ----</div>
+    <div v-if="isPC && pageTotal>1" class="pageWrap clear">
+        <a v-if="params.num>1" class="prev" @click="toPagination(params.num*1-1)" href="javascript:void(0);"></a>
+        <template v-for="n in showPageBtn">
+            <a v-if="n" :class="{'on':(n==params.num)}" @click="toPagination(n)" href="javascript:void(0);" v-text="n"></a>
+            <span v-else>···</span>
+        </template>
+        <a v-if="params.num<pageTotal" class="next" @click="toPagination(params.num*1+1)" href="javascript:void(0);"></a>
+        <span>共<b v-text="pageTotal>1?pageTotal:1"></b>页</span>
+        <span>跳至</span>
+        <input v-model="pageInput" @blur="checkNum()"/>
+        <span>页</span>&nbsp;
+        <a class="btn" href="javascript:void(0);" @click="toPagination(pageInput)">点击跳转</a>
     </div>
 </div>
 <!-- 引入底部 -->

+ 3 - 2
src/main/resources/templates/shopping/confirm.html

@@ -287,7 +287,8 @@
                 <span v-if="payInfo.freePostFlag==0">包邮</span>
                 <span v-if="payInfo.freePostFlag==1"><em>¥{{payInfo.freight | NumFormat}}</em></span>
             </p>
-            <p v-if="balance.deductMoney>0">抵扣账户余额: <span><em>¥{{balance.deductMoney | NumFormat}}</em></span></p>
+            <p v-if="reducedPrice>0">促销满减: <span><em>- ¥{{reducedPrice | NumFormat}}</em></span></p>
+            <p v-if="balance.deductMoney>0">抵扣账户余额: <span><em>- ¥{{balance.deductMoney | NumFormat}}</em></span></p>
             <p>总价: <span><em>¥{{payInfo.orderShouldPayFee | NumFormat}}</em></span></p>
         </div>
     </div>
@@ -301,7 +302,7 @@
             </div>
             <div class="right mfbt">
                 <div class="item">总价:<em v-text="'¥'+toFloat(totalPrice)"></em></div>
-                <a class="submit" href="javascript:void(0);" @click="submitOrder()">提交订单</a>
+                <a :class="submitLoading?'submit dis':'submit'" href="javascript:void(0);" @click="submitOrder()">提交订单</a>
             </div>
         </div>
     </div>