|
|
<template>
|
|
|
<view class="content">
|
|
|
<view class="sureshop">
|
|
|
<!-- 店铺商品-->
|
|
|
<view v-if="data1.length!=0">
|
|
|
<view class="sureorderbox flexone">
|
|
|
<view class="sureimg">
|
|
|
<image src="../../static/nearshop.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="sureshopname">红大地面品厂</view>
|
|
|
|
|
|
</view>
|
|
|
<view class='cartlist'>
|
|
|
<view class="sureorderitem flexone">
|
...
|
...
|
@@ -17,7 +18,7 @@ |
|
|
<image src="../../static/goodtailtop.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class='shuright'>
|
|
|
<view class="suregoodname">商品名称商品名称商品名称商
|
|
|
<view class="suregoodnamek">商品名称商品名称商品名称商
|
|
|
品名称商品名称商品名称商品名称商品名称
|
|
|
</view>
|
|
|
<view class="surebot flextwo">
|
...
|
...
|
@@ -33,98 +34,471 @@ |
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
<view class="sureorderitem flexone">
|
|
|
<view class="cartselimg">
|
|
|
<image src="../../static/cartnosel.png" mode=""></image>
|
|
|
<!-- 面坊商品 -->
|
|
|
<view v-if="data2.length!=0">
|
|
|
<view class="sureorderbox flexone">
|
|
|
<view class="sureimg">
|
|
|
<image src="../../static/nearshop.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="sureshopname">面坊商品</view>
|
|
|
</view>
|
|
|
<view class='cartlist'>
|
|
|
<view class="sureorderitem flexone" v-for="(item,index) in data2" :key="index">
|
|
|
<view class="cartselimg" @click="selectcart(item,index)">
|
|
|
|
|
|
<image src="../../static/cartnosel.png" mode="" v-if="item.sel==false"></image>
|
|
|
<image src="../../static/cartsel.png" mode="" v-else></image>
|
|
|
</view>
|
|
|
<view class="sureorderitemleft">
|
|
|
<image src="../../static/goodtailtop.png" mode=""></image>
|
|
|
<image :src="item.flour_goods.flour_goods_spec.spec_image" mode=""></image>
|
|
|
</view>
|
|
|
<view class='shuright'>
|
|
|
<view class="suregoodname">商品名称商品名称商品名称商
|
|
|
品名称商品名称商品名称商品名称商品名称
|
|
|
<view class="suregoodnamek">
|
|
|
{{item.flour_goods.name}}
|
|
|
</view>
|
|
|
<!-- 商品属性 -->
|
|
|
<view v-if="item.flour_goods.spec.length!=0">
|
|
|
<view class="spec" v-for="(item,index) in item.flour_goods.spec" :key="index">{{item.spec_name}}:{{item.spec_value}}</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="surebot flextwo">
|
|
|
<view class="saleprice">¥288</view>
|
|
|
<view class="saleprice">¥{{item.flour_goods.price}}</view>
|
|
|
<view class="weightnumk flexone">
|
|
|
<view class="weightnumkleft leftk">
|
|
|
<view class="weightnumkleft rightk" @click="reducecart(item)">
|
|
|
<image src="../../static/reduceimg.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="detailnum">{{item.number}}</view>
|
|
|
<view class="weightnumkleft leftk" @click="addcart(item)">
|
|
|
<image src="../../static/addimg.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="detailnum">1</view>
|
|
|
<view class="weightnumkleft rightk">
|
|
|
<image src="../../static/reduceimg.png" mode=""></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 积分商品 -->
|
|
|
<view v-if="data3.length!=0">
|
|
|
<view class="sureorderbox flexone" @click="jifenshop">
|
|
|
<view class="sureimg">
|
|
|
<image src="../../static/nearshop.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="sureshopname">积分商品</view>
|
|
|
</view>
|
|
|
<view class='cartlist'>
|
|
|
<view class="sureorderitem flexone" v-for="(item,index) in data3" :key="index">
|
|
|
<view class="flexone" @click="selectcart(item)">
|
|
|
<view class="cartselimg">
|
|
|
{{item.sel}}
|
|
|
<image src="../../static/cartsel.png" mode="" v-if="item.sel==true"></image>
|
|
|
<image src="../../static/cartnosel.png" mode="" v-else></image>
|
|
|
</view>
|
|
|
<view class="sureorderitemleft">
|
|
|
<image src="" mode=""></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class='shuright'>
|
|
|
<!-- {{item.score_goods.name}} {{item.sel}} -->
|
|
|
<view class="suregoodnamek">
|
|
|
{{item.score_goods.name}}
|
|
|
</view>
|
|
|
<view v-if="item.score_goods.spec.length!=0">
|
|
|
<view class="spec" v-for="(item,index) in item.score_goods.spec" :key="index">{{item.spec_name}}:{{item.spec_value}}</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="surebot flextwo">
|
|
|
<view class="saleprice">¥{{item.score_goods.price}}</view>
|
|
|
<view class="weightnumk flexone">
|
|
|
<view class="weightnumkleft rightk" @click="reducecart(item)">
|
|
|
<image src="../../static/reduceimg.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="detailnum">{{item.number}}</view>
|
|
|
<view class="weightnumkleft leftk" @click='addcart(item)'>
|
|
|
<image src="../../static/addimg.png" mode=""></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="cartbottom flextwo">
|
|
|
<view class="cartbotleft flexone">
|
|
|
<view class="cartbotleft flexone" @click="selectall">
|
|
|
<view class="cartselimg">
|
|
|
<image src="../../static/cartnosel.png" mode=""></image>
|
|
|
<image src="../../static/cartsel.png" mode="" v-if="selall"></image>
|
|
|
<image src="../../static/cartnosel.png" mode="" v-else></image>
|
|
|
</view>
|
|
|
<view class="totalnum">总计:</view>
|
|
|
<view class="totalmoney">¥28880</view>
|
|
|
<view class="totalmoney">¥{{total}}</view>
|
|
|
</view>
|
|
|
<view class='jiesuan'>去结算(2件)</view>
|
|
|
<view class='jiesuan' @click="jiesuan">去结算({{arr.length}}件)</view>
|
|
|
</view>
|
|
|
|
|
|
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import app from "../../App.vue";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
data1: [], //店铺商品
|
|
|
data2: [], //面坊商品
|
|
|
data3: [], //积分商品
|
|
|
selall: false,
|
|
|
total: 0,
|
|
|
arr:[],
|
|
|
data:[]
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
// 获取购物车列表
|
|
|
this.getcartlist()
|
|
|
console.log(uni.getStorageSync("token"))
|
|
|
},
|
|
|
methods: {
|
|
|
// 积分商品
|
|
|
jifenshop() {
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/homepage/jifenshop'
|
|
|
})
|
|
|
},
|
|
|
//面坊商品
|
|
|
mianfang() {
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/homepage/shoplist'
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 获取购物车列表
|
|
|
getcartlist() {
|
|
|
let that = this;
|
|
|
var url = 'car/get_all';
|
|
|
var params = {
|
|
|
}
|
|
|
console.log(params)
|
|
|
app.post(url, params).then((res) => {
|
|
|
console.log(res);
|
|
|
that.data1 = res.data.data.data3;
|
|
|
that.data2 = res.data.data.data1;
|
|
|
that.data3 = res.data.data.data2;
|
|
|
// 面坊商品
|
|
|
that.data2.forEach(function(value, index, array) {
|
|
|
value.sel = false;
|
|
|
})
|
|
|
that.data2 = that.data2;
|
|
|
console.log('738932893', that.data2)
|
|
|
// 积分商品
|
|
|
that.data3.forEach(function(value, index, array) {
|
|
|
value.sel = false
|
|
|
})
|
|
|
that.data3 = that.data3;
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//面坊商品选择购物车
|
|
|
selectcart(item, index) {
|
|
|
console.log(item, index)
|
|
|
let that = this;
|
|
|
let obj={}
|
|
|
if (item.type == 2) {
|
|
|
that.data3.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
value.sel = !value.sel;
|
|
|
if (value.sel == true) {
|
|
|
that.arr.push(1)
|
|
|
that.total = that.total * 100 / 100 + value.score_goods.price * 100 / 100 * value.number;
|
|
|
console.log(6666);
|
|
|
obj.type=item.type;
|
|
|
obj.goods_id=item.goods_id;
|
|
|
obj.spec_sku_id=item.spec_sku_id;
|
|
|
obj.number=item.number;
|
|
|
console.log('34898348',obj);
|
|
|
that.data.push(obj)
|
|
|
} else {
|
|
|
that.arr.splice(0,1)
|
|
|
that.total = that.total * 100 / 100 - value.score_goods.price * 100 / 100 * value.number;
|
|
|
that.data.forEach(function(value,index,array){
|
|
|
console.log(value.goods_id);
|
|
|
console.log(item.goods_id)
|
|
|
if(item.goods_id==value.goods_id){
|
|
|
console.log(34349349043)
|
|
|
that.data.splice(index,1)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
that.data=that.data;
|
|
|
console.log(that.data)
|
|
|
}
|
|
|
})
|
|
|
that.data3 = that.data3
|
|
|
} else if (item.type == 1) {
|
|
|
console.log(88888)
|
|
|
that.data2.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
value.sel = !value.sel;
|
|
|
if (value.sel == true) {
|
|
|
that.arr.push(1)
|
|
|
that.total = that.total * 100 / 100 + value.flour_goods.price * 100 / 100 * value.number;
|
|
|
obj.type=item.type;
|
|
|
obj.goods_id=item.goods_id;
|
|
|
obj.spec_sku_id=item.spec_sku_id;
|
|
|
obj.number=item.number;
|
|
|
that.data.push(obj)
|
|
|
|
|
|
} else {
|
|
|
that.total = that.total * 100 / 100 - value.flour_goods.price * 100 / 100 * value.number;
|
|
|
that.arr.splice(0,1);
|
|
|
that.data.forEach(function(value,index,array){
|
|
|
if(item.goods_id==value.goods_id){
|
|
|
that.data.splice(index,1)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.data2 = that.data2;
|
|
|
that.data=that.data;
|
|
|
console.log(that.data)
|
|
|
}
|
|
|
|
|
|
},
|
|
|
// 选择全部购物车
|
|
|
selectall() {
|
|
|
let that=this;
|
|
|
this.selall = !this.selall;
|
|
|
let newarr=[];
|
|
|
let newtotal=0
|
|
|
if (this.selall == true) {
|
|
|
this.data3.forEach(function(value, index, array) {
|
|
|
value.sel = true;
|
|
|
newarr.push(1);
|
|
|
newtotal=newtotal+value.score_goods.price * 100 / 100 * value.number
|
|
|
// this.total = this.total * 100 / 100 + value.score_goods.price * 100 / 100 * value.number
|
|
|
})
|
|
|
this.data2.forEach(function(value, index, array){
|
|
|
value.sel = true;
|
|
|
newtotal=newtotal+value.flour_goods.price * 100 / 100 * value.number
|
|
|
// this.total = this.total * 100 / 100 + value.flour_goods.price * 100 / 100 * value.number;
|
|
|
newarr.push(1)
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
this.data3.forEach(function(value, index, array) {
|
|
|
value.sel = false;
|
|
|
})
|
|
|
this.data2.forEach(function(value, index, array){
|
|
|
value.sel =false
|
|
|
})
|
|
|
newarr=[];
|
|
|
newtotal=0
|
|
|
}
|
|
|
this.data3 = this.data3;
|
|
|
this.total=newtotal;
|
|
|
this.arr=newarr;
|
|
|
|
|
|
},
|
|
|
//购物车增加
|
|
|
addcart(item) {
|
|
|
let that = this
|
|
|
if (item.type == 2) {
|
|
|
that.data3.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
value.number++;
|
|
|
if (item.sel == true) {
|
|
|
that.total = that.total * 100 / 100 + value.score_goods.price * 100 / 100 * 1;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.data3 = that.data3;
|
|
|
|
|
|
} else if (item.type == 1) {
|
|
|
that.data2.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
value.number++;
|
|
|
if (item.sel == true) {
|
|
|
that.total = that.total * 100 / 100 + value.flour_goods.price * 100 / 100 * 1;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
})
|
|
|
that.data2 = that.data2;
|
|
|
|
|
|
}
|
|
|
that.addcartk(item.id)
|
|
|
|
|
|
},
|
|
|
// 购物车增加
|
|
|
addcartk(id) {
|
|
|
let that = this;
|
|
|
var url = 'car/update_car';
|
|
|
var params = {
|
|
|
type: 1,
|
|
|
car_id: id
|
|
|
}
|
|
|
console.log(params)
|
|
|
app.post(url, params).then((res) => {
|
|
|
console.log(res);
|
|
|
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
|
|
|
})
|
|
|
},
|
|
|
// 购物车减少
|
|
|
reducecart(item) {
|
|
|
let that = this;
|
|
|
if (item.type == 2) {
|
|
|
that.data3.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
if (value.number > 1) {
|
|
|
value.number = value.number - 1;
|
|
|
if (item.sel == true) {
|
|
|
that.total = that.total * 100 / 100 - value.score_goods.price * 100 / 100 * 1;
|
|
|
}
|
|
|
that.reducecartk(item.id)
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '不能再减少了~',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.data3 = that.data3;
|
|
|
|
|
|
} else if (item.type == 1) {
|
|
|
that.data2.forEach(function(value, index, array) {
|
|
|
if (value.id == item.id) {
|
|
|
if (value.number > 1) {
|
|
|
value.number = value.number - 1;
|
|
|
that.reducecartk(item.id);
|
|
|
if (item.sel == true) {
|
|
|
that.total = that.total * 100 / 100 - value.flour_goods.price * 100 / 100 * 1;
|
|
|
}
|
|
|
}else{
|
|
|
uni.showToast({
|
|
|
title: '不能再减少了~',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.data2 = that.data2;
|
|
|
}
|
|
|
},
|
|
|
reducecartk(id) {
|
|
|
let that = this;
|
|
|
var url = 'car/update_car';
|
|
|
var params = {
|
|
|
type: 2,
|
|
|
car_id: id
|
|
|
}
|
|
|
console.log(params)
|
|
|
app.post(url, params).then((res) => {
|
|
|
console.log(res);
|
|
|
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
|
|
|
})
|
|
|
},
|
|
|
// 去结算
|
|
|
jiesuan(){
|
|
|
let that = this;
|
|
|
if(that.data.length==0){
|
|
|
uni.showToast({
|
|
|
title:'请选择商品',
|
|
|
icon:'none'
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
var url = 'order/confirm_order';
|
|
|
console.log('获取的参数',that.data)
|
|
|
var params = {
|
|
|
data: JSON.stringify(that.data),
|
|
|
|
|
|
}
|
|
|
console.log(params)
|
|
|
app.post(url, params,"post").then((res) => {
|
|
|
console.log(res);
|
|
|
console.log(res.data.data)
|
|
|
uni.setStorageSync("goodinfo",res.data.data);
|
|
|
uni.navigateTo({
|
|
|
url:'/pages/nearshop/sureorder'
|
|
|
})
|
|
|
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
},
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
@import url('../../base/nearshop');
|
|
|
@import url('../../base/homepage');
|
|
|
page{
|
|
|
|
|
|
page {
|
|
|
background: #F8F6F9;
|
|
|
}
|
|
|
.cartlist{
|
|
|
padding-bottom: 120rpx;
|
|
|
|
|
|
.cartlist {
|
|
|
/* padding-bottom: 120rpx; */
|
|
|
}
|
|
|
.spec{
|
|
|
color:#3D454C;
|
|
|
font-size: 28rpx;
|
|
|
}
|
|
|
.cartselimg{
|
|
|
width:30rpx;
|
|
|
height:30rpx;
|
|
|
.cartselimg {
|
|
|
width: 30rpx;
|
|
|
height: 30rpx;
|
|
|
font-size: 0;
|
|
|
margin-right:30rpx;
|
|
|
margin-right: 30rpx;
|
|
|
flex: 0 0 auto;
|
|
|
}
|
|
|
.sureorderitem{
|
|
|
|
|
|
.sureorderitem {
|
|
|
padding-bottom: 30rpx;
|
|
|
box-sizing: border-box;
|
|
|
}
|
|
|
.cartbottom{
|
|
|
width:750rpx;
|
|
|
position:fixed;
|
|
|
bottom:0;
|
|
|
left:0;
|
|
|
|
|
|
.cartbottom {
|
|
|
width: 750rpx;
|
|
|
position: fixed;
|
|
|
bottom: 0;
|
|
|
left: 0;
|
|
|
padding: 38rpx 32rpx;
|
|
|
box-sizing: border-box;
|
|
|
background: #fff;
|
|
|
}
|
|
|
.totalnum{
|
|
|
color:#3D454C;
|
|
|
|
|
|
.totalnum {
|
|
|
color: #3D454C;
|
|
|
font-size: 28rpx;
|
|
|
/* margin-left:12rpx; */
|
|
|
}
|
|
|
.totalmoney{
|
|
|
color:#E26335;
|
|
|
|
|
|
.totalmoney {
|
|
|
color: #E26335;
|
|
|
font-size: 28rpx;
|
|
|
/* margin-left:12rpx; */
|
|
|
}
|
|
|
.jiesuan{
|
|
|
width:280rpx;
|
|
|
height:88rpx;
|
|
|
background:rgba(194,148,69,1);
|
|
|
border-radius:16rpx;
|
|
|
color:#fff;
|
|
|
|
|
|
.jiesuan {
|
|
|
width: 280rpx;
|
|
|
height: 88rpx;
|
|
|
background: rgba(194, 148, 69, 1);
|
|
|
border-radius: 16rpx;
|
|
|
color: #fff;
|
|
|
font-size: 28rpx;
|
|
|
text-align: center;
|
|
|
line-height: 88rpx;
|
...
|
...
|
|