From cf7e71c6d0fb64eeb6b5deac540da843b4bb465c Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期二, 26 八月 2025 10:41:52 +0800 Subject: [PATCH] 关于我们-理念与品牌文化 --- src/views/personalCenter/myCart.vue | 308 +++++++++++++++++++++------------------------------ 1 files changed, 127 insertions(+), 181 deletions(-) diff --git a/src/views/personalCenter/myCart.vue b/src/views/personalCenter/myCart.vue index a726dfc..3c03131 100644 --- a/src/views/personalCenter/myCart.vue +++ b/src/views/personalCenter/myCart.vue @@ -3,16 +3,9 @@ <div class="personalPage-title">鎴戠殑璐墿杞�</div> <div class="personalPage-content"> <div class="deleteBox"> - <el-dialog - v-model="dialogVisible" - width="30%" - draggable - align-center - :modal="false" - > + <el-dialog v-model="dialogVisible" width="30%" draggable align-center :modal="false"> <span> - <el-icon style="color: orange"> <Warning /> </el-icon - >纭瑕佸垹闄ら�変腑鐨勫晢鍝佸悧锛�</span + <el-icon style="color: orange"> <Warning /> </el-icon>纭瑕佸垹闄ら�変腑鐨勫晢鍝佸悧锛�</span > <template #footer> <span class="dialog-footer"> @@ -24,8 +17,7 @@ <el-dialog v-model="showHide" width="30%" draggable align-center :modal="false"> <span - ><el-icon style="color: orange"> <Warning /> </el-icon - >纭瑕佸垹闄ら�変腑鐨勫晢鍝佸悧锛�</span + ><el-icon style="color: orange"> <Warning /> </el-icon>纭瑕佸垹闄ら�変腑鐨勫晢鍝佸悧锛�</span > <template #footer> <span class="dialog-footer"> @@ -34,12 +26,6 @@ </span> </template> </el-dialog> - </div> - - <div class="breadcrumbsBox"> - <p> - 浣嶇疆锛� <span>璐墿杞�({{ total }})</span> - </p> </div> <div class="selectproduct"> <el-table @@ -58,11 +44,8 @@ <el-table-column label="鍏ㄩ��" width="200"> <template #default="scope"> - <div style="position: relative; width: 110px"> - <el-image - :src="scope.row.imgUrl ? scope.row.imgUrl : defaultImg" - class="bookImg" - > + <div style="position: relative;width: 120px;"> + <el-image :src="scope.row.imgUrl ? scope.row.imgUrl : defaultImg" class="bookImg"> </el-image> <div class="labelBox" @@ -76,13 +59,8 @@ </template> </el-table-column> - <el-table-column - property="name" - label="鍟嗗搧淇℃伅" - width="300" - :cell-style="{ margin: '30px' }" - /> - <el-table-column property="productType" label="鍟嗗搧绫诲瀷" width="300" /> + <el-table-column property="name" label="鍟嗗搧淇℃伅" width="200" /> + <el-table-column property="productType" label="鍟嗗搧绫诲瀷" width="200" /> <el-table-column label="浠锋牸"> <template #default="scope">楼{{ scope.row.unitprice.toFixed(2) }}</template> </el-table-column> @@ -126,9 +104,7 @@ 鎬讳环锛�<span v-if="sumUnitprice">楼{{ sumUnitprice.toFixed(2) }}</span> <span v-else>楼0.00</span> </p> - <el-button class="button" type="warning" @click="goPaymentPage" - >缁撶畻</el-button - > + <el-button class="button" type="primary" @click="goPaymentPage">缁撶畻</el-button> </div> </div> </div> @@ -137,128 +113,126 @@ </template> <script setup lang="ts"> -import { onMounted, ref, inject, watch } from "vue"; -import { ElTable, ElMessage } from "element-plus"; -import { reactive } from "vue"; -import { useRouter } from "vue-router"; -import { InfoFilled } from "@element-plus/icons-vue"; -import { useUserStore, useBreadcrumbStore } from "@/store"; -import { getPublicImage } from "@/assets/js/middleGround/tool.js"; -import defaultImg from "@/assets/images/default-book-img.png"; -const dialogVisible = ref(false); -const crumbStore = useBreadcrumbStore(); -const router = useRouter(); -const userStore = useUserStore(); -const MG = inject("MG"); -const total = ref(); -const multipleTableRef = ref(); -const loading = ref(true); -const selectAll = ref(false); -const multipleSelection = ref([]); -const orderNumber = ref(); -const select = ref(false); -const showHide = ref(false); -const selectedItemCount = ref(0); // 鏂板涓�涓彉閲忕敤浜庡瓨鍌ㄥ凡閫夊晢鍝佹暟閲� -const sumUnitprice = ref(); +import { onMounted, ref, inject, watch } from 'vue' +import { ElTable, ElMessage } from 'element-plus' +import { reactive } from 'vue' +import { useRouter } from 'vue-router' +import { useUserStore } from '@/store' +import { getPublicImage } from '@/assets/js/middleGround/tool.js' +import defaultImg from '@/assets/images/default-book-img.png' +const dialogVisible = ref(false) +const router = useRouter() +const userStore = useUserStore() +const MG: any = inject('MG') +const total = ref() +const multipleTableRef = ref() +const loading = ref(true) +const selectAll = ref(false) +const multipleSelection = ref([]) +const orderNumber = ref() +const select = ref(false) +const showHide = ref(false) +const selectedItemCount = ref(0) // 鏂板涓�涓彉閲忕敤浜庡瓨鍌ㄥ凡閫夊晢鍝佹暟閲� +const sumUnitprice = ref() watch(multipleSelection, (newSelection) => { // 褰� multipleSelection.value 鍙戠敓鍙樺寲鏃惰Е鍙戠殑鍥炶皟鍑芥暟 - let sum = 0; + let sum = 0 newSelection.forEach((item) => { - sum += item.unitprice; - }); + sum += item.unitprice + }) - sumUnitprice.value = sum; + sumUnitprice.value = sum - selectedItemCount.value = newSelection.length; -}); + selectedItemCount.value = newSelection.length +}) onMounted(() => { - shoppingCartGet(); + shoppingCartGet() // totalPrice() -}); +}) const batchDelete = (evt) => { - let target = evt.target; - if (target.nodeName == "SPAN") { - target = evt.target.parentNode; + let target = evt.target + if (target.nodeName == 'SPAN') { + target = evt.target.parentNode } - target.blur(); + target.blur() if (multipleSelection.value.length === 0) { // 濡傛灉娌℃湁閫夋嫨浠讳綍鍟嗗搧锛屽彲浠ュ湪姝ゅ缁欏嚭鎻愮ず鎴栬�呯洿鎺ヨ繑鍥� ElMessage({ - message: "鏈�夋嫨鍟嗗搧", - type: "warning", - }); + message: '鏈�夋嫨鍟嗗搧', + type: 'warning', + }) } else { - showHide.value = true; + showHide.value = true // showHide.value = false } -}; +} const handleSelectionChange = (val) => { // console.log(val); - multipleSelection.value = val; + multipleSelection.value = val // 鍒ゆ柇鏄惁鍏ㄩ儴閫夋嫨 if (!delShoppingSelec.value) { if (val.length === shoppingCartData.length) { - selectAll.value = true; + selectAll.value = true } else { - selectAll.value = false; + selectAll.value = false } } -}; +} // 鍒囨崲鎵�鏈夎閫変腑鐘舵�佺殑鏂规硶 const toggleAllSelection = () => { if (shoppingCartData.length === 0) { - selectAll.value = false; + selectAll.value = false ElMessage({ - message: "娌℃湁鍙�夋嫨鐨勫晢鍝�", - type: "warning", - }); + message: '娌℃湁鍙�夋嫨鐨勫晢鍝�', + type: 'warning', + }) } else { - multipleTableRef.value.toggleAllSelection(); + multipleTableRef.value.toggleAllSelection() } -}; -const selectedRow = ref(); +} +const selectedRow = ref() const dialog = (index, row) => { - dialogVisible.value = true; + dialogVisible.value = true // 灏嗗綋鍓嶈鏁版嵁瀛樺偍璧锋潵锛屼互澶囧垹闄ゆ椂浣跨敤 - selectedRow.value = row; -}; + selectedRow.value = row +} const handleDelete = () => { - const row = selectedRow.value; - dialogVisible.value = false; + const row = selectedRow.value + dialogVisible.value = false MG.store .delShoppingCart({ ids: [row.id], }) .then((res) => { - shoppingCartGet(); + shoppingCartGet() ElMessage({ - message: "鍒犻櫎鎴愬姛", - type: "success", - }); + message: '鍒犻櫎鎴愬姛', + type: 'success', + }) //鏇存柊璐墿杞︽暟閲� - userStore.updateRightPop(); + userStore.updateRightPop() }) .catch((error) => { - ElMessage.error("鍒犻櫎澶辫触"); - }); -}; + ElMessage.error('鍒犻櫎澶辫触') + }) +} //琛ㄥ崟鐨勬牱寮� const cellStyle = ({ row, column, rowIndex, columnIndex }) => { if (columnIndex === 4) { - return { color: "#FF6C00" }; + return { color: '#019e58' } } -}; +} -const shoppingCartData = reactive([]); +const shoppingCartData = reactive([]) const shoppingCartGet = () => { let query = { @@ -266,137 +240,112 @@ size: 999, filterList: [], searchList: [], - }; + } MG.store.getShoppingCartProductList(query).then((res) => { const newData = res.datas.map((item) => { - console.log(item.saleMethod.type, "item.saleMethod.type"); - if (item.productMonWithLinkDto.links[0].storeRefCode == "jsek_digitalTextbooks") { - item.typeTxt = "鏁板瓧鏁欐潗"; - item.productType = "鏁板瓧鏁欐潗"; - } else if ( - item.productMonWithLinkDto.links[0].storeRefCode == "jsek_digitalCourses" - ) { - item.typeTxt = "鏁板瓧璇剧▼"; - item.productType = "鏁板瓧璇剧▼"; - } else { - item.typeTxt = "鐢靛瓙涔�"; - item.productType = "鍥句功鏈嶅姟-鐢靛瓙涔�"; - } + item.typeTxt = '鏁板瓧鏁欐潗' + item.productType = '鏁板瓧鏁欐潗' // console.log(item.saleMethod.id); - console.log(item.saleMethod.type, "item.saleMethod.type"); + console.log(item.saleMethod.type, 'item.saleMethod.type') return { saleMethodId: item.saleMethod.id, id: item.id, name: item.linkCmsItems.length && item.linkCmsItems[0].name - ? item.productMonWithLinkDto.product.name + "锛�" + item.linkCmsItems[0].name + ? item.productMonWithLinkDto.product.name + '锛�' + item.linkCmsItems[0].name : item.productMonWithLinkDto.product.name, - type: item.saleMethod.type == "createProductItemSaleMethod" ? "item" : "product", + type: item.saleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product', typeTxt: item.typeTxt, productType: item.productType, - imgUrl: getPublicImage(item.productMonWithLinkDto.product.icon, "", "160"), + imgUrl: getPublicImage(item.productMonWithLinkDto.product.icon, '', '160'), unitprice: item.saleMethod.price, expire: new Date(item.saleMethod.endDate).getTime() < new Date().getTime() || new Date().getTime() < new Date(item.saleMethod.beginDate).getTime() ? true : false, - }; - }); + } + }) // 閲嶆柊璧嬪�� shoppingCartData.value - shoppingCartData.splice(0, shoppingCartData.length, ...newData); - loading.value = false; - }); -}; + shoppingCartData.splice(0, shoppingCartData.length, ...newData) + loading.value = false + }) +} //璺宠浆闈㈠寘灞� const goPaymentPage = async () => { try { // console.log(multipleSelection.value, 346588998) - let expire = multipleSelection.value.filter((item) => item.expire == true); + let expire = multipleSelection.value.filter((item) => item.expire == true) if (expire.length > 0) { ElMessage({ - message: "鎮ㄩ�夋嫨鐨勫晢鍝佹湁涓嶅湪鏈夋晥鏈熷唴鐨�,璇烽噸鏂伴�夋嫨鍙喘涔板晢鍝�!", - type: "warning", - }); + message: '鎮ㄩ�夋嫨鐨勫晢鍝佹湁涓嶅湪鏈夋晥鏈熷唴鐨�,璇烽噸鏂伴�夋嫨鍙喘涔板晢鍝�!', + type: 'warning', + }) } else { - const selectedIds = multipleSelection.value.map((item) => item.id); - const saleMethodId = multipleSelection.value.map((item) => item.saleMethodId); + const selectedIds = multipleSelection.value.map((item) => item.id) + const saleMethodId = multipleSelection.value.map((item) => item.saleMethodId) - console.log(saleMethodId, 789); + console.log(saleMethodId, 789) - let queryCreateOrder = { linkIds: selectedIds }; - const createOrderResult = await MG.store.shoppingCartCreateOrder(queryCreateOrder); - orderNumber.value = createOrderResult.orderNumber; + let queryCreateOrder = { linkIds: selectedIds } + const createOrderResult = await MG.store.shoppingCartCreateOrder(queryCreateOrder) + orderNumber.value = createOrderResult.orderNumber if (selectedIds.length) { - let crumbs = { - name: "璁㈠崟鏀粯", // 闈㈠寘灞戝悕绉� - pathName: "paymentPage", // 闈㈠寘灞戣烦杞矾鐢憋紝鍙紶閫� pathName 鎴� path - isCrumbs: true, // 闈㈠寘灞戠偣鍑昏烦杞椂鏄惁鍒涘缓鏂扮殑闈㈠寘灞戣褰� - type: "shoppingCart", // 濡傛灉闇�瑕佸垱寤烘柊鐨勯潰鍖呭睉璁板綍锛屽垱寤虹殑type - }; - // 鍦ㄥ叏灞�鏁版嵁涓缃潰鍖呭睉 - crumbStore.setCrumbs({ - type: "shoppingCart", - data: [crumbs], - callback: (key) => { - router.push({ - name: "paymentPage", - query: { - crumbsKey: key, - orderNumber: orderNumber.value, - // type: route.query.type, - type: "shoppingCart", - onNorderSaleMethod: saleMethodId, - }, - }); + router.push({ + name: 'paymentPage', + query: { + orderNumber: orderNumber.value, + // type: route.query.type, + type: 'shoppingCart', + onNorderSaleMethod: saleMethodId, }, - }); + }) } else { ElMessage({ - message: "璇烽�夋嫨鍟嗗搧", - type: "warning", - }); + message: '璇烽�夋嫨鍟嗗搧', + type: 'warning', + }) } } } catch (error) { - console.error(error); + console.error(error) // 閿欒澶勭悊閫昏緫 } -}; +} -const delShoppingSelec = ref(); +const delShoppingSelec = ref() const confirmEvent = () => { - showHide.value = false; + showHide.value = false if (multipleSelection.value.length === 0) { // 濡傛灉娌℃湁閫夋嫨浠讳綍鍟嗗搧锛屽彲浠ュ湪姝ゅ缁欏嚭鎻愮ず鎴栬�呯洿鎺ヨ繑鍥� - return; + return } else { - const selectedIds = multipleSelection.value.map((item) => item.id); + const selectedIds = multipleSelection.value.map((item) => item.id) MG.store .delShoppingCart({ ids: selectedIds }) .then((res) => { - delShoppingSelec.value = res; + delShoppingSelec.value = res ElMessage({ - message: "鎵归噺鍒犻櫎鎴愬姛", - type: "success", - }); - selectAll.value = false; + message: '鎵归噺鍒犻櫎鎴愬姛', + type: 'success', + }) + selectAll.value = false // 鍒犻櫎鎴愬姛鍚庯紝鍒锋柊璐墿杞﹀垪琛� - shoppingCartGet(); + shoppingCartGet() //鏇存柊璐墿杞︽暟閲� - userStore.updateRightPop(); + userStore.updateRightPop() }) .catch((error) => { - console.error("鎵归噺鍒犻櫎澶辫触", error); - ElMessage.error("鎵归噺鍒犻櫎澶辫触"); - }); + console.error('鎵归噺鍒犻櫎澶辫触', error) + ElMessage.error('鎵归噺鍒犻櫎澶辫触') + }) } -}; +} </script> <style lang="less" scoped> @@ -496,10 +445,6 @@ } } -.selectproduct { - margin-top: 30px; -} - ::v-deep { .el-checkbox__label { margin-left: 6px; @@ -532,8 +477,8 @@ .el-image__inner { box-shadow: 0px 0px 20px 1px #ccc; object-fit: contain !important; - width: 110px; - height: 140px; + width: 120px; + height: 160px; } .el-icon { @@ -571,6 +516,7 @@ right: 0; margin: 0 !important; border-radius: 0px 0px 0px 5px; + box-sizing: border-box; p { display: flex; -- Gitblit v1.9.1