Commit e6289522 by 肖康

购物车

parent 3db64095
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.pagebot{ .pagebot{
height: 62rpx; height: 62rpx;
line-height: 62rpx; line-height: 62rpx;
background: #F5F5F7; // background: #F5F5F7;
font-size: 22rpx; font-size: 22rpx;
text-align: center; text-align: center;
color:#C6C7CC; color:#C6C7CC;
...@@ -143,7 +143,6 @@ ...@@ -143,7 +143,6 @@
.searchgo{ .searchgo{
font-size: 24rpx; font-size: 24rpx;
color:$uni-coloract; color:$uni-coloract;
margin-right: 24rpx;
position: relative; position: relative;
top:8rpx; top:8rpx;
} }
......
...@@ -54,6 +54,9 @@ export default { ...@@ -54,6 +54,9 @@ export default {
} }
} }
}); });
},
updateCar(){
this.getData()
} }
} }
}; };
......
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
<view class="header"> <view class="header">
<view class="ht row bothSide"> <view class="ht row bothSide">
<view class="tabbox row"> <view class="tabbox row">
<view class="tabeitem act">大陆交货<text>(5)</text></view> <view class="tabeitem" :class="{'act':isDl==1}" @click.stop="tab(1)">大陆交货<text>({{dlcount}})</text>
<view class="tabeitem">香港交货<text>(5)</text></view> </view>
<view class="tabeitem" :class="{'act':isDl==2}" @click.stop="tab(2)">香港交货<text>({{hkcount}})</text>
</view>
</view> </view>
<view class="glbtn" @click="editStatus=!editStatus">{{editStatus?'退出管理':'管理'}}</view> <view class="glbtn" @click="editStatus=!editStatus">{{editStatus?'退出管理':'管理'}}</view>
</view> </view>
...@@ -22,81 +24,85 @@ ...@@ -22,81 +24,85 @@
</view> </view>
<view class="dataBox"> <view class="dataBox">
<delSlideLeft @delItem="delItem(666)" v-for="(item,index) in carList" :key="index"> <delSlideLeft @delItem="delItem(item.cart_id,'normal')" v-for="(item,index) in carList" :key="index">
<view class="goodsitem"> <view class="goodsitem" >
<view class="t1 row bothSide"> <view class="t1 row bothSide">
<view class="row"> <view class="row">
<view><text class="checkbox "><text class="icon iconfont icon-xzs"></text></text></view> <view @click.stop="checkboxchange(item.cart_id)">
<view class="goodsname elep">L6207PD013</view> <text class="checkbox " :class="{'checked':item.checked}">
<view class="actag">95折</view> <text class="icon iconfont icon-xzs"></text>
</text>
</view> </view>
<view class="edit" v-show="!editStatus"><text class="icon iconfont icon-bjt"></text>编辑</view> <a class="goodsname elep" :href="'/#/item/'+item.goods_id">{{item.goods_name}}</a>
<view class="edit del" v-show="editStatus"><text class="icon iconfont icon-del"></text>删除 <view class="actag" v-if="item.ac_type==10">{{item.activity_info.sign}}</view>
</view>
<!-- <view class="edit" v-show="!editStatus"><text class="icon iconfont icon-bjt"></text>编辑</view> -->
<view class="edit del" v-show="editStatus" @click.stop="delItem(item.cart_id,'normal')"><text class="icon iconfont icon-del"></text>删除
</view> </view>
</view> </view>
<view class="t2 row bothSide"> <view class="t2 row bothSide">
<view class="lbo"> <view class="lbo">
<view class="elep"><text class="label">品牌:</text>Ti</view> <view class="elep"><text class="label">品牌:</text>{{item.brand_name}}</view>
<view class="elep"><text class="label">供应商:</text>mouse</view> <view class="elep"><text class="label">供应商:</text>{{item.supplier_name}}</view>
<view class="elep"><text class="label">交期:</text>大陆3-5</view> <view class="elep"><text class="label">交期:</text>{{(isDl==1)?'大陆':'香港'}}{{item.delivery_time}}</view>
</view> </view>
<view class="rbo"> <view class="rbo">
<view class="ipbox row"> <view class="ipbox row">
<text>¥1.0784</text> <text>{{item.goods_price_format}}</text>
<text class="ch">x</text> <text class="ch">x</text>
<input type="number" /> <input type="number" v-model="item.goods_number" @input="onInput(item.cart_id)"/>
</view> </view>
<view class="xjbox "> <view class="xjbox ">
<text>小计:</text> <text>小计:</text>
<text class="xjmoney">¥1.0784</text> <text class="xjmoney">{{item.goods_amount_format}}</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</delSlideLeft> </delSlideLeft>
<delSlideLeft @delItem="delItem(777)"> <delSlideLeft @delItem="delItem(item.cart_id,'faild')" v-for="(item,index) in carsxList" :key="item.cart_id+index">
<view class="goodsitem sxbox"> <view class="goodsitem sxbox">
<view class="t1 row bothSide"> <view class="t1 row bothSide">
<view class="row"> <view class="row">
<view><text class="checkbox "><text class="icon iconfont icon-xzs"></text></text></view> <view @click.stop="clickbug()"><text class="checkbox "><text class="icon iconfont icon-xzs"></text></text></view>
<view class="goodsname elep">L6207PD013</view> <a class="goodsname elep" :href="'/#/item/'+item.goods_id">{{item.goods_name}}</a>
<view class="xxtag">失效</view> <view class="xxtag">失效</view>
</view> </view>
<view class="row"> <view class="row">
<navigator url="#" class="searchgo">重新搜索</navigator> <navigator :url="'/s?k='+item.goods_name" v-show="!editStatus" class="searchgo">重新搜索</navigator>
<view class="edit del"><text class="icon iconfont icon-del"></text>删除</view> <view class="edit del" v-show="editStatus" @click.stop="delItem(item.cart_id,'faild')"><text class="icon iconfont icon-del"></text>删除</view>
</view> </view>
</view> </view>
<view class="t2 row bothSide"> <view class="t2 row bothSide">
<view class="lbo"> <view class="lbo" @click.stop="clickbug()">
<view class="elep"><text class="label">品牌:</text>Ti</view> <view class="elep" ><text class="label">品牌:</text>{{item.brand_name}}</view>
<view class="elep"><text class="label">供应商:</text>mouse</view> <view class="elep"><text class="label">供应商:</text>{{item.supplier_name}}</view>
<view class="elep"><text class="label">交期:</text>大陆3-5</view> <view class="elep"><text class="label">交期:</text>{{(isDl==1)?'大陆':'香港'}}{{item.delivery_time}}</view>
</view> </view>
<view class="rbo"> <view class="rbo" @click.stop="clickbug()">
<view class="ipbox row"> <view class="ipbox row">
<text>¥1.0784</text> <text>{{item.goods_price_format}}</text>
<text class="ch">x</text> <text class="ch">x</text>
<input type="number" /> <input type="number" v-model="item.goods_number" disabled/>
</view> </view>
<view class="xjbox "> <view class="xjbox ">
<text>小计:</text> <text>小计:</text>
<text class="xjmoney">¥1.0784</text> <text class="xjmoney">{{item.goods_amount_format}}</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</delSlideLeft> </delSlideLeft>
</view> </view>
<view class="pagebot">—— 已经到底了 ——</view> <view class="pagebot" v-if="isloading&&(carList.length>0||carsxList.length>0)">—— 已经到底了 ——</view>
<view class="nodata" style="display:none;"> <view class="nodata" v-if="isloading&&(carList.length==0&&carsxList.length==0)">
<image src="https://img.ichunt.com/images/ichunt/202304/11/124e12f1e680f6eb5f5f46780d679eb3.png"> <image src="https://img.ichunt.com/images/ichunt/202304/11/124e12f1e680f6eb5f5f46780d679eb3.png">
</image> </image>
<view class="loginyes" style="display:none;"> <view class="loginyes" v-if="isLogin">
<view class="ndtips">当前购物车内暂无商品哦</view> <view class="ndtips">当前购物车内暂无商品哦</view>
</view> </view>
<view class="loginno"> <view class="loginno" v-else>
<view class="ndtips">登录后商品会同步到您的帐户中</view> <view class="ndtips">登录后商品会同步到您的帐户中</view>
<navigator url="/login">去登录</navigator> <navigator url="/login">去登录</navigator>
</view> </view>
...@@ -105,38 +111,38 @@ ...@@ -105,38 +111,38 @@
<view class="footer"> <view class="footer">
<view v-show="!editStatus" class="jsboxcar row bothSide"> <view v-show="!editStatus" class="jsboxcar row bothSide">
<view class="jsl row"> <view class="jsl row">
<view><text class="checkbox "><text class="icon iconfont icon-xzs"></text></text></view> <view><text class="checkbox " :class="{'checked':allcheck}" @click.stop="checkboxchange(460053411)"><text class="icon iconfont icon-xzs"></text></text></view>
<text class="trps">全选</text> <text class="trps" @click.stop="checkboxchange(460053411)">全选</text>
</view> </view>
<view class="jsr row"> <view class="jsr row">
<view> <view>
<view><text class="titg">总金额:</text><text class="tity">¥0</text></view> <view><text class="titg">总金额:</text><text class="tity">{{isDl?'¥':'$'}}{{totalprice}}</text></view>
<view class="yxbox">已选 <text class="checkcount">0</text> 件( 不含运费 )</view> <view class="yxbox">已选 <text class="checkcount">{{checkcount}}</text> 件( 不含运费 )</view>
</view> </view>
<view class="goconfirm">去结算</view> <view class="goconfirm" @click.stop="goOrder()">去结算</view>
</view> </view>
</view> </view>
<view v-show="editStatus" class="jsboxcar row bothSide"> <view v-show="editStatus" class="jsboxcar row bothSide">
<view class="jsl row"> <view class="jsl row">
<view><text class="checkbox "><text class="icon iconfont icon-xzs"></text></text></view> <view><text class="checkbox " :class="{'checked':allcheck}" @click.stop="checkboxchange(460053411)"><text class="icon iconfont icon-xzs"></text></text></view>
<text class="trps">全选</text> <text class="trps" @click.stop="checkboxchange(460053411)">全选</text>
<text class="clearsx">清除失效商品</text> <text class="clearsx" @click.stop="clearsxdata()">清除失效商品</text>
</view> </view>
<view class="jsr row"> <view class="jsr row">
<view class="goconfirm1">更换交货地</view> <view class="goconfirm1" @click.stop="changeplace()">更换交货地</view>
<view class="goconfirm goconfirm2">删除</view> <view class="goconfirm goconfirm2" @click.stop="delItem(460053411)">删除</view>
</view> </view>
</view> </view>
</view> </view>
<bottomNavFixed actval="3" /> <bottomNavFixed actval="3" ref="bottomNav"/>
<uni-popup ref="frendpopup" type="bottom"> <uni-popup ref="frendpopup" type="bottom">
<view class="frend-pop" > <view class="frend-pop">
<view class="poppbox" > <view class="poppbox">
<view class="cons" > <view class="cons">
<view class="pophead row bothSide"> <view class="pophead row bothSide">
<text class="tits">友情提醒</text> <text class="tits">友情提醒</text>
<text class="icon iconfont icon-xxx" @click="closefrend()"></text> <text class="icon iconfont icon-xxx" @click="closefrend()"></text>
...@@ -170,6 +176,14 @@ ...@@ -170,6 +176,14 @@
</template> </template>
<script> <script>
import {
Ichunt_Api,
Api_Url
} from '@/util/api.js';
import {
getCookie,
setCookie
} from '@/util/util.js'
import delSlideLeft from '@/components/ay-operate/del_slideLeft.vue' import delSlideLeft from '@/components/ay-operate/del_slideLeft.vue'
import bottomNavFixed from '@/components/bottom_nav.vue'; import bottomNavFixed from '@/components/bottom_nav.vue';
export default { export default {
...@@ -179,14 +193,255 @@ ...@@ -179,14 +193,255 @@
}, },
data() { data() {
return { return {
editStatus:false, timeout:"",//请求延迟定时器
carList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] allcheck:true,
isDl: 1,
editStatus: false,
carList: [],
carsxList: [],
isloading: false,
hkcount: 0,
dlcount: 0,
totalprice:0,
checkcount:0,
isLogin: (getCookie('Yo4teW_uid') && getCookie('Yo4teW_uid') != 0) ? true : false
} }
}, },
onShow() {
this.getData();
},
methods: { methods: {
delItem(car_id) { goOrder(){
console.log(car_id) let result=this.carList.filter(item=>item.checked)
let ids=result.map(item=>item.cart_id).join(',')
if(!ids){
uni.showToast({
title: '请选择至少一个商品',
duration: 2000,
icon:"none"
})
return
}
uni.setStorageSync('car_xk',ids);
uni.navigateTo({
url: '/order/confirm'
});
},
updateCar() {
this.$refs.bottomNav.updateCar();
},
onInput(cart_id){
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
let result=(this.carList.filter(item=>(item.cart_id==cart_id)))[0]
let mpl = Number(result.multiple||result.mpl);//倍数 加减的数量基数
let stock = Number(result.stock);//库存
let moq = Number(result.min_buy);//起订量
let value_ = Number(result.goods_number);//当前的数量
value_ = Math.ceil(value_ / mpl) * mpl;//失去焦点数量
result.goods_number = value_;//最终的数量
if (value_ < moq) {
result.goods_number = moq
}
if (value_ > stock) {
result.goods_number = Math.floor(stock / mpl) * mpl;
}
this.request(Api_Url + '/cart/changenum', 'POST', {
delivery_place:this.isDl,
num: result.goods_number,
cart_id:cart_id
}, true, true).then(res => {
this.handleSuccess(res,"修改数量成功")
});
}, 800);
},
checkboxchange(cart_id){
if(cart_id=='460053411'){
this.allcheck=!this.allcheck
//全选
this.carList.forEach(item=>{
item.checked=this.allcheck
})
}else{
var isall=1;
this.carList.forEach(item=>{
if(item.cart_id==cart_id){
item.checked=!item.checked
}
if(!item.checked){
isall=0;
}
})
if(!isall){
this.allcheck=false
}else{
this.allcheck=true
}
}
this.totalpriceui()
return false
},
clickbug(e) {
return false;
},
totalpriceui(){
this.totalprice=0
this.checkcount=0
this.carList.forEach(item=>{
if(item.checked){
this.checkcount++
this.totalprice+=Number((item.goods_amount_format).slice(1))
}
})
this.totalprice=this.totalprice.toFixed(2)
},
tab(guid) {
this.isDl = guid
this.getData()
},
handleSuccess(res,text_){
var msg_=text_?text_:res.err_msg
if (res.err_code == 0) {
uni.showToast({
title: msg_,
duration: 2000,
icon:"none"
})
setTimeout(()=>{
this.getData()
},2000)
this.updateCar()
}else{
uni.showToast({
title: msg_,
duration: 2000,
icon:"none"
})
}
}, },
clearsxdata(){
if(this.carsxList.length==0){
uni.showToast({
title:"当前没有失效商品",
duration: 2000,
icon:"none"
})
return
}
let ids=this.carsxList.map(item=>item.cart_id).join(',')
uni.showModal({
title:"清除失效商品",
content:"确认清除当前交货地的失效商品吗?",
success:(resp)=>{
if (resp.confirm) {
this.request(Api_Url + '/cart/delete', 'POST', {
cart_id: ids,
act:"faild"
}, true, true).then(res => {
this.handleSuccess(res,"清除失效商品成功")
});
}
}
})
},
changeplace(){
let result=this.carList.filter(item=>item.checked)
let ids=result.map(item=>item.cart_id).join(',')
if(!ids){
uni.showToast({
title: '请选择至少一个商品',
duration: 2000,
icon:"none"
})
return
}
uni.showModal({
title:"更换交货地",
content:"确认为选中商品更换交货地吗?",
success:(resp)=>{
if (resp.confirm) {
this.request(Api_Url + '/cart/change', 'POST', {
cart_id: ids
}, true, true).then(res => {
this.handleSuccess(res)
});
}
}
})
},
getData() {
this.carList=[]
this.carsxList=[]
this.isloading=false
this.request(Api_Url + '/cart/lists', 'POST', {
delivery_place: this.isDl
}, true, true).then(res => {
this.isloading = true;
this.allcheck=true
this.hkcount = res.data.hk_count
this.dlcount = res.data.cn_count
if (res.err_code == 0) {
let arr_ = res.data.list || [];
arr_.forEach(item => {
item.checked = true
item.goods_number = Number(item.goods_number)
if (item.status != -1) {
this.carList.push(item)
} else {
this.carsxList.push(item)
}
})
this.totalpriceui()
}
});
},
delItem(cart_id,act) {
var ids=cart_id;
var acts=act;
var texts='是否删除当前商品?'
if(cart_id=='460053411'){
//批量删除
acts='normal'
texts="是否删除当前选中商品?"
let result=this.carList.filter(item=>item.checked)
ids=result.map(item=>item.cart_id).join(',')
}
if(!ids){
uni.showToast({
title: '请选择至少一个商品',
duration: 2000,
icon:"none"
})
return
}
uni.showModal({
title:"删除",
content:texts,
success:(resp)=>{
if (resp.confirm) {
this.request(Api_Url + '/cart/delete', 'POST', {
cart_id: ids,
act:acts
}, true, true).then(res => {
this.handleSuccess(res)
});
}
}
})
},
openfrend() { openfrend() {
this.$refs.frendpopup.open('bottom'); this.$refs.frendpopup.open('bottom');
}, },
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<view class="titlesi">订单确认</view> <view class="titlesi">订单确认</view>
</view> </view>
<view class="tabs row bothSide"> <view class="tabs row bothSide">
<view class="itemt act row rowCenter verCenter">快递配送</view> <view class="itemt row rowCenter verCenter" @click.stop="shippingtypetab(1)" :class="{'act':shipping_type==1}">快递配送</view>
<view class="itemt row rowCenter verCenter">客户自提</view> <view class="itemt row rowCenter verCenter" @click.stop="shippingtypetab(2)" :class="{'act':shipping_type==2}">客户自提</view>
</view> </view>
<view class="kdbox" style="display:none;"> <view class="kdbox" v-show="shipping_type==1">
<navigator url="" class="kditem row verCenter bothSide" > <navigator url="" class="kditem row verCenter bothSide" >
<text class="icon iconfont icon-dzz"></text> <text class="icon iconfont icon-dzz"></text>
<view class="iteminfo"> <view class="iteminfo">
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<text>添加收货地址</text> <text>添加收货地址</text>
</navigator> </navigator>
</view> </view>
<view class="ztbox"> <view class="ztbox" v-show="shipping_type==2">
<view class="zttips row"><text class="icon iconfont icon-dzz"></text> <text>请在接到猎芯网系统短信通知后,再携带已盖章的合同打印件上门取货。</text></view> <view class="zttips row"><text class="icon iconfont icon-dzz"></text> <text>请在接到猎芯网系统短信通知后,再携带已盖章的合同打印件上门取货。</text></view>
<view class="ztitem row verCenter bothSide act"> <view class="ztitem row verCenter bothSide act">
<view class="ztl"> <view class="ztl">
...@@ -315,13 +315,35 @@ ...@@ -315,13 +315,35 @@
</template> </template>
<script> <script>
import {
Ichunt_Api,
Api_Url
} from '@/util/api.js';
export default { export default {
data() { data() {
return { return {
shipping_type:1,
currency:1,
ztaddress:{},//自提地址信息
} }
}, },
onShow() {
this.getData();
},
methods: { methods: {
//获取商品信息
getData(){
},
//获取自提地址
getSelfaddress(){
this.request(Api_Url + '/cart/selfaddress', 'POST', {}, true, true).then(res => {
});
},
shippingtypetab(type){
this.shipping_type=type
},
openzt() { openzt() {
this.$refs.popupztinfo.open('bottom'); this.$refs.popupztinfo.open('bottom');
}, },
......
...@@ -76,7 +76,8 @@ const router = new Router({ ...@@ -76,7 +76,8 @@ const router = new Router({
path: '/pages/confirm/confirm', path: '/pages/confirm/confirm',
aliasPath: '/order/confirm', aliasPath: '/order/confirm',
meta: { meta: {
title: '确认订单' title: '确认订单',
auth: true
} }
}, },
{ {
......
...@@ -16,7 +16,7 @@ const request = (url = '', type = 'GET', param = {}, Loading, headertype) => { ...@@ -16,7 +16,7 @@ const request = (url = '', type = 'GET', param = {}, Loading, headertype) => {
pf: 2 pf: 2
}); });
//请求es相关 //请求es相关
if (url.indexOf("so12.ichunt.") != -1 || url.indexOf("/esapi/") != -1 || url.indexOf("/goods/detail") != -1|| url.indexOf("/optimum/goods") != -1) { if (url.indexOf("so12.ichunt.") != -1 || url.indexOf("/esapi/") != -1 || url.indexOf("/goods/detail") != -1|| url.indexOf("/optimum/goods") != -1|| url.indexOf("/cart/lists") != -1) {
params = Object.assign(param, { hkyefgyd: 1 }); params = Object.assign(param, { hkyefgyd: 1 });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment