|
|
|
@ -3,16 +3,16 @@ |
|
|
|
<uni-nav-bar :statusBar="true" left-icon="left" title="Shipping Cart" color="#000000" :fixed="true" @clickLeft="back"> |
|
|
|
<block slot="right"> |
|
|
|
<view class="nav_right"> |
|
|
|
<image src="../../static/img/delete1.png" mode=""></image> |
|
|
|
<image src="../../static/img/delete1.png" mode="" @click="deleteCart"></image> |
|
|
|
</view> |
|
|
|
</block> |
|
|
|
</uni-nav-bar> |
|
|
|
<view class="empty" v-if="isEmpty"> |
|
|
|
<view class="empty" v-if="goods_list.length==0"> |
|
|
|
<image src="/static/img/cart3.png" mode=""></image> |
|
|
|
<text>Your cart is empty</text> |
|
|
|
<button>Shop Now</button> |
|
|
|
</view> |
|
|
|
<template v-if="!isEmpty"> |
|
|
|
<template v-else> |
|
|
|
<view class="cart_info"> |
|
|
|
<image src="/static/img/Shipped.png" mode=""></image> |
|
|
|
<view class="cart_title_content">Buy US$32.00 more to enjoy FREE STANDARD SHIPPING!</view> |
|
|
|
@ -20,9 +20,9 @@ |
|
|
|
</view> |
|
|
|
<view class="cart"> |
|
|
|
<view class="cart_content"> |
|
|
|
<view class="good_info" v-for="(item,index) in goods_list " :key="item.rec_id"> |
|
|
|
<image src="../../static/img/select1.png" mode="" class="cart_select" v-show="is_check==1"></image> |
|
|
|
<image src="../../static/img/select2.png" mode="" class="cart_select" v-show="is_check==0"></image> |
|
|
|
<view class="good_info" v-for="(item,index) in goods_list" :key="item.rec_id"> |
|
|
|
<image src="../../static/img/select1.png" mode="" class="cart_select" v-show="item.is_check==1" @click="cartCheck(1,0,item.rec_id,index)"></image> |
|
|
|
<image src="../../static/img/select2.png" mode="" class="cart_select" v-show="item.is_check==0" @click="cartCheck(1,1,item.rec_id,index)"></image> |
|
|
|
<view class="good_info_left "> |
|
|
|
<view class="good_info_image"> |
|
|
|
<image :src="item.goods_thumb" mode=""></image> |
|
|
|
@ -37,7 +37,7 @@ |
|
|
|
</view> |
|
|
|
<view class="info_price"> |
|
|
|
<text>US${{item.goods_price}}</text> |
|
|
|
<uni-number-box background="#FFFFFF">{{item.goods_number}}</uni-number-box> |
|
|
|
<uni-number-box background="#FFFFFF" :min="1" :value="item.goods_number" @change="updateCart($event,item.rec_id)"></uni-number-box> |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -91,20 +91,24 @@ |
|
|
|
|
|
|
|
<view class="footer"> |
|
|
|
<view class="footer_left"> |
|
|
|
<image src="../../static/img/select2.png" mode=""></image> |
|
|
|
<image src="../../static/img/select1.png" mode="" v-if="all_allno==1 && goods_list.length>0" @click="cartCheck(0,0)"></image> |
|
|
|
<image src="../../static/img/select2.png" mode="" v-else @click="cartCheck(0,1)"></image> |
|
|
|
<text>All</text> |
|
|
|
</view> |
|
|
|
<view class="footer_right"> |
|
|
|
<text>US$314.00</text> |
|
|
|
<button>CHECKOUT(2)</button> |
|
|
|
<text>US${{total.goods_price}}</text> |
|
|
|
<button @click="cartCheckOut">CHECKOUT({{total.goods_count}})</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<uni-popup ref="alertDialog" type="dialog"> |
|
|
|
<uni-popup-dialog type="error" cancelText="Close" confirmText="Delete" title="Tips" content="Whether to delete goods?" |
|
|
|
@confirm="dialogConfirm" ></uni-popup-dialog> |
|
|
|
</uni-popup> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import {defaultRequest2} from '../../api/index.js' |
|
|
|
import {defaultRequest2,defaultRequest4} from '../../api/index.js' |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -114,23 +118,142 @@ |
|
|
|
// 商品数据 |
|
|
|
goods_list:[], |
|
|
|
// 全选标识。1-全部选中,2-全部未选,3-部分选中。 |
|
|
|
all_allno:2 |
|
|
|
|
|
|
|
all_allno:2, |
|
|
|
deleteQuery:{ |
|
|
|
_action:'removecart' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
// 修改商品数量 |
|
|
|
updateCart(e,id){ |
|
|
|
let data={_action:'updatecart',rec_id:id,goods_number:e} |
|
|
|
defaultRequest4(data).then(res=>{ |
|
|
|
console.info(res) |
|
|
|
if(res.error==0){ |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 提交订单 |
|
|
|
cartCheckOut(){ |
|
|
|
if(this.goods_list.length==0) return |
|
|
|
if(this.all_allno==2){ |
|
|
|
uni.showToast({ |
|
|
|
icon:'none', |
|
|
|
title:'Please select the product' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
let data={_action:'cartcheckout',is_new:1,direct_shopping:0,consignee:''} |
|
|
|
defaultRequest2(data).then(res=>{ |
|
|
|
console.info(res) |
|
|
|
if(res.error==0){ |
|
|
|
// uni.navigateTo({ |
|
|
|
// url:'' |
|
|
|
// }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 删除商品 |
|
|
|
deleteCart(){ |
|
|
|
if(this.goods_list.length==0) return |
|
|
|
if(this.all_allno==2){ |
|
|
|
uni.showToast({ |
|
|
|
icon:'none', |
|
|
|
title:'Please select the product to delete' |
|
|
|
}) |
|
|
|
return |
|
|
|
}else if(this.all_allno==3){ |
|
|
|
let selectNum=0, |
|
|
|
rec_id='' |
|
|
|
this.goods_list.map(item=>{ |
|
|
|
if(item.is_check==1){ |
|
|
|
rec_id=item.rec_id |
|
|
|
selectNum++ |
|
|
|
} |
|
|
|
}) |
|
|
|
if(selectNum>1){ |
|
|
|
uni.showToast({ |
|
|
|
icon:'none', |
|
|
|
title:'Only one or all items can be deleted' |
|
|
|
}) |
|
|
|
return |
|
|
|
}else{ |
|
|
|
this.deleteQuery.rec_id=rec_id |
|
|
|
} |
|
|
|
}else{ |
|
|
|
// this.deleteQuery._action='clearcart' |
|
|
|
} |
|
|
|
this.$refs.alertDialog.open() |
|
|
|
|
|
|
|
}, |
|
|
|
dialogConfirm(){ |
|
|
|
defaultRequest2(this.deleteQuery).then(res=>{ |
|
|
|
console.info(res) |
|
|
|
if(res.error==0){ |
|
|
|
uni.showToast({ |
|
|
|
icon:'none', |
|
|
|
title:'Successfully deleted!' |
|
|
|
}) |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 购物车-商品勾选-单个记录 type: 1为单选 、0为全选 |
|
|
|
cartCheck(type,is_check,id,index){ |
|
|
|
if(this.goods_list.length==0) return |
|
|
|
let data={} |
|
|
|
if(type==1){ |
|
|
|
data={_action:'cartcheck',rec_id:id,is_check:is_check} |
|
|
|
}else{ |
|
|
|
data={_action:'cartcheckall',is_check:is_check} |
|
|
|
} |
|
|
|
defaultRequest4(data).then(res=>{ |
|
|
|
console.info(res) |
|
|
|
if(res.error==0){ |
|
|
|
this.getList() |
|
|
|
|
|
|
|
// Object.assign(this.total,res.data) |
|
|
|
// this.total.goods_price=res.data.price |
|
|
|
// this.all_allno=res.data.all_allno |
|
|
|
// if(type==1){ |
|
|
|
// if(is_check==0){ |
|
|
|
// this.goods_list[index].is_check=0 |
|
|
|
// }else{ |
|
|
|
// this.goods_list[index].is_check=1 |
|
|
|
// } |
|
|
|
|
|
|
|
// }else{ |
|
|
|
// this.goods_list.map(item=>{ |
|
|
|
// if(is_check==0){ |
|
|
|
// item.is_check=0 |
|
|
|
// }else{ |
|
|
|
// item.is_check=1 |
|
|
|
// } |
|
|
|
|
|
|
|
// }) |
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
getList(){ |
|
|
|
let data={_action:'getcartgoods'} |
|
|
|
defaultRequest2(data).then(res=>{ |
|
|
|
defaultRequest4(data).then(res=>{ |
|
|
|
console.info(res) |
|
|
|
if(res.error==0){ |
|
|
|
this.total=res.data.total |
|
|
|
this.all_allno=res.data.all_allno |
|
|
|
res.data.goods_list.map(item=>{ |
|
|
|
item.goods_attr=item.goods_attr.replace(/\n/,""); |
|
|
|
console.info(item.goods_attr) |
|
|
|
}) |
|
|
|
this.goods_list=res.data.goods_list |
|
|
|
if(res.data.goods_list){ |
|
|
|
res.data.goods_list.map(item=>{ |
|
|
|
item.goods_attr=item.goods_attr.replace(/\s\n/g,';'); |
|
|
|
}) |
|
|
|
this.goods_list=res.data.goods_list |
|
|
|
}else{ |
|
|
|
this.goods_list=[] |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
|