|
@ -2,43 +2,84 @@ |
|
|
<div class="main"> |
|
|
<div class="main"> |
|
|
<div class="cart-main"> |
|
|
<div class="cart-main"> |
|
|
<div class="cart-top"> |
|
|
<div class="cart-top"> |
|
|
<div class="cart-num">图书数量<span>({{list.length}})</span></div> |
|
|
|
|
|
<span @click="cartDelt">{{ !isDeltHandle ? '管理' : '完成' }}</span> |
|
|
|
|
|
|
|
|
<div class="cart-num"> |
|
|
|
|
|
图书数量<span>({{ totalLength }})</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
<span @click="cartDelt">{{ |
|
|
|
|
|
!isDeltHandle ? '管理' : '完成' |
|
|
|
|
|
}}</span> |
|
|
</div> |
|
|
</div> |
|
|
<div class="cart-list"> |
|
|
<div class="cart-list"> |
|
|
<div class="cart-item" v-if="list.length !== 0"> |
|
|
|
|
|
|
|
|
<div v-for="(bookItem, index) in list" :key="index" > |
|
|
|
|
|
<div class="cart-item" v-if="bookItem.length !== 0"> |
|
|
<div class="list-top"> |
|
|
<div class="list-top"> |
|
|
<van-checkbox v-model="activeSelect" @change="handleselectedAll"></van-checkbox> |
|
|
|
|
|
|
|
|
<van-checkbox v-model="bookItem.activeSelect" @change="handleselectedAll(index)"></van-checkbox> |
|
|
<div class="top-info"> |
|
|
<div class="top-info"> |
|
|
<p class="active-name">{{ list[0].selectName }}<i></i></p> |
|
|
|
|
|
<p class="dealer">{{ list[0].supplierName }}</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<p class="active-name"> |
|
|
|
|
|
{{ bookItem[0] && bookItem[0].selectName }}<i></i> |
|
|
|
|
|
</p> |
|
|
|
|
|
<p class="dealer">{{ bookItem[0] && bookItem[0].supplierName}}</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="product-list" v-for="(item, i) in bookItem" :key="item.id"> |
|
|
|
|
|
<div class="product-item"> |
|
|
|
|
|
<!-- @change="handleSingle(index)" --> |
|
|
|
|
|
<van-checkbox v-model="item.checked"></van-checkbox> |
|
|
|
|
|
<div |
|
|
|
|
|
class="product-cont" |
|
|
|
|
|
@click="getOnlineBookDetail(item.bookId)" |
|
|
|
|
|
> |
|
|
|
|
|
<div class="product-img"> |
|
|
|
|
|
<img |
|
|
|
|
|
:src=" |
|
|
|
|
|
'http://192.168.99.67:8080/demoOnlineSelect/getBookCover.do?id=' + |
|
|
|
|
|
item.bookId |
|
|
|
|
|
" |
|
|
|
|
|
alt="" |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
<div class="product-list"> |
|
|
|
|
|
<div v-for="(item,index) in list" :key="item.id" class="product-item" > |
|
|
|
|
|
<van-checkbox v-model="item.checked" @change="handleSingle(index)"></van-checkbox> |
|
|
|
|
|
<div class="product-cont" @click="getOnlineBookDetail(item.bookId)"> |
|
|
|
|
|
<div class="product-img"><img :src="'http://192.168.99.67:8080/demoOnlineSelect/getBookCover.do?id='+item.bookId" alt="" /></div> |
|
|
|
|
|
<div class="product-txt"> |
|
|
<div class="product-txt"> |
|
|
<div class="product-info"> |
|
|
<div class="product-info"> |
|
|
<h4 class="overflow-txt-only">{{item.bookName}} </h4> |
|
|
|
|
|
|
|
|
<h4 class="overflow-txt-only"> |
|
|
|
|
|
{{ item.bookName }} |
|
|
|
|
|
</h4> |
|
|
<div class="author-date"> |
|
|
<div class="author-date"> |
|
|
<p class="author overflow-txt-only">{{item.author}}</p> |
|
|
|
|
|
<p class="date overflow-txt-only">{{item.createdDate}}</p> |
|
|
|
|
|
|
|
|
<p class="author overflow-txt-only"> |
|
|
|
|
|
{{ item.author }} |
|
|
|
|
|
</p> |
|
|
|
|
|
<p class="date overflow-txt-only"> |
|
|
|
|
|
{{ item.createdDate }} |
|
|
|
|
|
</p> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="intro overflow-txt"> |
|
|
|
|
|
{{ item.introduce }} |
|
|
</div> |
|
|
</div> |
|
|
<div class="intro overflow-txt">{{item.introduce}}</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div class="product-bottom"> |
|
|
<div class="product-bottom"> |
|
|
<p class="product-price">实付款 <span><i class="rmb">¥</i>0</span><i><em>¥</em>{{item.price}}</i></p> |
|
|
|
|
|
<span v-if="!isDeltHandle" class="product-num">x1</span> |
|
|
|
|
|
<span v-else class="item-delt" @click.stop="deltCurrentItem(item.bookId)"></span> |
|
|
|
|
|
|
|
|
<p class="product-price"> |
|
|
|
|
|
实付款 |
|
|
|
|
|
<span><i class="rmb">¥</i>0</span |
|
|
|
|
|
><i><em>¥</em>{{ item.price }}</i> |
|
|
|
|
|
</p> |
|
|
|
|
|
<span |
|
|
|
|
|
v-if="!isDeltHandle" |
|
|
|
|
|
class="product-num" |
|
|
|
|
|
>x1</span |
|
|
|
|
|
> |
|
|
|
|
|
<span |
|
|
|
|
|
v-else |
|
|
|
|
|
class="item-delt" |
|
|
|
|
|
@click.stop=" |
|
|
|
|
|
deltCurrentItem(item.id) |
|
|
|
|
|
" |
|
|
|
|
|
></span> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="empty-data" v-if="list.length === 0"> |
|
|
<div class="empty-data" v-if="list.length === 0"> |
|
|
<img src="@assets/images/empty.png" alt="" /> |
|
|
<img src="@assets/images/empty.png" alt="" /> |
|
|
</div> |
|
|
</div> |
|
@ -46,9 +87,11 @@ |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="cart-pay" v-if="list.length !== 0"> |
|
|
<div class="cart-pay" v-if="list.length !== 0"> |
|
|
<van-checkbox v-model="activeSelect">全选</van-checkbox> |
|
|
|
|
|
|
|
|
<van-checkbox v-model="allSelected">全选</van-checkbox> |
|
|
<div v-if="!isDeltHandle" class="payment-right"> |
|
|
<div v-if="!isDeltHandle" class="payment-right"> |
|
|
<div class="total-num">合计:<span><i class="rmb">¥</i>0</span></div> |
|
|
|
|
|
|
|
|
<div class="total-num"> |
|
|
|
|
|
合计:<span><i class="rmb">¥</i>0</span> |
|
|
|
|
|
</div> |
|
|
<p class="pay-btn" @click="goPay">下单</p> |
|
|
<p class="pay-btn" @click="goPay">下单</p> |
|
|
</div> |
|
|
</div> |
|
|
<div v-else class="payment-right"> |
|
|
<div v-else class="payment-right"> |
|
@ -68,11 +111,23 @@ |
|
|
<div class="product-cont"> |
|
|
<div class="product-cont"> |
|
|
<div class="product-cont-left"> |
|
|
<div class="product-cont-left"> |
|
|
<div class="product-img"> |
|
|
<div class="product-img"> |
|
|
<img :src="'http://192.168.99.67:8080/demoOnlineSelect/getBookCover.do?id='+detailBook.id" alt="" /> |
|
|
|
|
|
|
|
|
<img |
|
|
|
|
|
:src=" |
|
|
|
|
|
$coverUrl+'/demoOnlineSelect/getBookCover.do?id=' + |
|
|
|
|
|
detailBook.id |
|
|
|
|
|
" |
|
|
|
|
|
alt="" |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
<div class="book-inventory"> |
|
|
<div class="book-inventory"> |
|
|
<p>剩余库存</p> |
|
|
<p>剩余库存</p> |
|
|
<span><i>{{ parseInt(detailBook.total)-parseInt(detailBook.purchase) }}</i>册</span> |
|
|
|
|
|
|
|
|
<span |
|
|
|
|
|
><i>{{ |
|
|
|
|
|
parseInt(detailBook.total) - |
|
|
|
|
|
parseInt(detailBook.purchase) |
|
|
|
|
|
}}</i |
|
|
|
|
|
>册</span |
|
|
|
|
|
> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="product-txt"> |
|
|
<div class="product-txt"> |
|
@ -91,9 +146,14 @@ |
|
|
<p>{{ detailBook.createdDate }}</p> |
|
|
<p>{{ detailBook.createdDate }}</p> |
|
|
</div> |
|
|
</div> |
|
|
<div class="bookItem-txt"> |
|
|
<div class="bookItem-txt"> |
|
|
<!-- :style="{ width: detailBook.introduce !== '' ? '1.42rem' : 'auto' }" --> |
|
|
|
|
|
<span class="txt-title">简介:</span> |
|
|
<span class="txt-title">简介:</span> |
|
|
<p class="intro-txt">{{ detailBook.introduce !== '' ? detailBook.introduce : '暂无简介'}}</p> |
|
|
|
|
|
|
|
|
<p class="intro-txt"> |
|
|
|
|
|
{{ |
|
|
|
|
|
detailBook.introduce !== '' |
|
|
|
|
|
? detailBook.introduce |
|
|
|
|
|
: '暂无简介' |
|
|
|
|
|
}} |
|
|
|
|
|
</p> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
@ -101,13 +161,17 @@ |
|
|
<div class="order-dealer"> |
|
|
<div class="order-dealer"> |
|
|
<p class="dealer">{{ detailBook.supplierName }}</p> |
|
|
<p class="dealer">{{ detailBook.supplierName }}</p> |
|
|
<div class="order-pay"> |
|
|
<div class="order-pay"> |
|
|
<p>实付款<span><i>¥</i>0</span></p> |
|
|
|
|
|
<span class="yj-price"><i>¥</i><em>{{ detailBook.price }}</em></span> |
|
|
|
|
|
|
|
|
<p> |
|
|
|
|
|
实付款<span><i>¥</i>0</span> |
|
|
|
|
|
</p> |
|
|
|
|
|
<span class="yj-price" |
|
|
|
|
|
><i>¥</i><em>{{ detailBook.price }}</em></span |
|
|
|
|
|
> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="dialog-btn"> |
|
|
<div class="dialog-btn"> |
|
|
<span @click="showDetial=false">关闭</span> |
|
|
|
|
|
|
|
|
<span @click="showDetial = false">关闭</span> |
|
|
</div> |
|
|
</div> |
|
|
</van-dialog> |
|
|
</van-dialog> |
|
|
</div> |
|
|
</div> |
|
@ -115,8 +179,9 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { Toast } from 'vant' |
|
|
import { Toast } from 'vant' |
|
|
import { reactive, computed, onMounted, getCurrentInstance, toRefs } from 'vue' |
|
|
|
|
|
|
|
|
import { reactive, computed, watch, onMounted, getCurrentInstance, toRefs } from 'vue' |
|
|
import TabBar from '@/components/tabBar/index.vue' |
|
|
import TabBar from '@/components/tabBar/index.vue' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'Cart', |
|
|
name: 'Cart', |
|
|
components: { TabBar }, |
|
|
components: { TabBar }, |
|
@ -124,30 +189,69 @@ export default { |
|
|
const { proxy } = getCurrentInstance() |
|
|
const { proxy } = getCurrentInstance() |
|
|
let data = reactive({ |
|
|
let data = reactive({ |
|
|
tabCur: 1, |
|
|
tabCur: 1, |
|
|
activeSelect: false, |
|
|
|
|
|
allSelected: false, |
|
|
allSelected: false, |
|
|
isDeltHandle: false, |
|
|
isDeltHandle: false, |
|
|
showDetial: false, |
|
|
showDetial: false, |
|
|
list:[], |
|
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
totalLength: 0, |
|
|
checkedCount: [], |
|
|
checkedCount: [], |
|
|
detailBook: null |
|
|
|
|
|
|
|
|
detailBook: null, |
|
|
|
|
|
checkedBooks:[], |
|
|
|
|
|
checkedBooksPay:[] |
|
|
}) |
|
|
}) |
|
|
|
|
|
watch(data.list, () => { |
|
|
|
|
|
data.allSelected = allSelected; |
|
|
|
|
|
}, { deep: true }); |
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
getMyshoppingCart() |
|
|
getMyshoppingCart() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const allSelected = computed({ |
|
|
|
|
|
get() { |
|
|
|
|
|
return data.list.every(bookItem => { |
|
|
|
|
|
return bookItem.every(item => item.checked); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
set(checked) { |
|
|
|
|
|
data.list.forEach(bookItem => { |
|
|
|
|
|
bookItem.forEach(item => { |
|
|
|
|
|
item.checked = checked; |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
let getMyshoppingCart = () => { |
|
|
let getMyshoppingCart = () => { |
|
|
let param = { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let param = {} |
|
|
proxy.$http |
|
|
proxy.$http |
|
|
.get(proxy.$API.MYSHOPPINGCART, |
|
|
|
|
|
{ |
|
|
|
|
|
params: param |
|
|
|
|
|
|
|
|
.get(proxy.$API.MYSHOPPINGCART, { |
|
|
|
|
|
params: param, |
|
|
|
|
|
}) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
if(res.data.length === 0){ |
|
|
|
|
|
data.list = [] |
|
|
|
|
|
}else{ |
|
|
|
|
|
let allArraysEmpty = true; |
|
|
|
|
|
for (let i = 0; i < res.data.length; i++) { |
|
|
|
|
|
if (res.data[i].length !== 0) { // 如果当前子数组不为空 |
|
|
|
|
|
allArraysEmpty = false; // 设置所有子数组都不为空的标记为 false |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (allArraysEmpty) { |
|
|
|
|
|
data.list = [] |
|
|
|
|
|
console.log('都为空') |
|
|
|
|
|
} else { |
|
|
|
|
|
data.list = res.data |
|
|
|
|
|
data.list.forEach(bookItem => { |
|
|
|
|
|
watch(bookItem, () => { |
|
|
|
|
|
bookItem.activeSelect = bookItem.every(item => item.checked); |
|
|
|
|
|
}, { deep: true }); |
|
|
|
|
|
}) |
|
|
|
|
|
data.totalLength = data.list.map(books => books.length).reduce((total, length) => total + length, 0); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
data.list = res.data[0] |
|
|
|
|
|
}) |
|
|
}) |
|
|
.catch((res) => { |
|
|
.catch((res) => { |
|
|
console.log(res) |
|
|
console.log(res) |
|
@ -156,17 +260,18 @@ export default { |
|
|
|
|
|
|
|
|
let getOnlineBookDetail = (bookId) => { |
|
|
let getOnlineBookDetail = (bookId) => { |
|
|
proxy.$http |
|
|
proxy.$http |
|
|
.post(proxy.$API.BOOKONLINEDETAIL, |
|
|
|
|
|
|
|
|
.post( |
|
|
|
|
|
proxy.$API.BOOKONLINEDETAIL, |
|
|
{ |
|
|
{ |
|
|
bookId: bookId |
|
|
|
|
|
|
|
|
bookId: bookId, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
headers: { |
|
|
headers: { |
|
|
'Content-Type': 'application/x-www-form-urlencoded' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded', |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
.then(res => { |
|
|
|
|
|
|
|
|
.then((res) => { |
|
|
data.detailBook = res.data.book |
|
|
data.detailBook = res.data.book |
|
|
data.showDetial = true |
|
|
data.showDetial = true |
|
|
}) |
|
|
}) |
|
@ -174,79 +279,166 @@ export default { |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let deltBookShoppingCart = (ids) => { |
|
|
let deltBookShoppingCart = (ids) => { |
|
|
let param = { |
|
|
let param = { |
|
|
ids: ids |
|
|
|
|
|
|
|
|
ids: ids, |
|
|
} |
|
|
} |
|
|
proxy.$http |
|
|
proxy.$http |
|
|
.post(proxy.$API.DELETBOOKTOSHOPPINGCART, |
|
|
|
|
|
param,{ |
|
|
|
|
|
|
|
|
.put( |
|
|
|
|
|
proxy.$API.DELETBOOKTOSHOPPINGCART, |
|
|
|
|
|
param, |
|
|
|
|
|
{ |
|
|
headers: { |
|
|
headers: { |
|
|
'Content-Type': 'application/x-www-form-urlencoded' |
|
|
'Content-Type': 'application/x-www-form-urlencoded' |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
.then(res => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
getMyshoppingCart() |
|
|
|
|
|
Toast("删除成功") |
|
|
}) |
|
|
}) |
|
|
.catch((res) => { |
|
|
.catch((res) => { |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let goPay = () => { |
|
|
|
|
|
proxy.$router.push({ path: '/CartResult' }) |
|
|
|
|
|
|
|
|
let confirmDelt = () => { |
|
|
|
|
|
// let ids = data.list.filter(item => item.checked).map(item => item.id); |
|
|
|
|
|
// console.log('ids',ids) |
|
|
|
|
|
// if(ids.length === 0){ |
|
|
|
|
|
// Toast('请选择你需要删除的书籍') |
|
|
|
|
|
// }else{ |
|
|
|
|
|
// ids = ids.join(',') |
|
|
|
|
|
// console.log(ids) |
|
|
|
|
|
// deltBookShoppingCart(ids) |
|
|
|
|
|
// } |
|
|
|
|
|
data.checkedBooks = data.list |
|
|
|
|
|
.flat() // 将二维数组转为一维数组 |
|
|
|
|
|
.filter(item => item.checked === true) |
|
|
|
|
|
.map(item => item.id); |
|
|
|
|
|
|
|
|
|
|
|
if(data.checkedBooks.length === 0){ |
|
|
|
|
|
Toast('请选择你需要删除的书籍') |
|
|
|
|
|
}else{ |
|
|
|
|
|
const ids = data.checkedBooks.join(',') |
|
|
|
|
|
console.log(ids) |
|
|
|
|
|
deltBookShoppingCart(ids) |
|
|
} |
|
|
} |
|
|
let cartDelt = () =>{ |
|
|
|
|
|
data.isDeltHandle = !data.isDeltHandle |
|
|
|
|
|
} |
|
|
} |
|
|
let deltCurrentItem = (bookId) =>{ |
|
|
|
|
|
// const targetList = type === 'active1' ? data.list : data.list2 |
|
|
|
|
|
const index = data.list.findIndex(item => item.bookId === bookId) |
|
|
|
|
|
if (index !== -1) { |
|
|
|
|
|
// data.list.splice(index, 1) |
|
|
|
|
|
let ids = []; |
|
|
|
|
|
ids.push(data.list[index].bookId) |
|
|
|
|
|
ids = ids.join(','); |
|
|
|
|
|
deltBookShoppingCart(ids) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cartDelt = () => { |
|
|
|
|
|
data.isDeltHandle = !data.isDeltHandle |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let deltCurrentItem = (bookId) => { |
|
|
|
|
|
deltBookShoppingCart(bookId) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 商品单选 |
|
|
// 商品单选 |
|
|
let handleSingle = (index) => { |
|
|
let handleSingle = (index) => { |
|
|
const selectedProductsCount = data.list.filter(item => item.checked).length; |
|
|
|
|
|
if (selectedProductsCount === 1 && !data.list.find(p => p.checked).checked) { |
|
|
|
|
|
data.activeSelect = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
data.activeSelect = selectedProductsCount === data.list.length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// const selectedProductsCount = data.list.filter((item) => item.checked).length |
|
|
|
|
|
// if ( |
|
|
|
|
|
// selectedProductsCount === 1 && !data.list.find((p) => p.checked).checked |
|
|
|
|
|
// ) { |
|
|
|
|
|
// data.activeSelect = false |
|
|
|
|
|
// } else { |
|
|
|
|
|
// data.activeSelect = selectedProductsCount === data.list.length |
|
|
|
|
|
// } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 全选 |
|
|
// 全选 |
|
|
let handleselectedAll = () =>{ |
|
|
|
|
|
data.list.forEach(item => { |
|
|
|
|
|
item.checked = data.activeSelect; |
|
|
|
|
|
|
|
|
let handleselectedAll = (index) => { |
|
|
|
|
|
data.list[index].forEach(item=>{ |
|
|
|
|
|
item.checked = data.list[index].activeSelect |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let confirmDelt = () => { |
|
|
|
|
|
if(data.activeSelect){ |
|
|
|
|
|
// data.list = [] |
|
|
|
|
|
// let ids = []; |
|
|
|
|
|
// for (let i = 0; i < data.list.length; i++) { |
|
|
|
|
|
// ids.push(data.list[i].bookId) |
|
|
|
|
|
|
|
|
let goPay = () => { |
|
|
|
|
|
// let bookIds = data.list.filter(item => item.checked).map(item => item.bookId); |
|
|
|
|
|
// console.log('bookIds',bookIds) |
|
|
|
|
|
// if(bookIds.length === 0){ |
|
|
|
|
|
// Toast('请选择您需要下单的书籍') |
|
|
|
|
|
// }else{ |
|
|
|
|
|
// bookIds = bookIds.join(',') |
|
|
|
|
|
// console.log(bookIds) |
|
|
|
|
|
// getMyAddress() |
|
|
|
|
|
// // addPlaceOrder(bookIds) |
|
|
// } |
|
|
// } |
|
|
// ids = parse.ids.join(','); |
|
|
|
|
|
// deltBookShoppingCart(ids) |
|
|
|
|
|
|
|
|
data.checkedBooksPay = data.list |
|
|
|
|
|
.flat() // 将二维数组转为一维数组 |
|
|
|
|
|
.filter(item => item.checked === true) |
|
|
|
|
|
.map(item => item); |
|
|
|
|
|
console.log(data.checkedBooksPay) |
|
|
|
|
|
if(data.checkedBooksPay.length === 0){ |
|
|
|
|
|
Toast('请选择你需要下单的书籍') |
|
|
}else{ |
|
|
}else{ |
|
|
const index = data.list.findIndex(p => p.checked); |
|
|
|
|
|
if (index !== -1) { |
|
|
|
|
|
data.list.splice(index, 1); |
|
|
|
|
|
}else{ |
|
|
|
|
|
Toast('请选择你需要删除的书籍') |
|
|
|
|
|
|
|
|
getMyAddress() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let addPlaceOrder = (param) => { |
|
|
|
|
|
proxy.$http |
|
|
|
|
|
.put( |
|
|
|
|
|
proxy.$API.PLACEORDER, |
|
|
|
|
|
param, |
|
|
|
|
|
{ |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded', |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
if(res.errCode === 0){ |
|
|
|
|
|
proxy.$router.push({ path: '/CartResult' }) |
|
|
} |
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((res) => { |
|
|
|
|
|
console.log(res) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let getMyAddress = () => { |
|
|
|
|
|
let param = { |
|
|
|
|
|
openid: 'ocHu-sysUQ6-xb9knAJ5mATqCOJE' |
|
|
|
|
|
} |
|
|
|
|
|
proxy.$http |
|
|
|
|
|
.get(proxy.$API.MYADDRESS, { |
|
|
|
|
|
params: param, |
|
|
|
|
|
}) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
if(res.data.myAddress.length !== 0){ |
|
|
|
|
|
const defaultAddress = res.data.myAddress.find(function(address) { |
|
|
|
|
|
return address.isDefault === 1; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 将数据按照 supplierName 进行分组 |
|
|
|
|
|
const bookIdMap = new Map(); |
|
|
|
|
|
for (const item of data.checkedBooksPay) { |
|
|
|
|
|
if (!bookIdMap.has(item.supplierName)) { |
|
|
|
|
|
bookIdMap.set(item.supplierName, []); |
|
|
|
|
|
} |
|
|
|
|
|
bookIdMap.get(item.supplierName).push(item.bookId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 遍历每个 supplierName 对应的 bookId,进行相应的操作 |
|
|
|
|
|
for (const [key, value] of bookIdMap) { |
|
|
|
|
|
console.log(`SupplierName: ${key}`); |
|
|
|
|
|
console.log(`BookId list: ${value}`); |
|
|
|
|
|
let param = { |
|
|
|
|
|
addressId: defaultAddress.id, |
|
|
|
|
|
bookIds: value.join(',') |
|
|
|
|
|
} |
|
|
|
|
|
console.log(param) |
|
|
|
|
|
addPlaceOrder(param) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
Toast('请先添加收货地址后再下单') |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((res) => { |
|
|
|
|
|
console.log(res) |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
@ -259,17 +451,20 @@ export default { |
|
|
confirmDelt, |
|
|
confirmDelt, |
|
|
getMyshoppingCart, |
|
|
getMyshoppingCart, |
|
|
getOnlineBookDetail, |
|
|
getOnlineBookDetail, |
|
|
deltBookShoppingCart |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
deltBookShoppingCart, |
|
|
|
|
|
addPlaceOrder, |
|
|
|
|
|
allSelected, |
|
|
|
|
|
getMyAddress |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
<style scoped lang="scss"> |
|
|
.cart-main{ |
|
|
|
|
|
padding: 0 .16rem 2.2rem .16rem; |
|
|
|
|
|
color: #191A1A; |
|
|
|
|
|
.cart-top{ |
|
|
|
|
|
|
|
|
.cart-main { |
|
|
|
|
|
padding: 0 0.16rem 2.2rem 0.16rem; |
|
|
|
|
|
color: #191a1a; |
|
|
|
|
|
.cart-top { |
|
|
position: fixed; |
|
|
position: fixed; |
|
|
top: 0; |
|
|
top: 0; |
|
|
right: 0; |
|
|
right: 0; |
|
@ -277,71 +472,70 @@ export default { |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
font-size: .32rem; |
|
|
|
|
|
|
|
|
font-size: 0.32rem; |
|
|
height: 1rem; |
|
|
height: 1rem; |
|
|
padding: 0 .32rem; |
|
|
|
|
|
|
|
|
padding: 0 0.32rem; |
|
|
background-color: #fff; |
|
|
background-color: #fff; |
|
|
box-shadow: 0 0.06rem 0.1rem 1px #EFECEC; |
|
|
|
|
|
|
|
|
box-shadow: 0 0.06rem 0.1rem 1px #efecec; |
|
|
z-index: 999; |
|
|
z-index: 999; |
|
|
.cart-num{ |
|
|
|
|
|
font-size: .32rem; |
|
|
|
|
|
|
|
|
.cart-num { |
|
|
|
|
|
font-size: 0.32rem; |
|
|
opacity: 0.6; |
|
|
opacity: 0.6; |
|
|
span{ |
|
|
|
|
|
|
|
|
span { |
|
|
font-size: 0.3rem; |
|
|
font-size: 0.3rem; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
.cart-list{ |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
.cart-list { |
|
|
padding-top: 1.2rem; |
|
|
padding-top: 1.2rem; |
|
|
} |
|
|
|
|
|
.cart-item{ |
|
|
|
|
|
padding: .24rem; |
|
|
|
|
|
margin-bottom: .2rem; |
|
|
|
|
|
box-shadow: 0px .03rem 0.6rem 1px rgba(0,0,0,0.08); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
.cart-item { |
|
|
|
|
|
padding: 0.24rem; |
|
|
|
|
|
margin-bottom: 0.2rem; |
|
|
|
|
|
box-shadow: 0px 0.03rem 0.6rem 1px rgba(0, 0, 0, 0.08); |
|
|
border-radius: 0.1rem; |
|
|
border-radius: 0.1rem; |
|
|
background-color: #fff; |
|
|
background-color: #fff; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.product-list{ |
|
|
|
|
|
.product-item{ |
|
|
|
|
|
|
|
|
.product-list { |
|
|
|
|
|
.product-item { |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: flex-start; |
|
|
justify-content: flex-start; |
|
|
margin-top: .3rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
margin-top: 0.3rem; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.cart-pay{ |
|
|
|
|
|
|
|
|
.cart-pay { |
|
|
position: fixed; |
|
|
position: fixed; |
|
|
left: 0; |
|
|
left: 0; |
|
|
right: 0; |
|
|
right: 0; |
|
|
bottom: 0.98rem; |
|
|
bottom: 0.98rem; |
|
|
padding: 0 .32rem; |
|
|
|
|
|
|
|
|
padding: 0 0.32rem; |
|
|
height: 1rem; |
|
|
height: 1rem; |
|
|
background: linear-gradient(#fff, #f1f1f1); |
|
|
background: linear-gradient(#fff, #f1f1f1); |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
.payment-right{ |
|
|
|
|
|
|
|
|
.payment-right { |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
font-size: .28rem; |
|
|
|
|
|
.total-num{ |
|
|
|
|
|
font-size: 0.28rem; |
|
|
font-size: 0.28rem; |
|
|
span{ |
|
|
|
|
|
font-size: .4rem; |
|
|
|
|
|
|
|
|
.total-num { |
|
|
|
|
|
font-size: 0.28rem; |
|
|
|
|
|
span { |
|
|
|
|
|
font-size: 0.4rem; |
|
|
font-weight: bold; |
|
|
font-weight: bold; |
|
|
color: #FF3871; |
|
|
|
|
|
.rmb{ |
|
|
|
|
|
|
|
|
color: #ff3871; |
|
|
|
|
|
.rmb { |
|
|
font-style: normal; |
|
|
font-style: normal; |
|
|
font-size: .28rem; |
|
|
|
|
|
|
|
|
font-size: 0.28rem; |
|
|
text-decoration: none; |
|
|
text-decoration: none; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
.pay-btn{ |
|
|
|
|
|
|
|
|
.pay-btn { |
|
|
width: 1.5rem; |
|
|
width: 1.5rem; |
|
|
height: 0.6rem; |
|
|
height: 0.6rem; |
|
|
margin-left: 0.4rem; |
|
|
margin-left: 0.4rem; |
|
@ -351,45 +545,45 @@ export default { |
|
|
background: url('@assets/images/btn3.png') no-repeat center center; |
|
|
background: url('@assets/images/btn3.png') no-repeat center center; |
|
|
background-size: 100% 100%; |
|
|
background-size: 100% 100%; |
|
|
} |
|
|
} |
|
|
.delt-btn{ |
|
|
|
|
|
|
|
|
.delt-btn { |
|
|
width: 1.5rem; |
|
|
width: 1.5rem; |
|
|
height: 0.6rem; |
|
|
height: 0.6rem; |
|
|
line-height: 0.6rem; |
|
|
line-height: 0.6rem; |
|
|
font-size: .28rem; |
|
|
|
|
|
|
|
|
font-size: 0.28rem; |
|
|
color: #000; |
|
|
color: #000; |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
border: 0.02rem solid #000; |
|
|
border: 0.02rem solid #000; |
|
|
opacity: 0.6; |
|
|
opacity: 0.6; |
|
|
border-radius: .4rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
border-radius: 0.4rem; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.van-checkbox{ |
|
|
|
|
|
margin-right: .2rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.van-checkbox { |
|
|
|
|
|
margin-right: 0.2rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
:deep(.van-checkbox__icon){ |
|
|
|
|
|
height: .35rem; |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__icon .van-icon){ |
|
|
|
|
|
width: .35rem; |
|
|
|
|
|
height: .35rem; |
|
|
|
|
|
border-color: rgba(0,0,0,.3); |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__icon--checked .van-icon){ |
|
|
|
|
|
|
|
|
:deep(.van-checkbox__icon) { |
|
|
|
|
|
height: 0.35rem; |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__icon .van-icon) { |
|
|
|
|
|
width: 0.35rem; |
|
|
|
|
|
height: 0.35rem; |
|
|
|
|
|
border-color: rgba(0, 0, 0, 0.3); |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__icon--checked .van-icon) { |
|
|
border: none; |
|
|
border: none; |
|
|
background: url('@assets/images/selected.png') no-repeat transparent; |
|
|
background: url('@assets/images/selected.png') no-repeat transparent; |
|
|
background-size: .35rem .35rem; |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-icon-success:before){ |
|
|
|
|
|
|
|
|
background-size: 0.35rem 0.35rem; |
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-icon-success:before) { |
|
|
display: none; |
|
|
display: none; |
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__label){ |
|
|
|
|
|
font-size: .28rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
:deep(.van-checkbox__label) { |
|
|
|
|
|
font-size: 0.28rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.bookItem-dialog-detail{ |
|
|
|
|
|
|
|
|
.bookItem-dialog-detail { |
|
|
border-bottom: none; |
|
|
border-bottom: none; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |