|
@@ -26,8 +26,45 @@
|
|
|
<scroll-view scroll-y="true" class="scroll-view">
|
|
|
<view class="list-scroll-view">
|
|
|
<checkbox-group name="checkbox" @change="marketChange">
|
|
|
- <view class="lists" v-for="(item, index) in list" :key="index">
|
|
|
- <view class="list">
|
|
|
+ <view class="list" v-for="(item, index) in list" :key="index">
|
|
|
+ <view class="list_1" v-if="item.is_set=='0'">
|
|
|
+ <view class="title">
|
|
|
+ <checkbox :value="item._id" :checked="item.check">
|
|
|
+ 优惠套装---{{item.name||'暂无名称'}}</checkbox>
|
|
|
+ </view>
|
|
|
+ <checkbox-group name="checkbox" @change="goodsChange">
|
|
|
+ <view class="content" v-for="gs in item.goods" :key="gs.goodsSpec_id">
|
|
|
+ <view class="img">
|
|
|
+ <image :src="getFile(gs)"></image>
|
|
|
+ </view>
|
|
|
+ <view class="one_1" @click="toCommon('/pagesHome/order/detail',gs)">
|
|
|
+ <view class="name"><text class="set">套装</text> {{gs.goods_name}}
|
|
|
+ </view>
|
|
|
+ <view class="info">
|
|
|
+ <view class="title_1" v-if="gs.spec_name">
|
|
|
+ <text>规格:{{gs.spec_name}}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="money">
|
|
|
+ <view>{{gs.set_num}}件/套x{{gs.set_num}}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="total">
|
|
|
+ <view class="total_1"> <text>套装价</text>¥{{item.sell_money||0}} </view>
|
|
|
+ <view class="total_2">
|
|
|
+ <view class="num">
|
|
|
+ <uni-number-box @change="changeValue(item)" name="num" value="item"
|
|
|
+ :min="1" v-model="item.num" />
|
|
|
+ </view>
|
|
|
+ <view class="del">
|
|
|
+ <text class="iconfont icon-del-copy" @click="toDel(item)"></text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </checkbox-group>
|
|
|
+ </view>
|
|
|
+ <view class="list_2" v-else>
|
|
|
<view class="title">
|
|
|
<checkbox :value="item.shop" :checked="item.check">
|
|
|
<text class="iconfont icon-shangdian"></text>
|
|
@@ -168,7 +205,9 @@
|
|
|
value
|
|
|
} = e.detail;
|
|
|
for (const p1 of list) {
|
|
|
- let p2 = value.find((i) => i == p1.shop);
|
|
|
+ let p2;
|
|
|
+ if (p1._id) p2 = value.find((i) => i == p1._id);
|
|
|
+ if (p1.shop) p2 = value.find((i) => i == p1.shop);
|
|
|
let a = p2 ? true : false;
|
|
|
p1.check = a;
|
|
|
for (let s of p1.goods) {
|
|
@@ -244,16 +283,30 @@
|
|
|
async changeValue(value) {
|
|
|
const that = this;
|
|
|
this.$nextTick(async () => {
|
|
|
- const {
|
|
|
- goodsSpec_id: goodsSpecId,
|
|
|
- num,
|
|
|
- cart_id: cartId
|
|
|
- } = value
|
|
|
- const res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
|
|
|
- cartId,
|
|
|
- goodsSpecId,
|
|
|
- num
|
|
|
- });
|
|
|
+ let res;
|
|
|
+ if (value.is_set == '0') {
|
|
|
+ const {
|
|
|
+ _id: set_id,
|
|
|
+ num,
|
|
|
+ cart_id: cartId
|
|
|
+ } = value
|
|
|
+ res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
|
|
|
+ cartId,
|
|
|
+ set_id,
|
|
|
+ num
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const {
|
|
|
+ goodsSpec_id: goodsSpecId,
|
|
|
+ num,
|
|
|
+ cart_id: cartId
|
|
|
+ } = value
|
|
|
+ res = await that.$api(`/cart/checkGoodsNum`, 'GET', {
|
|
|
+ cartId,
|
|
|
+ goodsSpecId,
|
|
|
+ num
|
|
|
+ });
|
|
|
+ }
|
|
|
if (res.errcode === 0) {
|
|
|
const {
|
|
|
enough,
|
|
@@ -328,11 +381,18 @@
|
|
|
// 渲染结束执行下面方法
|
|
|
that.$nextTick(() => {
|
|
|
for (const val of list) {
|
|
|
- for (let s of val.goods) {
|
|
|
- if (s.check == true) {
|
|
|
- let total = that.$multiply(s.price, s.num);
|
|
|
+ if (val.is_set == '0') {
|
|
|
+ if (val.check == true) {
|
|
|
+ let total = that.$multiply(val.sell_money, val.num);
|
|
|
totalMoney += Number(total);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ for (let s of val.goods) {
|
|
|
+ if (s.check == true) {
|
|
|
+ let total = that.$multiply(s.price, s.num);
|
|
|
+ totalMoney += Number(total);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
that.$set(that, `totalMoney`, totalMoney.toFixed(2))
|
|
@@ -346,8 +406,21 @@
|
|
|
// 去结算
|
|
|
async toSettle() {
|
|
|
// 将选中的购物车放到数组中,传回服务端进行检查.然后拿着key去订单页请求数据
|
|
|
- const goodsList = this.list.map(i => i.goods).flat();
|
|
|
- const cartIds = goodsList.filter(i => i.check).map(i => i.cart_id)
|
|
|
+ let goodsList = [];
|
|
|
+ let cartIds = [];
|
|
|
+ for (let val of this.list) {
|
|
|
+ if (val.is_set == '0') goodsList.push(val)
|
|
|
+ else goodsList.push(val.goods)
|
|
|
+ }
|
|
|
+ for (let val of goodsList) {
|
|
|
+ if (val.is_set == '0') {
|
|
|
+ if (val.check) cartIds.push(val.cart_id)
|
|
|
+ } else {
|
|
|
+ for (let set of val) {
|
|
|
+ if (set.check) cartIds.push(set.cart_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const res = await this.$api(`/util/checkCartBuy`, 'POST', {
|
|
|
cartIds
|
|
|
});
|
|
@@ -440,7 +513,129 @@
|
|
|
flex-grow: 1;
|
|
|
margin: 0 2vw;
|
|
|
|
|
|
- .list {
|
|
|
+ .list_1 {
|
|
|
+ background-color: var(--mainColor);
|
|
|
+ margin: 2vw 0 2vw 0;
|
|
|
+ padding: 2vw 3vw;
|
|
|
+ border-radius: 4px;
|
|
|
+
|
|
|
+ .title {
|
|
|
+ border-bottom: 1px solid var(--fcColor);
|
|
|
+ padding: 0 0 2vw 0;
|
|
|
+ font-size: var(--font18Size);
|
|
|
+
|
|
|
+ text {
|
|
|
+ margin: 0 1vw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .content {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ padding: 2vw 0;
|
|
|
+ font-size: var(--font16Size);
|
|
|
+ border-bottom: 1px dashed var(--fcColor);
|
|
|
+
|
|
|
+ .img {
|
|
|
+ width: 20vw;
|
|
|
+ height: 20vw;
|
|
|
+ border-radius: 2vw;
|
|
|
+ border: 1px solid var(--fcColor);
|
|
|
+
|
|
|
+ image {
|
|
|
+ width: 20vw;
|
|
|
+ height: 20vw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .one_1 {
|
|
|
+ margin: 0 2.5vw;
|
|
|
+ flex-grow: 1;
|
|
|
+
|
|
|
+ .name {
|
|
|
+ .set {
|
|
|
+ margin: 0 1vw 0 0;
|
|
|
+ font-size: 12px;
|
|
|
+ border-radius: 5px;
|
|
|
+ padding: 0 1vw;
|
|
|
+ color: #ffffff;
|
|
|
+ background-color: #FF6347;
|
|
|
+ border: 1px solid #FFA500;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .info {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+
|
|
|
+ .title_1 {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #666;
|
|
|
+ margin-top: 10px;
|
|
|
+
|
|
|
+ text {
|
|
|
+ background-color: #eee;
|
|
|
+ padding: 5px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .gift {
|
|
|
+ margin: 2vw 1vw 0 0;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #FFA500;
|
|
|
+ border: 1px solid #FFA500;
|
|
|
+ border-radius: 5px;
|
|
|
+ padding: 0 1vw;
|
|
|
+ }
|
|
|
+
|
|
|
+ .act {
|
|
|
+ margin: 2vw 0 0 0;
|
|
|
+ font-size: 12px;
|
|
|
+ border-radius: 5px;
|
|
|
+ padding: 0 1vw;
|
|
|
+ border: 1px solid var(--fFB1Color);
|
|
|
+ color: var(--fFB1Color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .money {
|
|
|
+ font-size: 14px;
|
|
|
+ margin-top: 2vw;
|
|
|
+ text-align: right;
|
|
|
+ flex-grow: 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .total {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 1vw;
|
|
|
+
|
|
|
+ .total_1 {
|
|
|
+ font-size: 20px;
|
|
|
+ color: var(--fFB1Color);
|
|
|
+
|
|
|
+ text {
|
|
|
+ font-size: 12px;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .total_2 {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .del {
|
|
|
+ margin: 0 0 0 3vw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .list_2 {
|
|
|
background-color: var(--mainColor);
|
|
|
margin: 2vw 0 2vw 0;
|
|
|
padding: 2vw 3vw;
|