1.0
This commit is contained in:
@@ -0,0 +1,374 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 页面标题 -->
|
||||
<view class="page-header">
|
||||
<text class="page-title">收货地址</text>
|
||||
<view class="add-btn" @tap="addAddress">
|
||||
<uni-icons type="plus" size="20" color="white"></uni-icons>
|
||||
<text class="add-text">新增地址</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 地址列表 -->
|
||||
<view class="address-list" v-if="!loading && addressList.length > 0">
|
||||
<view class="address-item" v-for="(address, index) in addressList" :key="address.id">
|
||||
<!-- 默认标签 -->
|
||||
<view class="default-tag" v-if="address.is_default === 1">
|
||||
<text class="default-text">默认</text>
|
||||
</view>
|
||||
|
||||
<!-- 地址信息 -->
|
||||
<view class="address-content" @tap="editAddress(address)">
|
||||
<view class="address-header">
|
||||
<text class="consignee-name">{{ address.consignee_name }}</text>
|
||||
<text class="consignee-phone">{{ address.consignee_phone }}</text>
|
||||
</view>
|
||||
<view class="address-detail">
|
||||
<text class="address-text">{{ formatAddress(address) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<view class="address-actions">
|
||||
<view class="action-btn default-btn"
|
||||
v-if="address.is_default !== 1"
|
||||
@tap="setDefaultAddress(address.id)">
|
||||
<text class="action-text">设为默认</text>
|
||||
</view>
|
||||
<view class="action-btn edit-btn" @tap="editAddress(address)">
|
||||
<text class="action-text">编辑</text>
|
||||
</view>
|
||||
<view class="action-btn delete-btn" @tap="deleteAddress(address.id, index)">
|
||||
<text class="action-text">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-if="!loading && addressList.length === 0">
|
||||
<uni-icons type="location" size="100" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无收货地址</text>
|
||||
<button class="add-first-btn" @tap="addAddress">添加收货地址</button>
|
||||
</view>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view class="loading-state" v-if="loading">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
addressList: [],
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.loadAddressList()
|
||||
},
|
||||
onShow() {
|
||||
// 页面显示时重新加载地址列表(用于从编辑页面返回时刷新)
|
||||
this.loadAddressList()
|
||||
},
|
||||
methods: {
|
||||
// 加载地址列表
|
||||
async loadAddressList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await request.get('/back/user/addresses')
|
||||
if (res.success) {
|
||||
this.addressList = res.data || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载地址列表失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化地址
|
||||
formatAddress(address) {
|
||||
return `${address.province} ${address.city} ${address.district} ${address.detail_address}`
|
||||
},
|
||||
|
||||
// 新增地址
|
||||
addAddress() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/address/edit'
|
||||
})
|
||||
},
|
||||
|
||||
// 编辑地址
|
||||
editAddress(address) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/address/edit?id=${address.id}`
|
||||
})
|
||||
},
|
||||
|
||||
// 设置默认地址
|
||||
async setDefaultAddress(addressId) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '设置中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
const res = await request.put(`/back/user/addresses/${addressId}/default`)
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '设置成功',
|
||||
icon: 'success'
|
||||
})
|
||||
// 重新加载地址列表
|
||||
this.loadAddressList()
|
||||
} else {
|
||||
throw new Error(res.message || '设置失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('设置默认地址失败:', error)
|
||||
uni.showToast({
|
||||
title: '设置失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
|
||||
// 删除地址
|
||||
deleteAddress(addressId, index) {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除这个收货地址吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
await this.confirmDeleteAddress(addressId, index)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 确认删除地址
|
||||
async confirmDeleteAddress(addressId, index) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '删除中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
const res = await request.delete(`/back/user/addresses/${addressId}`)
|
||||
if (res.success) {
|
||||
// 从列表中移除
|
||||
this.addressList.splice(index, 1)
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
throw new Error(res.message || '删除失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除地址失败:', error)
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
padding: 15rpx 25rpx;
|
||||
border-radius: 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.add-text {
|
||||
color: white;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.address-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.address-item {
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.default-tag {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 20rpx;
|
||||
background: #FF4444;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.default-text {
|
||||
color: white;
|
||||
font-size: 22rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.address-content {
|
||||
padding: 30rpx;
|
||||
padding-right: 100rpx;
|
||||
}
|
||||
|
||||
.address-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.consignee-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.consignee-phone {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.address-detail {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.address-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.address-actions {
|
||||
display: flex;
|
||||
border-top: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
flex: 1;
|
||||
padding: 25rpx;
|
||||
text-align: center;
|
||||
border-right: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.action-btn:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.default-btn {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
background: #f0f8ff;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background: #fff0f0;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.delete-btn .action-text {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
.edit-btn .action-text {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 100rpx 50rpx;
|
||||
text-align: center;
|
||||
background: white;
|
||||
margin: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin: 30rpx 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.add-first-btn {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 30rpx;
|
||||
padding: 20rpx 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
padding: 100rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 页面标题 -->
|
||||
<view class="page-header">
|
||||
<text class="page-title">{{ isEdit ? '编辑地址' : '新增地址' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 地址表单 -->
|
||||
<view class="form-container">
|
||||
<!-- 收件人信息 -->
|
||||
<view class="form-section">
|
||||
<view class="section-title">收件人信息</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">收件人姓名</text>
|
||||
<input class="form-input"
|
||||
type="text"
|
||||
v-model="formData.consignee_name"
|
||||
placeholder="请输入收件人姓名"
|
||||
maxlength="20">
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">手机号码</text>
|
||||
<input class="form-input"
|
||||
type="number"
|
||||
v-model="formData.consignee_phone"
|
||||
placeholder="请输入手机号码"
|
||||
maxlength="11">
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 收货地址 -->
|
||||
<view class="form-section">
|
||||
<view class="section-title">收货地址</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">所在地区</text>
|
||||
<view class="region-container">
|
||||
<Region
|
||||
:width="420"
|
||||
:height="92"
|
||||
:showAllDistrict="false"
|
||||
:isRevise="hasSelectedRegion"
|
||||
:previnceId="provinceId"
|
||||
:cityId="cityId"
|
||||
:countyId="countyId"
|
||||
@region="onRegionChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">详细地址</text>
|
||||
<textarea class="form-textarea"
|
||||
v-model="formData.detail_address"
|
||||
placeholder="请输入详细地址,如道路、门牌号、小区、楼栋号等"
|
||||
maxlength="200"
|
||||
auto-height>
|
||||
</textarea>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">邮政编码</text>
|
||||
<input class="form-input"
|
||||
type="text"
|
||||
v-model="formData.postal_code"
|
||||
placeholder="请输入邮政编码(可选)"
|
||||
maxlength="6">
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 默认地址设置 -->
|
||||
<view class="form-section">
|
||||
<view class="form-item no-border">
|
||||
<text class="form-label">设为默认地址</text>
|
||||
<switch :checked="formData.is_default === 1" @change="onDefaultChange"></switch>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<view class="save-section">
|
||||
<button class="save-btn" @tap="saveAddress" :disabled="saving">
|
||||
<text v-if="saving">保存中...</text>
|
||||
<text v-else>{{ isEdit ? '保存修改' : '保存地址' }}</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
import Region from '@/components/k-region.vue'
|
||||
export default {
|
||||
components:{
|
||||
Region
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isEdit: false,
|
||||
addressId: null,
|
||||
formData: {
|
||||
consignee_name: '',
|
||||
consignee_phone: '',
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
detail_address: '',
|
||||
postal_code: '',
|
||||
is_default: 0
|
||||
},
|
||||
saving: false,
|
||||
// k-region组件需要的数据
|
||||
provinceId: 11, // 默认北京
|
||||
cityId: 1101, // 默认北京市
|
||||
countyId: 110101 // 默认东城区
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
regionText() {
|
||||
if (this.formData.province && this.formData.city && this.formData.district) {
|
||||
return `${this.formData.province} ${this.formData.city} ${this.formData.district}`
|
||||
}
|
||||
return ''
|
||||
},
|
||||
hasSelectedRegion() {
|
||||
return !!(this.formData.province && this.formData.city && this.formData.district)
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是编辑还是新增
|
||||
if (options.id) {
|
||||
this.isEdit = true
|
||||
this.addressId = options.id
|
||||
this.loadAddressDetail()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载地址详情
|
||||
async loadAddressDetail() {
|
||||
try {
|
||||
const res = await request.get(`/back/user/addresses/${this.addressId}`)
|
||||
if (res.success) {
|
||||
this.formData = res.data
|
||||
// 转换地区名称为代码(这里需要添加映射逻辑,暂时使用默认值)
|
||||
this.updateRegionCodes()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载地址详情失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 更新地区代码(根据地区名称)
|
||||
updateRegionCodes() {
|
||||
// 这里可以添加地区名称到代码的映射逻辑
|
||||
// 暂时使用默认值,实际应用中需要完整的地区代码映射表
|
||||
if (this.formData.province && this.formData.city && this.formData.district) {
|
||||
// 如果有具体的映射需求,可以在这里添加
|
||||
// 例如:this.provinceId = getProvinceCodeByName(this.formData.province)
|
||||
}
|
||||
},
|
||||
|
||||
// k-region组件回调
|
||||
onRegionChange(regionArray) {
|
||||
console.log('选择的地区:', regionArray)
|
||||
this.formData.province = regionArray[0] || ''
|
||||
this.formData.city = regionArray[1] || ''
|
||||
this.formData.district = regionArray[2] || ''
|
||||
},
|
||||
|
||||
// 默认地址开关变化
|
||||
onDefaultChange(e) {
|
||||
this.formData.is_default = e.detail.value ? 1 : 0
|
||||
},
|
||||
|
||||
// 表单验证
|
||||
validateForm() {
|
||||
if (!this.formData.consignee_name.trim()) {
|
||||
uni.showToast({
|
||||
title: '请输入收件人姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.formData.consignee_phone.trim()) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号码',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
const phoneReg = /^1[3-9]\d{9}$/
|
||||
if (!phoneReg.test(this.formData.consignee_phone)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号码',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.formData.province || !this.formData.city || !this.formData.district) {
|
||||
uni.showToast({
|
||||
title: '请选择所在地区',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.formData.detail_address.trim()) {
|
||||
uni.showToast({
|
||||
title: '请输入详细地址',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
// 保存地址
|
||||
async saveAddress() {
|
||||
if (!this.validateForm()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.saving = true
|
||||
try {
|
||||
let res
|
||||
if (this.isEdit) {
|
||||
res = await request.put(`/back/user/addresses/${this.addressId}`, this.formData)
|
||||
} else {
|
||||
res = await request.post('/back/user/addresses', this.formData)
|
||||
}
|
||||
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: this.isEdit ? '修改成功' : '添加成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 延迟返回上一页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(res.message || '保存失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存地址失败:', error)
|
||||
uni.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
padding: 30rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.form-item.no-border {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
width: 200rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-left: 20rpx;
|
||||
min-height: 100rpx;
|
||||
}
|
||||
|
||||
.region-picker {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-left: 20rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.region-container {
|
||||
flex: 1;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.region-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.region-placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.save-section {
|
||||
padding: 40rpx 20rpx;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 45rpx;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.save-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,482 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 顶部搜索框 -->
|
||||
<view class="search-container">
|
||||
<view class="search-box">
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<input class="search-input" placeholder="请输入关键词搜索" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 轮播图 -->
|
||||
<view class="banner-container" v-if="banners.length > 0">
|
||||
<swiper class="banner-swiper" indicator-dots="true" autoplay="true" interval="3000" duration="500">
|
||||
<swiper-item v-for="banner in banners" :key="banner.id" @click="onBannerClick(banner)">
|
||||
<view class="banner-item">
|
||||
<image class="banner-image" :src="getFullImageUrl(banner.image_url)" mode="aspectFill"></image>
|
||||
<!-- <view class="banner-content" v-if="banner.title || banner.description">
|
||||
<text class="banner-title" v-if="banner.title">{{ banner.title }}</text>
|
||||
<text class="banner-description" v-if="banner.description">{{ banner.description }}</text>
|
||||
</view> -->
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<!-- 分类导航 -->
|
||||
<view class="category-container" v-if="categories.length > 0">
|
||||
<swiper class="category-swiper" indicator-dots="true" v-if="categoryPages.length > 1">
|
||||
<swiper-item v-for="(page, pageIndex) in categoryPages" :key="pageIndex">
|
||||
<view class="category-grid">
|
||||
<view class="category-row" v-for="(row, rowIndex) in page" :key="rowIndex">
|
||||
<view class="category-item" v-for="category in row" :key="category.id" @click="navigateToCategory(category.id)">
|
||||
<image v-if="category.category_icon" class="category-icon" :src="getFullImageUrl(category.category_icon)" mode="aspectFit"></image>
|
||||
<uni-icons v-else type="apps" size="40" color="#FF4444"></uni-icons>
|
||||
<text class="category-text">{{ category.category_name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<!-- 如果只有一页分类,不显示swiper -->
|
||||
<view class="category-grid" v-else-if="categoryPages.length === 1">
|
||||
<view class="category-row" v-for="(row, rowIndex) in categoryPages[0]" :key="rowIndex">
|
||||
<view class="category-item" v-for="category in row" :key="category.id" @click="navigateToCategory(category.id)">
|
||||
<image v-if="category.category_icon" class="category-icon" :src="getFullImageUrl(category.category_icon)" mode="aspectFit"></image>
|
||||
<uni-icons v-else type="apps" size="40" color="#FF4444"></uni-icons>
|
||||
<text class="category-text">{{ category.category_name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 一级商品列表 -->
|
||||
<view class="product-section" v-if="primaryProducts.length > 0">
|
||||
<view class="section-header">
|
||||
<text class="section-title">热门商品</text>
|
||||
<text class="view-all" @click="viewAllProducts">查看全部></text>
|
||||
</view>
|
||||
<view class="product-grid">
|
||||
<view class="product-item" v-for="product in displayProducts" :key="product.id" @click="navigateToProduct(product.id)">
|
||||
<view class="product-image-container">
|
||||
<image v-if="product.product_images"
|
||||
:src="getFullImageUrl(getFirstImage(product.product_images))"
|
||||
mode="aspectFill"
|
||||
class="product-image"></image>
|
||||
<view v-else class="default-image">
|
||||
<uni-icons type="image" size="60" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ product.product_name }}</text>
|
||||
<text class="product-description">{{ product.product_description }}</text>
|
||||
<view class="product-price">
|
||||
<text class="current-price">¥{{ product.current_price }}</text>
|
||||
<text class="original-price" v-if="product.original_price > product.current_price">¥{{ product.original_price }}</text>
|
||||
</view>
|
||||
<view class="product-stats">
|
||||
<text class="stats-text">销量 {{ product.sales_count }}</text>
|
||||
<text class="stats-text">库存 {{ product.stock_quantity }}</text>
|
||||
<!-- <text class="stats-text">浏览 {{ product.view_count }}</text> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
banners: [],
|
||||
categories: [],
|
||||
primaryProducts: [],
|
||||
token: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.checkLogin()
|
||||
this.loadData()
|
||||
},
|
||||
computed: {
|
||||
// 将分类按每页8个分组,用于滑动分页
|
||||
categoryPages() {
|
||||
const pages = []
|
||||
for (let i = 0; i < this.categories.length; i += 8) {
|
||||
const pageCategories = this.categories.slice(i, i + 8)
|
||||
// 每页内部按每行4个分组
|
||||
const rows = []
|
||||
for (let j = 0; j < pageCategories.length; j += 4) {
|
||||
rows.push(pageCategories.slice(j, j + 4))
|
||||
}
|
||||
pages.push(rows)
|
||||
}
|
||||
return pages
|
||||
},
|
||||
// 首页只显示前8个商品,每行2个
|
||||
displayProducts() {
|
||||
return this.primaryProducts
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 检查登录状态
|
||||
checkLogin() {
|
||||
this. token = uni.getStorageSync('token')
|
||||
if (!this. token) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 加载数据
|
||||
async loadData() {
|
||||
try {
|
||||
// 加载首页数据
|
||||
const res = await request.get('/back/user/home/data')
|
||||
if (res.success) {
|
||||
this.banners = res.data.banners || []
|
||||
this.categories = res.data.categories || []
|
||||
this.primaryProducts = res.data.primary_products || []
|
||||
this.primaryProducts=this.primaryProducts.slice(0,12)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载首页数据失败:', error)
|
||||
// uni.showToast({
|
||||
// title: '加载数据失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
},
|
||||
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
// 如果是逗号分隔的字符串
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
// 如果是数组
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 导航到分类页面(商城页面)
|
||||
navigateToCategory(categoryId) {
|
||||
|
||||
uni.setStorage({
|
||||
data:categoryId,
|
||||
key:"categoryId",
|
||||
success() {
|
||||
setTimeout(()=>{
|
||||
uni.switchTab({
|
||||
url: `/pages/mall/mall`
|
||||
})
|
||||
},500)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
// 导航到商品详情
|
||||
navigateToProduct(productId) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/product/detail?id=${productId}&type=primary`
|
||||
})
|
||||
},
|
||||
|
||||
// 轮播图点击事件
|
||||
onBannerClick(banner) {
|
||||
if (banner.link_url) {
|
||||
// 如果有链接,跳转到对应页面
|
||||
if (banner.link_url.startsWith('http')) {
|
||||
// 外部链接,打开浏览器
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.openURL(banner.link_url)
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
window.open(banner.link_url, '_blank')
|
||||
// #endif
|
||||
} else {
|
||||
// 内部链接,使用uni.navigateTo
|
||||
uni.navigateTo({
|
||||
url: banner.link_url
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 查看全部商品
|
||||
async viewAllProducts() {
|
||||
try {
|
||||
// 加载首页数据
|
||||
const res = await request.get('/back/user/home/data')
|
||||
if (res.success) {
|
||||
this.banners = res.data.banners || []
|
||||
this.categories = res.data.categories || []
|
||||
this.primaryProducts = res.data.primary_products || []
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载首页数据失败:', error)
|
||||
// uni.showToast({
|
||||
// title: '加载数据失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 搜索框样式 */
|
||||
.search-container {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
background-color: #fff;
|
||||
border-radius: 50rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-box uni-icons {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 轮播图样式 */
|
||||
.banner-container {
|
||||
margin: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.banner-swiper {
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.banner-item {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-content {
|
||||
position: absolute;
|
||||
right: 30rpx;
|
||||
top: 30rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
color: #fff;
|
||||
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.banner-description {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
/* 分类容器样式 */
|
||||
.category-container {
|
||||
margin: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.category-swiper {
|
||||
height: 400rpx;
|
||||
|
||||
}
|
||||
|
||||
/* 分类网格样式 */
|
||||
.category-grid {
|
||||
padding: 40rpx 20rpx;
|
||||
}
|
||||
|
||||
.category-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.category-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 140rpx;
|
||||
}
|
||||
|
||||
.category-item uni-icons {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.category-text {
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 商品区域样式 */
|
||||
.product-section {
|
||||
margin: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.view-all {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 商品网格样式 */
|
||||
.product-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.product-item {
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.product-image-container {
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.default-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-description {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-bottom: 15rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.current-price {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.original-price {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.product-stats {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.stats-text {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,251 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="login-header">
|
||||
<text class="app-title">商帮帮</text>
|
||||
<!-- <text class="app-subtitle">虚拟商品交易平台</text> -->
|
||||
</view>
|
||||
|
||||
<view class="login-form">
|
||||
<view class="form-item">
|
||||
<uni-icons type="phone" size="20" color="rgba(255,255,255,0.8)"></uni-icons>
|
||||
<input class="form-input"
|
||||
v-model="loginForm.phone"
|
||||
type="number"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<uni-icons type="locked" size="20" color="rgba(255,255,255,0.8)"></uni-icons>
|
||||
<input class="form-input"
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
placeholder="请输入密码" />
|
||||
</view>
|
||||
|
||||
<button class="login-btn" @click="handleLogin" :disabled="loginLoading">
|
||||
{{ loginLoading ? '登录中...' : '登录' }}
|
||||
</button>
|
||||
|
||||
<view class="action-links">
|
||||
<text class="link-text" @click="goToRegister">立即注册</text>
|
||||
<!-- <text class="link-text" @click="forgotPassword">忘记密码</text> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loginForm: {
|
||||
phone: '',
|
||||
password: ''
|
||||
},
|
||||
loginLoading: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 检查是否已登录
|
||||
const token = uni.getStorageSync('token')
|
||||
if (token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 登录验证
|
||||
validateForm() {
|
||||
if (!this.loginForm.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (!/^1[3-9]\d{9}$/.test(this.loginForm.phone)) {
|
||||
uni.showToast({
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.loginForm.password) {
|
||||
uni.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.loginForm.password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '密码长度不能少于6位',
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
// 处理登录
|
||||
async handleLogin() {
|
||||
if (!this.validateForm()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.loginLoading = true
|
||||
|
||||
try {
|
||||
const res = await request.post('/back/auth/login', this.loginForm)
|
||||
|
||||
if (res.success) {
|
||||
const { token, user } = res.data
|
||||
|
||||
// 保存token和用户信息到本地存储
|
||||
uni.setStorageSync('token', token)
|
||||
uni.setStorageSync('userInfo', user)
|
||||
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 跳转到首页
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '登录失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
// console.error('登录失败:', error)
|
||||
// uni.showToast({
|
||||
// title: '网络错误,请稍后重试',
|
||||
// icon: 'none'
|
||||
// })
|
||||
} finally {
|
||||
this.loginLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到注册页面
|
||||
goToRegister() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/register/register'
|
||||
})
|
||||
},
|
||||
|
||||
// 忘记密码
|
||||
forgotPassword() {
|
||||
uni.showModal({
|
||||
title: '忘记密码',
|
||||
content: '请联系客服重置密码\n客服电话:400-123-4567',
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
min-height: 100vh;
|
||||
padding: 100rpx 60rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 120rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.app-title {
|
||||
display: block;
|
||||
font-size: 64rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.app-subtitle {
|
||||
font-size: 28rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
border-radius: 50rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 40rpx;
|
||||
margin-bottom: 40rpx;
|
||||
border: 2rpx solid rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
.form-item:focus-within {
|
||||
background-color: rgba(255,255,255,0.2);
|
||||
border-color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
.form-item uni-icons {
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
font-size: 32rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.form-input::placeholder {
|
||||
color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
background-color: rgba(255,255,255,0.9);
|
||||
color: #FF4444;
|
||||
border-radius: 50rpx;
|
||||
height: 100rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin: 60rpx 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.login-btn:disabled {
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
color: rgba(255,68,68,0.5);
|
||||
}
|
||||
|
||||
.action-links {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.link-text {
|
||||
color: rgba(255,255,255,0.9);
|
||||
font-size: 28rpx;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,753 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 筛选栏 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="showSortMenu('default')">
|
||||
<text class="filter-text" :class="{ active: sortType === 'default' }">默认</text>
|
||||
<uni-icons type="arrowdown" size="12" color="#999"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showSortMenu('price')">
|
||||
<text class="filter-text" :class="{ active: sortType === 'price' }">价格</text>
|
||||
<uni-icons type="arrowdown" size="12" color="#999"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showSortMenu('quantity')">
|
||||
<text class="filter-text" :class="{ active: sortType === 'quantity' }">库存</text>
|
||||
<uni-icons type="arrowdown" size="12" color="#999"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showAddressFilter">
|
||||
<text class="filter-text" :class="{ active: selectedRegion }">{{ selectedRegion || '地区' }}</text>
|
||||
<uni-icons type="location" size="12" color="#999"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="resetAllFilters">
|
||||
<text class="filter-text">重置</text>
|
||||
<uni-icons type="reload" size="12" color="#999"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showFilterPanel">
|
||||
<uni-icons type="bars" size="16" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品列表 -->
|
||||
<view class="product-list">
|
||||
<view class="product-item"
|
||||
:class="{ 'disabled': !item.can_purchase }"
|
||||
v-for="(item, index) in productList"
|
||||
:key="index"
|
||||
@click="goToDetail(item)">
|
||||
<view class="product-image-container">
|
||||
<image v-if="item.product_images"
|
||||
:src="getFullImageUrl(getFirstImage(item.product_images))"
|
||||
mode="aspectFill"
|
||||
:class="['product-image', { 'image-disabled': !item.can_purchase }]"></image>
|
||||
<view v-else class="default-image">
|
||||
<uni-icons type="image" size="40" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
<!-- 购买限制提示遮罩 -->
|
||||
<view class="purchase-limit-overlay" v-if="!item.can_purchase">
|
||||
<!-- <text class="limit-text">{{ item.purchase_limit_message || '暂时无法购买' }}</text> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="product-info">
|
||||
<text class="product-title" :class="{ 'text-disabled': !item.can_purchase }">{{ item.product_name }}</text>
|
||||
<view class="product-stats">
|
||||
<text class="stats-text">销量 {{ item.sales_count || 0 }}</text>
|
||||
<text class="stats-text">库存 {{ item.quantity || 0 }}</text>
|
||||
</view>
|
||||
<view class="product-price">
|
||||
<text class="current-price" :class="{ 'price-disabled': !item.can_purchase }">¥{{ item.selling_price || item.current_price }}</text>
|
||||
</view>
|
||||
<view class="seller-info" v-if="item.seller">
|
||||
<text class="seller-text" :class="{ 'text-disabled': !item.can_purchase }">卖家:{{ item.seller.real_name || item.seller.phone }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore">
|
||||
<text>加载更多...</text>
|
||||
</view>
|
||||
<view class="no-more" v-else-if="productList.length > 0">
|
||||
<text>没有更多了</text>
|
||||
</view>
|
||||
|
||||
<!-- 地址筛选弹窗 -->
|
||||
<view class="address-modal" v-if="showAddressModal" @tap="hideAddressFilter">
|
||||
<view class="modal-content" @tap.stop>
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">选择地区</text>
|
||||
<text class="modal-close" @tap="hideAddressFilter">×</text>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<view class="region-options">
|
||||
<!-- <view class="region-option" :class="{ active: !tempProvince }" @tap="selectAllRegion">
|
||||
<text class="option-text">全部地区</text>
|
||||
<view class="option-check" v-if="!tempProvince">✓</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 使用k-region组件 -->
|
||||
<view class="k-region-container">
|
||||
<Region
|
||||
:width="300"
|
||||
:height="92"
|
||||
:showAllDistrict="true"
|
||||
:isRevise="false"
|
||||
@region="onRegionChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="filter-actions">
|
||||
<button class="reset-btn" @tap="resetRegionFilter">重置</button>
|
||||
<button class="confirm-btn" @tap="confirmRegionFilter">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
import Region from '@/components/k-region.vue'
|
||||
export default {
|
||||
components: {
|
||||
Region
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
productList: [],
|
||||
sortType: 'default',
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
categoryId: '',
|
||||
// 地址筛选相关
|
||||
showAddressModal: false,
|
||||
selectedProvince: '',
|
||||
selectedCity: '',
|
||||
selectedDistrict: '',
|
||||
tempProvince: '',
|
||||
tempCity: '',
|
||||
tempDistrict: '',
|
||||
showAllDistrict: false
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
var that=this
|
||||
uni.getStorage({
|
||||
key:"categoryId",
|
||||
success(res) {
|
||||
that.categoryId=res.data
|
||||
that.currentPage=1
|
||||
that.loadProducts()
|
||||
uni.setStorage({
|
||||
key:"categoryId",
|
||||
data:0,
|
||||
success() {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
that.loadProducts()
|
||||
}
|
||||
})
|
||||
},
|
||||
computed: {
|
||||
selectedRegion() {
|
||||
if (this.selectedProvince && this.selectedCity) {
|
||||
if (this.selectedDistrict) {
|
||||
return `${this.selectedProvince} ${this.selectedCity} ${this.selectedDistrict}`
|
||||
} else {
|
||||
return `${this.selectedProvince} ${this.selectedCity} 全部区`
|
||||
}
|
||||
}
|
||||
return ''
|
||||
},
|
||||
regionText() {
|
||||
if (this.tempProvince && this.tempCity) {
|
||||
if (this.tempDistrict) {
|
||||
return `${this.tempProvince} ${this.tempCity} ${this.tempDistrict}`
|
||||
} else if (this.showAllDistrict) {
|
||||
return `${this.tempProvince} ${this.tempCity} 全部区`
|
||||
} else {
|
||||
return `${this.tempProvince} ${this.tempCity}`
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
var that=this
|
||||
that.currentPage=1
|
||||
uni.getStorage({
|
||||
key:"categoryId",
|
||||
success(res) {
|
||||
that.categoryId=res.data
|
||||
|
||||
that.loadProducts()
|
||||
uni.setStorage({
|
||||
key:"categoryId",
|
||||
data:0,
|
||||
success() {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
that.loadProducts()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
|
||||
// // 保存分类参数
|
||||
// if (options.category_id) {
|
||||
// this.categoryId = options.category_id
|
||||
// }
|
||||
|
||||
// this.loadProducts()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
// 如果是逗号分隔的字符串
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
// 如果是数组
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 加载商品列表
|
||||
async loadProducts() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
page_size: this.pageSize,
|
||||
sort: this.sortType
|
||||
}
|
||||
|
||||
// 如果有分类ID,添加到参数中
|
||||
if (this.categoryId) {
|
||||
params.category_id = this.categoryId
|
||||
}
|
||||
|
||||
// 如果有地址筛选,添加到参数中
|
||||
if (this.selectedProvince) {
|
||||
params.province = this.selectedProvince
|
||||
}
|
||||
if (this.selectedCity) {
|
||||
params.city = this.selectedCity
|
||||
}
|
||||
if (this.selectedDistrict) {
|
||||
params.district = this.selectedDistrict
|
||||
}
|
||||
|
||||
// 这里显示二级商品(用户挂售的商品)
|
||||
const res = await request.get('/back/user/products/secondary', params)
|
||||
|
||||
if (res.success) {
|
||||
const data = res.data
|
||||
if (this.currentPage === 1) {
|
||||
this.productList = data.list || []
|
||||
} else {
|
||||
this.productList = [...this.productList, ...(data.list || [])]
|
||||
}
|
||||
|
||||
this.hasMore = this.productList.length < data.total
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载商品失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 加载更多
|
||||
loadMore() {
|
||||
this.currentPage++
|
||||
this.loadProducts()
|
||||
},
|
||||
|
||||
// 显示排序菜单
|
||||
showSortMenu(type) {
|
||||
this.sortType = type
|
||||
this.currentPage = 1
|
||||
this.loadProducts()
|
||||
},
|
||||
|
||||
// 显示筛选面板
|
||||
showFilterPanel() {
|
||||
uni.showActionSheet({
|
||||
itemList: ['价格升序', '价格降序', '销量排序', '库存排序'],
|
||||
success: (res) => {
|
||||
const sortTypes = ['price_asc', 'price_desc', 'sales', 'quantity']
|
||||
this.sortType = sortTypes[res.tapIndex]
|
||||
this.currentPage = 1
|
||||
this.loadProducts()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到商品详情
|
||||
goToDetail(item) {
|
||||
// 如果不可购买,显示提示
|
||||
if (!item.can_purchase) {
|
||||
uni.showToast({
|
||||
title: item.purchase_limit_message || '暂时无法购买',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/product/detail?id=${item.id}&type=secondary`
|
||||
})
|
||||
},
|
||||
|
||||
// 显示地址筛选
|
||||
showAddressFilter() {
|
||||
this.showAddressModal = true
|
||||
// 将当前选择的地址设为临时变量
|
||||
this.tempProvince = this.selectedProvince
|
||||
this.tempCity = this.selectedCity
|
||||
this.tempDistrict = this.selectedDistrict
|
||||
// 如果选择了省市但没有选择区,说明是"全部区"状态
|
||||
this.showAllDistrict = this.selectedProvince && this.selectedCity && !this.selectedDistrict
|
||||
},
|
||||
|
||||
// 隐藏地址筛选
|
||||
hideAddressFilter() {
|
||||
this.showAddressModal = false
|
||||
},
|
||||
|
||||
// k-region组件回调
|
||||
onRegionChange(regionArray) {
|
||||
console.log('选择的地区:', regionArray)
|
||||
this.tempProvince = regionArray[0] || ''
|
||||
this.tempCity = regionArray[1] || ''
|
||||
this.tempDistrict = regionArray[2] || ''
|
||||
|
||||
// 如果选择了省市但区为空,说明选择了"全部区"
|
||||
this.showAllDistrict = this.tempProvince && this.tempCity && !this.tempDistrict
|
||||
},
|
||||
|
||||
// 重置地区筛选
|
||||
resetRegionFilter() {
|
||||
this.tempProvince = ''
|
||||
this.tempCity = ''
|
||||
this.tempDistrict = ''
|
||||
this.showAllDistrict = false
|
||||
this.selectedProvince = ''
|
||||
this.selectedCity = ''
|
||||
this.selectedDistrict = ''
|
||||
this.currentPage = 1
|
||||
this.loadProducts()
|
||||
this.hideAddressFilter()
|
||||
},
|
||||
|
||||
// 确认地区筛选
|
||||
confirmRegionFilter() {
|
||||
this.selectedProvince = this.tempProvince
|
||||
this.selectedCity = this.tempCity
|
||||
// 如果选择了"全部区",则不设置具体区名
|
||||
this.selectedDistrict = this.showAllDistrict ? '' : this.tempDistrict
|
||||
this.currentPage = 1
|
||||
this.loadProducts()
|
||||
this.hideAddressFilter()
|
||||
},
|
||||
|
||||
// 选择全部地区
|
||||
selectAllRegion() {
|
||||
this.tempProvince = ''
|
||||
this.tempCity = ''
|
||||
this.tempDistrict = ''
|
||||
this.showAllDistrict = false
|
||||
},
|
||||
|
||||
// 选择全部区
|
||||
selectAllDistrict() {
|
||||
this.tempDistrict = ''
|
||||
this.showAllDistrict = true
|
||||
},
|
||||
|
||||
// 重置所有筛选条件
|
||||
resetAllFilters() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要重置所有筛选条件吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 重置排序
|
||||
this.sortType = 'default'
|
||||
// 重置地区筛选
|
||||
this.selectedProvince = ''
|
||||
this.selectedCity = ''
|
||||
this.selectedDistrict = ''
|
||||
this.tempProvince = ''
|
||||
this.tempCity = ''
|
||||
this.tempDistrict = ''
|
||||
this.showAllDistrict = false
|
||||
// 重置分类
|
||||
this.categoryId = ''
|
||||
// 重置分页
|
||||
this.currentPage = 1
|
||||
// 重新加载数据
|
||||
this.loadProducts()
|
||||
|
||||
uni.showToast({
|
||||
title: '已重置',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 筛选栏样式 */
|
||||
.filter-bar {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.filter-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.filter-text.active {
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
/* 商品列表样式 */
|
||||
.product-list {
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.product-item {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.product-item.disabled {
|
||||
opacity: 0.6;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.product-image-container {
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.product-image.image-disabled {
|
||||
filter: grayscale(100%);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.purchase-limit-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.limit-text {
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
padding: 10rpx 20rpx;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.default-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.product-title {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-title.text-disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.product-stats {
|
||||
display: flex;
|
||||
margin-bottom: 10rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.stats-text {
|
||||
font-size: 20rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.current-price {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
.current-price.price-disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.original-price {
|
||||
font-size: 20rpx;
|
||||
color: #999;
|
||||
text-decoration: line-through;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.seller-info {
|
||||
margin-top: 8rpx;
|
||||
padding-top: 8rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.seller-text {
|
||||
font-size: 20rpx;
|
||||
color: #666;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.seller-text.text-disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 加载更多样式 */
|
||||
.load-more, .no-more {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 地址筛选弹窗样式 */
|
||||
.address-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
width: 600rpx;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
font-size: 40rpx;
|
||||
color: #999;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.region-options {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.region-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 20rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.region-option.active {
|
||||
background-color: #e3f2fd;
|
||||
border: 2rpx solid #2196f3;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.option-check {
|
||||
font-size: 28rpx;
|
||||
color: #2196f3;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.region-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 20rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.k-region-container {
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.region-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.region-placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.reset-btn, .confirm-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
background-color: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,837 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 订单状态 -->
|
||||
<view class="status-section">
|
||||
<view class="status-icon" :class="statusClass">
|
||||
<uni-icons :type="statusIcon" size="40" color="#fff"></uni-icons>
|
||||
</view>
|
||||
<view class="status-info">
|
||||
<text class="status-text">{{ statusText }}</text>
|
||||
<text class="status-desc">{{ statusDesc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<view class="order-section">
|
||||
<view class="section-title">订单信息</view>
|
||||
<view class="order-item">
|
||||
<text class="item-label">订单号:</text>
|
||||
<text class="item-value">{{ orderInfo.order_no }}</text>
|
||||
</view>
|
||||
<view class="order-item">
|
||||
<text class="item-label">订单类型:</text>
|
||||
<text class="item-value">{{ orderInfo.product_type === 1 ? '一级商品' : '二级商品' }}</text>
|
||||
</view>
|
||||
<view class="order-item">
|
||||
<text class="item-label">下单时间:</text>
|
||||
<text class="item-value">{{ formatTime(orderInfo.created_at) }}</text>
|
||||
</view>
|
||||
<view class="order-item" v-if="orderInfo.confirm_time">
|
||||
<text class="item-label">确认时间:</text>
|
||||
<text class="item-value">{{ formatTime(orderInfo.confirm_time) }}</text>
|
||||
</view>
|
||||
<view class="order-item" v-if="orderInfo.complete_time">
|
||||
<text class="item-label">完成时间:</text>
|
||||
<text class="item-value">{{ formatTime(orderInfo.complete_time) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品信息 -->
|
||||
<view class="product-section">
|
||||
<view class="section-title">商品信息</view>
|
||||
<view class="product-card">
|
||||
<image v-if="productImage" :src="getFullImageUrl(productImage)" class="product-image" mode="aspectFill"></image>
|
||||
<view class="default-image" v-else>
|
||||
<uni-icons type="image" size="40" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ orderInfo.product_name }}</text>
|
||||
|
||||
<view class="product-price">
|
||||
<text class="price-label">单价:</text>
|
||||
<text class="price-value">¥{{ orderInfo.unit_price||orderInfo.selling_price }}</text>
|
||||
</view>
|
||||
<view class="product-price">
|
||||
<text class="price-label">订单金额:</text>
|
||||
<text class="price-value">¥{{ orderInfo.total_amount }}</text>
|
||||
</view>
|
||||
<view class="product-quantity">
|
||||
<text class="quantity-label">数量:</text>
|
||||
<text class="quantity-value">{{ orderInfo.quantity || 1 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 交易双方信息 -->
|
||||
<view class="parties-section">
|
||||
<view class="section-title">交易信息</view>
|
||||
<view class="party-info" v-if="orderType === 'purchase'">
|
||||
<text class="party-label">卖家:</text>
|
||||
<text class="party-value">{{ orderInfo.seller ? ( orderInfo.seller.real_name||orderInfo.seller.customer_name || orderInfo.seller.phone) : '暂无' }}</text>
|
||||
</view>
|
||||
<view class="party-info" v-if="orderType === 'sales'">
|
||||
<text class="party-label">买家:</text>
|
||||
<text class="party-value">{{ orderInfo.buyer ? (orderInfo.buyer.real_name || orderInfo.buyer.customer_name || orderInfo.buyer.phone) : '暂无' }}</text>
|
||||
</view>
|
||||
<view class="party-info" v-if="orderInfo.address">
|
||||
<text class="party-label">收货地址:</text>
|
||||
<text class="party-value">{{ formatAddress(orderInfo.address) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 付款凭证 -->
|
||||
<view class="proof-section" v-if="orderInfo.payment_proof_image">
|
||||
<view class="section-title">付款凭证</view>
|
||||
<view class="proof-image" @click="previewProof">
|
||||
<image :src="getFullImageUrl(orderInfo.payment_proof_image)" mode="aspectFill"></image>
|
||||
<view class="proof-overlay">
|
||||
<uni-icons type="eye" size="30" color="#fff"></uni-icons>
|
||||
<text class="proof-text">点击查看</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 留言区域 -->
|
||||
<view class="message-section">
|
||||
<view class="section-title">
|
||||
<text>订单留言</text>
|
||||
<text class="message-count">({{ messages.length }}条)</text>
|
||||
</view>
|
||||
|
||||
<!-- 留言列表 -->
|
||||
<view class="message-list" v-if="messages.length > 0">
|
||||
<view class="message-item" v-for="(msg, index) in messages" :key="index">
|
||||
<view class="message-header">
|
||||
<text class="message-user">{{ msg.user.real_name || '匿名用户' }}</text>
|
||||
<text class="message-time">{{ formatTime(msg.created_at) }}</text>
|
||||
</view>
|
||||
<view class="message-content">{{ msg.content }}</view>
|
||||
<!-- 留言图片 -->
|
||||
<view class="message-images" v-if="msg.images">
|
||||
<image
|
||||
v-for="(image, imgIndex) in getMessageImages(msg.images)"
|
||||
:key="imgIndex"
|
||||
:src="getFullImageUrl(image)"
|
||||
class="message-image"
|
||||
mode="aspectFill"
|
||||
@click="previewMessageImage(msg.images, imgIndex)"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="no-message" v-else>
|
||||
<uni-icons type="chatboxes" size="40" color="#ccc"></uni-icons>
|
||||
<text>暂无留言</text>
|
||||
</view>
|
||||
|
||||
<!-- 发送留言 -->
|
||||
<view class="send-message">
|
||||
<view class="message-input-container">
|
||||
<textarea
|
||||
v-model="newMessage"
|
||||
class="message-input"
|
||||
placeholder="请输入留言内容..."
|
||||
maxlength="500"
|
||||
auto-height
|
||||
></textarea>
|
||||
<text class="char-count">{{ newMessage.length }}/500</text>
|
||||
</view>
|
||||
|
||||
<!-- 图片选择和预览 -->
|
||||
<view class="image-section" v-if="selectedImages.length > 0">
|
||||
<view class="selected-images">
|
||||
<view class="image-item" v-for="(image, index) in selectedImages" :key="index">
|
||||
<image :src="image" class="selected-image" mode="aspectFill" />
|
||||
<view class="remove-image" @click="removeImage(index)">
|
||||
<uni-icons type="closeempty" size="16" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="send-actions">
|
||||
<view class="action-buttons">
|
||||
<button class="image-btn" @click="chooseImage" :disabled="selectedImages.length >= 6">
|
||||
<uni-icons type="camera" size="20" color="#666"></uni-icons>
|
||||
<text class="btn-text">图片({{ selectedImages.length }}/6)</text>
|
||||
</button>
|
||||
</view>
|
||||
<button class="send-btn" @click="sendMessage" :disabled="(!newMessage.trim() && selectedImages.length === 0) || sending">
|
||||
<text v-if="sending">发送中...</text>
|
||||
<text v-else>发送</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
orderType: 'purchase', // purchase: 买单, sales: 卖单
|
||||
orderId: '',
|
||||
orderInfo: {},
|
||||
messages: [],
|
||||
newMessage: '',
|
||||
selectedImages: [], // 选中的图片列表
|
||||
sending: false,
|
||||
loading: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
statusClass() {
|
||||
const statusMap = {
|
||||
0: 'status-pending', // 待付款
|
||||
1: 'status-paid', // 已付款
|
||||
2: 'status-completed', // 已完成
|
||||
3: 'status-cancelled' // 已取消
|
||||
}
|
||||
return statusMap[this.orderInfo.order_status] || 'status-pending'
|
||||
},
|
||||
statusIcon() {
|
||||
const iconMap = {
|
||||
0: 'wallet', // 待付款
|
||||
1: 'checkmarkempty', // 已付款
|
||||
2: 'checkbox', // 已完成
|
||||
3: 'closeempty' // 已取消
|
||||
}
|
||||
return iconMap[this.orderInfo.order_status] || 'wallet'
|
||||
},
|
||||
statusText() {
|
||||
const textMap = {
|
||||
0: '待付款',
|
||||
1: '已付款',
|
||||
2: '已完成',
|
||||
3: '已取消'
|
||||
}
|
||||
return textMap[this.orderInfo.order_status] || '未知状态'
|
||||
},
|
||||
statusDesc() {
|
||||
const descMap = {
|
||||
0: '请及时完成付款',
|
||||
1: '等待卖家确认',
|
||||
2: '交易已完成',
|
||||
3: '订单已取消'
|
||||
}
|
||||
return descMap[this.orderInfo.order_status] || ''
|
||||
},
|
||||
productImage() {
|
||||
if (this.orderInfo.product_images) {
|
||||
const images = this.orderInfo.product_images
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
}
|
||||
if (this.orderInfo.secondary_product?.primary_product?.product_images) {
|
||||
const images = this.orderInfo.secondary_product.primary_product.product_images
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
},
|
||||
productName() {
|
||||
return this.orderInfo.primary_product?.product_name ||
|
||||
this.orderInfo.secondary_product?.primary_product?.product_name ||
|
||||
'未知商品'
|
||||
},
|
||||
productDesc() {
|
||||
return this.orderInfo.primary_product?.product_description ||
|
||||
this.orderInfo.secondary_product?.primary_product?.product_description ||
|
||||
'暂无描述'
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.orderType = options.type || 'purchase' // purchase 或 sales
|
||||
this.orderId = options.id
|
||||
|
||||
if (!this.orderId) {
|
||||
uni.showToast({
|
||||
title: '订单ID不能为空',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
return
|
||||
}
|
||||
|
||||
this.loadOrderDetail()
|
||||
this.loadMessages()
|
||||
},
|
||||
methods: {
|
||||
// 加载订单详情
|
||||
async loadOrderDetail() {
|
||||
this.loading = true
|
||||
try {
|
||||
const url = this.orderType === 'purchase'
|
||||
? `/back/user/orders/purchase/${this.orderId}`
|
||||
: `/back/user/orders/sales/${this.orderId}`
|
||||
|
||||
const res = await request.get(url)
|
||||
if (res.success) {
|
||||
this.orderInfo = res.data
|
||||
} else {
|
||||
throw new Error(res.message || '加载订单详情失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载订单详情失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 加载留言列表
|
||||
async loadMessages() {
|
||||
try {
|
||||
const res = await request.get(`/back/user/orders/${this.orderId}/messages`,{type:this.orderType})
|
||||
if (res.success) {
|
||||
this.messages = res.data.list || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载留言失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 发送留言
|
||||
async sendMessage() {
|
||||
if (!this.newMessage.trim() && this.selectedImages.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请输入留言内容或选择图片',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.sending = true
|
||||
try {
|
||||
// 上传图片并获取URL
|
||||
let imageUrls = []
|
||||
if (this.selectedImages.length > 0) {
|
||||
for (let image of this.selectedImages) {
|
||||
const uploadRes = await request.upload('/back/upload', image)
|
||||
if (uploadRes.success) {
|
||||
imageUrls.push(uploadRes.data.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const res = await request.post(`/back/user/orders/${this.orderId}/messages`, {
|
||||
content: this.newMessage.trim(),
|
||||
images: imageUrls.join(',')
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
this.newMessage = ''
|
||||
this.selectedImages = []
|
||||
this.loadMessages() // 重新加载留言列表
|
||||
uni.showToast({
|
||||
title: '发送成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
throw new Error(res.message || '发送失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('发送留言失败:', error)
|
||||
uni.showToast({
|
||||
title: '发送失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.sending = false
|
||||
}
|
||||
},
|
||||
|
||||
// 预览付款凭证
|
||||
previewProof() {
|
||||
uni.previewImage({
|
||||
urls: [this.getFullImageUrl(this.orderInfo.payment_proof_image)],
|
||||
current: 0
|
||||
})
|
||||
},
|
||||
|
||||
// 获取完整图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(time) {
|
||||
if (!time) return '暂无'
|
||||
const date = new Date(time)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`
|
||||
},
|
||||
|
||||
// 格式化地址
|
||||
formatAddress(address) {
|
||||
if (!address) return '暂无'
|
||||
return `${address.province || ''} ${address.city || ''} ${address.district || ''} ${address.detail_address || ''}`
|
||||
},
|
||||
|
||||
// 选择图片
|
||||
chooseImage() {
|
||||
const remaining = 6 - this.selectedImages.length
|
||||
if (remaining <= 0) {
|
||||
uni.showToast({
|
||||
title: '最多只能选择6张图片',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.chooseImage({
|
||||
count: remaining,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
this.selectedImages = this.selectedImages.concat(res.tempFilePaths)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 删除图片
|
||||
removeImage(index) {
|
||||
this.selectedImages.splice(index, 1)
|
||||
},
|
||||
|
||||
// 获取留言图片列表
|
||||
getMessageImages(images) {
|
||||
if (!images) return []
|
||||
return images.split(',').filter(img => img.trim())
|
||||
},
|
||||
|
||||
// 预览留言图片
|
||||
previewMessageImage(images, currentIndex) {
|
||||
const imageList = this.getMessageImages(images)
|
||||
const urls = imageList.map(img => this.getFullImageUrl(img))
|
||||
uni.previewImage({
|
||||
urls: urls,
|
||||
current: currentIndex
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
/* 状态区域 */
|
||||
.status-section {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
padding: 40rpx 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.status-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.status-desc {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
/* 通用section样式 */
|
||||
.order-section, .product-section, .parties-section, .proof-section, .message-section {
|
||||
background-color: #fff;
|
||||
margin: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.message-count {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* 订单信息 */
|
||||
.order-item, .party-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.order-item:last-child, .party-info:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.item-label, .party-label {
|
||||
width: 200rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-value, .party-value {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 商品卡片 */
|
||||
.product-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.default-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
display: block;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-desc {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-bottom: 15rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-price, .product-quantity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.price-label, .quantity-label {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.price-value {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
.quantity-value {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 付款凭证 */
|
||||
.proof-image {
|
||||
position: relative;
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.proof-image image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.proof-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.proof-text {
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
/* 留言区域 */
|
||||
.message-list {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
padding-bottom: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.message-item:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.message-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.message-user {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.no-message {
|
||||
text-align: center;
|
||||
padding: 60rpx 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.no-message text {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
/* 留言图片 */
|
||||
.message-images {
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.message-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
/* 发送留言 */
|
||||
.send-message {
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
padding-top: 30rpx;
|
||||
}
|
||||
|
||||
.message-input-container {
|
||||
position: relative;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.message-input {
|
||||
width: 100%;
|
||||
min-height: 120rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e0e0e0;
|
||||
border-radius: 12rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.char-count {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
bottom: 10rpx;
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 图片选择区域 */
|
||||
.image-section {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.selected-images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.image-item {
|
||||
position: relative;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.selected-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.remove-image {
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: -10rpx;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
background-color: #ff4444;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* 发送操作区域 */
|
||||
.send-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.image-btn {
|
||||
background: transparent;
|
||||
border: 1rpx solid #e0e0e0;
|
||||
border-radius: 8rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.image-btn:disabled {
|
||||
color: #ccc;
|
||||
border-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.btn-text {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 30rpx;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.send-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
/* 状态颜色 */
|
||||
.status-pending {
|
||||
background-color: rgba(255, 193, 7, 0.2) !important;
|
||||
}
|
||||
|
||||
.status-paid {
|
||||
background-color: rgba(23, 162, 184, 0.2) !important;
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
background-color: rgba(40, 167, 69, 0.2) !important;
|
||||
}
|
||||
|
||||
.status-cancelled {
|
||||
background-color: rgba(220, 53, 69, 0.2) !important;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,694 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 状态切换标签 -->
|
||||
<view class="status-tabs">
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === 'all' }"
|
||||
@click="switchStatus('all')">
|
||||
<text class="tab-text">全部</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '0' }"
|
||||
@click="switchStatus('0')">
|
||||
<text class="tab-text">待付款</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '1' }"
|
||||
@click="switchStatus('1')">
|
||||
<text class="tab-text">待确认</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '2' }"
|
||||
@click="switchStatus('2')">
|
||||
<text class="tab-text">已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 筛选条件 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="showDatePicker('start')">
|
||||
<text class="filter-label">开始日期</text>
|
||||
<text class="filter-value">{{ startDate || '选择日期' }}</text>
|
||||
</view>
|
||||
<view class="filter-item" @click="showDatePicker('end')">
|
||||
<text class="filter-label">结束日期</text>
|
||||
<text class="filter-value">{{ endDate || '选择日期' }}</text>
|
||||
</view>
|
||||
<view class="filter-item" @click="showAmountFilter">
|
||||
<text class="filter-label">按日期筛选</text>
|
||||
<text class="filter-value">总金额</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 总金额显示 -->
|
||||
<view class="amount-summary" v-if="totalAmount > 0">
|
||||
<text class="summary-label">重置</text>
|
||||
<text class="summary-amount">{{ totalAmount }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单列表 -->
|
||||
<view class="order-list">
|
||||
<view class="order-item" v-for="(item, index) in orderList" :key="index" @click="goToOrderDetail(item)">
|
||||
<view class="order-header">
|
||||
<text class="order-number">订单编号:{{ item.order_no }}</text>
|
||||
<view class="order-status" :class="getStatusClass(item.order_status)">
|
||||
<text class="status-text">{{ getStatusText(item.order_status) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-content">
|
||||
<view class="product-info">
|
||||
<image :src="getFullImageUrl(getFirstImage(item.product_images))"
|
||||
class="product-image"
|
||||
mode="aspectFill">
|
||||
</image>
|
||||
<view class="product-details">
|
||||
<text class="product-name">{{ item.product_name }}</text>
|
||||
<text class="product-price">¥{{ item.unit_price }}</text>
|
||||
<text class="product-quantity">×{{ item.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-footer">
|
||||
<text class="order-time">下单时间:{{ formatTime(item.created_at) }}</text>
|
||||
<view class="order-summary">
|
||||
<!-- <text class="summary-text">共{{ item.quantity }}件商品 运费 ¥0.00 合计:</text> -->
|
||||
<text class="summary-price">¥{{ item.total_amount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-actions">
|
||||
<!-- <button class="action-btn detail-btn" @click.stop="goToDetail(item)">
|
||||
查看详情
|
||||
</button> -->
|
||||
<button v-if="item.payment_proof_image"
|
||||
class="action-btn proof-btn"
|
||||
@click.stop="viewPaymentProof(item)">
|
||||
查看凭证
|
||||
</button>
|
||||
<button v-if="item.order_status === 0"
|
||||
class="action-btn pay-btn"
|
||||
@click.stop="payOrder(item)">
|
||||
立即付款
|
||||
</button>
|
||||
<button v-if="item.order_status === 0"
|
||||
class="action-btn cancel-btn"
|
||||
@click.stop="cancelOrder(item)">
|
||||
取消订单
|
||||
</button>
|
||||
<!-- <button v-if="item.order_status === 1"
|
||||
class="action-btn confirm-btn"
|
||||
@click.stop="confirmOrder(item)">
|
||||
确认收货
|
||||
</button> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-if="orderList.length === 0 && !loading">
|
||||
<uni-icons type="list" size="100" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无订单</text>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore && orderList.length > 0">
|
||||
<text>加载更多...</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentStatus: 'all',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
totalAmount: 0,
|
||||
orderList: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (options.status) {
|
||||
this.currentStatus = options.status
|
||||
}
|
||||
this.loadOrders()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 切换状态
|
||||
switchStatus(status) {
|
||||
this.currentStatus = status
|
||||
this.currentPage = 1
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
// 显示日期选择器
|
||||
showDatePicker(type) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['今天', '最近7天', '最近30天', '最近90天'],
|
||||
success: (res) => {
|
||||
const now = new Date()
|
||||
let startDate, endDate
|
||||
|
||||
switch (res.tapIndex) {
|
||||
case 0: // 今天
|
||||
startDate = endDate = this.formatDate(now)
|
||||
break
|
||||
case 1: // 最近7天
|
||||
startDate = this.formatDate(new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
case 2: // 最近30天
|
||||
startDate = this.formatDate(new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
case 3: // 自定义
|
||||
startDate = this.formatDate(new Date(now.getTime() - 90 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
}
|
||||
|
||||
if (type === 'start') {
|
||||
this.startDate = startDate
|
||||
} else {
|
||||
this.endDate = endDate
|
||||
}
|
||||
|
||||
this.currentPage = 1
|
||||
this.loadOrders()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 显示金额筛选
|
||||
showAmountFilter() {
|
||||
this.startDate = ''
|
||||
this.endDate = ''
|
||||
this.currentPage = 1
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
// 加载订单列表
|
||||
async loadOrders() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
page_size: this.pageSize
|
||||
}
|
||||
|
||||
if (this.currentStatus !== 'all') {
|
||||
// 状态映射:前端显示状态 -> 后端查询参数
|
||||
const statusMap = {
|
||||
'0': 'pending',
|
||||
'1': 'confirming',
|
||||
'2': 'completed',
|
||||
'3': 'cancelled'
|
||||
}
|
||||
params.status = statusMap[this.currentStatus] || this.currentStatus
|
||||
}
|
||||
|
||||
if (this.startDate) {
|
||||
params.start_date = this.startDate
|
||||
}
|
||||
|
||||
if (this.endDate) {
|
||||
params.end_date = this.endDate
|
||||
}
|
||||
|
||||
const res = await request.get('/back/user/orders/purchase', params)
|
||||
|
||||
if (res.success) {
|
||||
const data = res.data
|
||||
if (this.currentPage === 1) {
|
||||
this.orderList = data.list || []
|
||||
} else {
|
||||
this.orderList = [...this.orderList, ...(data.list || [])]
|
||||
}
|
||||
|
||||
this.hasMore = this.orderList.length < data.total
|
||||
this.totalAmount = data.total_amount || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载订单失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 加载更多
|
||||
loadMore() {
|
||||
this.currentPage++
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
// 获取状态样式类
|
||||
getStatusClass(status) {
|
||||
const classMap = {
|
||||
0: 'status-pending',
|
||||
1: 'status-confirming',
|
||||
2: 'status-completed',
|
||||
3: 'status-cancelled'
|
||||
}
|
||||
return classMap[status] || ''
|
||||
},
|
||||
|
||||
// 获取状态文本
|
||||
getStatusText(status) {
|
||||
const textMap = {
|
||||
0: '待付款',
|
||||
1: '待确认',
|
||||
2: '已完成',
|
||||
3: '已取消'
|
||||
}
|
||||
return textMap[status] || '未知状态'
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(time) {
|
||||
if (!time) return ''
|
||||
const date = new Date(time)
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(date) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||
},
|
||||
|
||||
// 跳转到订单详情
|
||||
goToDetail(order) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/detail?id=${order.id}&type=purchase`
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到订单详情页面
|
||||
goToOrderDetail(order) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/orders/detail?id=${order.id}&type=purchase`
|
||||
})
|
||||
},
|
||||
|
||||
// 查看付款凭证
|
||||
viewPaymentProof(order) {
|
||||
if (!order.payment_proof_image) {
|
||||
uni.showToast({
|
||||
title: '暂无付款凭证',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [this.getFullImageUrl(order.payment_proof_image)],
|
||||
current: 0
|
||||
})
|
||||
},
|
||||
|
||||
// 支付订单 - 跳转到付款页面
|
||||
payOrder(order) {
|
||||
var isSecond=order.product_type == 1 ? false : true
|
||||
uni.navigateTo({
|
||||
url: `/pages/payment/purchase?order_id=${order.id}&order_no=${order.order_no}&is_second=${isSecond}`
|
||||
})
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
async cancelOrder(order) {
|
||||
uni.showModal({
|
||||
title: '确认取消',
|
||||
content: '确定要取消这个订单吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request.put(`/back/user/orders/purchase/${order.id}/cancel`)
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '订单已取消',
|
||||
icon: 'success'
|
||||
})
|
||||
this.loadOrders()
|
||||
} else {
|
||||
throw new Error(result.message || '取消失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('取消订单失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '取消失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 确认收货
|
||||
async confirmOrder(order) {
|
||||
uni.showModal({
|
||||
title: '确认收货',
|
||||
content: '确认已收到商品吗?确认后商品将进入您的仓库。',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request.put(`/back/user/orders/purchase/${order.id}/confirm`)
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '确认收货成功',
|
||||
icon: 'success'
|
||||
})
|
||||
this.loadOrders()
|
||||
} else {
|
||||
throw new Error(result.message || '确认失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('确认收货失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '确认失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 状态标签 */
|
||||
.status-tabs {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-text {
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 60rpx;
|
||||
height: 4rpx;
|
||||
background-color: #FF4444;
|
||||
}
|
||||
|
||||
/* 筛选条件 */
|
||||
.filter-bar {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.filter-label {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.filter-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 总金额 */
|
||||
.amount-summary {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 28rpx;
|
||||
color: #007AFF;
|
||||
}
|
||||
|
||||
.summary-amount {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
/* 订单列表 */
|
||||
.order-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.order-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.order-number {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background-color: #FFF2E6;
|
||||
color: #FF8800;
|
||||
}
|
||||
|
||||
.status-confirming {
|
||||
background-color: #E6F7FF;
|
||||
color: #1890FF;
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
background-color: #F6FFED;
|
||||
color: #52C41A;
|
||||
}
|
||||
|
||||
.status-cancelled {
|
||||
background-color: #FFF1F0;
|
||||
color: #FF4D4F;
|
||||
}
|
||||
|
||||
.order-content {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 160rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.product-details {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 32rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.product-quantity {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.order-footer {
|
||||
padding: 30rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.order-time {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.order-summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.summary-price {
|
||||
font-size: 32rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.order-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 30rpx;
|
||||
gap: 20rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 16rpx 32rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
}
|
||||
|
||||
.detail-btn {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.proof-btn {
|
||||
background-color: #1890FF;
|
||||
color: #fff;
|
||||
border-color: #1890FF;
|
||||
}
|
||||
|
||||
.pay-btn {
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
border-color: #FF4444;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #fff;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #52C41A;
|
||||
color: #fff;
|
||||
border-color: #52C41A;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.empty-state uni-icons {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 加载更多 */
|
||||
.load-more {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,411 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 页面标题 -->
|
||||
<view class="page-header">
|
||||
<text class="page-title">收款方式</text>
|
||||
<text class="page-subtitle">设置您的主收款码和副收款码</text>
|
||||
</view>
|
||||
|
||||
<!-- 主收款码 -->
|
||||
<view class="payment-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">主收款码</text>
|
||||
<text class="section-subtitle">优先使用的收款二维码</text>
|
||||
</view>
|
||||
<view class="qr-upload-container">
|
||||
<view class="qr-preview" @tap="uploadMainQr">
|
||||
<image v-if="paymentInfo.main_payment_qr_image"
|
||||
:src="getFullImageUrl(paymentInfo.main_payment_qr_image)"
|
||||
class="qr-image"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
<view v-else class="qr-placeholder">
|
||||
<uni-icons type="camera" size="40" color="#ccc"></uni-icons>
|
||||
<text class="placeholder-text">点击上传主收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload-tips">
|
||||
<text class="tip-text">建议上传四大行收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 副收款码 -->
|
||||
<view class="payment-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">副收款码</text>
|
||||
<text class="section-subtitle">备用收款二维码</text>
|
||||
</view>
|
||||
<view class="qr-upload-container">
|
||||
<view class="qr-preview" @tap="uploadSubQr">
|
||||
<image v-if="paymentInfo.sub_payment_qr_image"
|
||||
:src="getFullImageUrl(paymentInfo.sub_payment_qr_image)"
|
||||
class="qr-image"
|
||||
mode="aspectFit">
|
||||
</image>
|
||||
<view v-else class="qr-placeholder">
|
||||
<uni-icons type="camera" size="40" color="#ccc"></uni-icons>
|
||||
<text class="placeholder-text">点击上传副收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload-tips">
|
||||
<text class="tip-text">可选,作为备用收款方式</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<view class="save-section">
|
||||
<button class="save-btn" @tap="savePaymentInfo" :disabled="saving">
|
||||
<text v-if="saving">保存中...</text>
|
||||
<text v-else>保存收款方式</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 使用说明 -->
|
||||
<view class="help-section">
|
||||
<view class="help-header">
|
||||
<uni-icons type="help" size="20" color="#999"></uni-icons>
|
||||
<text class="help-title">使用说明</text>
|
||||
</view>
|
||||
<view class="help-content">
|
||||
<text class="help-text">1. 主收款码会优先显示给买家</text>
|
||||
<text class="help-text">2. 副收款码作为备用收款方式</text>
|
||||
<text class="help-text">3. 建议上传清晰的收款二维码图片</text>
|
||||
<text class="help-text">4. 支持所有银行及三方等收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
paymentInfo: {
|
||||
main_payment_qr_image: '',
|
||||
sub_payment_qr_image: '',
|
||||
|
||||
},
|
||||
saving: false,
|
||||
loading: false,
|
||||
ismain:false,
|
||||
issub:false,
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.loadPaymentInfo()
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 加载收款方式信息
|
||||
async loadPaymentInfo() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await request.get('/back/user/payment/info')
|
||||
if (res.success) {
|
||||
this.paymentInfo = res.data
|
||||
if(this.paymentInfo.main_payment_qr_image){
|
||||
this.ismain=true
|
||||
}
|
||||
if(this.paymentInfo.sub_payment_qr_image){
|
||||
this.issub=true
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载收款方式失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 上传主收款码
|
||||
uploadMainQr() {
|
||||
if(this.ismain){
|
||||
uni.showToast({
|
||||
title:"已上传"
|
||||
})
|
||||
return
|
||||
}
|
||||
this.chooseAndUploadImage('main')
|
||||
},
|
||||
|
||||
// 上传副收款码
|
||||
uploadSubQr() {
|
||||
if(this.issub){
|
||||
uni.showToast({
|
||||
title:"已上传"
|
||||
})
|
||||
return
|
||||
}
|
||||
this.chooseAndUploadImage('sub')
|
||||
},
|
||||
|
||||
// 选择并上传图片
|
||||
chooseAndUploadImage(type) {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['camera', 'album'],
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
await this.uploadImage(filePath, type)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择图片失败:', err)
|
||||
uni.showToast({
|
||||
title: '选择图片失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 上传图片
|
||||
async uploadImage(filePath, type) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
const token = uni.getStorageSync('token')
|
||||
const res = await request.upload('/back/upload', filePath, {
|
||||
token: token,
|
||||
name: 'file'
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
// 更新对应的收款码
|
||||
if (type === 'main') {
|
||||
this.paymentInfo.main_payment_qr_image = res.data.url
|
||||
} else {
|
||||
this.paymentInfo.sub_payment_qr_image = res.data.url
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
throw new Error(res.message || '上传失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('上传图片失败:', error)
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
|
||||
// 保存收款方式信息
|
||||
async savePaymentInfo() {
|
||||
if (!this.paymentInfo.main_payment_qr_image && !this.paymentInfo.sub_payment_qr_image) {
|
||||
uni.showToast({
|
||||
title: '请至少上传一个收款码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.saving = true
|
||||
try {
|
||||
const res = await request.put('/back/user/payment/info', this.paymentInfo)
|
||||
if (res.success) {
|
||||
this.paymentInfo = res.data
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
this.loadPaymentInfo()
|
||||
} else {
|
||||
throw new Error(res.message || '保存失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存收款方式失败:', error)
|
||||
uni.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background: white;
|
||||
padding: 40rpx 30rpx;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.payment-section {
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.qr-upload-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.qr-preview {
|
||||
width: 400rpx;
|
||||
height: 400rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.qr-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.qr-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.placeholder-text {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.upload-tips {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.save-section {
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 45rpx;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.save-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.help-section {
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.help-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.help-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.help-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15rpx;
|
||||
}
|
||||
|
||||
.help-text {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,805 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 页面标题 -->
|
||||
<view class="page-header">
|
||||
<text class="page-title">确认付款</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<view class="order-section">
|
||||
<view class="section-title">订单信息</view>
|
||||
<view class="order-item">
|
||||
<image :src="getFullImageUrl(productInfo.image)" class="product-image" mode="aspectFill" v-if="productInfo.image"></image>
|
||||
<view class="product-details">
|
||||
<text class="product-name">{{ productInfo.name }}</text>
|
||||
<view class="product-price-info">
|
||||
<text class="unit-price">单价:¥{{ orderInfo.unit_price }}</text>
|
||||
<text class="quantity">数量:{{ orderInfo.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="total-amount">
|
||||
<text class="total-label">总金额:</text>
|
||||
<text class="total-price">¥{{ orderInfo.total_amount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 收货地址 -->
|
||||
<view class="address-section">
|
||||
<view class="section-title">收货地址</view>
|
||||
<view class="address-selector" @tap="selectAddress">
|
||||
<view class="address-content" v-if="selectedAddress">
|
||||
<view class="address-info">
|
||||
<text class="consignee">{{ selectedAddress.consignee_name }}</text>
|
||||
<text class="phone">{{ selectedAddress.consignee_phone }}</text>
|
||||
</view>
|
||||
<text class="address-detail">{{ formatAddress(selectedAddress) }}</text>
|
||||
</view>
|
||||
<view class="no-address" v-else>
|
||||
<text class="no-address-text">请选择收货地址</text>
|
||||
</view>
|
||||
<uni-icons type="right" size="16" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 付款方式 -->
|
||||
<view class="payment-section">
|
||||
<view class="section-title">请扫码付款</view>
|
||||
<view class="payment-qr-container">
|
||||
<!-- 管理员付款码(一级商品) -->
|
||||
<view class="qr-section" v-if="orderInfo.product_type === 1">
|
||||
<view class="qr-title">
|
||||
<text class="qr-label">请扫描以下二维码付款</text>
|
||||
<text class="qr-subtitle">官方收款账户</text>
|
||||
</view>
|
||||
<view class="qr-code-wrapper">
|
||||
<image :src="getFullImageUrl(adminPaymentQr.main)"
|
||||
class="qr-code"
|
||||
mode="aspectFit"
|
||||
v-if="adminPaymentQr.main"
|
||||
@tap="previewQrCode(adminPaymentQr.main)">
|
||||
</image>
|
||||
<view class="qr-placeholder" v-else>
|
||||
<text class="placeholder-text">暂无付款码</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="backup-qr" v-if="adminPaymentQr.sub">
|
||||
<text class="backup-label">备用付款码</text>
|
||||
<image :src="getFullImageUrl(adminPaymentQr.sub)"
|
||||
class="backup-qr-image"
|
||||
mode="aspectFit"
|
||||
@tap="previewQrCode(adminPaymentQr.sub)">
|
||||
</image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 卖家付款码(二级商品) -->
|
||||
<view class="qr-section" v-if="orderInfo.product_type === 2">
|
||||
<view class="qr-title">
|
||||
<text class="qr-label">请扫描以下二维码付款</text>
|
||||
<text class="qr-subtitle">卖家收款账户</text>
|
||||
</view>
|
||||
<view class="seller-info">
|
||||
<image :src="getFullImageUrl(sellerInfo.avatar)" class="seller-avatar" mode="aspectFill" v-if="sellerInfo.avatar"></image>
|
||||
<view class="seller-avatar-placeholder" v-else>
|
||||
<uni-icons type="person" size="30" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
<view class="seller-details">
|
||||
<text class="seller-name">{{ sellerInfo.customer_name || sellerInfo.real_name }}</text>
|
||||
<text class="seller-code">ID: {{ sellerInfo.identity_code }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="qr-code-wrapper">
|
||||
<image :src="getFullImageUrl(sellerPaymentQr.main)"
|
||||
class="qr-code"
|
||||
mode="aspectFit"
|
||||
v-if="sellerPaymentQr.main"
|
||||
@tap="previewQrCode(sellerPaymentQr.main)">
|
||||
</image>
|
||||
<view class="qr-placeholder" v-else>
|
||||
<text class="placeholder-text">卖家暂未设置付款码</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="backup-qr" v-if="sellerPaymentQr.sub">
|
||||
<text class="backup-label">备用付款码</text>
|
||||
<image :src="getFullImageUrl(sellerPaymentQr.sub)"
|
||||
class="backup-qr-image"
|
||||
mode="aspectFit"
|
||||
@tap="previewQrCode(sellerPaymentQr.sub)">
|
||||
</image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 上传付款凭证 -->
|
||||
<view class="upload-section">
|
||||
<view class="section-title">上传付款凭证</view>
|
||||
<view class="upload-container">
|
||||
<view class="upload-item" @tap="uploadPaymentProof">
|
||||
<image v-if="paymentProofImage"
|
||||
:src="getFullImageUrl(paymentProofImage)"
|
||||
class="proof-image"
|
||||
mode="aspectFill">
|
||||
</image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="40" color="#ccc"></uni-icons>
|
||||
<text class="upload-text">点击上传付款截图</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload-tips">
|
||||
<text class="tip-text">请上传完整的付款截图,包含金额和时间信息</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<view class="submit-section">
|
||||
<view class="action-buttons">
|
||||
<button class="cancel-btn" @tap="cancelOrder" v-if="canCancel">
|
||||
取消订单
|
||||
</button>
|
||||
<button class="submit-btn" @tap="submitOrder" :disabled="!canSubmit || submitting">
|
||||
<text v-if="submitting">提交中...</text>
|
||||
<text v-else>提交付款凭证</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
orderId: '',
|
||||
orderNo: '',
|
||||
orderInfo: {},
|
||||
productInfo: {
|
||||
name: '',
|
||||
image: ''
|
||||
},
|
||||
selectedAddress: null,
|
||||
adminPaymentQr: {
|
||||
main: '',
|
||||
sub: ''
|
||||
},
|
||||
sellerInfo: {},
|
||||
sellerPaymentQr: {
|
||||
main: '',
|
||||
sub: ''
|
||||
},
|
||||
paymentProofImage: '',
|
||||
submitting: false,
|
||||
canCancel: true,
|
||||
productType:1
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSubmit() {
|
||||
return this.paymentProofImage && !this.submitting
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取订单信息
|
||||
this.orderId = options.order_id || ''
|
||||
this.orderNo = options.order_no || ''
|
||||
if(options.is_second=="true"){
|
||||
this.productType=2
|
||||
}else
|
||||
{
|
||||
this.productType=1
|
||||
}
|
||||
|
||||
if (!this.orderId) {
|
||||
uni.showToast({
|
||||
title: '订单信息有误',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
return
|
||||
}
|
||||
|
||||
this.loadOrderData()
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 加载订单数据
|
||||
async loadOrderData() {
|
||||
try {
|
||||
// 获取订单详情
|
||||
const orderRes = await request.get(`/back/user/orders/purchase?order_id=${this.orderId}`)
|
||||
if (orderRes.success && orderRes.data.list && orderRes.data.list.length > 0) {
|
||||
this.orderInfo = orderRes.data.list[0]
|
||||
this.selectedAddress = this.orderInfo.address
|
||||
|
||||
// 设置商品信息
|
||||
this.productInfo = {
|
||||
name: this.orderInfo.product_name,
|
||||
image: this.getFirstImage(this.orderInfo.product_images)
|
||||
}
|
||||
|
||||
// 检查订单状态
|
||||
if (this.orderInfo.order_status !== 0) {
|
||||
this.canCancel = false
|
||||
}
|
||||
|
||||
// 如果是二级商品,获取卖家信息
|
||||
if (this.orderInfo.product_type === 2 && this.orderInfo.seller_id) {
|
||||
this.sellerInfo = this.orderInfo.seller
|
||||
}
|
||||
|
||||
// 加载付款信息
|
||||
await this.loadPaymentInfo()
|
||||
} else {
|
||||
throw new Error('订单不存在')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载订单失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载订单失败',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 加载付款信息
|
||||
async loadPaymentInfo() {
|
||||
try {
|
||||
if (this.orderInfo.product_type === 1) { // 一级商品
|
||||
// 加载管理员付款码
|
||||
const res = await request.get('/back/admin/payment/info')
|
||||
if (res.success) {
|
||||
this.adminPaymentQr = {
|
||||
main: res.data.main_payment_qr_image || '',
|
||||
sub: res.data.sub_payment_qr_image || ''
|
||||
}
|
||||
}
|
||||
} else { // 二级商品
|
||||
// 加载卖家付款码
|
||||
const res = await request.get(`/back/user/seller/${this.orderInfo.seller_id}/payment`)
|
||||
if (res.success) {
|
||||
this.sellerPaymentQr = {
|
||||
main: res.data.main_payment_qr_image || '',
|
||||
sub: res.data.sub_payment_qr_image || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载付款信息失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化地址
|
||||
formatAddress(address) {
|
||||
if (!address) return ''
|
||||
return `${address.province} ${address.city} ${address.district} ${address.detail_address}`
|
||||
},
|
||||
|
||||
// 选择收货地址
|
||||
selectAddress() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/address/select'
|
||||
})
|
||||
},
|
||||
|
||||
// 预览二维码
|
||||
previewQrCode(qrCode) {
|
||||
if (!qrCode) return
|
||||
uni.previewImage({
|
||||
urls: [this.getFullImageUrl(qrCode)],
|
||||
current: 0
|
||||
})
|
||||
},
|
||||
|
||||
// 上传付款凭证
|
||||
uploadPaymentProof() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['camera', 'album'],
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
await this.uploadImage(filePath)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择图片失败:', err)
|
||||
uni.showToast({
|
||||
title: '选择图片失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 上传图片
|
||||
async uploadImage(filePath) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
const token = uni.getStorageSync('token')
|
||||
const res = await request.upload('/back/upload', filePath, {
|
||||
token: token,
|
||||
name: 'file'
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
this.paymentProofImage = res.data.url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
throw new Error(res.message || '上传失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('上传图片失败:', error)
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
|
||||
// 提交付款凭证
|
||||
async submitOrder() {
|
||||
if (!this.canSubmit) {
|
||||
if (!this.paymentProofImage) {
|
||||
uni.showToast({
|
||||
title: '请上传付款凭证',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
this.submitting = true
|
||||
try {
|
||||
|
||||
const res = await request.put(`/back/user/orders/purchase/${this.orderId}/payment`, {
|
||||
payment_proof_image: this.paymentProofImage,
|
||||
product_type :this.productType
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '付款凭证提交成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 延迟跳转到订单页面
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/orders/orders'
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(res.message || '提交付款凭证失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交付款凭证失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
async cancelOrder() {
|
||||
uni.showModal({
|
||||
title: '确认取消',
|
||||
content: '确定要取消这个订单吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request.put(`/back/user/orders/purchase/${this.orderId}/cancel`)
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '订单已取消',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(result.message || '取消订单失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('取消订单失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '取消失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.order-section,
|
||||
.address-section,
|
||||
.payment-section,
|
||||
.upload-section {
|
||||
background: white;
|
||||
margin: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.product-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.product-price-info {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.unit-price,
|
||||
.quantity {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.total-label {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.total-price {
|
||||
font-size: 36rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.address-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx;
|
||||
background: #f8f8f8;
|
||||
border-radius: 15rpx;
|
||||
min-height: 100rpx;
|
||||
}
|
||||
|
||||
.address-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.address-info {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.consignee {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.phone {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.address-detail {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.no-address {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.no-address-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.payment-qr-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.qr-section {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.qr-title {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.qr-label {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.qr-subtitle {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.seller-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 15rpx;
|
||||
background: #f8f8f8;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
.seller-avatar {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 30rpx;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.seller-avatar-placeholder {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 30rpx;
|
||||
background: #e5e5e5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.seller-details {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.seller-name {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.seller-code {
|
||||
font-size: 22rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.qr-code-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.qr-code {
|
||||
width: 400rpx;
|
||||
height: 400rpx;
|
||||
border: 2rpx solid #eee;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
.qr-placeholder {
|
||||
width: 400rpx;
|
||||
height: 400rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
border-radius: 15rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.placeholder-text {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.backup-qr {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.backup-label {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.backup-qr-image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.upload-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.upload-item {
|
||||
width: 400rpx;
|
||||
height: 300rpx;
|
||||
margin: 0 auto 20rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
border-radius: 15rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.proof-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.upload-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.upload-tips {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.submit-section {
|
||||
padding: 40rpx 30rpx;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
background: #f5f5f5;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 40rpx;
|
||||
color: #666;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
flex: 2;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.submit-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,781 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 商品图片轮播 -->
|
||||
<view class="image-section">
|
||||
<swiper class="image-swiper" :indicator-dots="imageList.length > 1" indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#FF4444" :autoplay="false" :circular="true">
|
||||
<swiper-item v-for="(image, index) in imageList" :key="index">
|
||||
<image :src="getFullImageUrl(image)" class="product-image" mode="aspectFill" @tap="previewImage(index)"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="image-count" v-if="imageList.length > 1">
|
||||
<text>{{ currentImageIndex + 1 }}/{{ imageList.length }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品基本信息 -->
|
||||
<view class="product-info-section">
|
||||
<view class="price-section">
|
||||
<view class="current-price">
|
||||
<text class="price-symbol">¥</text>
|
||||
<text class="price-value">{{ productInfo.current_price || productInfo.selling_price }}</text>
|
||||
</view>
|
||||
<view class="original-price" v-if="productInfo.original_price && productInfo.original_price != productInfo.current_price">
|
||||
<text class="original-price-text">原价 ¥{{ productInfo.original_price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="product-title">
|
||||
<text class="product-name">{{ productInfo.product_name }}</text>
|
||||
</view>
|
||||
|
||||
<view class="product-stats">
|
||||
<text class="stats-item">销量 {{ productInfo.sales_count || 0 }}</text>
|
||||
<text class="stats-item">库存 {{ productInfo.stock_quantity || productInfo.quantity || 0 }}</text>
|
||||
<text class="stats-item">浏览 {{ productInfo.view_count || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 卖家信息(仅二级商品显示) -->
|
||||
<view class="seller-section" v-if="productType === 'secondary' && productInfo.seller">
|
||||
<view class="section-title">卖家信息</view>
|
||||
<view class="seller-info">
|
||||
<image :src="getFullImageUrl(productInfo.seller.avatar)" class="seller-avatar" mode="aspectFill" v-if="productInfo.seller.avatar"></image>
|
||||
<view class="seller-avatar-placeholder" v-else>
|
||||
<uni-icons type="person" size="40" color="#ccc"></uni-icons>
|
||||
</view>
|
||||
<view class="seller-details">
|
||||
<text class="seller-name">{{ productInfo.seller.real_name || productInfo.seller.customer_name }}</text>
|
||||
<text class="seller-code">ID: {{ productInfo.seller.identity_code }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品描述 -->
|
||||
<view class="description-section" v-if="productInfo.product_description">
|
||||
<view class="section-title">商品描述</view>
|
||||
<view class="description-content">
|
||||
<text class="description-text">{{ productInfo.product_description }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 购买数量选择弹窗 -->
|
||||
<uni-popup ref="quantityPopup" type="bottom" background-color="#fff" border-radius="20rpx 20rpx 0 0">
|
||||
<view class="quantity-popup">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">选择购买数量</text>
|
||||
<view class="close-btn" @tap="closeQuantityPopup">
|
||||
<uni-icons type="close" size="20" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-product-info">
|
||||
<image :src="getFullImageUrl(getFirstImage(productInfo.product_images))" class="popup-product-image" mode="aspectFill"></image>
|
||||
<view class="popup-product-details">
|
||||
<text class="popup-product-name">{{ productInfo.product_name }}</text>
|
||||
<text class="popup-product-price">¥{{ productInfo.current_price || productInfo.selling_price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="quantity-selector">
|
||||
<text class="quantity-label">购买数量</text>
|
||||
<view class="quantity-controls">
|
||||
<view class="quantity-btn" @tap="decreaseQuantity" :class="{ disabled: selectedQuantity <= 1 }">
|
||||
<uni-icons type="minus" size="16" color="#666"></uni-icons>
|
||||
</view>
|
||||
<input class="quantity-input" type="number" v-model="selectedQuantity" @input="onQuantityInput" />
|
||||
<view class="quantity-btn" @tap="increaseQuantity" :class="{ disabled: selectedQuantity >= maxQuantity }">
|
||||
<uni-icons type="plus" size="16" color="#666"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<text class="stock-info">库存{{ maxQuantity }}件</text>
|
||||
</view>
|
||||
|
||||
<view class="total-price">
|
||||
<text class="total-label">总价:</text>
|
||||
<text class="total-amount">¥{{ (selectedQuantity * (productInfo.current_price || productInfo.selling_price)).toFixed(2) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-footer">
|
||||
<button class="confirm-buy-btn" @tap="confirmPurchase">
|
||||
立即购买
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 底部购买栏 -->
|
||||
<view class="bottom-bar">
|
||||
<button class="buy-btn" @tap="showQuantityPopup" :disabled="!canPurchase">
|
||||
<text v-if="!canPurchase">暂时无法购买</text>
|
||||
<text v-else>立即购买</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view class="loading-overlay" v-if="loading">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
productId: '',
|
||||
productType: '', // 'primary' 或 'secondary'
|
||||
productInfo: {},
|
||||
imageList: [],
|
||||
currentImageIndex: 0,
|
||||
selectedQuantity: 1,
|
||||
maxQuantity: 0,
|
||||
loading: false,
|
||||
canPurchase: true
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 显示安全提示弹窗
|
||||
this.showSecurityAlert()
|
||||
|
||||
if (options.id && options.type) {
|
||||
this.productId = options.id
|
||||
this.productType = options.type
|
||||
this.loadProductDetail()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '商品信息有误',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 显示安全提示弹窗
|
||||
showSecurityAlert() {
|
||||
// 检查是否已经显示过,避免重复提示
|
||||
const hasShownAlert = uni.getStorageSync('security_alert_shown')
|
||||
if (hasShownAlert) {
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '安全提示',
|
||||
content: '为了您的账户安全,请在使用过程中:\n\n• 关闭WiFi连接\n• 关闭位置服务\n• 关闭蓝牙功能\n• 关闭热点功能\n\n这样可以防止信息泄露,保护您的隐私安全。',
|
||||
showCancel: true,
|
||||
cancelText: '知道了',
|
||||
confirmText: '不再提示',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 用户选择不再提示,记录到本地存储
|
||||
uni.setStorageSync('security_alert_shown', true)
|
||||
}
|
||||
// 无论用户选择什么,都已经显示过提示了
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
// 如果是逗号分隔的字符串
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
// 如果是数组
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 加载商品详情
|
||||
async loadProductDetail() {
|
||||
this.loading = true
|
||||
try {
|
||||
let url = ''
|
||||
if (this.productType === 'primary') {
|
||||
url = `/back/user/products/primary/${this.productId}`
|
||||
} else {
|
||||
url = `/back/user/products/secondary/${this.productId}`
|
||||
}
|
||||
|
||||
const res = await request.get(url)
|
||||
if (res.success) {
|
||||
this.productInfo = res.data
|
||||
this.processProductImages()
|
||||
this.calculateMaxQuantity()
|
||||
this.checkCanPurchase()
|
||||
} else {
|
||||
throw new Error(res.message || '加载商品详情失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载商品详情失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 处理商品图片
|
||||
processProductImages() {
|
||||
if (this.productInfo.product_images) {
|
||||
if (typeof this.productInfo.product_images === 'string') {
|
||||
this.imageList = this.productInfo.product_images.split(',').map(img => img.trim()).filter(img => img)
|
||||
} else if (Array.isArray(this.productInfo.product_images)) {
|
||||
this.imageList = this.productInfo.product_images
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有图片,设置默认图片
|
||||
if (this.imageList.length === 0) {
|
||||
this.imageList = ['/static/images/default-product.png']
|
||||
}
|
||||
},
|
||||
|
||||
// 计算最大购买数量
|
||||
calculateMaxQuantity() {
|
||||
if (this.productType === 'primary') {
|
||||
this.maxQuantity = this.productInfo.stock_quantity || 0
|
||||
} else {
|
||||
this.maxQuantity = this.productInfo.quantity || 0
|
||||
}
|
||||
},
|
||||
|
||||
// 检查是否可以购买
|
||||
checkCanPurchase() {
|
||||
if (this.maxQuantity <= 0) {
|
||||
this.canPurchase = false
|
||||
return
|
||||
}
|
||||
|
||||
// 如果是二级商品,需要检查是否是自己的商品
|
||||
if (this.productType === 'secondary') {
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (userInfo && this.productInfo.seller_id === userInfo.id) {
|
||||
this.canPurchase = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.canPurchase = true
|
||||
},
|
||||
|
||||
// 预览图片
|
||||
previewImage(index) {
|
||||
const urls = this.imageList.map(img => this.getFullImageUrl(img))
|
||||
uni.previewImage({
|
||||
urls: urls,
|
||||
current: index
|
||||
})
|
||||
},
|
||||
|
||||
// 显示数量选择弹窗
|
||||
showQuantityPopup() {
|
||||
if (!this.canPurchase) return
|
||||
|
||||
this.selectedQuantity = 1
|
||||
this.$refs.quantityPopup.open()
|
||||
},
|
||||
|
||||
// 关闭数量选择弹窗
|
||||
closeQuantityPopup() {
|
||||
this.$refs.quantityPopup.close()
|
||||
},
|
||||
|
||||
// 减少数量
|
||||
decreaseQuantity() {
|
||||
if (this.selectedQuantity > 1) {
|
||||
this.selectedQuantity--
|
||||
}
|
||||
},
|
||||
|
||||
// 增加数量
|
||||
increaseQuantity() {
|
||||
if (this.selectedQuantity < this.maxQuantity) {
|
||||
this.selectedQuantity++
|
||||
}
|
||||
},
|
||||
|
||||
// 数量输入处理
|
||||
onQuantityInput(e) {
|
||||
let value = parseInt(e.detail.value) || 1
|
||||
if (value < 1) value = 1
|
||||
if (value > this.maxQuantity) value = this.maxQuantity
|
||||
this.selectedQuantity = value
|
||||
},
|
||||
|
||||
// 确认购买
|
||||
async confirmPurchase() {
|
||||
if (this.selectedQuantity <= 0 || this.selectedQuantity > this.maxQuantity) {
|
||||
uni.showToast({
|
||||
title: '购买数量有误',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 先检查是否有收货地址
|
||||
try {
|
||||
const addressRes = await request.get('/back/user/addresses')
|
||||
if (!addressRes.success || !addressRes.data || addressRes.data.length === 0) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先设置收货地址',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/address/edit'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
const orderData = {
|
||||
product_id: parseInt(this.productId),
|
||||
product_type: this.productType === 'primary' ? 1 : 2,
|
||||
product_name: this.productInfo.product_name,
|
||||
product_images: this.getFirstImage(this.productInfo.product_images),
|
||||
unit_price: this.productInfo.current_price || this.productInfo.selling_price,
|
||||
quantity: this.selectedQuantity,
|
||||
total_amount: parseFloat((this.selectedQuantity * (this.productInfo.current_price || this.productInfo.selling_price)).toFixed(2)),
|
||||
address_id: addressRes.data.find(addr => addr.is_default === 1)?.id || addressRes.data[0].id,
|
||||
remark: ''
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
title: '创建订单中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
const orderRes = await request.post('/back/user/orders/purchase', orderData)
|
||||
var isSecond=this.productType === 'primary' ? false : true
|
||||
if (orderRes.success) {
|
||||
uni.hideLoading()
|
||||
|
||||
// 关闭弹窗
|
||||
this.closeQuantityPopup()
|
||||
|
||||
// 跳转到付款页面
|
||||
uni.navigateTo({
|
||||
url: `/pages/payment/purchase?order_id=${orderRes.data.order_id}&order_no=${orderRes.data.order_no}&is_second=${isSecond}`
|
||||
})
|
||||
|
||||
uni.showToast({
|
||||
title: '订单创建成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
throw new Error(orderRes.message || '创建订单失败')
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('创建订单失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '创建订单失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
.image-section {
|
||||
position: relative;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.image-swiper {
|
||||
width: 100%;
|
||||
height: 750rpx;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.image-count {
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
right: 20rpx;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.product-info-section {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.price-section {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.current-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.price-symbol {
|
||||
font-size: 28rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price-value {
|
||||
font-size: 48rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.original-price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.original-price-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.product-title {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-stats {
|
||||
display: flex;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.stats-item {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.seller-section {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.seller-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.seller-avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.seller-avatar-placeholder {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
background: #f5f5f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.seller-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.seller-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.seller-code {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.description-section {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.description-content {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.description-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.bottom-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: white;
|
||||
padding: 20rpx 30rpx;
|
||||
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
|
||||
|
||||
}
|
||||
|
||||
.buy-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.buy-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.quantity-popup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 75vh;
|
||||
background: white;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
flex: 1;
|
||||
padding: 40rpx 30rpx 20rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
padding: 20rpx 30rpx;
|
||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.popup-product-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
background: #f8f8f8;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.popup-product-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.popup-product-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.popup-product-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.popup-product-price {
|
||||
font-size: 32rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.quantity-selector {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.quantity-label {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.quantity-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.quantity-btn {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.quantity-btn.disabled {
|
||||
background: #f5f5f5;
|
||||
border-color: #eee;
|
||||
}
|
||||
|
||||
.quantity-input {
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
text-align: center;
|
||||
border: 1rpx solid #ddd;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.stock-info {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.total-price {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.total-label {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-size: 36rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.confirm-buy-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.confirm-buy-btn:disabled {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.loading-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,703 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<view class="nav-bar">
|
||||
|
||||
<text class="nav-title">编辑个人信息</text>
|
||||
<view class="nav-right" @click="saveProfile">
|
||||
<text class="save-btn">保存</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="content">
|
||||
<!-- 头像上传 -->
|
||||
<view class="form-item">
|
||||
<text class="label">头像</text>
|
||||
<view class="avatar-upload" @click="chooseAvatar">
|
||||
<image v-if="userForm.avatar" class="avatar-preview" :src="getFullImageUrl(userForm.avatar)" mode="aspectFill"></image>
|
||||
<view v-else class="avatar-placeholder">
|
||||
<uni-icons type="camera" size="40" color="#999"></uni-icons>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 手机号 -->
|
||||
<view class="form-item">
|
||||
<text class="label">手机号</text>
|
||||
<input class="input" v-model="userForm.phone" placeholder="请输入手机号" maxlength="11" />
|
||||
</view>
|
||||
|
||||
<!-- 客户姓名 -->
|
||||
<view class="form-item">
|
||||
<text class="label">客户姓名</text>
|
||||
<input class="input" v-model="userForm.customer_name" placeholder="请输入客户姓名" />
|
||||
</view>
|
||||
|
||||
<!-- 真实姓名 -->
|
||||
<view class="form-item">
|
||||
<text class="label">真实姓名</text>
|
||||
<input class="input" v-model="userForm.real_name" placeholder="请输入真实姓名" />
|
||||
</view>
|
||||
|
||||
<!-- 公司名称 -->
|
||||
<view class="form-item">
|
||||
<text class="label">公司名称</text>
|
||||
<input class="input" v-model="userForm.company_name" placeholder="请输入公司名称" />
|
||||
</view>
|
||||
|
||||
<!-- 个人介绍 -->
|
||||
<view class="form-item">
|
||||
<text class="label">个人介绍</text>
|
||||
<textarea class="textarea" v-model="userForm.personal_intro" placeholder="请输入个人介绍" maxlength="200"></textarea>
|
||||
</view>
|
||||
|
||||
<!-- 修改密码 -->
|
||||
<view class="password-section">
|
||||
<text class="section-title">修改密码</text>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">当前密码</text>
|
||||
<input class="input" v-model="passwordForm.current_password" type="password" placeholder="请输入当前密码" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">新密码</text>
|
||||
<input class="input" v-model="passwordForm.new_password" type="password" placeholder="请输入新密码" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">确认新密码</text>
|
||||
<input class="input" v-model="passwordForm.confirm_password" type="password" placeholder="请再次输入新密码" />
|
||||
</view>
|
||||
|
||||
<view class="password-actions">
|
||||
<button class="password-btn" @click="changePassword" :disabled="passwordLoading">
|
||||
{{ passwordLoading ? '修改中...' : '修改密码' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 证件照片上传区域 -->
|
||||
<!-- <view class="upload-section">
|
||||
<text class="section-title">证件照片</text>
|
||||
|
||||
|
||||
<view class="upload-item">
|
||||
<text class="upload-label">营业执照</text>
|
||||
<view class="image-upload" @click="chooseBusinessLicense">
|
||||
<image v-if="userForm.business_license" class="upload-preview" :src="getFullImageUrl(userForm.business_license)" mode="aspectFill"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">上传营业执照</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="upload-item">
|
||||
<text class="upload-label">身份证正面</text>
|
||||
<view class="image-upload" @click="chooseIDCardFront">
|
||||
<image v-if="userForm.id_card_front" class="upload-preview" :src="getFullImageUrl(userForm.id_card_front)" mode="aspectFill"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">上传身份证正面</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="upload-item">
|
||||
<text class="upload-label">身份证反面</text>
|
||||
<view class="image-upload" @click="chooseIDCardBack">
|
||||
<image v-if="userForm.id_card_back" class="upload-preview" :src="getFullImageUrl(userForm.id_card_back)" mode="aspectFill"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">上传身份证反面</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 收款码上传区域 -->
|
||||
<!-- <view class="upload-section">
|
||||
<text class="section-title">收款二维码</text>
|
||||
|
||||
|
||||
<view class="upload-item">
|
||||
<text class="upload-label">主收款码</text>
|
||||
<view class="image-upload" @click="chooseMainPayment">
|
||||
<image v-if="userForm.main_payment_qr_image" class="upload-preview" :src="getFullImageUrl(userForm.main_payment_qr_image)" mode="aspectFill"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">上传主收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="upload-item">
|
||||
<text class="upload-label">副收款码</text>
|
||||
<view class="image-upload" @click="chooseSubPayment">
|
||||
<image v-if="userForm.sub_payment_qr_image" class="upload-preview" :src="getFullImageUrl(userForm.sub_payment_qr_image)" mode="aspectFill"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">上传副收款码</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userForm: {
|
||||
phone: '',
|
||||
customer_name: '',
|
||||
real_name: '',
|
||||
avatar: '',
|
||||
company_name: '',
|
||||
personal_intro: '',
|
||||
business_license: '',
|
||||
id_card_front: '',
|
||||
id_card_back: '',
|
||||
main_payment_qr_image: '',
|
||||
sub_payment_qr_image: ''
|
||||
},
|
||||
passwordForm: {
|
||||
current_password: '',
|
||||
new_password: '',
|
||||
confirm_password: ''
|
||||
},
|
||||
loading: false,
|
||||
passwordLoading: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 加载用户信息
|
||||
async loadUserInfo() {
|
||||
try {
|
||||
const res = await request.get('/back/current-user')
|
||||
if (res.success) {
|
||||
const user = res.data
|
||||
this.userForm = {
|
||||
phone: user.phone || '',
|
||||
customer_name: user.customer_name || '',
|
||||
real_name: user.real_name || '',
|
||||
avatar: user.avatar || '',
|
||||
company_name: user.company_name || '',
|
||||
personal_intro: user.personal_intro || '',
|
||||
business_license: user.business_license_image || '',
|
||||
id_card_front: user.id_card_front_image || '',
|
||||
id_card_back: user.id_card_back_image || '',
|
||||
main_payment_qr_image: user.main_payment_qr_image || '',
|
||||
sub_payment_qr_image: user.sub_payment_qr_image || ''
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载用户信息失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
// 保存个人信息
|
||||
async saveProfile() {
|
||||
// 表单验证
|
||||
if (!this.userForm.customer_name) {
|
||||
uni.showToast({
|
||||
title: '请输入客户姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.userForm.real_name) {
|
||||
uni.showToast({
|
||||
title: '请输入真实姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.userForm.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 手机号格式验证
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
if (!phoneRegex.test(this.userForm.phone)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
try {
|
||||
const updateData = {
|
||||
phone: this.userForm.phone,
|
||||
customer_name: this.userForm.customer_name,
|
||||
real_name: this.userForm.real_name,
|
||||
avatar: this.userForm.avatar,
|
||||
company_name: this.userForm.company_name,
|
||||
personal_intro: this.userForm.personal_intro,
|
||||
business_license: this.userForm.business_license,
|
||||
id_card_front: this.userForm.id_card_front,
|
||||
id_card_back: this.userForm.id_card_back,
|
||||
main_payment_code: this.userForm.main_payment_qr_image,
|
||||
backup_payment_code: this.userForm.sub_payment_qr_image
|
||||
}
|
||||
|
||||
const res = await request.put('/back/update-profile', updateData)
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 更新本地存储中的用户信息
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
|
||||
// 延迟返回,让用户看到成功提示
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url:"/pages/profile/profile"
|
||||
})
|
||||
}, 500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存个人信息失败:', error)
|
||||
uni.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 上传图片的通用方法
|
||||
async uploadImage(tempFilePath) {
|
||||
try {
|
||||
const uploadRes = await request.upload('/back/upload', tempFilePath)
|
||||
if (uploadRes.success) {
|
||||
return uploadRes.data.url
|
||||
} else {
|
||||
throw new Error(uploadRes.message || '上传失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('上传图片失败:', error)
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
return null
|
||||
}
|
||||
},
|
||||
|
||||
// 选择头像
|
||||
chooseAvatar() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.avatar = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 选择营业执照
|
||||
chooseBusinessLicense() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.business_license = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 选择身份证正面
|
||||
chooseIDCardFront() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.id_card_front = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 选择身份证反面
|
||||
chooseIDCardBack() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.id_card_back = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 选择主收款码
|
||||
chooseMainPayment() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.main_payment_qr_image = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 选择副收款码
|
||||
chooseSubPayment() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
const url = await this.uploadImage(tempFilePath)
|
||||
if (url) {
|
||||
this.userForm.sub_payment_qr_image = url
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 修改密码
|
||||
async changePassword() {
|
||||
// 表单验证
|
||||
if (!this.passwordForm.current_password) {
|
||||
uni.showToast({
|
||||
title: '请输入当前密码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.passwordForm.new_password) {
|
||||
uni.showToast({
|
||||
title: '请输入新密码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (this.passwordForm.new_password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '新密码至少6位',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (this.passwordForm.new_password !== this.passwordForm.confirm_password) {
|
||||
uni.showToast({
|
||||
title: '两次输入的密码不一致',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (this.passwordForm.current_password === this.passwordForm.new_password) {
|
||||
uni.showToast({
|
||||
title: '新密码不能与当前密码相同',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.passwordLoading = true
|
||||
try {
|
||||
const passwordData = {
|
||||
current_password: this.passwordForm.current_password,
|
||||
new_password: this.passwordForm.new_password
|
||||
}
|
||||
|
||||
const res = await request.put('/back/change-password', passwordData)
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '密码修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 清空密码表单
|
||||
this.passwordForm = {
|
||||
current_password: '',
|
||||
new_password: '',
|
||||
confirm_password: ''
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '密码修改失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('修改密码失败:', error)
|
||||
uni.showToast({
|
||||
title: '密码修改失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.passwordLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: #fff;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.nav-left {
|
||||
width: 80rpx;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.nav-right {
|
||||
width: 80rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
color: #FF4444;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
background-color: #fff;
|
||||
margin: 20rpx 0;
|
||||
padding: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
width: 200rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
padding: 20rpx;
|
||||
min-height: 120rpx;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.avatar-upload {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.avatar-preview {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 60rpx;
|
||||
}
|
||||
|
||||
.avatar-placeholder {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 60rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.placeholder-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.upload-section {
|
||||
background-color: #fff;
|
||||
margin: 40rpx 0;
|
||||
padding: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 30rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.upload-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.upload-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.upload-label {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
width: 200rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.image-upload {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.upload-preview {
|
||||
width: 200rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.upload-placeholder {
|
||||
width: 200rpx;
|
||||
height: 150rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.password-section {
|
||||
background-color: #fff;
|
||||
margin: 40rpx 0;
|
||||
padding: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.password-actions {
|
||||
margin-top: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.password-btn {
|
||||
background-color: #FF4444;
|
||||
color: white;
|
||||
border: none;
|
||||
|
||||
border-radius: 50rpx;
|
||||
font-size: 32rpx;
|
||||
min-width: 200rpx;
|
||||
}
|
||||
|
||||
.password-btn:disabled {
|
||||
background-color: #ccc;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,490 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 用户信息头部 -->
|
||||
<view class="user-header">
|
||||
<view class="user-info">
|
||||
<view class="avatar-container">
|
||||
<view class="avatar" v-if="userInfo.avatar">
|
||||
<image class="avatar-image" :src="getFullImageUrl(userInfo.avatar)" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="avatar default-avatar" v-else>
|
||||
<uni-icons type="person-filled" size="60" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="user-details" @click="goToEditProfile">
|
||||
<text class="user-name">{{ userInfo.customer_name || '未设置姓名' }}</text>
|
||||
<text class="user-phone">{{ userInfo.phone }}</text>
|
||||
<view class="user-points" @click.stop="goToScores">
|
||||
<text class="points-text">积分:{{ userInfo.current_points || 0 }}</text>
|
||||
<uni-icons type="right" size="16" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="edit-btn" @click="goToEditProfile">
|
||||
<uni-icons type="compose" size="24" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的买单 -->
|
||||
<view class="order-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">我的买单</text>
|
||||
<text class="view-all" @click="viewAllOrders('purchase')">查看全部></text>
|
||||
</view>
|
||||
<view class="order-status-bar">
|
||||
<view class="status-item" @click="goToOrders('purchase', 'pending')">
|
||||
<uni-icons type="wallet" size="32" color="#FF8800"></uni-icons>
|
||||
<text class="status-text">待付款</text>
|
||||
<view class="status-badge" v-if="pendingCount > 0">{{ pendingCount }}</view>
|
||||
</view>
|
||||
<view class="status-item" @click="goToOrders('purchase', 'confirming')">
|
||||
<uni-icons type="checkmarkempty" size="32" color="#1890FF"></uni-icons>
|
||||
<text class="status-text">待确认</text>
|
||||
<view class="status-badge" v-if="confirmingCount > 0">{{ confirmingCount }}</view>
|
||||
</view>
|
||||
<view class="status-item" @click="goToOrders('purchase', 'completed')">
|
||||
<uni-icons type="checkbox" size="32" color="#52C41A"></uni-icons>
|
||||
<text class="status-text">已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的卖单 -->
|
||||
<view class="order-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">我的卖单</text>
|
||||
<text class="view-all" @click="viewAllOrders('sales')">查看全部></text>
|
||||
</view>
|
||||
<view class="order-status-bar">
|
||||
<view class="status-item" @click="goToOrders('sales', 'pending')">
|
||||
<uni-icons type="shop" size="32" color="#FF8800"></uni-icons>
|
||||
<text class="status-text">待付款</text>
|
||||
<view class="status-badge" v-if="salesPendingCount > 0">{{ salesPendingCount }}</view>
|
||||
</view>
|
||||
<view class="status-item" @click="goToOrders('sales', 'confirming')">
|
||||
<uni-icons type="eye" size="32" color="#1890FF"></uni-icons>
|
||||
<text class="status-text">待确认</text>
|
||||
<view class="status-badge" v-if="salesConfirmingCount > 0">{{ salesConfirmingCount }}</view>
|
||||
</view>
|
||||
<view class="status-item" @click="goToOrders('sales', 'completed')">
|
||||
<uni-icons type="checkmarkempty" size="32" color="#52C41A"></uni-icons>
|
||||
<text class="status-text">已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 其他服务 -->
|
||||
<view class="service-section">
|
||||
<view class="section-title">其他服务</view>
|
||||
<view class="service-grid">
|
||||
<view class="service-item" @click="goToWarehouse">
|
||||
<uni-icons type="home" size="32" color="#666"></uni-icons>
|
||||
<text class="service-text">我的仓库</text>
|
||||
</view>
|
||||
<view class="service-item" @click="goToScores">
|
||||
<uni-icons type="medal" size="32" color="#666"></uni-icons>
|
||||
<text class="service-text">积分明细</text>
|
||||
</view>
|
||||
<view class="service-item" @click="goToReconciliation">
|
||||
<uni-icons type="bars" size="32" color="#666"></uni-icons>
|
||||
<text class="service-text">对账管理</text>
|
||||
</view>
|
||||
<view class="service-item" @click="goToPayment">
|
||||
<uni-icons type="wallet" size="32" color="#666"></uni-icons>
|
||||
<text class="service-text">收款方式</text>
|
||||
</view>
|
||||
<view class="service-item" @click="goToService">
|
||||
<uni-icons type="chatbubble" size="32" color="#666"></uni-icons>
|
||||
<text class="service-text">联系客服</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部功能 -->
|
||||
<view class="bottom-section">
|
||||
<view class="bottom-item" @click="goToAddress">
|
||||
<uni-icons type="location" size="32" color="#666"></uni-icons>
|
||||
<text class="bottom-text">收货地址</text>
|
||||
</view>
|
||||
<view class="bottom-item" @click="logout">
|
||||
<uni-icons type="loop" size="32" color="#666"></uni-icons>
|
||||
<text class="bottom-text">退出登录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
confirmingCount: 0,
|
||||
salesConfirmingCount: 0,
|
||||
pendingCount: 0,
|
||||
salesPendingCount: 0,
|
||||
phone:''
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
// 从本地存储获取用户信息
|
||||
this.userInfo = uni.getStorageSync('userInfo') || {}
|
||||
},
|
||||
onLoad() {
|
||||
this.loadUserInfo()
|
||||
this.loadOrderStats()
|
||||
this.loadPhone()
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.loadUserInfo()
|
||||
this.loadOrderStats()
|
||||
this.loadPhone()
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
async loadPhone(){
|
||||
const res= await request.get("/back/config",{key:"phone"})
|
||||
if(res.success) this.phone=res.data
|
||||
},
|
||||
// 加载用户信息
|
||||
async loadUserInfo() {
|
||||
try {
|
||||
const res = await request.get('/back/current-user')
|
||||
if (res.success) {
|
||||
this.userInfo = res.data
|
||||
// 更新本地存储中的用户信息
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 加载订单统计
|
||||
async loadOrderStats() {
|
||||
try {
|
||||
const res = await request.get('/back/user/orders/stats')
|
||||
if (res.success) {
|
||||
this.pendingCount = res.data.purchase_pending_count || 0
|
||||
this.confirmingCount = res.data.purchase_confirming_count || 0
|
||||
this.salesPendingCount = res.data.sales_pending_count || 0
|
||||
this.salesConfirmingCount = res.data.sales_confirming_count || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取订单统计失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到个人信息编辑页面
|
||||
goToEditProfile() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/profile/edit'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到订单页面
|
||||
goToOrders(type, status) {
|
||||
const url = type === 'purchase' ? '/pages/orders/orders' : '/pages/sales/sales'
|
||||
uni.navigateTo({
|
||||
url: `${url}?status=${status}`
|
||||
})
|
||||
},
|
||||
|
||||
// 查看全部订单
|
||||
viewAllOrders(type) {
|
||||
const url = type === 'purchase' ? '/pages/orders/orders' : '/pages/sales/sales'
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到仓库
|
||||
goToWarehouse() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/warehouse/warehouse'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到积分明细
|
||||
goToScores() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/scores/scores'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到对账管理
|
||||
goToReconciliation() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/reconciliation/reconciliation'
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到收款方式
|
||||
goToPayment() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/payment/payment'
|
||||
})
|
||||
},
|
||||
|
||||
// 联系客服
|
||||
goToService() {
|
||||
|
||||
uni.showModal({
|
||||
title: '联系客服',
|
||||
content: '请在服务群内联系客服',
|
||||
showCancel: false,
|
||||
|
||||
|
||||
|
||||
})
|
||||
// const res = uni.getSystemInfoSync();
|
||||
// const phone=""+this.phone
|
||||
// // ios系统默认有个模态框
|
||||
// if (res.platform == 'ios') {
|
||||
// uni.makePhoneCall({
|
||||
// phoneNumber: phone,
|
||||
// })
|
||||
// } else {
|
||||
// //安卓手机手动设置一个showActionSheet
|
||||
// uni.showActionSheet({
|
||||
// itemList: ['phone', '呼叫'],
|
||||
// success: function(res) {
|
||||
// if (res.tapIndex == 1) {
|
||||
// uni.makePhoneCall({
|
||||
// phoneNumber: phone,
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
},
|
||||
|
||||
// 跳转到收货地址
|
||||
goToAddress() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/address/address'
|
||||
})
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
logout() {
|
||||
uni.showModal({
|
||||
title: '确认退出',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 清除本地存储
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 用户信息头部 */
|
||||
.user-header {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
padding: 40rpx 30rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid rgba(255, 255, 255, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.avatar-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.default-avatar {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.user-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.user-phone {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.user-points {
|
||||
font-size: 28rpx;
|
||||
opacity: 0.9;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 20rpx;
|
||||
padding: 8rpx 15rpx;
|
||||
margin-top: 10rpx;
|
||||
max-width: 200rpx;
|
||||
}
|
||||
|
||||
.points-text {
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
/* 订单区域 */
|
||||
.order-section {
|
||||
background-color: #fff;
|
||||
margin: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.view-all {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.order-status-bar {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.status-item uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
position: absolute;
|
||||
top: -5rpx;
|
||||
right: -5rpx;
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 4rpx 8rpx;
|
||||
border-radius: 20rpx;
|
||||
min-width: 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 服务区域 */
|
||||
.service-section {
|
||||
background-color: #fff;
|
||||
margin: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.service-grid {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.service-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.service-item uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.service-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* 底部区域 */
|
||||
.bottom-section {
|
||||
display: flex;
|
||||
margin: 20rpx;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.bottom-item {
|
||||
flex: 1;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bottom-item uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.bottom-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,581 @@
|
||||
<template>
|
||||
<view class="reconciliation-container">
|
||||
|
||||
|
||||
|
||||
<!-- 日期选择区域 -->
|
||||
<view class="date-selector">
|
||||
<view class="date-row">
|
||||
<view class="date-item">
|
||||
<text class="date-label">开始日期</text>
|
||||
<view class="date-picker" @click="showStartDatePicker">
|
||||
<text class="date-text">{{ startDate }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="date-item">
|
||||
<text class="date-label">结束日期</text>
|
||||
<view class="date-picker" @click="showEndDatePicker">
|
||||
<text class="date-text">{{ endDate }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="date-item">
|
||||
<text class="date-label blue">按日期筛选</text>
|
||||
<view class="refresh-btn" @click="refreshData">
|
||||
<text class="refresh-text">重置</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 一级市场统计 -->
|
||||
<view class="stats-section">
|
||||
<view class="stats-title green">一级市场已确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ primaryConfirmed.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ primaryConfirmed.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-section">
|
||||
<view class="stats-title red">一级市场待确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ primaryPending.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ primaryPending.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 二级市场买单统计 -->
|
||||
<view class="stats-section">
|
||||
<view class="stats-title green">二级市场买单已确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ secondaryBuyConfirmed.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ secondaryBuyConfirmed.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-section">
|
||||
<view class="stats-title red">二级市场买单待确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ secondaryBuyPending.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ secondaryBuyPending.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 二级市场卖单统计 -->
|
||||
<view class="stats-section">
|
||||
<view class="stats-title green">二级市场卖单已确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ secondarySellConfirmed.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ secondarySellConfirmed.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-section">
|
||||
<view class="stats-title red">二级市场卖单待确认</view>
|
||||
<view class="stats-row">
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ secondarySellPending.amount }}</text>
|
||||
</view>
|
||||
<view class="stats-item">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ secondarySellPending.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 仓库商品统计 -->
|
||||
<view class="warehouse-section">
|
||||
<view class="warehouse-title red">仓库商品不参与日期筛选</view>
|
||||
<view class="warehouse-row">
|
||||
<view class="warehouse-item">
|
||||
<view class="warehouse-status green">寄售中</view>
|
||||
<view class="warehouse-stats">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ warehouseActive.amount }}</text>
|
||||
</view>
|
||||
<view class="warehouse-stats">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ warehouseActive.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="warehouse-item">
|
||||
<view class="warehouse-status gray">未寄售</view>
|
||||
<view class="warehouse-stats">
|
||||
<text class="stats-label">金额:</text>
|
||||
<text class="stats-value">{{ warehouseInactive.amount }}</text>
|
||||
</view>
|
||||
<view class="warehouse-stats">
|
||||
<text class="stats-label">数量:</text>
|
||||
<text class="stats-value">{{ warehouseInactive.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 积分变更统计 -->
|
||||
<view class="score-section">
|
||||
<view class="score-left">
|
||||
<view class="score-title">积分变更</view>
|
||||
<view class="score-stats">
|
||||
<text class="score-label">增加积分:</text>
|
||||
<text class="score-value">{{ scoreChange.increase }}</text>
|
||||
</view>
|
||||
<view class="score-stats">
|
||||
<text class="score-label">减少积分:</text>
|
||||
<text class="score-value">{{ scoreChange.decrease }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="score-right" @click="goToScoreDetail">
|
||||
<view class="score-icon">📋</view>
|
||||
<text class="score-link">积分变更记录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<uni-datetime-picker
|
||||
ref="startPicker"
|
||||
type="date"
|
||||
v-model="startDate"
|
||||
@change="onStartDateChange"
|
||||
:clear-icon="false"
|
||||
/>
|
||||
|
||||
<uni-datetime-picker
|
||||
ref="endPicker"
|
||||
type="date"
|
||||
v-model="endDate"
|
||||
@change="onEndDateChange"
|
||||
:clear-icon="false"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
name: 'Reconciliation',
|
||||
data() {
|
||||
return {
|
||||
// 日期选择
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
|
||||
// 一级市场统计
|
||||
primaryConfirmed: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
primaryPending: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
|
||||
// 二级市场买单统计
|
||||
secondaryBuyConfirmed: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
secondaryBuyPending: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
|
||||
// 二级市场卖单统计
|
||||
secondarySellConfirmed: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
secondarySellPending: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
|
||||
// 仓库商品统计
|
||||
warehouseActive: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
warehouseInactive: {
|
||||
amount: 0,
|
||||
quantity: 0
|
||||
},
|
||||
|
||||
// 积分变更统计
|
||||
scoreChange: {
|
||||
increase: 0,
|
||||
decrease: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.initDates()
|
||||
this.loadReconciliationData()
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化日期(默认今天)
|
||||
initDates() {
|
||||
const today = new Date()
|
||||
const dateStr = today.getFullYear() + '-' +
|
||||
String(today.getMonth() + 1).padStart(2, '0') + '-' +
|
||||
String(today.getDate()).padStart(2, '0')
|
||||
this.startDate = dateStr
|
||||
this.endDate = dateStr
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
// 显示开始日期选择器
|
||||
showStartDatePicker() {
|
||||
this.$refs.startPicker.show()
|
||||
},
|
||||
|
||||
// 显示结束日期选择器
|
||||
showEndDatePicker() {
|
||||
this.$refs.endPicker.show()
|
||||
},
|
||||
|
||||
// 开始日期变更
|
||||
onStartDateChange(e) {
|
||||
this.startDate = e
|
||||
this.loadReconciliationData()
|
||||
},
|
||||
|
||||
// 结束日期变更
|
||||
onEndDateChange(e) {
|
||||
this.endDate = e
|
||||
this.loadReconciliationData()
|
||||
},
|
||||
|
||||
// 重置数据
|
||||
refreshData() {
|
||||
this.initDates()
|
||||
this.loadReconciliationData()
|
||||
},
|
||||
|
||||
// 加载对账数据
|
||||
async loadReconciliationData() {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
|
||||
const params = {
|
||||
start_date: this.startDate,
|
||||
end_date: this.endDate
|
||||
}
|
||||
|
||||
const response = await request.get('/back/user/reconciliation/stats', params )
|
||||
|
||||
if (response.success) {
|
||||
const data = response.data
|
||||
|
||||
// 一级市场统计
|
||||
this.primaryConfirmed = data.primary_confirmed || { amount: 0, quantity: 0 }
|
||||
this.primaryPending = data.primary_pending || { amount: 0, quantity: 0 }
|
||||
|
||||
// 二级市场买单统计
|
||||
this.secondaryBuyConfirmed = data.secondary_buy_confirmed || { amount: 0, quantity: 0 }
|
||||
this.secondaryBuyPending = data.secondary_buy_pending || { amount: 0, quantity: 0 }
|
||||
|
||||
// 二级市场卖单统计
|
||||
this.secondarySellConfirmed = data.secondary_sell_confirmed || { amount: 0, quantity: 0 }
|
||||
this.secondarySellPending = data.secondary_sell_pending || { amount: 0, quantity: 0 }
|
||||
|
||||
// 仓库商品统计
|
||||
this.warehouseActive = data.warehouse_active || { amount: 0, quantity: 0 }
|
||||
this.warehouseInactive = data.warehouse_inactive || { amount: 0, quantity: 0 }
|
||||
|
||||
// 积分变更统计
|
||||
this.scoreChange = data.score_change || { increase: 0, decrease: 0 }
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载对账数据失败:', error)
|
||||
uni.showToast({
|
||||
title: '网络错误',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到积分明细页面
|
||||
goToScoreDetail() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/scores/scores'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.reconciliation-container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/* 导航栏 */
|
||||
.nav-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 88rpx;
|
||||
background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
|
||||
color: white;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-back {
|
||||
position: absolute;
|
||||
left: 30rpx;
|
||||
}
|
||||
|
||||
.nav-back-text {
|
||||
font-size: 32rpx;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 日期选择区域 */
|
||||
.date-selector {
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.date-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.date-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.date-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.date-label.blue {
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.date-picker {
|
||||
padding: 10rpx 20rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.date-text {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
padding: 10rpx 20rpx;
|
||||
background: #007aff;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.refresh-text {
|
||||
font-size: 26rpx;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* 统计区域 */
|
||||
.stats-section {
|
||||
background: white;
|
||||
margin: 0 30rpx 20rpx;
|
||||
padding: 30rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.stats-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stats-title.green {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.stats-title.red {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.stats-row {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.stats-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stats-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.stats-value {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
/* 仓库商品区域 */
|
||||
.warehouse-section {
|
||||
background: white;
|
||||
margin: 0 30rpx 20rpx;
|
||||
padding: 30rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.warehouse-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #ff4d4f;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.warehouse-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.warehouse-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.warehouse-status {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.warehouse-status.green {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.warehouse-status.gray {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.warehouse-stats {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
/* 积分变更区域 */
|
||||
.score-section {
|
||||
background: white;
|
||||
margin: 0 30rpx 40rpx;
|
||||
padding: 30rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.score-left {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.score-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.score-stats {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.score-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.score-value {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.score-right {
|
||||
text-align: center;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.score-icon {
|
||||
font-size: 60rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.score-link {
|
||||
font-size: 24rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,669 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="register-header">
|
||||
<text class="page-title">用户注册</text>
|
||||
</view>
|
||||
|
||||
<view class="register-form">
|
||||
<!-- 基本信息 -->
|
||||
<view class="section-title">基本信息</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">手机号 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.phone"
|
||||
type="number"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">密码 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.password"
|
||||
type="password"
|
||||
placeholder="请输入密码(6-20位)" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">确认密码 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.confirmPassword"
|
||||
type="password"
|
||||
placeholder="请再次输入密码" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">店铺名称 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.customer_name"
|
||||
placeholder="请输入店铺名称" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">法人名称 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.real_name"
|
||||
placeholder="请输入法人名称" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">公司名称 *</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.company_name"
|
||||
placeholder="请输入公司名称" />
|
||||
</view>
|
||||
|
||||
<!-- 证件上传 -->
|
||||
<view class="section-title">证件信息</view>
|
||||
|
||||
<view class="upload-section">
|
||||
<text class="upload-label">身份证正面 *</text>
|
||||
<view class="upload-area" @click="chooseIdCardFront">
|
||||
<image v-if="registerForm.id_card_front"
|
||||
:src="getFullImageUrl(registerForm.id_card_front)"
|
||||
mode="aspectFill"
|
||||
class="upload-image"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">点击上传身份证正面</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="upload-section">
|
||||
<text class="upload-label">身份证反面 *</text>
|
||||
<view class="upload-area" @click="chooseIdCardBack">
|
||||
<image v-if="registerForm.id_card_back"
|
||||
:src="getFullImageUrl(registerForm.id_card_back)"
|
||||
mode="aspectFill"
|
||||
class="upload-image"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">点击上传身份证反面</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="upload-section">
|
||||
<text class="upload-label">营业执照 *</text>
|
||||
<view class="upload-area" @click="chooseBusinessLicense">
|
||||
<image v-if="registerForm.business_license"
|
||||
:src="getFullImageUrl(registerForm.business_license)"
|
||||
mode="aspectFill"
|
||||
class="upload-image"></image>
|
||||
<view v-else class="upload-placeholder">
|
||||
<uni-icons type="camera" size="30" color="#999"></uni-icons>
|
||||
<text class="upload-text">点击上传营业执照</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 验证方式 -->
|
||||
<view class="section-title">验证信息</view>
|
||||
|
||||
<!-- 短信验证码(必填) -->
|
||||
<view class="verify-section">
|
||||
<view class="form-item">
|
||||
<text class="form-label">短信验证码 *</text>
|
||||
<view class="verify-input-group">
|
||||
<input class="form-input verify-input"
|
||||
v-model="registerForm.sms_code"
|
||||
type="number"
|
||||
placeholder="请输入验证码"
|
||||
maxlength="6" />
|
||||
<button class="verify-btn"
|
||||
@click="sendSmsCode"
|
||||
:disabled="smsLoading || countdown > 0">
|
||||
{{ smsLoading ? '发送中...' : countdown > 0 ? `${countdown}s` : '获取验证码' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 推荐人身份码(选填) -->
|
||||
<view class="form-item">
|
||||
<text class="form-label">推荐人身份码</text>
|
||||
<input class="form-input"
|
||||
v-model="registerForm.referrer_identity_code"
|
||||
placeholder="请输入推荐人身份码(选填)" />
|
||||
</view>
|
||||
|
||||
<!-- 用户协议 -->
|
||||
<view class="agreement-section">
|
||||
<view class="agreement-item" @click="toggleAgreement">
|
||||
<uni-icons :type="agreed ? 'checkbox-filled' : 'circle'" size="16" :color="agreed ? '#FF4444' : '#999'"></uni-icons>
|
||||
<text class="agreement-text">我已阅读并同意</text>
|
||||
<text class="agreement-link">《用户协议》</text>
|
||||
<text class="agreement-text">和</text>
|
||||
<text class="agreement-link">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 注册按钮 -->
|
||||
<button class="register-btn" @click="handleRegister" :disabled="registerLoading">
|
||||
{{ registerLoading ? '注册中...' : '立即注册' }}
|
||||
</button>
|
||||
|
||||
<view class="login-link">
|
||||
<text class="link-text">已有账号?</text>
|
||||
<text class="link-action" @click="goToLogin">立即登录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
token:'',
|
||||
registerForm: {
|
||||
phone: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
customer_name: '',
|
||||
real_name: '',
|
||||
company_name: '',
|
||||
id_card_front: '',
|
||||
id_card_back: '',
|
||||
business_license: '',
|
||||
referrer_identity_code: '',
|
||||
sms_code: ''
|
||||
},
|
||||
agreed: false,
|
||||
registerLoading: false,
|
||||
smsLoading: false,
|
||||
countdown: 0
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.token=uni.getStorageSync('token')
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 选择身份证正面
|
||||
chooseIdCardFront() {
|
||||
this.chooseImage('id_card_front')
|
||||
},
|
||||
|
||||
// 选择身份证反面
|
||||
chooseIdCardBack() {
|
||||
this.chooseImage('id_card_back')
|
||||
},
|
||||
|
||||
// 选择营业执照
|
||||
chooseBusinessLicense() {
|
||||
this.chooseImage('business_license')
|
||||
},
|
||||
|
||||
// 选择图片并上传
|
||||
chooseImage(field) {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['camera', 'album'],
|
||||
success: (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0]
|
||||
this.uploadImage(tempFilePath, field)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 上传图片
|
||||
async uploadImage(filePath, field) {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
})
|
||||
|
||||
try {
|
||||
const res = await request.upload("/back/upload", filePath, {
|
||||
token: this.token
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
this.registerForm[field] = res.data.url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// uni.uploadFile({
|
||||
// url: request.config.baseURL + '/back/upload',
|
||||
// filePath: filePath,
|
||||
// name: 'file',
|
||||
// header: {
|
||||
// 'token': token
|
||||
// },
|
||||
// success: (uploadRes) => {
|
||||
// try {
|
||||
// const result = JSON.parse(uploadRes.data)
|
||||
// if (result.success) {
|
||||
// this.registerForm[field] = result.data.url
|
||||
// uni.showToast({
|
||||
// title: '上传成功',
|
||||
// icon: 'success'
|
||||
// })
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: result.message || '上传失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
// } catch (e) {
|
||||
// uni.showToast({
|
||||
// title: '上传失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// console.log(err)
|
||||
// uni.showToast({
|
||||
// title: '上传失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// },
|
||||
// complete: () => {
|
||||
// uni.hideLoading()
|
||||
// }
|
||||
// })
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
|
||||
// 发送短信验证码
|
||||
async sendSmsCode() {
|
||||
if (!this.registerForm.phone) {
|
||||
uni.showToast({
|
||||
title: '请先输入手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!/^1[3-9]\d{9}$/.test(this.registerForm.phone)) {
|
||||
uni.showToast({
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.smsLoading = true
|
||||
|
||||
try {
|
||||
const res = await request.post('/back/auth/send-sms', {
|
||||
phone: this.registerForm.phone
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '验证码发送成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 开始倒计时
|
||||
this.startCountdown()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '发送失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '发送失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.smsLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 开始倒计时
|
||||
startCountdown() {
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
// 切换协议同意状态
|
||||
toggleAgreement() {
|
||||
this.agreed = !this.agreed
|
||||
},
|
||||
|
||||
// 表单验证
|
||||
validateForm() {
|
||||
if (!this.registerForm.phone) {
|
||||
uni.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!/^1[3-9]\d{9}$/.test(this.registerForm.phone)) {
|
||||
uni.showToast({ title: '手机号格式不正确', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.password) {
|
||||
uni.showToast({ title: '请输入密码', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.registerForm.password.length < 6 || this.registerForm.password.length > 20) {
|
||||
uni.showToast({ title: '密码长度为6-20位', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.registerForm.password !== this.registerForm.confirmPassword) {
|
||||
uni.showToast({ title: '两次密码输入不一致', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.customer_name) {
|
||||
uni.showToast({ title: '请输入店铺名称', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.real_name) {
|
||||
uni.showToast({ title: '请输入法人名称', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.company_name) {
|
||||
uni.showToast({ title: '请输入公司名称', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.id_card_front) {
|
||||
uni.showToast({ title: '请上传身份证正面', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.id_card_back) {
|
||||
uni.showToast({ title: '请上传身份证反面', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.business_license) {
|
||||
uni.showToast({ title: '请上传营业执照', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.registerForm.sms_code) {
|
||||
uni.showToast({ title: '请输入短信验证码', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.agreed) {
|
||||
uni.showToast({ title: '请先同意用户协议', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
// 处理注册
|
||||
async handleRegister() {
|
||||
if (!this.validateForm()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.registerLoading = true
|
||||
|
||||
try {
|
||||
// 准备注册数据
|
||||
const registerData = {
|
||||
phone: this.registerForm.phone,
|
||||
password: this.registerForm.password,
|
||||
customer_name: this.registerForm.customer_name,
|
||||
real_name: this.registerForm.real_name,
|
||||
company_name: this.registerForm.company_name,
|
||||
business_license_image: this.registerForm.business_license,
|
||||
id_card_front_image: this.registerForm.id_card_front,
|
||||
id_card_back_image: this.registerForm.id_card_back
|
||||
}
|
||||
|
||||
// 添加验证信息(验证码必填,身份码选填)
|
||||
registerData.sms_code = this.registerForm.sms_code
|
||||
if (this.registerForm.referrer_identity_code) {
|
||||
registerData.referrer_identity_code = this.registerForm.referrer_identity_code
|
||||
}
|
||||
|
||||
const res = await request.post('/back/auth/register', registerData)
|
||||
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '注册失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('注册失败:', error)
|
||||
uni.showToast({
|
||||
title: '网络错误,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.registerLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到登录页面
|
||||
goToLogin() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.register-header {
|
||||
background: linear-gradient(135deg, #FF4444 0%, #FF6666 100%);
|
||||
padding: 40rpx 30rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.register-form {
|
||||
padding: 40rpx 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin: 40rpx 0 30rpx 0;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 上传区域 */
|
||||
.upload-section {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.upload-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
height: 200rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 2rpx dashed #ddd;
|
||||
}
|
||||
|
||||
.upload-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.upload-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.upload-placeholder uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.upload-text {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 验证码输入组 */
|
||||
.verify-section {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.verify-input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.verify-input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.verify-btn {
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.verify-btn:disabled {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
/* 用户协议 */
|
||||
.agreement-section {
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
|
||||
.agreement-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.agreement-item uni-icons {
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.agreement-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
font-size: 24rpx;
|
||||
color: #FF4444;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* 注册按钮 */
|
||||
.register-btn {
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
border-radius: 50rpx;
|
||||
height: 100rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin: 40rpx 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.register-btn:disabled {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
/* 登录链接 */
|
||||
.login-link {
|
||||
text-align: center;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.link-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.link-action {
|
||||
font-size: 28rpx;
|
||||
color: #FF4444;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,662 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 状态切换标签 -->
|
||||
<view class="status-tabs">
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === 'all' }"
|
||||
@click="switchStatus('all')">
|
||||
<text class="tab-text">全部</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '0' }"
|
||||
@click="switchStatus('0')">
|
||||
<text class="tab-text">待付款</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '1' }"
|
||||
@click="switchStatus('1')">
|
||||
<text class="tab-text">待确认</text>
|
||||
</view>
|
||||
<view class="tab-item"
|
||||
:class="{ active: currentStatus === '2' }"
|
||||
@click="switchStatus('2')">
|
||||
<text class="tab-text">已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 筛选条件 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="showDatePicker('start')">
|
||||
<text class="filter-label">开始日期</text>
|
||||
<text class="filter-value">{{ startDate || '选择日期' }}</text>
|
||||
</view>
|
||||
<view class="filter-item" @click="showDatePicker('end')">
|
||||
<text class="filter-label">结束日期</text>
|
||||
<text class="filter-value">{{ endDate || '选择日期' }}</text>
|
||||
</view>
|
||||
<view class="filter-item" @click="showAmountFilter">
|
||||
<text class="filter-label">按日期筛选</text>
|
||||
<text class="filter-value">总金额</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 总金额显示 -->
|
||||
<view class="amount-summary" v-if="totalAmount > 0">
|
||||
<text class="summary-label">重置</text>
|
||||
<text class="summary-amount">{{ totalAmount }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 卖单列表 -->
|
||||
<view class="sales-list">
|
||||
<view class="sales-item" v-for="(item, index) in salesList" :key="index" @click="goToOrderDetail(item)">
|
||||
<view class="order-header">
|
||||
<text class="order-number">订单编号:{{ item.order_no }}</text>
|
||||
<view class="order-status" :class="getStatusClass(item.order_status)">
|
||||
<text class="status-text">{{ getStatusText(item.order_status) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-content">
|
||||
<view class="product-info">
|
||||
<image :src="getFullImageUrl(getFirstImage(item.product_images))"
|
||||
class="product-image"
|
||||
mode="aspectFill">
|
||||
</image>
|
||||
<view class="product-details">
|
||||
<text class="product-name">{{ item.product_name }}</text>
|
||||
<text class="product-price">¥{{ item.selling_price }}</text>
|
||||
<text class="product-quantity">×{{ item.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-footer">
|
||||
<text class="order-time">下单时间:{{ formatTime(item.created_at) }}</text>
|
||||
<view class="order-summary">
|
||||
<!-- <text class="summary-text">共{{ item.quantity }}件商品 运费 ¥0.00 合计:</text> -->
|
||||
<text class="summary-price">¥{{ item.total_amount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-actions">
|
||||
<!-- <button class="action-btn detail-btn" @click.stop="goToDetail(item)">
|
||||
查看详情
|
||||
</button> -->
|
||||
<button v-if="item.payment_proof_image"
|
||||
class="action-btn proof-btn"
|
||||
@click.stop="viewPaymentProof(item)">
|
||||
查看凭证
|
||||
</button>
|
||||
<button v-if="item.order_status === 1"
|
||||
class="action-btn confirm-btn"
|
||||
@click.stop="confirmOrder(item)">
|
||||
确认发货
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-if="salesList.length === 0 && !loading">
|
||||
<uni-icons type="shop" size="100" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无卖单</text>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore && salesList.length > 0">
|
||||
<text>加载更多...</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentStatus: 'all',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
totalAmount: 0,
|
||||
salesList: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (options.status) {
|
||||
this.currentStatus = options.status
|
||||
}
|
||||
this.loadSales()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 切换状态
|
||||
switchStatus(status) {
|
||||
this.currentStatus = status
|
||||
this.currentPage = 1
|
||||
this.loadSales()
|
||||
},
|
||||
|
||||
// 显示日期选择器
|
||||
showDatePicker(type) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['今天', '最近7天', '最近30天', '最近90天'],
|
||||
success: (res) => {
|
||||
const now = new Date()
|
||||
let startDate, endDate
|
||||
|
||||
switch (res.tapIndex) {
|
||||
case 0: // 今天
|
||||
startDate = endDate = this.formatDate(now)
|
||||
break
|
||||
case 1: // 最近7天
|
||||
startDate = this.formatDate(new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
case 2: // 最近30天
|
||||
startDate = this.formatDate(new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
case 3:
|
||||
startDate = this.formatDate(new Date(now.getTime() - 90 * 24 * 60 * 60 * 1000))
|
||||
endDate = this.formatDate(now)
|
||||
break
|
||||
}
|
||||
|
||||
if (type === 'start') {
|
||||
this.startDate = startDate
|
||||
} else {
|
||||
this.endDate = endDate
|
||||
}
|
||||
|
||||
this.currentPage = 1
|
||||
this.loadSales()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 显示金额筛选
|
||||
showAmountFilter() {
|
||||
this.startDate = ''
|
||||
this.endDate = ''
|
||||
this.currentPage = 1
|
||||
this.loadSales()
|
||||
},
|
||||
|
||||
// 加载卖单列表
|
||||
async loadSales() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
page_size: this.pageSize
|
||||
}
|
||||
|
||||
if (this.currentStatus !== 'all') {
|
||||
// 状态映射:前端显示状态 -> 后端查询参数
|
||||
const statusMap = {
|
||||
'0': 'pending',
|
||||
'1': 'confirming',
|
||||
'2': 'completed',
|
||||
'3': 'cancelled'
|
||||
}
|
||||
params.status = statusMap[this.currentStatus] || this.currentStatus
|
||||
}
|
||||
|
||||
if (this.startDate) {
|
||||
params.start_date = this.startDate
|
||||
}
|
||||
|
||||
if (this.endDate) {
|
||||
params.end_date = this.endDate
|
||||
}
|
||||
|
||||
const res = await request.get('/back/user/orders/sales', params)
|
||||
|
||||
if (res.success) {
|
||||
const data = res.data
|
||||
if (this.currentPage === 1) {
|
||||
this.salesList = data.list || []
|
||||
} else {
|
||||
this.salesList = [...this.salesList, ...(data.list || [])]
|
||||
}
|
||||
|
||||
this.hasMore = this.salesList.length < data.total
|
||||
this.totalAmount = data.total_amount || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载卖单失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 加载更多
|
||||
loadMore() {
|
||||
this.currentPage++
|
||||
this.loadSales()
|
||||
},
|
||||
|
||||
// 获取状态样式类
|
||||
getStatusClass(status) {
|
||||
const classMap = {
|
||||
0: 'status-pending',
|
||||
1: 'status-confirming',
|
||||
2: 'status-completed',
|
||||
3: 'status-cancelled'
|
||||
}
|
||||
return classMap[status] || ''
|
||||
},
|
||||
|
||||
// 获取状态文本
|
||||
getStatusText(status) {
|
||||
const textMap = {
|
||||
0: '待付款',
|
||||
1: '待确认',
|
||||
2: '已完成',
|
||||
3: '已取消'
|
||||
}
|
||||
return textMap[status] || '未知状态'
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(time) {
|
||||
if (!time) return ''
|
||||
const date = new Date(time)
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(date) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||
},
|
||||
|
||||
// 跳转到订单详情
|
||||
goToDetail(order) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/detail?id=${order.id}&type=sales`
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到订单详情页面
|
||||
goToOrderDetail(order) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/orders/detail?id=${order.id}&type=sales`
|
||||
})
|
||||
},
|
||||
|
||||
// 查看付款凭证
|
||||
viewPaymentProof(order) {
|
||||
if (!order.payment_proof_image) {
|
||||
uni.showToast({
|
||||
title: '暂无付款凭证',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [this.getFullImageUrl(order.payment_proof_image)],
|
||||
current: 0
|
||||
})
|
||||
},
|
||||
|
||||
// 确认发货
|
||||
async confirmOrder(order) {
|
||||
uni.showModal({
|
||||
title: '确认发货',
|
||||
content: `确认向买家发货 ¥${order.total_amount} 的商品吗?确认后买家将收到商品。`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request.put(`/back/user/orders/sales/${order.id}/confirm`)
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '确认发货成功',
|
||||
icon: 'success'
|
||||
})
|
||||
this.loadSales()
|
||||
} else {
|
||||
throw new Error(result.message || '确认失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('确认发货失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '确认失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
async cancelOrder(order) {
|
||||
uni.showModal({
|
||||
title: '确认取消',
|
||||
content: '确定要取消这个订单吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request.post(`/back/user/orders/sales/${order.id}/cancel`)
|
||||
if (result.success) {
|
||||
uni.showToast({
|
||||
title: '订单已取消',
|
||||
icon: 'success'
|
||||
})
|
||||
this.loadSales()
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '取消失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 样式与买单页面基本一致,只调整部分颜色和文本 */
|
||||
.status-tabs {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-text {
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 60rpx;
|
||||
height: 4rpx;
|
||||
background-color: #FF4444;
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.filter-label {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.filter-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.amount-summary {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 28rpx;
|
||||
color: #007AFF;
|
||||
}
|
||||
|
||||
.summary-amount {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
.sales-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.sales-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.order-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.order-number {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background-color: #FFF2E6;
|
||||
color: #FF8800;
|
||||
}
|
||||
|
||||
.status-confirming {
|
||||
background-color: #E6F7FF;
|
||||
color: #1890FF;
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
background-color: #F6FFED;
|
||||
color: #52C41A;
|
||||
}
|
||||
|
||||
.status-cancelled {
|
||||
background-color: #FFF1F0;
|
||||
color: #FF4D4F;
|
||||
}
|
||||
|
||||
.order-content {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 160rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.product-details {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 32rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.product-quantity {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.order-footer {
|
||||
padding: 30rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.order-time {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.order-summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.summary-price {
|
||||
font-size: 32rpx;
|
||||
color: #FF4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.order-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 30rpx;
|
||||
gap: 20rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 16rpx 32rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
}
|
||||
|
||||
.detail-btn {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.proof-btn {
|
||||
background-color: #1890FF;
|
||||
color: #fff;
|
||||
border-color: #1890FF;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #52C41A;
|
||||
color: #fff;
|
||||
border-color: #52C41A;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #fff;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.empty-state uni-icons {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,366 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 积分概览 -->
|
||||
<view class="score-header">
|
||||
<view class="current-score">
|
||||
<text class="score-label">当前积分</text>
|
||||
<text class="score-value">{{ scoreStats.current_points || 0 }}</text>
|
||||
</view>
|
||||
<view class="score-stats">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ scoreStats.total_income || 0 }}</text>
|
||||
<text class="stat-label">累计获得</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ scoreStats.total_expense || 0 }}</text>
|
||||
<text class="stat-label">累计消费</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 筛选栏 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item"
|
||||
:class="{ active: currentFilter === 'all' }"
|
||||
@click="switchFilter('all')">
|
||||
<text class="filter-text">全部</text>
|
||||
</view>
|
||||
<view class="filter-item"
|
||||
:class="{ active: currentFilter === 'positive' }"
|
||||
@click="switchFilter('positive')">
|
||||
<text class="filter-text">收入</text>
|
||||
</view>
|
||||
<view class="filter-item"
|
||||
:class="{ active: currentFilter === 'negative' }"
|
||||
@click="switchFilter('negative')">
|
||||
<text class="filter-text">支出</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 积分记录列表 -->
|
||||
<view class="record-list">
|
||||
<view class="record-item" v-for="(item, index) in recordList" :key="index">
|
||||
<view class="record-content">
|
||||
<view class="record-info">
|
||||
<text class="record-note">{{ item.note }}</text>
|
||||
<text class="record-time">{{ formatTime(item.created_at) }}</text>
|
||||
</view>
|
||||
<view class="record-amount" :class="{ positive: item.change_number > 0, negative: item.change_number < 0 }">
|
||||
<text class="amount-text">
|
||||
{{ item.change_number > 0 ? '+' : '' }}{{ item.change_number }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-if="recordList.length === 0 && !loading">
|
||||
<uni-icons type="wallet" size="100" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无积分记录</text>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore && recordList.length > 0">
|
||||
<text>加载更多...</text>
|
||||
</view>
|
||||
|
||||
<!-- 加载中 -->
|
||||
<view class="loading" v-if="loading">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scoreStats: {
|
||||
current_points: 0,
|
||||
total_income: 0,
|
||||
total_expense: 0
|
||||
},
|
||||
recordList: [],
|
||||
currentFilter: 'all',
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.loadScoreStats()
|
||||
this.loadRecords()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载积分统计信息
|
||||
async loadScoreStats() {
|
||||
try {
|
||||
const res = await request.get('/back/user/scores/stats')
|
||||
if (res.success) {
|
||||
this.scoreStats = res.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载积分统计失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 加载积分记录
|
||||
async loadRecords() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
page_size: this.pageSize
|
||||
}
|
||||
|
||||
if (this.currentFilter !== 'all') {
|
||||
params.change_type = this.currentFilter
|
||||
}
|
||||
|
||||
const res = await request.get('/back/user/scores/records', params)
|
||||
|
||||
if (res.success) {
|
||||
const data = res.data
|
||||
if (this.currentPage === 1) {
|
||||
this.recordList = data.list || []
|
||||
} else {
|
||||
this.recordList = [...this.recordList, ...(data.list || [])]
|
||||
}
|
||||
|
||||
this.hasMore = this.recordList.length < data.total
|
||||
|
||||
// 更新统计信息
|
||||
if (data.current_points !== undefined) {
|
||||
this.scoreStats.current_points = data.current_points
|
||||
this.scoreStats.total_income = data.total_income || 0
|
||||
this.scoreStats.total_expense = data.total_expense || 0
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载积分记录失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 加载更多
|
||||
loadMore() {
|
||||
this.currentPage++
|
||||
this.loadRecords()
|
||||
},
|
||||
|
||||
// 切换筛选条件
|
||||
switchFilter(filter) {
|
||||
this.currentFilter = filter
|
||||
this.currentPage = 1
|
||||
this.loadRecords()
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatTime(time) {
|
||||
if (!time) return ''
|
||||
const date = new Date(time)
|
||||
const now = new Date()
|
||||
const diffTime = now.getTime() - date.getTime()
|
||||
const diffDays = Math.floor(diffTime / (24 * 60 * 60 * 1000))
|
||||
|
||||
if (diffDays === 0) {
|
||||
return `今天 ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
|
||||
} else if (diffDays === 1) {
|
||||
return `昨天 ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
|
||||
} else if (diffDays < 7) {
|
||||
return `${diffDays}天前`
|
||||
} else {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 积分概览 */
|
||||
.score-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 60rpx 40rpx 40rpx;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.current-score {
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.score-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
opacity: 0.8;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.score-value {
|
||||
font-size: 80rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.score-stats {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* 筛选栏 */
|
||||
.filter-bar {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
padding: 0 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filter-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.filter-item.active .filter-text {
|
||||
color: #667eea;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.filter-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 60rpx;
|
||||
height: 4rpx;
|
||||
background-color: #667eea;
|
||||
}
|
||||
|
||||
/* 记录列表 */
|
||||
.record-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.record-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.record-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.record-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.record-note {
|
||||
display: block;
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.record-time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.record-amount {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.amount-text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.record-amount.positive .amount-text {
|
||||
color: #52C41A;
|
||||
}
|
||||
|
||||
.record-amount.negative .amount-text {
|
||||
color: #FF4D4F;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.empty-state uni-icons {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 加载更多 */
|
||||
.load-more, .loading {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,672 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="warehouse-list">
|
||||
<view class="warehouse-item" v-for="(item, index) in warehouseList" :key="item.id">
|
||||
<view class="product-card">
|
||||
<image :src="getFullImageUrl(getFirstImage(item.product_images))"
|
||||
class="product-image"
|
||||
mode="aspectFill"
|
||||
@error="onImageError"></image>
|
||||
<view v-if="!getFirstImage(item.product_images)" class="default-product">
|
||||
<uni-icons type="image" size="60" color="#666"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ item.product_name }}</text>
|
||||
<view class="product-stats">
|
||||
<text class="stats-text">库存 {{ item.quantity }}件</text>
|
||||
<text class="stats-text">{{ getProductTypeText(item.product_type) }}</text>
|
||||
<text class="stats-text" v-if="item.status === 0">已出售</text>
|
||||
</view>
|
||||
<view class="product-price">
|
||||
<text class="purchase-price">购买价:¥{{ (item.purchase_price * item.quantity).toFixed(2) }}</text>
|
||||
<text class="current-price">当前价值:¥{{ (item.warehouse_price * item.quantity).toFixed(2) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="product-actions">
|
||||
<button v-if="item.status === 1"
|
||||
class="action-btn sell-btn"
|
||||
@click="sellProduct(item)">
|
||||
立即挂售
|
||||
</button>
|
||||
<button v-else-if="item.status === 0"
|
||||
class="action-btn disabled-btn"
|
||||
disabled>
|
||||
不可出售
|
||||
</button>
|
||||
<button v-else
|
||||
class="action-btn sold-btn"
|
||||
disabled>
|
||||
已出售
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" v-if="warehouseList.length === 0 && !loading">
|
||||
<uni-icons type="home" size="100" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">仓库暂无商品</text>
|
||||
</view>
|
||||
|
||||
<!-- 底部提示 -->
|
||||
<view class="bottom-tip" v-if="warehouseList.length > 0">
|
||||
<text class="tip-text">没有更多了</text>
|
||||
</view>
|
||||
|
||||
<!-- 挂售弹窗 -->
|
||||
<uni-popup ref="sellPopup" type="bottom" border-radius="10px 10px 0 0">
|
||||
<view class="sell-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">商品挂售</text>
|
||||
<uni-icons type="close" @click="closeSellPopup" class="close-btn"></uni-icons>
|
||||
</view>
|
||||
|
||||
<view class="popup-content" v-if="selectedItem">
|
||||
<view class="product-summary">
|
||||
<image :src="getFullImageUrl(getFirstImage(selectedItem.product_images))"
|
||||
class="summary-image"
|
||||
mode="aspectFill"></image>
|
||||
<view class="summary-info">
|
||||
<text class="summary-name">{{ selectedItem.product_name }}</text>
|
||||
<text class="summary-stock">库存:{{ selectedItem.quantity }}件</text>
|
||||
<text class="summary-price">仓库价值:¥{{ selectedItem.warehouse_price }}/件</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="sell-form">
|
||||
<view class="form-item">
|
||||
<text class="form-label">挂售数量</text>
|
||||
<view class="quantity-selector">
|
||||
<button class="quantity-btn" @click="decreaseQuantity" :disabled="sellQuantity <= 1">-</button>
|
||||
<input type="number" v-model.number="sellQuantity" class="quantity-input" :max="selectedItem.quantity" min="1">
|
||||
<button class="quantity-btn" @click="increaseQuantity" :disabled="sellQuantity >= selectedItem.quantity">+</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">出售价格</text>
|
||||
<view class="price-input-wrap">
|
||||
<text class="price-symbol">¥</text>
|
||||
<input disabled type="digit" v-model="sellPrice" class="price-input" placeholder="请输入出售价格">
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">商品描述</text>
|
||||
<textarea v-model="sellDescription" class="description-input" placeholder="请描述商品的具体情况..." maxlength="500"></textarea>
|
||||
</view>
|
||||
|
||||
<!-- <view class="form-item">
|
||||
<text class="form-label">商品成色</text>
|
||||
<view class="condition-selector">
|
||||
<view class="condition-item"
|
||||
v-for="condition in conditionOptions"
|
||||
:key="condition.value"
|
||||
:class="{ active: sellCondition === condition.value }"
|
||||
@click="sellCondition = condition.value">
|
||||
<text>{{ condition.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="sell-summary">
|
||||
<text class="summary-text">挂售 {{ sellQuantity }} 件,总价值 ¥{{ (sellPrice * sellQuantity).toFixed(2) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-footer">
|
||||
<button class="cancel-btn" @click="closeSellPopup">取消</button>
|
||||
<button class="confirm-btn" @click="confirmSell" :disabled="!canSubmit">确认挂售</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
warehouseList: [],
|
||||
loading: false,
|
||||
// 挂售相关数据
|
||||
selectedItem: null,
|
||||
sellQuantity: 1,
|
||||
sellPrice: '',
|
||||
sellDescription: '',
|
||||
sellCondition: '九成新',
|
||||
conditionOptions: [
|
||||
{ label: '全新', value: '全新' },
|
||||
{ label: '九成新', value: '九成新' },
|
||||
{ label: '八成新', value: '八成新' },
|
||||
{ label: '七成新', value: '七成新' },
|
||||
{ label: '六成新', value: '六成新' },
|
||||
{ label: '其他', value: '其他' }
|
||||
],
|
||||
submitting: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSubmit() {
|
||||
return this.sellQuantity > 0 &&
|
||||
this.sellQuantity <= (this.selectedItem?.quantity || 0) &&
|
||||
this.sellPrice > 0 &&
|
||||
this.sellDescription.trim() &&
|
||||
!this.submitting
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 检查登录状态
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.loadWarehouse()
|
||||
},
|
||||
onShow() {
|
||||
this.loadWarehouse()
|
||||
},
|
||||
methods: {
|
||||
// 获取完整的图片URL
|
||||
getFullImageUrl(url) {
|
||||
return request.getImageUrl(url)
|
||||
},
|
||||
|
||||
// 获取商品的第一张图片
|
||||
getFirstImage(images) {
|
||||
if (!images) return ''
|
||||
if (typeof images === 'string') {
|
||||
return images.split(',')[0].trim()
|
||||
}
|
||||
if (Array.isArray(images) && images.length > 0) {
|
||||
return images[0]
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
// 获取商品类型文本
|
||||
getProductTypeText(type) {
|
||||
return type === 1 ? '一级商品' : '二级商品'
|
||||
},
|
||||
|
||||
// 图片加载错误处理
|
||||
onImageError() {
|
||||
console.log('图片加载失败')
|
||||
},
|
||||
|
||||
// 加载仓库数据
|
||||
async loadWarehouse() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await request.get('/back/user/warehouse', {
|
||||
page: 1,
|
||||
page_size: 50
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
this.warehouseList = res.data.list || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载仓库失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 挂售商品
|
||||
sellProduct(item) {
|
||||
if (item.quantity <= 0) {
|
||||
uni.showToast({
|
||||
title: '库存不足,无法挂售',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 设置选中商品并重置表单
|
||||
this.selectedItem = item
|
||||
this.sellQuantity = 1
|
||||
this.sellPrice = item.warehouse_price.toString()
|
||||
this.sellDescription = `${item.product_name} - 来自个人仓库`
|
||||
this.sellCondition = '九成新'
|
||||
this.submitting = false
|
||||
|
||||
// 打开挂售弹窗
|
||||
this.$refs.sellPopup.open()
|
||||
},
|
||||
|
||||
// 关闭挂售弹窗
|
||||
closeSellPopup() {
|
||||
this.$refs.sellPopup.close()
|
||||
this.selectedItem = null
|
||||
},
|
||||
|
||||
// 减少数量
|
||||
decreaseQuantity() {
|
||||
if (this.sellQuantity > 1) {
|
||||
this.sellQuantity--
|
||||
}
|
||||
},
|
||||
|
||||
// 增加数量
|
||||
increaseQuantity() {
|
||||
if (this.sellQuantity < this.selectedItem.quantity) {
|
||||
this.sellQuantity++
|
||||
}
|
||||
},
|
||||
|
||||
// 确认挂售
|
||||
async confirmSell() {
|
||||
if (!this.canSubmit) return
|
||||
|
||||
this.submitting = true
|
||||
try {
|
||||
const sellData = {
|
||||
quantity: this.sellQuantity,
|
||||
price: parseFloat(this.sellPrice),
|
||||
description: this.sellDescription.trim(),
|
||||
condition: this.sellCondition
|
||||
}
|
||||
|
||||
const res = await request.post(`/back/user/warehouse/${this.selectedItem.id}/sell`, sellData)
|
||||
|
||||
if (res.success) {
|
||||
uni.showToast({
|
||||
title: '挂售成功',
|
||||
icon: 'success'
|
||||
})
|
||||
this.closeSellPopup()
|
||||
this.loadWarehouse() // 重新加载仓库数据
|
||||
} else {
|
||||
throw new Error(res.message || '挂售失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('挂售失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '挂售失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.warehouse-list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.warehouse-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.product-card {
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #333;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.default-product {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 15rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-stats {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.stats-text {
|
||||
display: block;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.current-price {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #FF4444;
|
||||
}
|
||||
|
||||
.product-actions {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
width: 100%;
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.sell-btn {
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.disabled-btn {
|
||||
background-color: #f5f5f5;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.sold-btn {
|
||||
background-color: #f0f0f0;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.purchase-price {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 200rpx 0;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.empty-state uni-icons {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 底部提示 */
|
||||
.bottom-tip {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
/* 挂售弹窗样式 */
|
||||
.sell-popup {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding: 0;
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
padding: 10rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
flex: 1;
|
||||
padding: 30rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.product-summary {
|
||||
display: flex;
|
||||
margin-bottom: 40rpx;
|
||||
padding: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.summary-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.summary-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.summary-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.summary-stock,
|
||||
.summary-price {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.sell-form {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 15rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.quantity-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.quantity-btn {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
font-size: 32rpx;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.quantity-btn:disabled {
|
||||
background-color: #f5f5f5;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.quantity-input {
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
text-align: center;
|
||||
border: 1rpx solid #ddd;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
font-size: 28rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.price-input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.price-symbol {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.price-input {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.description-input {
|
||||
width: 100%;
|
||||
min-height: 120rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.5;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.condition-selector {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15rpx;
|
||||
}
|
||||
|
||||
.condition-item {
|
||||
padding: 15rpx 25rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 30rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.condition-item.active {
|
||||
border-color: #FF4444;
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.sell-summary {
|
||||
padding: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 8rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.summary-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
padding: 30rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.cancel-btn,
|
||||
.confirm-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #FF4444;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn:disabled {
|
||||
background-color: #ccc;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user