|
@@ -17,7 +17,7 @@
|
|
<view class="text">{{item.name}}</view>
|
|
<view class="text">{{item.name}}</view>
|
|
</view>
|
|
</view>
|
|
<view class="productlist">
|
|
<view class="productlist">
|
|
- <view class="goods-pros" v-for="(pros,idx) in item.productsList" :key="idx" >
|
|
|
|
|
|
+ <view class="goods-pros" v-for="(pros,idx) in item.cartList" :key="idx" >
|
|
<view class="goods-pros-t">
|
|
<view class="goods-pros-t">
|
|
<!--选择商品-->
|
|
<!--选择商品-->
|
|
<view class="checkbox-box" @click.stop="ischeck(item,pros)" :class="[pros.validFlag == '3' && !isshowDelbtn ?'disabled' : '']">
|
|
<view class="checkbox-box" @click.stop="ischeck(item,pros)" :class="[pros.validFlag == '3' && !isshowDelbtn ?'disabled' : '']">
|
|
@@ -26,7 +26,7 @@
|
|
:class="[pros.productsChecked ?'icon-gouxuanl':'icon-weigouxuan']">
|
|
:class="[pros.productsChecked ?'icon-gouxuanl':'icon-weigouxuan']">
|
|
</button>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
- <view class="pros-img" @click.stop="navToListPage(pros.productID)" ><image :src="pros.mainImage ? pros.mainImage:''" alt="" /></view>
|
|
|
|
|
|
+ <view class="pros-img" @click.stop="navToListPage(pros.productID)" ><image :src="pros.image ? pros.image:''" alt="" /></view>
|
|
<view class="pros-product">
|
|
<view class="pros-product">
|
|
<view class="producttitle" @click.stop="navToListPage(pros.productID)" >
|
|
<view class="producttitle" @click.stop="navToListPage(pros.productID)" >
|
|
<text v-if="pros.validFlag == '3'" class="no-text">商品已下架</text>{{pros.name}}
|
|
<text v-if="pros.validFlag == '3'" class="no-text">商品已下架</text>{{pros.name}}
|
|
@@ -36,14 +36,14 @@
|
|
<!--使用过滤器对总价改变-->
|
|
<!--使用过滤器对总价改变-->
|
|
<view class="price" :class="[pros.validFlag == '3' ?'disabled' : '']">
|
|
<view class="price" :class="[pros.validFlag == '3' ?'disabled' : '']">
|
|
<text :class="[pros.validFlag == '3' ?'disabled' : 'money-sign']">¥</text>
|
|
<text :class="[pros.validFlag == '3' ?'disabled' : 'money-sign']">¥</text>
|
|
- {{pros.retailPrice?pros.retailPrice.toFixed(2):''}}
|
|
|
|
|
|
+ {{pros.price | NumFormat}}
|
|
</view>
|
|
</view>
|
|
<view class="count" v-if="pros.validFlag == '2'" :class="[isshowDelbtn ? 'none':'show']">
|
|
<view class="count" v-if="pros.validFlag == '2'" :class="[isshowDelbtn ? 'none':'show']">
|
|
- <text class="count-tips" v-if="pros.productCount<pros.minBuyNumber">起订量:{{pros.minBuyNumber}}</text>
|
|
|
|
|
|
+ <text class="count-tips" v-if="pros.number<pros.minBuyNumber">起订量:{{pros.minBuyNumber}}</text>
|
|
<text class="count-tips step" v-if="pros.isStep">购买量必须为起订量的整数倍</text>
|
|
<text class="count-tips step" v-if="pros.isStep">购买量必须为起订量的整数倍</text>
|
|
<view class="number-box">
|
|
<view class="number-box">
|
|
<view class="iconfont icon-jianhao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountSub(item,pros)"></view>
|
|
<view class="iconfont icon-jianhao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountSub(item,pros)"></view>
|
|
- <input class="btn-input" type="number" maxlength='4' v-model="pros.productCount" @blur="changeNnmber($event,item,pros)" @focus="changeInput(pros)">
|
|
|
|
|
|
+ <input class="btn-input" type="number" maxlength='4' v-model="pros.number" @blur="changeNnmber($event,item,pros)" @focus="changeInput(pros)">
|
|
<view class="iconfont icon-jiahao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountAdd(item,pros)"></view>
|
|
<view class="iconfont icon-jiahao" :class="[pros.validFlag == '3'?'disabled':'']" @click="changeCountAdd(item,pros)"></view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -126,7 +126,7 @@
|
|
import tuiNomore from "@/components/tui-components/nomore/nomore"
|
|
import tuiNomore from "@/components/tui-components/nomore/nomore"
|
|
import modalLayer from "@/components/modal-layer"
|
|
import modalLayer from "@/components/modal-layer"
|
|
import { mapState,mapMutations } from 'vuex';
|
|
import { mapState,mapMutations } from 'vuex';
|
|
- import { queryShoppingCartList,shoppingCartUpdate,shoppingCartDelete } from "@/api/cart.js"
|
|
|
|
|
|
+ import { shoppingCartUpdate,shoppingCartDelete } from "@/api/cart.js"
|
|
|
|
|
|
export default{
|
|
export default{
|
|
components:{
|
|
components:{
|
|
@@ -169,6 +169,11 @@
|
|
onLoad(){
|
|
onLoad(){
|
|
this.setScrollHeight();
|
|
this.setScrollHeight();
|
|
},
|
|
},
|
|
|
|
+ filters: {
|
|
|
|
+ NumFormat:function(text) {//处理金额
|
|
|
|
+ return Number(text).toFixed(2);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
computed: {
|
|
computed: {
|
|
...mapState(['hasLogin','userInfo'])
|
|
...mapState(['hasLogin','userInfo'])
|
|
},
|
|
},
|
|
@@ -211,18 +216,17 @@
|
|
}, 500)
|
|
}, 500)
|
|
},
|
|
},
|
|
initGetCartGoodsList(){//初始化购物车 index:1
|
|
initGetCartGoodsList(){//初始化购物车 index:1
|
|
- let params = {userID:this.userID}
|
|
|
|
- queryShoppingCartList(params).then(response =>{
|
|
|
|
|
|
+ this.ProductService.queryShoppingCartList({userId:this.userID}).then(response =>{
|
|
this.skeletonShow = false
|
|
this.skeletonShow = false
|
|
- this.$store.commit('updateAllNum',response.data.cartQuantity)
|
|
|
|
- const responseData = response.data
|
|
|
|
- if(responseData.pageDate.length > 0 || responseData.failureList.length > 0){
|
|
|
|
|
|
+ let data = response.data
|
|
|
|
+ this.$store.commit('updateAllNum',data.kindCount)
|
|
|
|
+ if( data.list.length > 0 || data.invalid.length > 0){
|
|
this.isEmpty =false
|
|
this.isEmpty =false
|
|
}else{
|
|
}else{
|
|
this.isEmpty =true
|
|
this.isEmpty =true
|
|
}
|
|
}
|
|
- if(responseData.pageDate && responseData.pageDate.length > 0 ){
|
|
|
|
- this.goodsList = responseData.pageDate;
|
|
|
|
|
|
+ if(data.list && data.list.length > 0 ){
|
|
|
|
+ this.goodsList = data.list;
|
|
this.goodsList.forEach((item,index) => {
|
|
this.goodsList.forEach((item,index) => {
|
|
let productsListLength = item.productsList.length,
|
|
let productsListLength = item.productsList.length,
|
|
invalidLength = 0;
|
|
invalidLength = 0;
|
|
@@ -231,8 +235,8 @@
|
|
pros.isStep = false
|
|
pros.isStep = false
|
|
if(pros.validFlag == '3' ) {invalidLength++;}
|
|
if(pros.validFlag == '3' ) {invalidLength++;}
|
|
if(pros.step === 2){
|
|
if(pros.step === 2){
|
|
- if(pros.productCount % pros.minBuyNumber != 0){
|
|
|
|
- pros.productCount = pros.minBuyNumber
|
|
|
|
|
|
+ if(pros.number % pros.minBuyNumber != 0){
|
|
|
|
+ pros.number = pros.minBuyNumber
|
|
this.totalShopPeice()
|
|
this.totalShopPeice()
|
|
this.updateShoppogNum(pros)
|
|
this.updateShoppogNum(pros)
|
|
}
|
|
}
|
|
@@ -261,44 +265,6 @@
|
|
this.$util.msg(error.msg,2000);
|
|
this.$util.msg(error.msg,2000);
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- getOnReachBottomData(){//上拉加载
|
|
|
|
- this.pageNum+=1
|
|
|
|
- let params = {userID:this.userID,pageNum:this.pageNum,pageSize:this.pageSize}
|
|
|
|
- queryShoppingCartList(params).then(response =>{
|
|
|
|
- let resultsData = response.data.pageDate
|
|
|
|
- this.hasNextPage = resultsData.hasNextPage;
|
|
|
|
- this.goodsList = this.goodsList.concat(resultsData.results)
|
|
|
|
- this.goodsList.forEach((item,index) => {
|
|
|
|
- let productsListLength = item.productsList.length,
|
|
|
|
- invalidLength = 0;
|
|
|
|
- item.productsList.forEach(pros => {
|
|
|
|
- pros.shopID = item.shopID;
|
|
|
|
- pros.isStep = false
|
|
|
|
- if(pros.validFlag == '3' ) {invalidLength++;}
|
|
|
|
- if(pros.step === 2){
|
|
|
|
- if(pros.productCount % pros.minBuyNumber != 0){
|
|
|
|
- pros.productCount = pros.minBuyNumber
|
|
|
|
- this.totalShopPeice()
|
|
|
|
- this.updateShoppogNum(pros)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- item.isDisabled = invalidLength === productsListLength;
|
|
|
|
- })
|
|
|
|
- this.pullFlag = false;// 防上拉暴滑
|
|
|
|
- setTimeout(()=>{this.pullFlag = true;},500)
|
|
|
|
- if(this.hasNextPage){
|
|
|
|
- this.pullUpOn = false
|
|
|
|
- this.nomoreText = '上拉显示更多'
|
|
|
|
- }else{
|
|
|
|
- this.loadding = false
|
|
|
|
- this.pullUpOn = false
|
|
|
|
- this.nomoreText = '已至底部'
|
|
|
|
- }
|
|
|
|
- }).catch(error =>{
|
|
|
|
- this.$util.msg(error.msg,2000);
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
ischeckFailure(failure){
|
|
ischeckFailure(failure){
|
|
failure.productsChecked = !failure.productsChecked
|
|
failure.productsChecked = !failure.productsChecked
|
|
this.updateCheckAllBtn()
|
|
this.updateCheckAllBtn()
|
|
@@ -401,11 +367,11 @@
|
|
let productsList=[];
|
|
let productsList=[];
|
|
this.goodsList.map((item,index)=>{
|
|
this.goodsList.map((item,index)=>{
|
|
productsList=item.productsList;
|
|
productsList=item.productsList;
|
|
- prosPrice=productsList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
|
|
|
|
|
|
+ prosPrice=productsList.reduce((p,e)=>p+e.retailPrice*e.number,0);
|
|
productsList.forEach(pros =>{
|
|
productsList.forEach(pros =>{
|
|
if(pros.validFlag =='3'){
|
|
if(pros.validFlag =='3'){
|
|
validList.push(pros)
|
|
validList.push(pros)
|
|
- validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
|
|
|
|
|
|
+ validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.number,0);
|
|
item.totalPrice = prosPrice - validPrice
|
|
item.totalPrice = prosPrice - validPrice
|
|
}else{
|
|
}else{
|
|
item.totalPrice = prosPrice
|
|
item.totalPrice = prosPrice
|
|
@@ -423,10 +389,10 @@
|
|
productsList=item.productsList;
|
|
productsList=item.productsList;
|
|
productsList.forEach(pros=>{
|
|
productsList.forEach(pros=>{
|
|
if(pros.productsChecked){
|
|
if(pros.productsChecked){
|
|
- prosPrice+=pros.retailPrice*pros.productCount;
|
|
|
|
|
|
+ prosPrice+=pros.retailPrice*pros.number;
|
|
if(pros.validFlag =='3'){
|
|
if(pros.validFlag =='3'){
|
|
validList.push(pros)
|
|
validList.push(pros)
|
|
- validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.productCount,0);
|
|
|
|
|
|
+ validPrice = validList.reduce((p,e)=>p+e.retailPrice*e.number,0);
|
|
this.allPrice = prosPrice - validPrice
|
|
this.allPrice = prosPrice - validPrice
|
|
}else{
|
|
}else{
|
|
this.allPrice = prosPrice
|
|
this.allPrice = prosPrice
|
|
@@ -445,11 +411,11 @@
|
|
productsList = item.productsList
|
|
productsList = item.productsList
|
|
productsList.forEach(pros=>{
|
|
productsList.forEach(pros=>{
|
|
if(pros.productsChecked){
|
|
if(pros.productsChecked){
|
|
- prosAllCount+=parseInt(pros.productCount);
|
|
|
|
|
|
+ prosAllCount+=parseInt(pros.number);
|
|
if(pros.validFlag =='3'){
|
|
if(pros.validFlag =='3'){
|
|
validList.push(pros)
|
|
validList.push(pros)
|
|
validList.forEach(val =>{
|
|
validList.forEach(val =>{
|
|
- validCount += val.productCount
|
|
|
|
|
|
+ validCount += val.number
|
|
})
|
|
})
|
|
this.allCount = prosAllCount - validCount
|
|
this.allCount = prosAllCount - validCount
|
|
}else{
|
|
}else{
|
|
@@ -462,11 +428,11 @@
|
|
changeCountAdd(item,pros){//商品数量加加
|
|
changeCountAdd(item,pros){//商品数量加加
|
|
if(pros.step === 2){
|
|
if(pros.step === 2){
|
|
pros.isStep = false
|
|
pros.isStep = false
|
|
- pros.productCount += pros.minBuyNumber
|
|
|
|
|
|
+ pros.number += pros.minBuyNumber
|
|
this.processActivityPrice(pros)
|
|
this.processActivityPrice(pros)
|
|
this.isStock = false
|
|
this.isStock = false
|
|
}else{
|
|
}else{
|
|
- pros.productCount++
|
|
|
|
|
|
+ pros.number++
|
|
this.processActivityPrice(pros)
|
|
this.processActivityPrice(pros)
|
|
this.isStock = false
|
|
this.isStock = false
|
|
}
|
|
}
|
|
@@ -474,16 +440,16 @@
|
|
this.totalShopPeice();
|
|
this.totalShopPeice();
|
|
},
|
|
},
|
|
changeCountSub(item,pros){//商品数量减减
|
|
changeCountSub(item,pros){//商品数量减减
|
|
- if(pros.productCount<=pros.minBuyNumber){
|
|
|
|
- pros.productCount= pros.minBuyNumber
|
|
|
|
|
|
+ if(pros.number<=pros.minBuyNumber){
|
|
|
|
+ pros.number= pros.minBuyNumber
|
|
this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
|
|
this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
|
|
return
|
|
return
|
|
}else{
|
|
}else{
|
|
if(pros.step === 2){
|
|
if(pros.step === 2){
|
|
pros.isStep = false
|
|
pros.isStep = false
|
|
- pros.productCount -= pros.minBuyNumber
|
|
|
|
|
|
+ pros.number -= pros.minBuyNumber
|
|
}else{
|
|
}else{
|
|
- pros.productCount--
|
|
|
|
|
|
+ pros.number--
|
|
}
|
|
}
|
|
this.processActivityPrice(pros)
|
|
this.processActivityPrice(pros)
|
|
}
|
|
}
|
|
@@ -497,16 +463,16 @@
|
|
|
|
|
|
let _value = Number(e.detail.value);
|
|
let _value = Number(e.detail.value);
|
|
if(!this.$api.isNumber(_value)){
|
|
if(!this.$api.isNumber(_value)){
|
|
- pros.productCount = pros.minBuyNumber
|
|
|
|
|
|
+ pros.number = pros.minBuyNumber
|
|
}else if(_value < pros.minBuyNumber){
|
|
}else if(_value < pros.minBuyNumber){
|
|
this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
|
|
this.$util.msg(`该商品最小起订量为${pros.minBuyNumber}`,2000);
|
|
- pros.productCount = pros.minBuyNumber
|
|
|
|
|
|
+ pros.number = pros.minBuyNumber
|
|
}else if(_value % pros.minBuyNumber != 0){
|
|
}else if(_value % pros.minBuyNumber != 0){
|
|
pros.isStep = true
|
|
pros.isStep = true
|
|
- pros.productCount = pros.minBuyNumber
|
|
|
|
|
|
+ pros.number = pros.minBuyNumber
|
|
}else{
|
|
}else{
|
|
pros.isStep = false
|
|
pros.isStep = false
|
|
- pros.productCount = e.detail.value
|
|
|
|
|
|
+ pros.number = e.detail.value
|
|
this.processActivityPrice(pros)
|
|
this.processActivityPrice(pros)
|
|
}
|
|
}
|
|
this.updateShoppogNum(pros)
|
|
this.updateShoppogNum(pros)
|
|
@@ -518,14 +484,14 @@
|
|
pros.retailPrice = pros.retailPrice
|
|
pros.retailPrice = pros.retailPrice
|
|
}else{
|
|
}else{
|
|
ladderPriceList.forEach((item,index)=>{
|
|
ladderPriceList.forEach((item,index)=>{
|
|
- if(pros.productCount>=item.buyNum){
|
|
|
|
|
|
+ if(pros.number>=item.buyNum){
|
|
pros.retailPrice = item.buyPrice
|
|
pros.retailPrice = item.buyPrice
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
updateShoppogNum(pros){//加减购物车商品更新到后台
|
|
updateShoppogNum(pros){//加减购物车商品更新到后台
|
|
- let params ={userID:this.userID,productID:pros.productID,productCount:pros.productCount}
|
|
|
|
|
|
+ let params ={userID:this.userID,productID:pros.productID,productCount:pros.number}
|
|
shoppingCartUpdate(params).then(response =>{
|
|
shoppingCartUpdate(params).then(response =>{
|
|
this.isshowDelbtn = false;
|
|
this.isshowDelbtn = false;
|
|
this.initGetCartGoodsList();
|
|
this.initGetCartGoodsList();
|
|
@@ -551,7 +517,7 @@
|
|
this.goodsList.forEach(el=>{
|
|
this.goodsList.forEach(el=>{
|
|
el.productsList.forEach(pros=>{
|
|
el.productsList.forEach(pros=>{
|
|
if(pros.productsChecked){
|
|
if(pros.productsChecked){
|
|
- if(pros.productCount<pros.minBuyNumber){
|
|
|
|
|
|
+ if(pros.number<pros.minBuyNumber){
|
|
this.isNoConfim = true
|
|
this.isNoConfim = true
|
|
}
|
|
}
|
|
}
|
|
}
|