jiazhipeng 1 month ago
parent
commit
991ce482d3
  1. 8
      src/libs/axios.js
  2. 10
      src/libs/utils.js
  3. 13
      src/router/index.js
  4. 2
      src/views/User/Index.vue
  5. 12
      src/views/User/MessageList.vue
  6. 241
      src/views/User/OrderList.vue
  7. 476
      src/views/User/ShoppingCart.vue
  8. 45
      src/views/User/UserCenter.vue
  9. 65
      src/views/User/UserInfo.vue
  10. 13
      vue.config.js

8
src/libs/axios.js

@ -9,16 +9,20 @@ const http = axios.create({
// 添加请求拦截器 // 添加请求拦截器
http.interceptors.request.use((config) => { http.interceptors.request.use((config) => {
const { customBaseURL } = config.params || {}; const { customBaseURL } = config.params || config.data || {};
if (customBaseURL) { if (customBaseURL) {
config.baseURL = customBaseURL; config.baseURL = customBaseURL;
if (config.params) {
delete config.params.customBaseURL; delete config.params.customBaseURL;
} else if (config.data) {
delete config.data.customBaseURL;
}
} else { } else {
config.baseURL = process.env.VUE_APP_URL; config.baseURL = process.env.VUE_APP_URL;
} }
const token = store.state.user?.userInfo?.token || ''; const token = store.state.user?.userInfo?.token || '';
config.headers['token'] = token config.headers['token'] = token || "745f2b4c-49b7-4393-bf58-bc380a87149a";
config.headers['Content-Type'] = 'application/json;charset=UTF-8'; config.headers['Content-Type'] = 'application/json;charset=UTF-8';
// 显示加载中状态(Element UI 的 Loading) // 显示加载中状态(Element UI 的 Loading)

10
src/libs/utils.js

@ -62,7 +62,17 @@ export default {
} else { } else {
return 'https://static.ticket.sz-trip.com' + img; return 'https://static.ticket.sz-trip.com' + img;
} }
},
imgToBase64(img) {
let reader = new FileReader();
reader.readAsDataURL(img);
return new Promise((resolve, reject) => {
reader.onload = () => {
resolve(reader.result);
} }
});
},
} }
} }
} }

13
src/router/index.js

@ -172,6 +172,12 @@ const router = new Router({
meta: { title: '消息中心 - 精品商城', keepAlive: false }, meta: { title: '消息中心 - 精品商城', keepAlive: false },
component: () => import('@/views/User/MessageList.vue') component: () => import('@/views/User/MessageList.vue')
}, },
{
path: 'PurchaserAdd',
name: 'PurchaserAdd',
meta: { title: '添加采购单位信息 - 精品商城', keepAlive: false },
component: () => import('@/views/User/PurchaserAdd.vue')
},
], ],
}, },
{ {
@ -186,12 +192,7 @@ const router = new Router({
meta: { title: '订单详情 - 精品商城', keepAlive: false }, meta: { title: '订单详情 - 精品商城', keepAlive: false },
component: () => import('@/views/Order/OrderDetail.vue') component: () => import('@/views/Order/OrderDetail.vue')
}, },
{
path: '/PurchaserAdd',
name: 'PurchaserAdd',
meta: { title: '添加采购单位信息 - 精品商城', keepAlive: false },
component: () => import('@/views/User/PurchaserAdd.vue')
},
{ {
path: '/OrderPay', path: '/OrderPay',
name: 'OrderPay', name: 'OrderPay',

2
src/views/User/Index.vue

@ -30,7 +30,7 @@ export default {
{title: '我的足迹',path:"/User/ViewHistory" }, {title: '我的足迹',path:"/User/ViewHistory" },
{title: '消息中心',path:"/User/MessageList" }, {title: '消息中心',path:"/User/MessageList" },
{title: '个人信息',path:"/User/UserInfo" }, {title: '个人信息',path:"/User/UserInfo" },
{title: '账号设置',path:"" }, {title: '采购人信息',path:"/User/PurchaserAdd" },
{title: '我的收货地址',path:"/User/UserAddress" } {title: '我的收货地址',path:"/User/UserAddress" }
] ]
} }

12
src/views/User/MessageList.vue

@ -5,11 +5,14 @@
<!-- 通知列表 --> <!-- 通知列表 -->
<el-card v-for="(item, index) in currentPageNotifications" :key="index" class="notification-card" :class="{ 'read': item.isRead }"> <el-card v-for="(item, index) in currentPageNotifications" :key="index" class="notification-card" :class="{ 'read': item.isRead }">
<div class="notification-header"> <div class="notification-header" @click="toggleExpand(item)">
<span class="dot" v-if="!item.isRead"></span> <span class="dot" v-if="!item.isRead"></span>
<span class="title">{{ item.title }}</span> <span class="title">{{ item.title }}</span>
<el-button type="text" @click="toggleExpand(item)" class="expand-btn"> <el-button type="text" class="expand-btn">
{{ item.isExpanded? '收起 ^' : '展开 ∨' }} {{ item.isExpanded? '收起' : '展开' }}
<i v-if="isExpanded" class="el-icon-arrow-up"></i>
<i v-else class="el-icon-arrow-down"></i>
</el-button> </el-button>
<span class="date">{{ item.date }}</span> <span class="date">{{ item.date }}</span>
</div> </div>
@ -106,8 +109,7 @@ export default {
<style scoped> <style scoped>
.notification-page { .notification-page {
width: 800px; width: 100%;
margin: 30px auto;
} }
.mark-all-read { .mark-all-read {
text-align: right; text-align: right;

241
src/views/User/OrderList.vue

@ -12,10 +12,10 @@
<div class="filter-bar"> <div class="filter-bar">
<el-form :inline="true" :model="filterForm" size="small"> <el-form :inline="true" :model="filterForm" size="small">
<el-form-item label="商品名称"> <el-form-item label="商品名称">
<el-input v-model="filterForm.goodsName" placeholder="请输入商品名称"></el-input> <el-input v-model="filterForm.keywords" placeholder="请输入商品名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="订单编号"> <el-form-item label="订单编号">
<el-input v-model="filterForm.orderNo" placeholder="请输入订单编号"></el-input> <el-input v-model="filterForm.order_id" placeholder="请输入订单编号"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="下单时间"> <el-form-item label="下单时间">
<el-date-picker v-model="filterForm.createTime" type="daterange" range-separator="" start-placeholder="开始日期" <el-date-picker v-model="filterForm.createTime" type="daterange" range-separator="" start-placeholder="开始日期"
@ -26,16 +26,11 @@
</el-form-item> </el-form-item>
<el-form-item label="交易状态"> <el-form-item label="交易状态">
<el-select v-model="filterForm.tradeStatus" placeholder="请选择" style="width: 200px;"> <el-select v-model="filterForm.tradeStatus" placeholder="请选择" style="width: 200px;">
<el-option label="全部" value=""></el-option> <el-option v-for="(item,i) in typeList" :key="i" :label="item.name" :value="item.id"></el-option>
<el-option label="待付款" value="pendingPayment"></el-option>
<el-option label="待发货" value="pendingDelivery"></el-option>
<el-option label="配送中" value="delivering"></el-option>
<el-option label="已完成" value="completed"></el-option>
<el-option label="已取消" value="cancelled"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="完成时间"> <el-form-item label="完成时间">
<el-date-picker v-model="filterForm.createTime" type="daterange" range-separator="" start-placeholder="开始日期" <el-date-picker v-model="filterForm.finishTime" type="daterange" range-separator="" start-placeholder="开始日期"
end-placeholder="结束日期" value-format="yyyy-MM-dd"></el-date-picker> end-placeholder="结束日期" value-format="yyyy-MM-dd"></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -64,32 +59,30 @@
</div> </div>
<!-- 订单卡片 - 按商家合并商品 --> <!-- 订单卡片 - 按商家合并商品 -->
<div class="order-card" v-for="order in filteredOrders" :key="order.id"> <div class="order-card" v-for="order in orders" :key="order.id">
<!-- 订单头部 - 包含商家信息 --> <!-- 订单头部 - 包含商家信息 -->
<div class="order-header flex-between"> <div class="order-header flex-between">
<div style="display: flex;"> <div style="display: flex;">
<div >订单号: {{ order.orderNo }}</div> <div >订单号: {{ order.order_id }}</div>
<div style="padding-left: 60px;">下单时间{{ order.createTime }}</div> <div style="padding-left: 60px;">下单时间{{ order.create_time }}</div>
</div> </div>
<div class="product-status"> <div class="product-status">
<el-tag :type="getStatusTagType(order.status)" size="small">{{ getStatusText(order.status) }}</el-tag> <el-tag :type="getStatusTagType(order.state)" size="small">{{ order.state_text }}</el-tag>
</div> </div>
</div> </div>
<!-- 订单商品列表 --> <!-- 订单商品列表 -->
<div class="order-products"> <div class="order-products">
<div class="product-item" v-for="product in order.products" :key="product.id"> <div class="product-item" v-for="product in order.order_product_list" :key="product.id">
<img :src="product.image" class="product-image" :alt="product.name"> <img :src="product.product_img" class="product-image" >
<div class="product-details"> <div class="product-details">
<div class="product-name">{{ product.name }}</div> <div class="product-name">{{ product.product_title }}</div>
<div class="product-spec">{{ product.spec }}</div> <div class="product-spec">{{ product.sku_name }}</div>
</div> </div>
<div class="product-price">¥{{ product.price.toFixed(2) }}</div> <div class="product-price">¥{{ (product.product_price/100).toFixed(2) }}</div>
<div class="product-quantity">x{{ product.quantity }}</div> <div class="product-quantity">x{{ product.product_num }}</div>
<div class="product-total">¥{{ (product.price * product.quantity).toFixed(2) }}</div> <div class="product-total">¥{{ (product.paid_money/100).toFixed(2) }}</div>
<!-- <div class="product-status">
<el-tag :type="getStatusTagType(product.status)" size="small">{{ getStatusText(product.status) }}</el-tag>
</div> -->
<div class="product-actions"> <div class="product-actions">
<el-button type="text" size="mini"> 商品详情</el-button> <el-button type="text" size="mini"> 商品详情</el-button>
</div> </div>
@ -100,7 +93,7 @@
<div class="order-footer"> <div class="order-footer">
<div class="order-summary"> <div class="order-summary">
<div class="order-amount"> <div class="order-amount">
合计: <strong>¥{{ order.totalAmount.toFixed(2) }}</strong> (含运费 ¥{{ order.freight.toFixed(2) }}) 合计: <strong>¥{{ (order.paid_money/100).toFixed(2) }}</strong> (含运费 ¥{{ (order.total_post_fee/100).toFixed(2) }})
</div> </div>
<!-- <div class="order-tips"> <!-- <div class="order-tips">
{{ order.products.length }}件商品 {{ order.products.length }}件商品
@ -140,18 +133,18 @@
</div> </div>
</div> </div>
</div> </div>
<el-empty description="暂无订单" v-if="filteredOrders.length<=0"></el-empty> <el-empty description="暂无订单" v-if="orders.length<=0"></el-empty>
<!-- 分页 --> <!-- 分页 -->
<div style="text-align: right; margin-top: 20px;"> <div style="text-align: right; margin-top: 20px;">
<el-pagination <el-pagination
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
:current-page="currentPage" :current-page="filterForm.currentPage"
:page-sizes="[5, 10, 20]" :page-sizes="[5, 10, 20]"
:page-size="pageSize" :page-size="filterForm.limit"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
:total="filteredOrders.length" :total="filterForm.total"
></el-pagination> ></el-pagination>
</div> </div>
</div> </div>
@ -163,181 +156,69 @@ export default {
name: 'OrderList', name: 'OrderList',
data () { data () {
return { return {
activeTab: 'all', activeTab: 'ALL',
currentPage: 1,
pageSize: 10,
filterForm: { filterForm: {
goodsName: '', keywords: "",
orderNo: '', currentPage: 1,
createTime: '', limit: 10,
merchantName: '', order_id: "",
tradeStatus: '' createTime: null,
start_date: "",
end_date: "",
total: 1,
}, },
typeList: [
{ name: '全部', id: 'ALL' },
{ name: '待付款', id: 'WAIT_PAYMENT' },
{ name: '待发货', id: 'WAIT_POST' },
{ name: '待使用/出行', id: 'WAIT_USE' },
{ name: '待收货', id: 'WAIT_DELIVERY' },
{ name: '退款/售后', id: 'NEED_REFUND' }
],
// - // -
orders: [ orders: []
{
id: 1,
orderNo: '209907091214560078',
createTime: '2099-07-09 10:47:49',
status: 'pendingPayment',
totalAmount: 937,
freight: 15,
isReviewed: false,
merchant: {
id: 101,
name: '花艺生活馆',
isOfficial: true
},
products: [
{
id: 1001,
name: '深情挚爱/卡罗拉玫瑰',
image: 'https://picsum.photos/200/200?random=1',
spec: '卡罗拉玫瑰33枝',
price: 349,
quantity: 1,
status: 'pendingPayment'
},
{
id: 1002,
name: '精美包装纸',
image: 'https://picsum.photos/200/200?random=4',
spec: '粉色',
price: 38,
quantity: 2,
status: 'pendingPayment'
}
]
},
{
id: 2,
orderNo: '209907091214560079',
createTime: '2099-07-09 10:48:49',
status: 'pendingDelivery',
totalAmount: 199,
freight: 0,
isReviewed: false,
merchant: {
id: 102,
name: '北欧家居旗舰店',
isOfficial: true
},
products: [
{
id: 2001,
name: '北欧花艺素雅仿真花',
image: 'https://picsum.photos/200/200?random=2',
spec: '白色',
price: 199,
quantity: 1,
status: 'pendingDelivery'
}
]
},
{
id: 3,
orderNo: '209907091214560080',
createTime: '2099-07-09 10:49:49',
status: 'delivering',
totalAmount: 389,
freight: 10,
isReviewed: false,
merchant: {
id: 101,
name: '花艺生活馆',
isOfficial: true
},
products: [
{
id: 3001,
name: '香槟玫瑰+白玫瑰混搭',
image: 'https://picsum.photos/200/200?random=3',
spec: '混搭',
price: 389,
quantity: 1,
status: 'delivering'
}
]
}
]
} }
}, },
computed: { computed: {
//
filteredOrders() {
let result = [...this.orders];
//
if (this.activeTab !== 'all') {
result = result.filter(order => order.status === this.activeTab);
}
// },
if (this.filterForm.goodsName) { mounted() {
const keyword = this.filterForm.goodsName.toLowerCase(); this.getList();
result = result.filter(order => {
return order.products.some(product =>
product.name.toLowerCase().includes(keyword)
);
});
}
//
if (this.filterForm.orderNo) {
result = result.filter(order =>
order.orderNo.includes(this.filterForm.orderNo)
);
}
//
if (this.filterForm.merchantName) {
const keyword = this.filterForm.merchantName.toLowerCase();
result = result.filter(order =>
order.merchant.name.toLowerCase().includes(keyword)
);
}
//
if (this.filterForm.tradeStatus) {
result = result.filter(order =>
order.status === this.filterForm.tradeStatus
);
}
return result;
}
}, },
methods: { methods: {
getList() {
this.post({
...this.filterForm,
offset:this.filterForm.currentPage*this.filterForm.limit,
customBaseURL:"/api",
},'/api/order/list').then(res=>{
this.orders = res.data.list
this.filterForm.total = res.data.total
})
},
// //
search() { search() {
this.currentPage = 1; //
this.$message({
message: '搜索条件已应用',
type: 'info'
});
}, },
// //
reset() { reset() {
this.filterForm = {
goodsName: '',
orderNo: '',
createTime: '',
merchantName: '',
tradeStatus: ''
};
this.activeTab = 'all';
this.currentPage = 1;
}, },
// //
handleSizeChange(val) { handleSizeChange(val) {
this.pageSize = val; this.filterForm.limit = val;
this.filterForm.currentPage = 1;
this.getList();
}, },
// //
handleCurrentChange(val) { handleCurrentChange(val) {
this.currentPage = val; this.filterForm.currentPage = val;
this.getList();
}, },
// //

476
src/views/User/ShoppingCart.vue

@ -1,226 +1,376 @@
<template> <template>
<div class="bg"> <div class="bg">
<div class="cart-page common-card">
<!-- 购物车标题与全选 -->
<div class="cart-header"> <div>
购物车(全部 {{ totalCount }} ) <div class="order-products" style="padding:0 20px;background: #f8f9fa; border-top: 1px solid #eee; border-bottom: 1px solid #eee;margin-bottom: 20px;">
</div> <div class="product-item" >
<div class="product-select">
<!-- 商品列表表格 --> <el-checkbox v-model="selectAll" @change="handleSelectAll">全选</el-checkbox>
<el-table :data="currentPageData" style="width: 100%" </div>
@select="selectRow" @select-all="selectAll" <div class="product-details">
ref="multipleTable"> <div class="product-name">商品</div>
<!-- 多选框列 --> </div>
<el-table-column type="selection" width="55" align="center"/> <div class="product-box">单价()</div>
<!-- 商品图片 --> <div class="product-quantity">数量</div>
<el-table-column label="商品" prop="image" > <div class="product-box">收货方式</div>
<template slot-scope="scope"> <div class="product-box">小计()</div>
<div style="display: flex;align-items: center;"> <div class="product-box">操作</div>
<img src="https://picsum.photos/200/200?random=1" alt="商品" class="product-img">
<div style="padding-left: 10px;">{{ scope.row.title }}</div> </div>
</div> </div>
</template>
</el-table-column> <!-- 订单卡片 - 按商家合并商品 -->
<!-- 规格 --> <div class="order-card" v-for="shop in list" :key="shop.id">
<el-table-column label="规格" prop="spec" align="center" /> <!-- 订单头部 - 包含商家信息 -->
<!-- 单价 --> <div class="order-header flex-between">
<el-table-column label="单价(元)" prop="price" align="center" width="100"/> <div class="product-select">
<!-- 数量 --> <el-checkbox v-model="shop.selected" @change="handleSelectShop(shop)"><span style="opacity: 0;">全选</span></el-checkbox>
<el-table-column label="数量" prop="quantity" width="160" align="center"> </div>
<template slot-scope="scope"> <div class="product-details">
<el-input-number size="small" <div class="product-name">供应商名称{{ shop.shop_name }}</div>
v-model="scope.row.quantity" :min="1" :step="1"/> </div>
</template> </div>
</el-table-column>
<!-- 金额 --> <!-- 订单商品列表 -->
<el-table-column label="金额(元)" prop="amount" width="100" align="center"> <div class="order-products">
<template slot-scope="scope"> <div class="product-item" v-for="goods in shop.goods" :key="goods.id">
¥{{ scope.row.price * scope.row.quantity }} <div class="product-select">
</template> <el-checkbox v-model="goods.selected" @change="handleSelect"><span style="opacity: 0;">全选</span></el-checkbox>
</el-table-column> </div>
<!-- 操作 --> <div class="product-details flex-between">
<el-table-column label="操作" width="100" align="center"> <img :src="goods.product.headimg" class="product-image">
<template slot-scope="scope"> <div class="product-details">
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button> <div class="product-name">{{ goods.product.title }}</div>
</template> <div class="product-spec">{{ goods.sku.sku_name }}</div>
</el-table-column> </div>
</el-table> </div>
<div class="product-box ">¥{{ (goods.sku.price/100).toFixed(2) }}</div>
<!-- 分页组件 --> <div class="product-quantity">
<el-input-number size="small" v-model="goods.num" @change="handleNumChange(goods)" :min="1" :step="1"/>
</div>
<div class="product-box">邮寄</div>
<div class="product-box product-price">¥{{ (goods.num * goods.sku.price/100).toFixed(2) }}</div>
<div class="product-box">
<el-button type="text" size="mini" @click="delItem(goods)">删除</el-button>
</div>
</div>
</div>
</div>
<el-empty description="暂无数据" v-if="list.length<=0"></el-empty>
<!-- 分页 -->
<!-- <div style="text-align: right; margin-top: 20px;">
<el-pagination <el-pagination
@size-change="handleSizeChange" @size-change="handleSizeChange"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
:current-page="currentPage" :current-page="currentPage"
:page-sizes="[3, 5, 10]" :page-sizes="[5, 10, 20]"
:page-size="pageSize" :page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
:total="totalCount" :total="list.length"
style="margin-top: 20px; text-align: right;" ></el-pagination>
/> </div> -->
<!-- 底部结算栏 -->
<div class="cart-footer"> <div class="cart-footer">
<el-button :disabled="selectedRows.length === 0" type="text" size="mini" @click="deleteSelected">
删除选中商品
</el-button>
<div class="flex-between">
<div class="selected-info"> <div class="selected-info">
已选商品 {{ selectedRows.length }} 已选商品 <span class="import-text">{{ selectedRows.length }}</span>
总价: ¥0 (不含运费)   
总价: <span class="import-text total-price">{{ totalPrice }}</span> (不含运费)
</div>
<el-button type="primary" @click="handleCheckout" :disabled="selectedRows.length === 0">去结算</el-button>
</div> </div>
<el-button
type="primary"
@click="handleCheckout"
:disabled="selectedRows.length === 0"
>去结算</el-button>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'CartPage', name: 'OrderList',
data() { data () {
return { return {
// activeTab: 'all',
cartData: [ currentPage: 1,
{ id: 1, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称一', price: 349, quantity: 1 }, pageSize: 10,
{ id: 2, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称一', price: 199, quantity: 1 },
{ id: 3, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称一', price: 389, quantity: 1 }, // -
{ id: 4, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称一', price: 249, quantity: 1 }, list: [],
{ id: 5, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称一', price: 449, quantity: 1 }, selectAll: false,
{ id: 6, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称二', price: 129, quantity: 1 },
{ id: 7, image: 'https://via.placeholder.com/60', title: '产品标题产品标题', spec: '规格名称二', price: 279, quantity: 1 }
],
//
pageSize: 3, //
currentPage: 1, //
//
selectedRows: [{id:1}] // ID
} }
}, },
computed: { mounted() {
// this.getList()
totalCount() {
return this.cartData.length
},
//
currentPageData() {
const start = (this.currentPage - 1) * this.pageSize
const end = start + this.pageSize
return this.cartData.slice(start, end)
}, },
computed: {
selectedRows() {
let rows = []
this.list.forEach(v=>{
v.goods.forEach(goods=>{
if (goods.selected) {
rows.push(goods)
}
})
})
return rows
}, },
mounted() { totalPrice() {
this.refreshTableCheck(); let price = 0
this.selectedRows.forEach(v=>{
price += v.num * v.sku.price/100
})
return price.toFixed(2)
}
}, },
methods: { methods: {
refreshTableCheck () { getList(){
this.$nextTick(()=>{ this.post({customBaseURL:"/api"},"/api/cart/get_list",true).then(res=>{
let selectIds = this.selectedRows.map(item => item.id) let resData = (res.data ||[])
this.currentPageData.forEach(item => { let currentSelectGoodsIds = this.selectedRows.map(v=>v.id)
if (selectIds.includes(item.id)) { resData.forEach(item=>{
this.$refs.multipleTable.toggleRowSelection(item, true); item.selected = false
item.goods.forEach(goods=>{
goods.selected = currentSelectGoodsIds.includes(goods.id)
})
})
this.list = resData
this.judgeSelectAll()
})
},
handleSelectAll(val) {
if (val) {
this.list.forEach(t=>{
t.goods.forEach(v=>{
if (v && v.product &&v.sku && v.sku.flag== "off") {
v.selected = false
} else { } else {
this.$refs.multipleTable.toggleRowSelection(item, false); v.selected = true
} }
}) })
}) })
} else {
this.cartList.forEach(t=>{
t.selected = false
})
}
this.judgeSelectAll()
}, },
handleSelectShop(shop) {
// selectedRows if (shop.selected) {
selectRow(selection ,row) { shop.goods.forEach(v=>{
// ID if (v && v.product &&v.sku && v.sku.flag== "off") {
let index = this.selectedRows.findIndex(v=>v.id === row.id) v.selected = false
console.log(index)
if(index>=0){
this.selectedRows.splice(index,1)
} else { } else {
this.selectedRows.push(row) v.selected = true
}
})
} }
console.log(this.selectedRows) this.judgeSelectAll()
},
handleSelect() {
this.judgeSelectAll()
}, },
selectAll (selection) { //
judgeSelectAll() {
this.selectedRows = []
this.list.forEach(v=>{
if (v.goods.some(x=>x.sku.flag=='on')) {
if(v.goods.some(x=>x.sku.flag=="on"&&!x.selected) ) {
v.selected = false;
} else {
v.selected = true;
}
} else {
v.selected = false
}
})
if (selection.length>0) { if (this.list.every(v=>v.selected) && this.list.length>0) {
let currentNotInselection = selection.filter(v => !this.selectedRows.some(x=>x.id==v.id)) this.selectAll = true
this.selectedRows = this.selectedRows.concat(currentNotInselection)
} else { } else {
// selectRows this.selectAll = false
this.selectedRows = this.selectedRows.filter(v => !this.currentPageData.some(x=>x.id==v.id))
} }
console.log(selection)
}, },
//
handleNumChange(goods) {
this.post({id: goods.id, num: goods.num,customBaseURL:"/api"},'/api/cart/update_sku').then(res =>{
})
},
// delItem(item){
handleDelete(row) { this.post({id: item.id,customBaseURL:"/api"},'/api/cart/del_sku').then(res =>{
// cartData this.getList()
this.cartData = this.cartData.filter(item => item.id!== row.id) })
// selectedRowKeys
this.selectedRows = this.selectedRows.filter(v => v.id!== row.id)
console.log('删除商品:', row)
//
this.refreshTableCheck();
}, },
deleteSelected() {
let ids = this.selectedRows.map(v=>v.id).join(',')
this.post({ids: ids,customBaseURL:"/api"},'/api/cart/del_skus').then(res =>{
this.getList()
})
},
// -
//
handleSizeChange(val) { handleSizeChange(val) {
this.pageSize = val this.pageSize = val;
this.currentPage = 1 // 1
this.refreshTableCheck();
}, },
// - //
handleCurrentChange(val) { handleCurrentChange(val) {
this.currentPage = val this.currentPage = val;
this.refreshTableCheck(); },
//
payOrder(orderId) {
this.$message({
message: `订单 ${orderId} 去付款`,
type: 'info'
});
}, },
//
handleCheckout() {
console.log('去结算,选中商品ID:', this.selectedRows)
//
}
} }
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
.common-card{ .bg{
width: 100%; display: flex;
background-color: white; flex-direction: column;
padding: 20px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1); ::v-deep .el-button--text {
} color: #6a8a27;
.cart-page {
.cart-header {
margin-bottom: 10px;
} }
.product-img { ::v-deep .el-tabs__item.is-active{
width: 60px; color: #6a8a27;
height: 60px; }
object-fit: cover; ::v-deep .el-tabs__active-bar{
background-color: #6a8a27
} }
.cart-footer { ::v-deep .el-tabs__item:hover{
color: #6a8a27;
}
}
/* 订单卡片样式 */
.order-card {
border-radius: 4px;
overflow: hidden;
}
/* 订单头部 - 包含商家信息 */
.order-header {
padding: 12px 20px;
display: flex; display: flex;
justify-content: space-between;
align-items: center; align-items: center;
margin-top: 10px; background: rgb(248, 249, 250);
padding: 15px; border-bottom: 1px solid #999;
background-color: #f5f7fa;
border-radius: 4px;
}
.selected-info {
color: #666; color: #666;
font-size: 14px; font-size: 14px;
}
} }
/* 订单商品列表 */
.order-products {
padding: 10px 20px;
}
.product-item {
display: flex;
align-items: center;
padding: 15px 0;
border-bottom: 1px dashed #eee;
font-size: 14px;
}
.product-item:last-child {
border-bottom: none;
}
.product-image {
width: 80px;
height: 80px;
object-fit: cover;
margin-right: 15px;
border-radius: 4px;
}
.product-details {
flex: 1;
}
.product-name {
color: #333;
}
.product-spec {
color: #999;
font-size: 12px;
}
.product-box {
width: 100px;
text-align: center;
color: #333;
}
.product-quantity{
width: 160px;
text-align: center;
color: #333;
}
.product-select {
width: 80px;
color: #333;
}
.product-price{
color: #ff5252;
}
.cart-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
padding: 15px;
background-color: #f5f7fa;
border-radius: 4px;
}
.selected-info {
color: #666;
font-size: 14px;
padding-right: 50px;
}
.import-text{
color: #c7020b;
font-size: 20px;
font-weight: bold;
}
.total-price{
&::before{
content: "¥";
margin-right: 5px;
font-size: 12px;
}
}
</style> </style>

45
src/views/User/UserCenter.vue

@ -14,30 +14,30 @@
<el-card> <el-card>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :xs="24" :sm="8" :md="8" v-for="(item,i) in headFun" :key="i"> <el-col :xs="24" :sm="8" :md="8" v-for="(item,i) in headFun" :key="i">
<div class="feature-item" > <router-link :to="item.path" class="feature-item" >
<div class="feature-icon"> <div class="feature-icon">
<i :class="item.icon"></i> <i :class="item.icon"></i>
</div> </div>
<span class="feature-name">{{ item.title }}</span> <span class="feature-name">{{ item.title }}</span>
<el-button type="text" size="mini" style="margin-top: 5px;">去设置</el-button> <el-button type="text" size="mini" style="margin-top: 5px;">去设置</el-button>
</div> </router-link>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<!-- 个人信息卡片 --> <!-- 个人信息卡片 -->
<el-card> <el-card v-if="userInfo">
<div slot="header">个人信息</div> <div slot="header">个人信息</div>
<div class="user-info"> <div class="user-info">
<img src="https://picsum.photos/id/1005/200/200" alt="用户头像" class="user-avatar"> <img :src="userInfo.avatar" alt="用户头像" class="user-avatar">
<div class="user-details"> <div class="user-details">
<div> <div>
<div class="user-name">张三哥</div> <div class="user-name">{{ userInfo.nickname }}</div>
<div class="user-other-info"> <div class="user-other-info">
ID: 200901071124 ID: {{ userInfo.user_id }}
<el-button type="text" size="mini" @click="copyId">复制</el-button> <el-button type="text" size="mini" @click="copyId">复制</el-button>
</div> </div>
<div class="user-other-info">手机号: 138****5678</div> <div class="user-other-info">手机号: {{ userInfo.mobile }}</div>
</div> </div>
@ -57,7 +57,7 @@
</div> </div>
</div> </div>
<div> <div>
<el-button type="primary" size="mini" style="background-color: #6a8a27;border: none;"> <el-button @click="goPath('/User/UserInfo')" type="primary" size="mini" style="background-color: #6a8a27;border: none;">
<i class="el-icon-edit"></i> 编辑个人信息 <i class="el-icon-edit"></i> 编辑个人信息
</el-button> </el-button>
</div> </div>
@ -108,9 +108,9 @@ export default {
showNotice: true, showNotice: true,
userId: '200901071124', userId: '200901071124',
headFun: [ headFun: [
{icon: "el-icon-location", title: "设置收货地址", path: ""}, {icon: "el-icon-location", title: "设置收货地址", path: "/User/UserAddress"},
{icon: "el-icon-document", title: "设置发票抬头", path: ""}, {icon: "el-icon-document", title: "设置发票抬头", path: "/User/UserInvoice"},
{icon: "el-icon-user", title: "设置采购人信息", path: ""}, {icon: "el-icon-user", title: "设置采购人信息", path: "/User/PurchaserAdd"},
], ],
bargaining: [ bargaining: [
{icon: "el-icon-time", title: "待回复", path: "", value: 2}, {icon: "el-icon-time", title: "待回复", path: "", value: 2},
@ -121,7 +121,9 @@ export default {
{icon: "el-icon-time", title: "待付款", path: "", value: 2}, {icon: "el-icon-time", title: "待付款", path: "", value: 2},
{icon: "el-icon-truck", title: "未发货", path: "", value: 2}, {icon: "el-icon-truck", title: "未发货", path: "", value: 2},
{icon: "el-icon-menu", title: "全部订单", path: "", value: 2}, {icon: "el-icon-menu", title: "全部订单", path: "", value: 2},
] ],
userInfo: null,
} }
@ -129,10 +131,22 @@ export default {
computed: { computed: {
}, },
created() { mounted() {
this.getUserInfo();
}, },
methods: { methods: {
getUserInfo() {
//
this.post({customBaseURL:"/api"},"/api/uservice/user/getMyInfo").then(res=>{
this.userInfo = res.data;
console.log(this.userInfo)
})
},
goPath(path) {
this.$router.push(path);
},
// ID // ID
copyId() { copyId() {
const input = document.createElement('input'); const input = document.createElement('input');
@ -146,7 +160,7 @@ export default {
message: 'ID已复制', message: 'ID已复制',
type: 'success' type: 'success'
}); });
} },
} }
} }
</script> </script>
@ -224,6 +238,7 @@ export default {
border-radius: 50%; border-radius: 50%;
margin-right: 20px; margin-right: 20px;
border: 4px solid #f5f7fa; border: 4px solid #f5f7fa;
object-fit: cover;
} }
.user-details { .user-details {

65
src/views/User/UserInfo.vue

@ -5,7 +5,7 @@
<span>个人信息</span> <span>个人信息</span>
</div> </div>
<div style="padding-right: 200px;"> <div style="padding-right: 200px;">
<el-form :model="user" label-width="100px" size="small"> <el-form ref="userForm" :model="user" label-width="100px" size="small">
<el-form-item label="用户头像"> <el-form-item label="用户头像">
<el-upload class="avatar-uploader" action="#" :auto-upload="false" <el-upload class="avatar-uploader" action="#" :auto-upload="false"
:on-change="handleAvatarChange" :show-file-list="false"> :on-change="handleAvatarChange" :show-file-list="false">
@ -16,11 +16,11 @@
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="*昵称"> <el-form-item label="昵称" prop="nickname" :rules="[{ required: true, message: '请输入昵称' }]">
<el-input v-model="user.nickname" placeholder="请输入昵称"></el-input> <el-input v-model="user.nickname" placeholder="请输入昵称"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="用户ID"> <el-form-item label="用户ID">
<el-input v-model="user.id" disabled> <el-input v-model="user.user_id" disabled>
<template slot="append"> <template slot="append">
<el-button @click="copyId">复制</el-button> <el-button @click="copyId">复制</el-button>
</template> </template>
@ -28,9 +28,9 @@
</el-form-item> </el-form-item>
<el-form-item label="性别"> <el-form-item label="性别">
<el-radio-group v-model="user.gender"> <el-radio-group v-model="user.gender">
<el-radio label="male">男性</el-radio> <el-radio :label="1">男性</el-radio>
<el-radio label="female">女性</el-radio> <el-radio :label="2">女性</el-radio>
<el-radio label="secret">保密</el-radio> <el-radio :label="0">保密</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="生日"> <el-form-item label="生日">
@ -39,7 +39,7 @@
</el-form-item> </el-form-item>
<el-form-item class="form-actions"> <el-form-item class="form-actions">
<el-button type="primary" @click="saveUser">保存</el-button> <el-button type="primary" @click="saveUser">保存</el-button>
<el-button @click="close">关闭</el-button> <!-- <el-button @click="close">关闭</el-button> -->
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -54,16 +54,37 @@ export default {
return { return {
user: { user: {
avatar: '', avatar: '',
nickname: '张三哥', nickname: '',
id: '209901071124', id: '',
gender: 'male', gender: null,
birthday: '' birthday: null,
} }
} }
}, },
mounted() {
this.getUserInfo();
},
methods:{ methods:{
getUserInfo() {
//
this.post({customBaseURL:"/api"},"/api/uservice/user/getMyInfo").then(res=>{
this.user = res.data;
})
},
handleAvatarChange(file) { handleAvatarChange(file) {
this.user.avatar = URL.createObjectURL(file.raw); // this.user.avatar = URL.createObjectURL(file.raw);
this.util.imgToBase64(file.raw).then(base64 => {
console.log(base64);
this.post({
customBaseURL:"/api",
img_base64: base64
}, "/api/pbservice/Other/base64Upload").then(res=>{
this.user.avatar = res.data.url;
})
})
}, },
copyId() { copyId() {
const input = document.createElement('input'); const input = document.createElement('input');
@ -78,17 +99,17 @@ export default {
}); });
}, },
saveUser() { saveUser() {
this.$message({ this.$refs.userForm.validate((valid)=>{
message: '保存成功', if(valid){
type: 'success' this.post({customBaseURL:"/api",...this.user},"/api/uservice/user/profile").then(res=>{
}); if (res.code == 1) {
}, this.$message({ message: '修改成功', type:'success'});
close() {
this.$message({
message: '已关闭',
type: 'info'
});
} }
})
}
})
},
} }
} }

13
vue.config.js

@ -1,5 +1,16 @@
const { defineConfig } = require('@vue/cli-service') const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({ module.exports = defineConfig({
transpileDependencies: true, transpileDependencies: true,
runtimeCompiler: true runtimeCompiler: true,
devServer: {
proxy: {
'/api':{
target: "https://swsz.api.js-dyyj.com",
changeOrigin: true,
pathRewrite: {
'/api':''
},
}
}
}
}) })

Loading…
Cancel
Save