秦佳浩 2 months ago
commit ab4971dcb0

@ -1,110 +1,138 @@
/* 容器样式 */
.container { .container {
background: #f4f4f4; background: #f4f4f4; /* 设置背景颜色为浅灰色 */
} }
/* 分类标题栏样式 */
.category-tit { .category-tit {
width: 100%; width: 100%; /* 宽度占满整个父元素 */
white-space: nowrap; white-space: nowrap; /* 禁止文本换行,确保所有分类项在一行显示 */
position: fixed; position: fixed; /* 固定定位,使标题栏始终位于页面顶部 */
top: 0px; top: 0px; /* 距离页面顶部0像素 */
z-index: 999; z-index: 999; /* 设置较高的堆叠顺序,确保标题栏在其他内容之上 */
background-color: #fff; background-color: #fff; /* 背景颜色为白色 */
border-bottom: 2rpx solid #f4f4f4; border-bottom: 2rpx solid #f4f4f4; /* 底部边框,使用浅灰色实线 */
font-size: 30rpx; font-size: 30rpx; /* 标题文字大小为30响应式像素 */
.category-item { .category-item {
display: inline-block; display: inline-block; /* 分类项作为行内块级元素显示,确保它们在同一行 */
padding: 20rpx 10rpx; padding: 20rpx 10rpx; /* 内边距为上下20响应式像素左右10响应式像素 */
margin: 0 20rpx; margin: 0 20rpx; /* 左右外边距为20响应式像素 */
box-sizing: border-box; box-sizing: border-box; /* 确保padding和border包含在元素的width和height之内 */
font-size: 28rpx; font-size: 28rpx; /* 分类项文字大小为28响应式像素 */
} }
} }
.prod-item {
height: calc(100vh - 100rpx); /* 当前选中的分类项样式 */
}
.on { .on {
border-bottom: 4rpx solid #e43130; border-bottom: 4rpx solid #e43130; /* 底部边框,使用红色实线,表示当前选中 */
color: #e43130; color: #e43130; /* 文本颜色为红色 */
}
/* 商品项容器样式 */
.prod-item {
height: calc(100vh - 100rpx); /* 高度为视口高度减去100响应式像素确保与固定头部有足够的间距 */
} }
/* 隐藏滚动条样式 */
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0; width: 0; /* 滚动条宽度为0 */
height: 0; height: 0; /* 滚动条高度为0 */
color: transparent; color: transparent; /* 滚动条颜色为透明 */
} }
/* 空状态样式 */
.empty { .empty {
margin-top: 200rpx; margin-top: 200rpx; /* 顶部外边距为200响应式像素确保空状态提示在页面中间 */
} }
/* 商品项样式 */
.prod-items { .prod-items {
width: 345rpx; width: 345rpx; /* 商品项宽度为345响应式像素 */
display: inline-block; display: inline-block; /* 作为行内块级元素显示,确保它们在同一行 */
background: #fff; background: #fff; /* 背景颜色为白色 */
padding-bottom: 20rpx; padding-bottom: 20rpx; /* 底部内边距为20响应式像素 */
box-sizing: border-box; box-sizing: border-box; /* 确保padding和border包含在元素的width和height之内 */
box-shadow: 0rpx 6rpx 8rpx rgba(58,134,185,0.2); box-shadow: 0rpx 6rpx 8rpx rgba(58, 134, 185, 0.2); /* 添加轻微的阴影效果,增强立体感 */
&:nth-child(2n-1) { &:nth-child(2n-1) {
margin: 20rpx 10rpx 10rpx 20rpx; margin: 20rpx 10rpx 10rpx 20rpx; /* 奇数商品项的外边距设置 */
} }
&:nth-child(2n) { &:nth-child(2n) {
margin: 20rpx 20rpx 10rpx 10rpx; margin: 20rpx 20rpx 10rpx 10rpx; /* 偶数商品项的外边距设置 */
} }
.hot-imagecont { .hot-imagecont {
.hotsaleimg { .hotsaleimg {
width: 341rpx; width: 341rpx; /* 图片宽度为341响应式像素 */
height: 341rpx; height: 341rpx; /* 图片高度为341响应式像素 */
} }
font-size: 0;
text-align: center; font-size: 0; /* 移除默认字体大小,防止影响图片显示 */
text-align: center; /* 图片居中对齐 */
} }
.hot-text { .hot-text {
.hotprod-text { .hotprod-text {
font-size: 28rpx; font-size: 28rpx; /* 商品名称文字大小为28响应式像素 */
white-space: nowrap; white-space: nowrap; /* 禁止文本换行 */
overflow: hidden; overflow: hidden; /* 隐藏超出容器的内容 */
text-overflow: ellipsis; text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
} }
margin-top: 20rpx;
padding: 0 10rpx; margin-top: 20rpx; /* 顶部外边距为20响应式像素 */
padding: 0 10rpx; /* 左右内边距为10响应式像素 */
.prod-info { .prod-info {
min-height: 30rpx; min-height: 30rpx; /* 最小高度为30响应式像素 */
font-size: 22rpx; font-size: 22rpx; /* 商品信息文字大小为22响应式像素 */
color: #999; color: #999; /* 文本颜色为灰色 */
white-space: nowrap; white-space: nowrap; /* 禁止文本换行 */
overflow: hidden; overflow: hidden; /* 隐藏超出容器的内容 */
text-overflow: ellipsis; text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
} }
.prod-text-info { .prod-text-info {
position: relative; position: relative; /* 相对定位,用于内部元素的绝对定位 */
height: 70rpx; height: 70rpx; /* 高度为70响应式像素 */
line-height: 70rpx; line-height: 70rpx; /* 行高设置为70响应式像素确保文本垂直居中 */
font-family: Arial; font-family: Arial; /* 字体系列为Arial */
.hotprod-price { .hotprod-price {
display: inline; display: inline; /* 价格文本作为行内元素显示 */
font-size: 26rpx; font-size: 26rpx; /* 价格文字大小为26响应式像素 */
color: #eb2444; color: #eb2444; /* 价格颜色为红色 */
} }
.basket-img { .basket-img {
width: 50rpx; width: 50rpx; /* 购物车图标宽度为50响应式像素 */
height: 50rpx; height: 50rpx; /* 购物车图标高度为50响应式像素 */
position: absolute; position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
right: 0; right: 0; /* 购物车图标距离右侧0像素 */
bottom: 7rpx; bottom: 7rpx; /* 购物车图标距离底部7响应式像素 */
padding: 8rpx; padding: 8rpx; /* 内边距为8响应式像素 */
} }
} }
} }
} }
/* 更多商品样式 */
.more-prod { .more-prod {
.prod-text-right { .prod-text-right {
.prod-info { .prod-info {
font-size: 22rpx; font-size: 22rpx; /* 商品信息文字大小为22响应式像素 */
color: #999; color: #999; /* 文本颜色为灰色 */
white-space: nowrap; white-space: nowrap; /* 禁止文本换行 */
overflow: hidden; overflow: hidden; /* 隐藏超出容器的内容 */
text-overflow: ellipsis; text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
} }
} }
} }
/* 空状态占位样式 */
.empty-wrap { .empty-wrap {
color: #aaa; color: #aaa; /* 文本颜色为浅灰色 */
text-align: center; text-align: center; /* 文本居中对齐 */
padding-top: 400rpx; padding-top: 400rpx; /* 顶部内边距为400响应式像素确保空状态提示在页面中间 */
} }

@ -1,71 +1,65 @@
<template> <template>
<view class="Mall4j container"> <view class="Mall4j container">
<!-- 顶部子分类tab --> <!-- 顶部子分类tab -->
<scroll-view <scroll-view scroll-x="true" <!-- -->
scroll-x="true" class="category-tit" <!-- 应用样式类 category-tit -->
class="category-tit" :scroll-into-view="intoView" <!-- 滚动到指定元素确保选中的分类项可见 -->
:scroll-into-view="intoView" :scroll-with-animation="true" <!-- 滚动时启用动画效果 -->
:scroll-with-animation="true"
> >
<block <block
v-for="(item, index) in subCategoryList" v-for="(item, index) in subCategoryList" <!-- 遍历子分类列表动态生成每个分类项 -->
:key="index" :key="index" <!-- 使用索引作为唯一标识 -->
> >
<view <view
:id="'sw' + item.categoryId" :id="'sw' + item.categoryId" <!-- 动态设置每个分类项的ID -->
:class="'category-item ' + (item.categoryId==categoryId? 'on':'')" :class="'category-item ' + (item.categoryId == categoryId ? 'on' : '')" <!-- 动态绑定类名当前选中的分类项添加 'on' -->
:data-id="item.categoryId" :data-id="item.categoryId" <!-- 传递分类ID -->
@tap="onSubCategoryTap" @tap="onSubCategoryTap" <!-- 点击分类项时触发切换分类的方法 -->
> >
{{ item.categoryName }} {{ item.categoryName }} <!-- 显示分类名称 -->
</view> </view>
</block> </block>
</scroll-view> </scroll-view>
<!-- 商品列表 --> <!-- 商品列表 -->
<view class="prod-item"> <view class="prod-item">
<!-- 商品列表容器 -->
<block v-if="prodList.length"> <block v-if="prodList.length">
<block <!-- 条件渲染只有当商品列表不为空时显示商品项 -->
v-for="(prod, key) in prodList" <block v-for="(prod, key) in prodList" <!-- -->
:key="key" :key="key" <!-- 使用索引作为唯一标识 -->
> >
<view <view
class="prod-items" class="prod-items" <!-- 商品项容器 -->
:data-prodid="prod.prodId" :data-prodid="prod.prodId" <!-- 传递商品ID -->
@tap="toProdPage" @tap="toProdPage" <!-- 点击商品项时跳转到商品详情页 -->
> >
<view class="hot-imagecont"> <view class="hot-imagecont"> <!-- 商品图片容器 -->
<image <image
:src="prod.pic" :src="prod.pic" <!-- 动态绑定商品图片路径 -->
class="hotsaleimg" class="hotsaleimg" <!-- 应用样式类 hotsaleimg -->
/> />
</view> </view>
<view class="hot-text"> <view class="hot-text"> <!-- 商品文本信息容器 -->
<view class="hotprod-text"> <view class="hotprod-text"> <!-- 商品名称 -->
{{ prod.prodName }} {{ prod.prodName }} <!-- 显示商品名称 -->
</view> </view>
<view class="prod-info"> <view class="prod-info"> <!-- 商品简介 -->
{{ prod.brief }} {{ prod.brief }} <!-- 显示商品简介 -->
</view> </view>
<view class="prod-text-info"> <view class="prod-text-info"> <!-- 商品价格信息 -->
<view class="price"> <view class="price"> <!-- 价格容器 -->
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(prod.price)[0] }}</text> <!-- 显示整数部分价格 -->
</text> <text class="small-num">.{{ wxs.parsePrice(prod.price)[1] }}</text> <!-- 显示小数部分价格 -->
<text class="big-num">
{{ wxs.parsePrice(prod.price)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(prod.price)[1] }}
</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</block> </block>
<view <view v-else <!-- -->
v-else class="empty-wrap" <!-- 应用样式类 empty-wrap -->
class="empty-wrap"
> >
暂无商品数据~ 暂无商品数据~
</view> </view>
@ -74,104 +68,147 @@
</template> </template>
<script setup> <script setup>
const wxs = number() import { ref, nextTick } from 'vue'; // Vue ref nextTick
//
const wxs = number(); // `number`
// ID
const parentId = ref('');
// ID
const categoryId = ref(0);
const parentId = ref('')
const categoryId = ref(0)
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad((options) => { onLoad((options) => {
parentId.value = options.parentId //
categoryId.value = options.categoryId parentId.value = options.parentId;
getSubCategory() categoryId.value = options.categoryId;
getProdList()
}) //
getSubCategory();
getProdList();
});
//
const current = ref(1);
//
const pages = ref(0);
const current = ref(1)
const pages = ref(0)
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom(() => { onReachBottom(() => {
//
if (current.value < pages.value) { if (current.value < pages.value) {
current.value = current.value + 1 current.value = current.value + 1;
getProdList() getProdList();
} }
}) });
//
const intoView = ref('');
//
const subCategoryList = ref([]);
const intoView = ref('')
const subCategoryList = ref([])
/** /**
* 获取顶栏子分类数据 * 获取顶栏子分类数据
*/ */
const getSubCategory = () => { const getSubCategory = () => {
//
http.request({ http.request({
url: '/category/categoryInfo', url: '/category/categoryInfo', // API
method: 'GET', method: 'GET', // GET
data: { data: {
parentId: parentId.value parentId: parentId.value // ID
} }
}) })
.then(({ data }) => { .then(({ data }) => {
subCategoryList.value = data // subCategoryList
subCategoryList.value = data;
// 使 nextTick DOM
nextTick(() => { nextTick(() => {
intoView.value = 'sw' + categoryId.value intoView.value = 'sw' + categoryId.value; //
}) });
}) });
} };
//
const prodList = ref([]);
//
const isLoaded = ref(false);
const prodList = ref([])
const isLoaded = ref(false) //
/** /**
* 根据分类id获取商品列表数据 * 根据分类ID获取商品列表数据
*/ */
const getProdList = () => { const getProdList = () => {
isLoaded.value = false isLoaded.value = false; //
//
http.request({ http.request({
url: '/prod/pageProd', url: '/prod/pageProd', // API
method: 'GET', method: 'GET', // GET
data: { data: {
categoryId: categoryId.value, categoryId: categoryId.value, // ID
current: current.value, current: current.value, //
size: 10, size: 10, //
sort: 0, sort: 0, // 0
isAllProdType: true isAllProdType: true //
} }
}) })
.then(({ data }) => { .then(({ data }) => {
isLoaded.value = true isLoaded.value = true; //
prodList.value = data.current == 1 ? data.records : prodList.value.concat(data.records)
current.value = data.current //
pages.value = data.pages prodList.value = data.current == 1 ? data.records : prodList.value.concat(data.records);
})
} //
current.value = data.current;
pages.value = data.pages;
});
};
/** /**
* 切换顶部分类 * 切换顶部分类
* @param e - 事件对象
*/ */
const onSubCategoryTap = (e) => { const onSubCategoryTap = (e) => {
categoryId.value = e.currentTarget.dataset.id // ID
current.value = 1 categoryId.value = e.currentTarget.dataset.id;
pages.value = 0
intoView.value = 'sw' + e.currentTarget.dataset.id //
getProdList() current.value = 1;
} pages.value = 0;
//
intoView.value = 'sw' + e.currentTarget.dataset.id;
//
getProdList();
};
/** /**
* 跳转商品下详情 * 跳转商品详情页
* @param e - 事件对象
*/ */
const toProdPage = (e) => { const toProdPage = (e) => {
const prodid = e.currentTarget.dataset.prodid const prodid = e.currentTarget.dataset.prodid; // ID
// ID
if (prodid) { if (prodid) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/prod/prod?prodid=' + prodid url: `/pages/prod/prod?prodid=${prodid}`
}) });
}
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./sub-category.scss"; @import "./sub-category.scss"; /* 引入外部样式文件 */
</style> </style>

@ -1,429 +1,489 @@
/* 容器样式 */
.container { .container {
background: #f4f4f4; background: #f4f4f4; /* 设置背景颜色为浅灰色 */
} }
/* 提交订单区域样式 */
.submit-order { .submit-order {
margin-bottom: 100rpx; margin-bottom: 100rpx; /* 底部外边距为100响应式像素 */
padding-bottom: 160rpx; padding-bottom: 160rpx; /* 底部内边距为160响应式像素 */
.delivery-addr {
position: relative; .delivery-addr { /* 配送地址样式 */
background: #fff; position: relative; /* 相对定位,用于内部元素的绝对定位 */
.addr-icon { background: #fff; /* 背景颜色为白色 */
width: 32rpx;
height: 32rpx; .addr-icon { /* 地址图标样式 */
display: block; width: 32rpx; /* 图标宽度为32响应式像素 */
position: absolute; height: 32rpx; /* 图标高度为32响应式像素 */
left: 30rpx; display: block; /* 作为块级元素显示 */
top: 24rpx; position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
image { left: 30rpx; /* 距离左侧30响应式像素 */
width: 100%; top: 24rpx; /* 距离顶部24响应式像素 */
height: 100%;
} image { /* 图片样式 */
} width: 100%; /* 宽度占满父元素 */
.user-info { height: 100%; /* 高度占满父元素 */
padding-top: 20rpx; }
line-height: 48rpx; }
word-wrap: break-word;
word-break: break-all; .user-info { /* 用户信息样式 */
overflow: hidden; padding-top: 20rpx; /* 顶部内边距为20响应式像素 */
text-overflow: ellipsis; line-height: 48rpx; /* 行高设置为48响应式像素 */
display: -webkit-box; word-wrap: break-word; /* 允许长单词或URL地址换行到下一行 */
-webkit-line-clamp: 1; word-break: break-all; /* 强制文本在任意字符处换行 */
-webkit-box-orient: vertical; overflow: hidden; /* 隐藏超出容器的内容 */
.item { text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
font-size: 30rpx; display: -webkit-box; /* 使用Webkit盒模型 */
margin-right: 30rpx; -webkit-line-clamp: 1; /* 限制文本显示为1行 */
vertical-align: top; -webkit-box-orient: vertical; /* 文本垂直排列 */
display: inline-block;
} .item { /* 用户信息项样式 */
} font-size: 30rpx; /* 文字大小为30响应式像素 */
.addr { margin-right: 30rpx; /* 右侧外边距为30响应式像素 */
font-size: 26rpx; vertical-align: top; /* 垂直对齐方式为顶部 */
line-height: 36rpx; display: inline-block; /* 作为行内块级元素显示 */
color: #999; }
width: 90%; }
padding-bottom: 20rpx;
margin-top: 15rpx; .addr { /* 地址样式 */
word-wrap: break-word; font-size: 26rpx; /* 文字大小为26响应式像素 */
} line-height: 36rpx; /* 行高设置为36响应式像素 */
.arrow { color: #999; /* 文本颜色为灰色 */
width: 15rpx; width: 90%; /* 宽度为父元素的90% */
height: 15rpx; padding-bottom: 20rpx; /* 底部内边距为20响应式像素 */
border-top: 2rpx solid #777; margin-top: 15rpx; /* 顶部外边距为15响应式像素 */
border-right: 2rpx solid #777; word-wrap: break-word; /* 允许长单词或URL地址换行到下一行 */
transform: rotate(45deg); }
position: absolute;
right: 30rpx; .arrow { /* 箭头样式 */
top: 60rpx; width: 15rpx; /* 宽度为15响应式像素 */
} height: 15rpx; /* 高度为15响应式像素 */
.arrow.empty { border-top: 2rpx solid #777; /* 上边框为2响应式像素宽的灰色实线 */
top: 39rpx; border-right: 2rpx solid #777; /* 右边框为2响应式像素宽的灰色实线 */
} transform: rotate(45deg); /* 旋转45度形成箭头形状 */
} position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
} right: 30rpx; /* 距离右侧30响应式像素 */
.delivery-addr { top: 60rpx; /* 距离顶部60响应式像素 */
.addr-bg { }
.add-addr {
.plus-sign { .arrow.empty { /* 空状态下的箭头样式 */
color: #eb2444; top: 39rpx; /* 距离顶部39响应式像素 */
border: 2rpx solid #eb2444; }
padding: 0rpx 6rpx; }
margin-right: 10rpx; }
}
font-size: 28rpx; .delivery-addr { /* 配送地址样式(重复定义,可能用于覆盖或扩展) */
color: #666; .addr-bg { /* 地址背景样式 */
display: flex; .add-addr { /* 添加地址按钮样式 */
align-items: center; .plus-sign { /* 加号样式 */
padding: 30rpx 0; color: #eb2444; /* 文本颜色为红色 */
} border: 2rpx solid #eb2444; /* 边框为2响应式像素宽的红色实线 */
padding: 0 30rpx; padding: 0rpx 6rpx; /* 内边距为上下0响应式像素左右6响应式像素 */
} margin-right: 10rpx; /* 右侧外边距为10响应式像素 */
.addr-bg.whole { }
padding: 0 39rpx 0 77rpx;
} font-size: 28rpx; /* 文字大小为28响应式像素 */
} color: #666; /* 文本颜色为深灰色 */
.addr-bg { display: flex; /* 使用Flex布局 */
.add-addr { align-items: center; /* 垂直居中对齐 */
.plus-sign-img { padding: 30rpx 0; /* 上下内边距为30响应式像素 */
width: 32rpx; }
height: 32rpx;
font-size: 0; padding: 0 30rpx; /* 左右内边距为30响应式像素 */
margin-right: 10rpx; }
image {
width: 100%; .addr-bg.whole { /* 整个地址背景样式 */
height: 100%; padding: 0 39rpx 0 77rpx; /* 左右内边距分别为39响应式像素和77响应式像素 */
} }
} }
}
} .addr-bg { /* 地址背景样式(重复定义,可能用于覆盖或扩展) */
.prod-item { .add-addr { /* 添加地址按钮样式 */
background-color: #fff; .plus-sign-img { /* 加号图片样式 */
margin-top: 15rpx; width: 32rpx; /* 宽度为32响应式像素 */
font-size: 28rpx; height: 32rpx; /* 高度为32响应式像素 */
.item-cont { font-size: 0; /* 移除默认字体大小,防止影响图片显示 */
.prod-pic { margin-right: 10rpx; /* 右侧外边距为10响应式像素 */
image {
width: 180rpx; image { /* 图片样式 */
height: 180rpx; width: 100%; /* 宽度占满父元素 */
width: 100%; height: 100%; /* 高度占满父元素 */
height: 100%; }
} }
font-size: 0; }
display: block; }
width: 160rpx;
height: 160rpx; .prod-item { /* 商品项样式 */
overflow: hidden; background-color: #fff; /* 背景颜色为白色 */
background: #fff; margin-top: 15rpx; /* 顶部外边距为15响应式像素 */
margin-right: 16rpx; font-size: 28rpx; /* 文字大小为28响应式像素 */
}
display: flex; .item-cont { /* 商品内容样式 */
align-items: center; .prod-pic { /* 商品图片样式 */
padding: 30rpx; image { /* 图片样式 */
border-bottom: 2rpx solid #f1f1f1; width: 180rpx; /* 宽度为180响应式像素 */
.prod-info { height: 180rpx; /* 高度为180响应式像素 */
margin-left: 10rpx; width: 100%; /* 宽度占满父元素 */
font-size: 28rpx; height: 100%; /* 高度占满父元素 */
width: 100%; }
position: relative;
height: 160rpx; font-size: 0; /* 移除默认字体大小,防止影响图片显示 */
-webkit-flex: 1; display: block; /* 作为块级元素显示 */
-ms-flex: 1; width: 160rpx; /* 宽度为160响应式像素 */
-webkit-box-flex: 1; height: 160rpx; /* 高度为160响应式像素 */
-moz-box-flex: 1; overflow: hidden; /* 隐藏超出容器的内容 */
flex: 1; background: #fff; /* 背景颜色为白色 */
.prodname { margin-right: 16rpx; /* 右侧外边距为16响应式像素 */
font-size: 28rpx; }
line-height: 40rpx;
max-height: 86rpx; display: flex; /* 使用Flex布局 */
overflow: hidden; align-items: center; /* 垂直居中对齐 */
display: -webkit-box; padding: 30rpx; /* 内边距为30响应式像素 */
-webkit-line-clamp: 2; border-bottom: 2rpx solid #f1f1f1; /* 底部边框为2响应式像素宽的浅灰色实线 */
-webkit-box-orient: vertical;
text-overflow: ellipsis; .prod-info { /* 商品信息样式 */
word-break: break-all; margin-left: 10rpx; /* 左侧外边距为10响应式像素 */
} font-size: 28rpx; /* 文字大小为28响应式像素 */
.prod-info-cont { width: 100%; /* 宽度占满父元素 */
color: #999; position: relative; /* 相对定位,用于内部元素的绝对定位 */
line-height: 40rpx; height: 160rpx; /* 高度为160响应式像素 */
margin-top: 10rpx; flex: 1; /* 占用剩余空间 */
font-size: 22rpx;
overflow: hidden; .prodname { /* 商品名称样式 */
display: -webkit-box; font-size: 28rpx; /* 文字大小为28响应式像素 */
-webkit-line-clamp: 1; line-height: 40rpx; /* 行高设置为40响应式像素 */
-webkit-box-orient: vertical; max-height: 86rpx; /* 最大高度为86响应式像素 */
text-overflow: ellipsis; overflow: hidden; /* 隐藏超出容器的内容 */
word-break: break-all; display: -webkit-box; /* 使用Webkit盒模型 */
} -webkit-line-clamp: 2; /* 限制文本显示为2行 */
} -webkit-box-orient: vertical; /* 文本垂直排列 */
} text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
.order-num { word-break: break-all; /* 强制文本在任意字符处换行 */
padding: 20rpx 30rpx; }
display: flex;
justify-content: space-between; .prod-info-cont { /* 商品信息内容样式 */
font-size: 28rpx; color: #999; /* 文本颜色为灰色 */
.clear-btn { line-height: 40rpx; /* 行高设置为40响应式像素 */
width: 32rpx; margin-top: 10rpx; /* 顶部外边距为10响应式像素 */
height: 32rpx; font-size: 22rpx; /* 文字大小为22响应式像素 */
font-size: 0; overflow: hidden; /* 隐藏超出容器的内容 */
vertical-align: top; display: -webkit-box; /* 使用Webkit盒模型 */
margin-top: 6rpx; -webkit-line-clamp: 1; /* 限制文本显示为1行 */
margin-left: 42rpx; -webkit-box-orient: vertical; /* 文本垂直排列 */
position: relative; text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
&::after { word-break: break-all; /* 强制文本在任意字符处换行 */
content: " "; }
display: block; }
position: absolute; }
left: -10px;
top: 1px; .order-num { /* 订单数量样式 */
width: 1px; padding: 20rpx 30rpx; /* 内边距为上下20响应式像素左右30响应式像素 */
height: 12px; display: flex; /* 使用Flex布局 */
background: #ddd; justify-content: space-between; /* 水平两端对齐 */
} font-size: 28rpx; /* 文字大小为28响应式像素 */
.clear-list-btn {
width: 100%; .clear-btn { /* 清空按钮样式 */
height: 100%; width: 32rpx; /* 宽度为32响应式像素 */
vertical-align: middle; height: 32rpx; /* 高度为32响应式像素 */
} font-size: 0; /* 移除默认字体大小,防止影响图片显示 */
} vertical-align: top; /* 垂直对齐方式为顶部 */
} margin-top: 6rpx; /* 顶部外边距为6响应式像素 */
.total-num { margin-left: 42rpx; /* 左侧外边距为42响应式像素 */
text-align: right; position: relative; /* 相对定位,用于内部元素的绝对定位 */
padding: 20rpx 30rpx;
font-size: 28rpx; &::after { /* 清空按钮后的竖线样式 */
.prodprice { content: " "; /* 生成伪元素 */
display: inline-block; display: block; /* 作为块级元素显示 */
color: #333; position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
} left: -10px; /* 距离左侧-10像素 */
.prodcount { top: 1px; /* 距离顶部1像素 */
margin-right: 20rpx; width: 1px; /* 宽度为1像素 */
} height: 12px; /* 高度为12像素 */
} background: #ddd; /* 背景颜色为浅灰色 */
.price-nums { }
.prodprice {
position: absolute; .clear-list-btn { /* 清空列表按钮样式 */
bottom: 0; width: 100%; /* 宽度占满父元素 */
} height: 100%; /* 高度占满父元素 */
.prodcount { vertical-align: middle; /* 垂直居中对齐 */
position: absolute; }
bottom: 5rpx; }
right: 0; }
color: #999;
font-family: verdana; .total-num { /* 总数量样式 */
} text-align: right; /* 文本右对齐 */
} padding: 20rpx 30rpx; /* 内边距为上下20响应式像素左右30响应式像素 */
} font-size: 28rpx; /* 文字大小为28响应式像素 */
.order-state {
display: flex; .prodprice { /* 商品价格样式 */
align-items: center; display: inline-block; /* 作为行内块级元素显示 */
} color: #333; /* 文本颜色为深灰色 */
.order-msg { }
background: #fff;
margin-top: 15rpx; .prodcount { /* 商品数量样式 */
padding: 0 30rpx; margin-right: 20rpx; /* 右侧外边距为20响应式像素 */
font-size: 28rpx; }
.msg-item { }
border-top: 2rpx solid #f1f1f1;
&:first-child { .price-nums { /* 价格和数量样式 */
border: 0; .prodprice { /* 商品价格样式 */
} position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
.item { bottom: 0; /* 距离底部0响应式像素 */
position: relative; }
display: flex;
padding: 16rpx 0; .prodcount { /* 商品数量样式 */
align-items: center; position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
.item-tit { bottom: 5rpx; /* 距离底部5响应式像素 */
line-height: 48rpx; right: 0; /* 距离右侧0响应式像素 */
} color: #999; /* 文本颜色为灰色 */
.item-txt { font-family: verdana; /* 字体系列为Verdana */
-webkit-box-flex: 1; }
-moz-box-flex: 1; }
flex: 1; }
font-family: arial;
max-height: 48rpx; .order-state { /* 订单状态样式 */
overflow: hidden; display: flex; /* 使用Flex布局 */
line-height: 48rpx; align-items: center; /* 垂直居中对齐 */
display: -webkit-box; }
-webkit-line-clamp: 1;
-webkit-box-orient: vertical; .order-msg { /* 订单消息样式 */
text-overflow: ellipsis; background: #fff; /* 背景颜色为白色 */
word-break: break-all; margin-top: 15rpx; /* 顶部外边距为15响应式像素 */
} padding: 0 30rpx; /* 左右内边距为30响应式像素 */
.item-txt.price { font-size: 28rpx; /* 文字大小为28响应式像素 */
padding: 0;
text-align: right; .msg-item { /* 消息项样式 */
} border-top: 2rpx solid #f1f1f1; /* 顶部边框为2响应式像素宽的浅灰色实线 */
input {
flex: 1; &:first-child { /* 第一个消息项样式 */
} border: 0; /* 移除边框 */
.coupon-btn { }
display: block;
margin: 0 30rpx; .item { /* 消息项内容样式 */
line-height: 28rpx; position: relative; /* 相对定位,用于内部元素的绝对定位 */
color: #999; display: flex; /* 使用Flex布局 */
} padding: 16rpx 0; /* 上下内边距为16响应式像素 */
.arrow { align-items: center; /* 垂直居中对齐 */
width: 15rpx;
height: 15rpx; .item-tit { /* 消息标题样式 */
border-top: 2rpx solid #999; line-height: 48rpx; /* 行高设置为48响应式像素 */
border-right: 2rpx solid #999; }
transform: rotate(45deg);
position: absolute; .item-txt { /* 消息文本样式 */
right: 0rpx; flex: 1; /* 占用剩余空间 */
} font-family: arial; /* 字体系列为Arial */
} max-height: 48rpx; /* 最大高度为48响应式像素 */
.item.payment { overflow: hidden; /* 隐藏超出容器的内容 */
border-top: 2rpx solid #f1f1f1; line-height: 48rpx; /* 行高设置为48响应式像素 */
color: #eb2444; display: -webkit-box; /* 使用Webkit盒模型 */
} -webkit-line-clamp: 1; /* 限制文本显示为1行 */
.item.coupon { -webkit-box-orient: vertical; /* 文本垂直排列 */
border-bottom: 2rpx solid #e1e1e1; text-overflow: ellipsis; /* 当文本溢出时显示省略号 */
} word-break: break-all; /* 强制文本在任意字符处换行 */
} }
}
.submit-order-footer { .item-txt.price { /* 价格文本样式 */
position: fixed; padding: 0; /* 移除内边距 */
bottom: 0; text-align: right; /* 文本右对齐 */
width: 100%; }
max-width: 750rpx;
background: #fff; input { /* 输入框样式 */
margin: auto; flex: 1; /* 占用剩余空间 */
display: -webkit-flex; }
display: -webkit-box;
display: -moz-box; .coupon-btn { /* 优惠券按钮样式 */
display: -ms-flexbox; display: block; /* 作为块级元素显示 */
display: flex; margin: 0 30rpx; /* 左右外边距为30响应式像素 */
font-size: 26rpx; line-height: 28rpx; /* 行高设置为28响应式像素 */
box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05); color: #999; /* 文本颜色为灰色 */
.sub-order { }
flex: 1;
margin: 0 30rpx; .arrow { /* 箭头样式 */
line-height: 100rpx; width: 15rpx; /* 宽度为15响应式像素 */
display: block; height: 15rpx; /* 高度为15响应式像素 */
text-align: left; border-top: 2rpx solid #999; /* 上边框为2响应式像素宽的灰色实线 */
font-size: 28rpx; border-right: 2rpx solid #999; /* 右边框为2响应式像素宽的灰色实线 */
.item-txt { transform: rotate(45deg); /* 旋转45度形成箭头形状 */
.price { position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
display: inline; right: 0rpx; /* 距离右侧0响应式像素 */
color: #eb2444; }
font-size: 28rpx; }
}
} .item.payment { /* 支付项样式 */
} border-top: 2rpx solid #f1f1f1; /* 顶部边框为2响应式像素宽的浅灰色实线 */
.footer-box { color: #eb2444; /* 文本颜色为红色 */
padding: 0 10rpx; }
width: 200rpx;
background: #eb2444; .item.coupon { /* 优惠券项样式 */
text-align: center; border-bottom: 2rpx solid #e1e1e1; /* 底部边框为2响应式像素宽的浅灰色实线 */
line-height: 100rpx; }
color: #fff; }
} }
}
.clearfix { .submit-order-footer { /* 提交订单页脚样式 */
&:after { position: fixed; /* 固定定位,确保始终位于页面底部 */
content: " "; bottom: 0; /* 距离页面底部0像素 */
display: table; width: 100%; /* 宽度占满整个屏幕 */
clear: both; max-width: 750rpx; /* 最大宽度为750响应式像素 */
} background: #fff; /* 背景颜色为白色 */
} margin: auto; /* 水平居中 */
.popup-hide { display: -webkit-flex; /* 使用Webkit Flex布局 */
position: fixed; display: -webkit-box; /* 使用Webkit盒模型 */
top: 0; display: -moz-box; /* 使用Mozilla盒模型 */
bottom: 0; display: -ms-flexbox; /* 使用IE Flex布局 */
left: 0; display: flex; /* 使用标准Flex布局 */
right: 0; font-size: 26rpx; /* 文字大小为26响应式像素 */
z-index: 999; box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05); /* 添加轻微的阴影效果 */
background-color: rgba(0, 0, 0, 0.3);
} .sub-order { /* 订单提交按钮样式 */
.popup-box { flex: 1; /* 占用剩余空间 */
position: absolute; margin: 0 30rpx; /* 左右外边距为30响应式像素 */
bottom: 0; line-height: 100rpx; /* 行高设置为100响应式像素 */
width: 100%; display: block; /* 作为块级元素显示 */
height: 80%; text-align: left; /* 文本左对齐 */
overflow: hidden; font-size: 28rpx; /* 文字大小为28响应式像素 */
background-color: #fff;
} .item-txt { /* 订单金额样式 */
.popup-tit { .price { /* 价格样式 */
position: relative; display: inline; /* 作为行内元素显示 */
height: 46px; color: #eb2444; /* 文本颜色为红色 */
line-height: 46px; font-size: 28rpx; /* 文字大小为28响应式像素 */
padding-left: 10px; }
font-size: 16px; }
color: #333; }
font-weight: bold;
} .footer-box { /* 页脚按钮样式 */
.close { padding: 0 10rpx; /* 左右内边距为10响应式像素 */
color: #aaa; width: 200rpx; /* 宽度为200响应式像素 */
border-radius: 12px; background: #eb2444; /* 背景颜色为红色 */
line-height: 20px; text-align: center; /* 文本居中对齐 */
text-align: center; line-height: 100rpx; /* 行高设置为100响应式像素 */
height: 20px; color: #fff; /* 文本颜色为白色 */
width: 20px; }
font-size: 18px; }
padding: 1px;
top: 10px; .clearfix { /* 清除浮动样式 */
right: 10px; &:after { /* 生成伪元素清除浮动 */
position: absolute; content: " "; /* 生成空内容 */
&::before { display: table; /* 作为表格元素显示 */
content: "\2716"; clear: both; /* 清除浮动 */
} }
} }
.coupon-tabs {
display: flex; .popup-hide { /* 弹出层隐藏样式 */
font-size: 14px; position: fixed; /* 固定定位,覆盖整个屏幕 */
justify-content: space-around; top: 0; /* 距离页面顶部0像素 */
border-bottom: 1px solid #f2f2f2; bottom: 0; /* 距离页面底部0像素 */
} left: 0; /* 距离页面左侧0像素 */
.coupon-tab { right: 0; /* 距离页面右侧0像素 */
padding: 10px 0; z-index: 999; /* 设置较高的堆叠顺序,确保弹出层在其他内容之上 */
} background-color: rgba(0, 0, 0, 0.3); /* 背景颜色为半透明黑色 */
.coupon-tab.on { }
border-bottom: 2px solid #eb2444;
font-weight: 600; .popup-box { /* 弹出层盒子样式 */
} position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
.popup-cnt { bottom: 0; /* 距离页面底部0像素 */
height: calc(100% - 88px); width: 100%; /* 宽度占满整个屏幕 */
overflow: auto; height: 80%; /* 高度为屏幕高度的80% */
padding: 0 10px; overflow: hidden; /* 隐藏超出容器的内容 */
background: #f4f4f4; background-color: #fff; /* 背景颜色为白色 */
} }
.coupon-ok {
position: fixed; .popup-tit { /* 弹出层标题样式 */
bottom: 0; position: relative; /* 相对定位,用于内部元素的绝对定位 */
width: 100%; height: 46px; /* 高度为46像素 */
height: 60px; line-height: 46px; /* 行高设置为46像素 */
line-height: 50px; padding-left: 10px; /* 左侧内边距为10像素 */
font-size: 14px; font-size: 16px; /* 文字大小为16像素 */
text-align: center; color: #333; /* 文本颜色为深灰色 */
box-shadow: 0px -1px 1px #ddd; font-weight: bold; /* 文本加粗 */
text { }
border-radius: 20px;
display: inline-block; .close { /* 关闭按钮样式 */
height: 20px; color: #aaa; /* 文本颜色为浅灰色 */
line-height: 20px; border-radius: 12px; /* 圆角半径为12像素 */
width: 450rpx; line-height: 20px; /* 行高设置为20像素 */
padding: 7px; text-align: center; /* 文本居中对齐 */
color: #fff; height: 20px; /* 高度为20像素 */
box-shadow: -1px 3px 3px #aaa; width: 20px; /* 宽度为20像素 */
} font-size: 18px; /* 文字大小为18像素 */
} padding: 1px; /* 内边距为1像素 */
.botm-empty { top: 10px; /* 距离顶部10像素 */
height: 60px; right: 10px; /* 距离右侧10像素 */
} position: absolute; /* 绝对定位,相对于最近的相对定位祖先元素 */
checkbox {
.wx-checkbox-input { &::before { /* 生成关闭符号样式 */
border-radius: 50%; content: "\2716"; /* 使用Unicode字符表示关闭符号 */
width: 35rpx; }
height: 35rpx; }
}
.wx-checkbox-input.wx-checkbox-input-checked { .coupon-tabs { /* 优惠券标签样式 */
background: #eb2444; display: flex; /* 使用Flex布局 */
border-color: #eb2444; font-size: 14px; /* 文字大小为14像素 */
&::before { justify-content: space-around; /* 水平均匀分布 */
text-align: center; border-bottom: 1px solid #f2f2f2; /* 底部边框为1像素宽的浅灰色实线 */
font-size: 22rpx; }
color: #fff;
background: transparent; .coupon-tab { /* 优惠券标签项样式 */
transform: translate(-50%, -50%) scale(1); padding: 10px 0; /* 上下内边距为10像素 */
-webkit-transform: translate(-50%, -50%) scale(1); }
.coupon-tab.on { /* 选中的优惠券标签项样式 */
border-bottom: 2px solid #eb2444; /* 底部边框为2像素宽的红色实线 */
font-weight: 600; /* 文本加粗 */
}
.popup-cnt { /* 弹出层内容样式 */
height: calc(100% - 88px); /* 高度为弹出层盒子高度减去88像素 */
overflow: auto; /* 允许滚动 */
padding: 0 10px; /* 左右内边距为10像素 */
background: #f4f4f4; /* 背景颜色为浅灰色 */
}
.coupon-ok { /* 优惠券确认按钮样式 */
position: fixed; /* 固定定位,确保始终位于页面底部 */
bottom: 0; /* 距离页面底部0像素 */
width: 100%; /* 宽度占满整个屏幕 */
height: 60px; /* 高度为60像素 */
line-height: 50px; /* 行高设置为50像素 */
font-size: 14px; /* 文字大小为14像素 */
text-align: center; /* 文本居中对齐 */
box-shadow: 0px -1px 1px #ddd; /* 添加轻微的阴影效果 */
text { /* 按钮文本样式 */
border-radius: 20px; /* 圆角半径为20像素 */
display: inline-block; /* 作为行内块级元素显示 */
height: 20px; /* 高度为20像素 */
line-height: 20px; /* 行高设置为20像素 */
width: 450rpx; /* 宽度为450响应式像素 */
padding: 7px; /* 内边距为7像素 */
color: #fff; /* 文本颜色为白色 */
box-shadow: -1px 3px 3px #aaa; /* 添加轻微的阴影效果 */
}
}
.botm-empty { /* 底部空白样式 */
height: 60px; /* 高度为60像素 */
}
checkbox { /* 复选框样式 */
.wx-checkbox-input { /* 复选框输入框样式 */
border-radius: 50%; /* 圆形边框 */
width: 35rpx; /* 宽度为35响应式像素 */
height: 35rpx; /* 高度为35响应式像素 */
}
.wx-checkbox-input.wx-checkbox-input-checked { /* 选中的复选框输入框样式 */
background: #eb2444; /* 背景颜色为红色 */
border-color: #eb2444; /* 边框颜色为红色 */
&::before { /* 选中符号样式 */
text-align: center; /* 文本居中对齐 */
font-size: 22rpx; /* 文字大小为22响应式像素 */
color: #fff; /* 文本颜色为白色 */
background: transparent; /* 背景颜色为透明 */
transform: translate(-50%, -50%) scale(1); /* 居中并缩放 */
-webkit-transform: translate(-50%, -50%) scale(1); /* Webkit浏览器兼容 */
} }
} }
} }

@ -3,100 +3,82 @@
<view class="container"> <view class="container">
<view class="submit-order"> <view class="submit-order">
<!-- 收货地址 --> <!-- 收货地址 -->
<view <view class="delivery-addr"
class="delivery-addr " @tap="toAddrListPage" <!-- 点击时跳转到收货地址列表页 -->
@tap="toAddrListPage"
> >
<!-- 如果没有选择收货地址 -->
<view <view
v-if="!userAddr" v-if="!userAddr" <!-- 条件渲染只有当 userAddr 为空时显示 -->
class="addr-bg" class="addr-bg"
> >
<view class="add-addr"> <view class="add-addr">
<view class="plus-sign-img"> <view class="plus-sign-img">
<image src="@/static/images/icon/plus-sign.png" /> <image src="@/static/images/icon/plus-sign.png" /> <!-- 加号图标 -->
</view> </view>
<text>新增收货地址</text> <text>新增收货地址</text> <!-- 提示文本 -->
</view> </view>
<view class="arrow empty" /> <view class="arrow empty" /> <!-- 空箭头图标 -->
</view> </view>
<!-- 如果已经选择了收货地址 -->
<view <view
v-if="userAddr" v-if="userAddr" <!-- 条件渲染只有当 userAddr 不为空时显示 -->
class="addr-bg whole" class="addr-bg whole"
> >
<view class="addr-icon"> <view class="addr-icon">
<image src="@/static/images/icon/addr.png" /> <image src="@/static/images/icon/addr.png" /> <!-- 地址图标 -->
</view> </view>
<view class="user-info"> <view class="user-info">
<text class="item"> <text class="item">{{ userAddr.receiver }}</text> <!-- 收货人姓名 -->
{{ userAddr.receiver }} <text class="item">{{ userAddr.mobile }}</text> <!-- 收货人电话 -->
</text>
<text class="item">
{{ userAddr.mobile }}
</text>
</view> </view>
<view class="addr"> <view class="addr">
{{ userAddr.province }}{{ userAddr.city }}{{ userAddr.area }}{{ userAddr.addr }} {{ userAddr.province }}{{ userAddr.city }}{{ userAddr.area }}{{ userAddr.addr }} <!-- 详细地址 -->
</view> </view>
<view class="arrow" /> <view class="arrow" /> <!-- 箭头图标 -->
</view> </view>
</view> </view>
<!-- 商品详情 --> <!-- 商品详情 -->
<view class="prod-item"> <view class="prod-item">
<block <block v-for="(item, index) in orderItems" <!-- -->
v-for="(item, index) in orderItems" :key="index" <!-- 使用索引作为唯一标识 -->
:key="index"
> >
<view <view
class="item-cont" class="item-cont"
:data-ordernum="item.primaryOrderNo" :data-ordernum="item.primaryOrderNo" <!-- 传递订单编号 -->
@tap="toOrderDetailPage" @tap="toOrderDetailPage" <!-- 点击时跳转到订单详情页 -->
> >
<view class="prod-pic"> <view class="prod-pic">
<image :src="item.pic" /> <image :src="item.pic" /> <!-- 动态绑定商品图片路径 -->
</view> </view>
<view class="prod-info"> <view class="prod-info">
<view class="prodname"> <view class="prodname">
{{ item.prodName }} {{ item.prodName }} <!-- 显示商品名称 -->
</view> </view>
<view class="prod-info-cont"> <view class="prod-info-cont">
{{ item.skuName }} {{ item.skuName }} <!-- 显示商品规格信息 -->
</view> </view>
<view class="price-nums"> <view class="price-nums">
<text class="prodprice"> <text class="prodprice">
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(item.price)[0] }}</text> <!-- 显示整数部分价格 -->
</text> <text class="small-num">.{{ wxs.parsePrice(item.price)[1] }}</text> <!-- 显示小数部分价格 -->
<text class="big-num">
{{ wxs.parsePrice(item.price)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(item.price)[1] }}
</text>
</text>
<text class="prodcount">
x{{ item.prodCount }}
</text> </text>
<text class="prodcount">x{{ item.prodCount }}</text> <!-- 显示商品数量 -->
</view> </view>
</view> </view>
</view> </view>
</block> </block>
<!-- 商品总数和合计金额 -->
<view class="total-num"> <view class="total-num">
<text class="prodcount"> <text class="prodcount">{{ totalCount }}件商品</text> <!-- 显示商品总数 -->
{{ totalCount }}件商品
</text>
<view class="prodprice"> <view class="prodprice">
合计 合计
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(total)[0] }}</text> <!-- 显示整数部分合计金额 -->
</text> <text class="small-num">.{{ wxs.parsePrice(total)[1] }}</text> <!-- 显示小数部分合计金额 -->
<text class="big-num">
{{ wxs.parsePrice(total)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(total)[1] }}
</text>
</view> </view>
</view> </view>
</view> </view>
@ -104,96 +86,58 @@
<!-- 订单详情 --> <!-- 订单详情 -->
<view class="order-msg"> <view class="order-msg">
<view class="msg-item"> <view class="msg-item">
<view <!-- 优惠券选择 -->
class="item coupon" <view class="item coupon"
@tap="showCouponPopup" @tap="showCouponPopup" <!-- 点击时显示优惠券弹窗 -->
> >
<text class="item-tit"> <text class="item-tit">优惠券</text>
优惠券 <text v-if="!coupons.canUseCoupons" class="item-txt"></text> <!-- -->
</text> <text class="coupon-btn">{{ coupons.totalLength ? coupons.totalLength : 0 }}</text> <!-- 显示优惠券总数 -->
<text <text class="arrow" /> <!-- 箭头图标 -->
v-if="!coupons.canUseCoupons"
class="item-txt"
>
暂无可用
</text>
<text class="coupon-btn">
{{ coupons.totalLength ? coupons.totalLength : 0 }}
</text>
<text class="arrow" />
</view> </view>
<!-- 买家留言 -->
<view class="item"> <view class="item">
<text>买家留言</text> <text>买家留言</text>
<input <input v-model="remarks" <!-- -->
v-model="remarks" placeholder="给卖家留言" <!-- 占位符提示 -->
placeholder="给卖家留言" />
>
</view> </view>
</view> </view>
</view> </view>
<!-- 订单金额明细 -->
<view class="order-msg"> <view class="order-msg">
<view class="msg-item"> <view class="msg-item">
<view class="item"> <view class="item">
<view class="item-tit"> <view class="item-tit">订单总额</view>
订单总额
</view>
<view class="item-txt price"> <view class="item-txt price">
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(total)[0] }}</text> <!-- 显示整数部分订单总额 -->
</text> <text class="small-num">.{{ wxs.parsePrice(total)[1] }}</text> <!-- 显示小数部分订单总额 -->
<text class="big-num">
{{ wxs.parsePrice(total)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(total)[1] }}
</text>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="item-tit"> <view class="item-tit">运费</view>
运费
</view>
<view class="item-txt price"> <view class="item-txt price">
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(transfee)[0] }}</text> <!-- 显示整数部分运费 -->
</text> <text class="small-num">.{{ wxs.parsePrice(transfee)[1] }}</text> <!-- 显示小数部分运费 -->
<text class="big-num">
{{ wxs.parsePrice(transfee)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(transfee)[1] }}
</text>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="item-tit"> <view class="item-tit">优惠金额</view>
优惠金额
</view>
<view class="item-txt price"> <view class="item-txt price">
<text class="symbol"> <text class="symbol">-</text> <!-- 负号和人民币符号 -->
- <text class="big-num">{{ wxs.parsePrice(shopReduce)[0] }}</text> <!-- 显示整数部分优惠金额 -->
</text> <text class="small-num">.{{ wxs.parsePrice(shopReduce)[1] }}</text> <!-- 显示小数部分优惠金额 -->
<text class="big-num">
{{ wxs.parsePrice(shopReduce)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(shopReduce)[1] }}
</text>
</view> </view>
</view> </view>
<view class="item payment"> <view class="item payment">
<view class="item-txt price"> <view class="item-txt price">
小计 小计
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(actualTotal)[0] }}</text> <!-- 显示整数部分小计金额 -->
</text> <text class="small-num">.{{ wxs.parsePrice(actualTotal)[1] }}</text> <!-- 显示小数部分小计金额 -->
<text class="big-num">
{{ wxs.parsePrice(actualTotal)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(actualTotal)[1] }}
</text>
</view> </view>
</view> </view>
</view> </view>
@ -206,21 +150,14 @@
<view class="item-txt"> <view class="item-txt">
合计 合计
<view class="price"> <view class="price">
<text class="symbol"> <text class="symbol"></text> <!-- 人民币符号 -->
<text class="big-num">{{ wxs.parsePrice(actualTotal)[0] }}</text> <!-- 显示整数部分合计金额 -->
</text> <text class="small-num">.{{ wxs.parsePrice(actualTotal)[1] }}</text> <!-- 显示小数部分合计金额 -->
<text class="big-num">
{{ wxs.parsePrice(actualTotal)[0] }}
</text>
<text class="small-num">
.{{ wxs.parsePrice(actualTotal)[1] }}
</text>
</view> </view>
</view> </view>
</view> </view>
<view <view class="footer-box"
class="footer-box" @tap="toPay" <!-- 点击时提交订单并支付 -->
@tap="toPay"
> >
提交订单 提交订单
</view> </view>
@ -228,69 +165,69 @@
</view> </view>
<!-- 选择优惠券弹窗 --> <!-- 选择优惠券弹窗 -->
<view <view v-if="popupShow" <!-- popupShow true -->
v-if="popupShow"
class="popup-hide" class="popup-hide"
> >
<view class="popup-box"> <view class="popup-box">
<view class="popup-tit"> <view class="popup-tit">
<text>优惠券</text> <text>优惠券</text> <!-- 弹窗标题 -->
<text <text
class="close" class="close"
@tap="closePopup" @tap="closePopup" <!-- 点击时关闭弹窗 -->
/> />
</view> </view>
<!-- 优惠券选项卡 -->
<view class="coupon-tabs"> <view class="coupon-tabs">
<view <view
:class="'coupon-tab ' + (couponSts==1?'on':'')" :class="'coupon-tab ' + (couponSts == 1 ? 'on' : '')" <!-- 动态绑定类名选中时添加 'on' -->
data-sts="1" data-sts="1"
@tap="changeCouponSts" @tap="changeCouponSts" <!-- 点击时切换优惠券状态 -->
> >
可用优惠券({{ coupons.canUseCoupons.length ? coupons.canUseCoupons.length : 0 }}) 可用优惠券({{ coupons.canUseCoupons.length ? coupons.canUseCoupons.length : 0 }}) <!-- 显示可用优惠券数量 -->
</view> </view>
<view <view
:class="'coupon-tab ' + (couponSts==2?'on':'')" :class="'coupon-tab ' + (couponSts == 2 ? 'on' : '')" <!-- 动态绑定类名选中时添加 'on' -->
data-sts="2" data-sts="2"
@tap="changeCouponSts" @tap="changeCouponSts" <!-- 点击时切换优惠券状态 -->
> >
不可用优惠券({{ coupons.unCanUseCoupons.length ? coupons.unCanUseCoupons.length : 0 }}) 不可用优惠券({{ coupons.unCanUseCoupons.length ? coupons.unCanUseCoupons.length : 0 }}) <!-- 显示不可用优惠券数量 -->
</view> </view>
</view> </view>
<!-- 优惠券列表 -->
<view class="popup-cnt"> <view class="popup-cnt">
<block v-if="couponSts == 1"> <block v-if="couponSts == 1"> <!-- couponSts 1 -->
<view <view
v-for="(item, index) in coupons.canUseCoupons" v-for="(item, index) in coupons.canUseCoupons" <!-- 遍历可用优惠券列表动态生成每个优惠券项 -->
:key="index" :key="index" <!-- 使用索引作为唯一标识 -->
> >
<coupon <coupon
:item="item" :item="item" <!-- 传递优惠券数据 -->
order="true" order="true" <!-- 标记为订单页面使用 -->
can-use="true" can-use="true" <!-- 标记为可用优惠券 -->
@check-coupon="checkCoupon" @check-coupon="checkCoupon" <!-- 点击时触发选择优惠券的方法 -->
/> />
</view> </view>
</block> </block>
<block v-if="couponSts == 2"> <block v-if="couponSts == 2"> <!-- couponSts 2 -->
<view <view
v-for="(item, index) in coupons.unCanUseCoupons" v-for="(item, index) in coupons.unCanUseCoupons" <!-- 遍历不可用优惠券列表动态生成每个优惠券项 -->
:key="index" :key="index" <!-- 使用索引作为唯一标识 -->
> >
<coupon <coupon
:item="item" :item="item" <!-- 传递优惠券数据 -->
order="true" order="true" <!-- 标记为订单页面使用 -->
can-use="false" can-use="false" <!-- 标记为不可用优惠券 -->
/> />
</view> </view>
</block> </block>
<view class="botm-empty" /> <view class="botm-empty" /> <!-- 空占位符 -->
</view> </view>
<!-- 确认按钮 -->
<view <view
v-if="couponSts==1" v-if="couponSts == 1" <!-- 条件渲染只有当 couponSts 1 时显示确认按钮 -->
class="coupon-ok" class="coupon-ok"
> >
<text @tap="choosedCoupon"> <text @tap="choosedCoupon"></text> <!-- -->
确定
</text>
</view> </view>
</view> </view>
</view> </view>
@ -298,31 +235,44 @@
</template> </template>
<script setup> <script setup>
// number
const wxs = number() const wxs = number()
let orderEntry = '0' // 0 1
// 0 1
let orderEntry = '0'
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
* @param options - 页面加载时传递的参数
*/ */
onLoad((options) => { onLoad((options) => {
//
orderEntry = options.orderEntry orderEntry = options.orderEntry
}) })
//
const userAddr = ref(null) const userAddr = ref(null)
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow(() => { onShow(() => {
//
const pages = getCurrentPages() const pages = getCurrentPages()
//
const currPage = pages[pages.length - 1] const currPage = pages[pages.length - 1]
// userAddr
if (currPage.selAddress === 'yes') { if (currPage.selAddress === 'yes') {
//
userAddr.value = currPage.item userAddr.value = currPage.item
} }
// //
loadOrderData() loadOrderData()
}) })
// ID
let couponIds = [] let couponIds = []
//
const coupons = ref({}) const coupons = ref({})
const total = ref(0) const total = ref(0)
const actualTotal = ref(0) const actualTotal = ref(0)
@ -330,37 +280,52 @@ const orderItems = ref([])
const totalCount = ref(0) const totalCount = ref(0)
const transfee = ref(0) const transfee = ref(0)
const shopReduce = ref('') const shopReduce = ref('')
/** /**
* 加载订单数据 * 加载订单数据
*/ */
const loadOrderData = () => { const loadOrderData = () => {
let addrId = 0 let addrId = 0
// ID
if (userAddr.value != null) { if (userAddr.value != null) {
addrId = userAddr.value.addrId addrId = userAddr.value.addrId
} }
//
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
//
http.request({ http.request({
url: '/p/order/confirm', url: '/p/order/confirm',
method: 'POST', method: 'POST',
data: { data: {
addrId, addrId,
//
orderItem: orderEntry === '1' ? JSON.parse(uni.getStorageSync('orderItem')) : undefined, orderItem: orderEntry === '1' ? JSON.parse(uni.getStorageSync('orderItem')) : undefined,
basketIds: orderEntry === '0' ? JSON.parse(uni.getStorageSync('basketIds')) : undefined, basketIds: orderEntry === '0' ? JSON.parse(uni.getStorageSync('basketIds')) : undefined,
couponIds, couponIds, // ID
userChangeCoupon: 1 userChangeCoupon: 1 //
} }
}) })
.then(({ data }) => { .then(({ data }) => {
//
uni.hideLoading() uni.hideLoading()
//
let orderItemsData = [] let orderItemsData = []
//
data.shopCartOrders[0].shopCartItemDiscounts?.forEach(itemDiscount => { data.shopCartOrders[0].shopCartItemDiscounts?.forEach(itemDiscount => {
orderItemsData = orderItems.value?.concat(itemDiscount.shopCartItems) orderItemsData = orderItems.value?.concat(itemDiscount.shopCartItems)
}) })
//
if (data.shopCartOrders[0].coupons) { if (data.shopCartOrders[0].coupons) {
const canUseCoupons = [] const canUseCoupons = [] //
const unCanUseCoupons = [] const unCanUseCoupons = [] //
//
data.shopCartOrders[0].coupons?.forEach(coupon => { data.shopCartOrders[0].coupons?.forEach(coupon => {
if (coupon.canUse) { if (coupon.canUse) {
canUseCoupons.push(coupon) canUseCoupons.push(coupon)
@ -368,12 +333,16 @@ const loadOrderData = () => {
unCanUseCoupons.push(coupon) unCanUseCoupons.push(coupon)
} }
}) })
//
coupons.value = { coupons.value = {
totalLength: data.shopCartOrders[0].coupons.length, totalLength: data.shopCartOrders[0].coupons.length, //
canUseCoupons, canUseCoupons, //
unCanUseCoupons unCanUseCoupons //
} }
} }
//
orderItems.value = orderItemsData orderItems.value = orderItemsData
actualTotal.value = data.actualTotal actualTotal.value = data.actualTotal
total.value = data.total total.value = data.total
@ -383,25 +352,31 @@ const loadOrderData = () => {
shopReduce.value = data.shopCartOrders[0].shopReduce shopReduce.value = data.shopCartOrders[0].shopReduce
}) })
.catch(err => { .catch(err => {
//
uni.hideLoading() uni.hideLoading()
//
chooseCouponErrHandle(err) chooseCouponErrHandle(err)
}) })
} }
/** /**
* 优惠券选择出错处理方法 * 优惠券选择出错处理方法
* @param res - 错误响应对象
*/ */
const chooseCouponErrHandle = (res) => { const chooseCouponErrHandle = (res) => {
// //
if (res.statusCode == 601) { if (res.statusCode == 601) {
//
uni.showToast({ uni.showToast({
title: res.data, title: res.data,
icon: 'none', icon: 'none',
duration: 3000, duration: 3000,
success: () => { success: () => {
// ID
couponIds = [] couponIds = []
} }
}) })
//
setTimeout(() => { setTimeout(() => {
loadOrderData() loadOrderData()
}, 2500) }, 2500)
@ -412,6 +387,7 @@ const chooseCouponErrHandle = (res) => {
* 提交订单 * 提交订单
*/ */
const toPay = () => { const toPay = () => {
//
if (!userAddr.value) { if (!userAddr.value) {
uni.showToast({ uni.showToast({
title: '请选择地址', title: '请选择地址',
@ -419,38 +395,52 @@ const toPay = () => {
}) })
return return
} }
//
submitOrder() submitOrder()
} }
//
const remarks = ref('') const remarks = ref('')
/**
* 提交订单
*/
const submitOrder = () => { const submitOrder = () => {
//
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
//
http.request({ http.request({
url: '/p/order/submit', url: '/p/order/submit',
method: 'POST', method: 'POST',
data: { data: {
orderShopParam: [{ orderShopParam: [{
remarks: remarks.value, remarks: remarks.value, //
shopId: 1 shopId: 1 // ID1
}] }]
} }
}) })
.then(({ data }) => { .then(({ data }) => {
//
uni.hideLoading() uni.hideLoading()
//
normalPay(data.orderNumbers) normalPay(data.orderNumbers)
}) })
} }
/** /**
* 模拟支付直接提交成功 * 模拟支付直接提交成功
* @param orderNumbers * @param orderNumbers - 订单编号列表
*/ */
const normalPay = (orderNumbers) => { const normalPay = (orderNumbers) => {
//
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
//
http.request({ http.request({
url: '/p/order/normalPay', url: '/p/order/normalPay',
method: 'POST', method: 'POST',
@ -459,8 +449,10 @@ const normalPay = (orderNumbers) => {
} }
}) })
.then(({ data }) => { .then(({ data }) => {
//
uni.hideLoading() uni.hideLoading()
if (data) { if (data) {
//
uni.showToast({ uni.showToast({
title: '模拟支付成功', title: '模拟支付成功',
icon: 'none' icon: 'none'
@ -471,6 +463,7 @@ const normalPay = (orderNumbers) => {
}) })
}, 1200) }, 1200)
} else { } else {
//
uni.showToast({ uni.showToast({
title: '支付失败!', title: '支付失败!',
icon: 'none' icon: 'none'
@ -479,49 +472,72 @@ const normalPay = (orderNumbers) => {
}) })
} }
// 12
const couponSts = ref(1) const couponSts = ref(1)
/**
* 切换优惠券状态
* @param e - 事件对象
*/
const changeCouponSts = (e) => { const changeCouponSts = (e) => {
//
couponSts.value = e.currentTarget.dataset.sts couponSts.value = e.currentTarget.dataset.sts
} }
//
const popupShow = ref(false) const popupShow = ref(false)
/**
* 显示优惠券弹窗
*/
const showCouponPopup = () => { const showCouponPopup = () => {
popupShow.value = true popupShow.value = true
} }
/**
* 关闭优惠券弹窗
*/
const closePopup = () => { const closePopup = () => {
popupShow.value = false popupShow.value = false
} }
/** /**
* 去地址页面 * 跳转到地址选择页面
*/ */
const toAddrListPage = () => { const toAddrListPage = () => {
//
uni.navigateTo({ uni.navigateTo({
url: '/pages/delivery-address/delivery-address?order=0' url: '/pages/delivery-address/delivery-address?order=0'
}) })
} }
/** /**
* 确定选择好的优惠券 * 确认选择好的优惠券
*/ */
const choosedCoupon = () => { const choosedCoupon = () => {
//
loadOrderData() loadOrderData()
//
popupShow.value = false popupShow.value = false
} }
/** /**
* 优惠券子组件发过来 * 处理优惠券子组件发过来的选择事件
* @param e - 事件对象
*/ */
const checkCoupon = (e) => { const checkCoupon = (e) => {
const index = couponIds.indexOf(e.detail.couponId) // ID
if (index === -1) { const couponId = e.detail.couponId
couponIds.push(e.detail.couponId) // ID
if (couponIds.indexOf(couponId) === -1) {
couponIds.push(couponId)
} else { } else {
couponIds.splice(index, 1) // ID
couponIds.splice(couponIds.indexOf(couponId), 1)
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use './submit-order.scss'; @use './submit-order.scss'; //
</style> </style>

@ -1,222 +1,400 @@
/* 定义容器样式 */
.container { .container {
/* 设置背景颜色 */
background-color: #f7f7f7; background-color: #f7f7f7;
/* 设置底部内边距,以确保内容与底部有适当的空间 */
padding-bottom: 60rpx; padding-bottom: 60rpx;
} }
/* 用户信息模块样式 */
.userinfo { .userinfo {
/* 设置相对定位,以便其子元素可以使用绝对定位 */
position: relative; position: relative;
/* 占满整个宽度 */
width: 100%; width: 100%;
/* 设置白色背景 */
background: #fff; background: #fff;
/* 文本居中显示 */
text-align: center; text-align: center;
/* 上下内边距,左右无内边距 */
padding: 30rpx 0; padding: 30rpx 0;
.userinfo-con { .userinfo-con {
/* 设置固定宽度,使用户信息框在页面中心对齐 */
width: 240rpx; width: 240rpx;
/* 水平居中 */
margin: auto; margin: auto;
.userinfo-avatar { .userinfo-avatar {
/* 确保超出部分不显示 */
overflow: hidden; overflow: hidden;
/* 块级显示 */
display: block; display: block;
/* 设置头像的尺寸 */
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
/* 圆形头像 */
border-radius: 50%; border-radius: 50%;
/* 添加阴影效果 */
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2); box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
/* 水平居中 */
margin: auto; margin: auto;
image { image {
/* 设置图像的尺寸 */
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
} }
} }
.userinfo-name { .userinfo-name {
/* 设置字体大小 */
font-size: 30rpx; font-size: 30rpx;
/* 加粗字体 */
font-weight: bold; font-weight: bold;
/* 与头像保持一定间距 */
margin-top: 20rpx; margin-top: 20rpx;
/* 处理文本溢出 */
overflow: hidden; overflow: hidden;
/* 使用 WebKit 独有的多行文本截断 */
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 1; -webkit-line-clamp: 1;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
/* 当文本溢出时用省略号表示 */
text-overflow: ellipsis; text-overflow: ellipsis;
/* 允许单词内部断行 */
word-break: break-all; word-break: break-all;
} }
} }
} }
/* 未登录用户的提示信息样式 */
.userinfo-none { .userinfo-none {
/* 使用 Flexbox 布局,使子元素垂直和水平居中 */
display: flex; display: flex;
/* 内边距 */
padding: 30rpx; padding: 30rpx;
/* 白色背景 */
background: #fff; background: #fff;
/* 子元素垂直居中 */
align-items: center; align-items: center;
.default-pic { .default-pic {
/* 右侧内边距 */
padding-right: 30rpx; padding-right: 30rpx;
image { image {
/* 设置图像的尺寸 */
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
} }
} }
} }
/* 未登录状态下的按钮和文本样式 */
.none-login { .none-login {
button { button {
/* 按钮背景色为白色 */
background: #fff; background: #fff;
&::after { &::after {
/* 移除默认的按钮边框 */
border: 0; border: 0;
} }
} }
.unlogin { .unlogin {
/* 设置字体大小 */
font-size: 30rpx; font-size: 30rpx;
/* 文本左对齐 */
text-align: left; text-align: left;
/* 移除上下内边距 */
padding: 0; padding: 0;
} }
.click-login { .click-login {
/* 设置较小的字体大小 */
font-size: 26rpx; font-size: 26rpx;
/* 颜色较深 */
color: #777; color: #777;
/* 文本左对齐 */
text-align: left; text-align: left;
/* 移除上下内边距 */
padding: 0; padding: 0;
} }
} }
/* 绑定手机号的样式 */
.binding-phone { .binding-phone {
/* 相对定位 */
position: relative; position: relative;
/* 白色背景 */
background: #fff; background: #fff;
/* 固定高度 */
height: 80rpx; height: 80rpx;
/* 行高与高度相同,使文本垂直居中 */
line-height: 80rpx; line-height: 80rpx;
/* 内边距 */
padding: 0 30rpx; padding: 0 30rpx;
/* 上下边框 */
border-top: 2rpx solid #f7f7f7; border-top: 2rpx solid #f7f7f7;
border-bottom: 2rpx solid #f7f7f7; border-bottom: 2rpx solid #f7f7f7;
.show-tip { .show-tip {
/* 设置字体大小 */
font-size: 26rpx; font-size: 26rpx;
} }
.gotobinding { .gotobinding {
/* 设置圆角 */
border-radius: 8rpx; border-radius: 8rpx;
/* 字体大小 */
font-size: 28rpx; font-size: 28rpx;
color: #e24b4b; /* 颜色为红色 */
color: #e24b42;
/* 加粗字体 */
font-weight: bold; font-weight: bold;
} }
} }
/* 列表内容样式 */
.list-cont { .list-cont {
/* 占满整个宽度 */
width: 100%; width: 100%;
/* 背景颜色 */
background: #f7f7f7; background: #f7f7f7;
/* 顶部外边距 */
margin-top: 20rpx; margin-top: 20rpx;
.total-order { .total-order {
/* 白色背景 */
background: #fff; background: #fff;
.order-tit { .order-tit {
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 两端对齐 */
justify-content: space-between; justify-content: space-between;
/* 固定高度 */
height: 80rpx; height: 80rpx;
/* 行高与高度相同,使文本垂直居中 */
line-height: 80rpx; line-height: 80rpx;
/* 字体大小 */
font-size: 30rpx; font-size: 30rpx;
/* 下边框 */
border-bottom: 1px solid #f7f7f7; border-bottom: 1px solid #f7f7f7;
/* 内边距 */
padding: 0 30rpx; padding: 0 30rpx;
.checkmore { .checkmore {
/* 较小的字体大小 */
font-size: 22rpx; font-size: 22rpx;
/* 颜色较暗 */
color: #80848f; color: #80848f;
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 垂直居中 */
align-items: center; align-items: center;
} }
} }
.procedure { .procedure {
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 项目均匀分布 */
justify-content: space-around; justify-content: space-around;
/* 项目垂直居中 */
align-items: center; align-items: center;
/* 字体大小 */
font-size: 25rpx; font-size: 25rpx;
/* 固定高度 */
height: 160rpx; height: 160rpx;
.items { .items {
/* 相对定位 */
position: relative; position: relative;
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 项目垂直排列 */
flex-direction: column; flex-direction: column;
/* 项目水平居中 */
align-items: center; align-items: center;
image { image {
/* 设置图像的尺寸 */
width: 70rpx; width: 70rpx;
height: 70rpx; height: 70rpx;
/* 与下方文字保持间距 */
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.num-badge { .num-badge {
/* 绝对定位 */
position: absolute; position: absolute;
/* 设置徽章位置 */
top: -15rpx; top: -15rpx;
right: -12rpx; right: -12rpx;
/* 颜色为红色 */
color: #eb2444; color: #eb2444;
/* 边框颜色为红色 */
border: 3rpx solid #eb2444; border: 3rpx solid #eb2444;
/* 圆形 */
border-radius: 50rpx; border-radius: 50rpx;
/* 白色背景 */
background: #fff; background: #fff;
/* 最小宽度 */
min-width: 30rpx; min-width: 30rpx;
/* 固定高度 */
height: 30rpx; height: 30rpx;
/* 行高与高度相同,使文本垂直居中 */
line-height: 30rpx; line-height: 30rpx;
/* 文本水平居中 */
text-align: center; text-align: center;
/* 内边距 */
padding: 2rpx; padding: 2rpx;
/* 块级显示 */
display: block; display: block;
} }
} }
} }
} }
.my-menu { .my-menu {
/* 白色背景 */
background-color: #fff; background-color: #fff;
/* 顶部外边距 */
margin-top: 20rpx; margin-top: 20rpx;
.memu-item { .memu-item {
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 项目垂直居中 */
align-items: center; align-items: center;
/* 项目两端对齐 */
justify-content: space-between; justify-content: space-between;
/* 固定高度 */
height: 100rpx; height: 100rpx;
/* 下边框 */
border-bottom: 2rpx solid #f7f7f7; border-bottom: 2rpx solid #f7f7f7;
/* 内边距 */
padding: 0 30rpx; padding: 0 30rpx;
&:nth-child(1) { &:nth-child(1) {
/* 第一个项目的上边框 */
border-top: 2rpx solid #f7f7f7; border-top: 2rpx solid #f7f7f7;
} }
&:last-child { &:last-child {
/* 最后一个项目的下边框移除 */
border-bottom: none; border-bottom: none;
} }
text { text {
/* 字体大小 */
font-size: 28rpx; font-size: 28rpx;
} }
image { image {
/* 设置图像的尺寸 */
width: 50rpx; width: 50rpx;
height: 50rpx; height: 50rpx;
/* 与右侧文本保持间距 */
margin-right: 20rpx; margin-right: 20rpx;
} }
.i-name { .i-name {
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 项目垂直居中 */
align-items: center; align-items: center;
} }
} }
} }
} }
/* 箭头样式 */
.arrowhead { .arrowhead {
/* 设置箭头的尺寸 */
width: 15rpx; width: 15rpx;
height: 15rpx; height: 15rpx;
/* 上边框 */
border-top: 2rpx solid #999; border-top: 2rpx solid #999;
/* 右边框 */
border-right: 2rpx solid #999; border-right: 2rpx solid #999;
/* 旋转45度形成箭头形状 */
transform: rotate(45deg); transform: rotate(45deg);
/* 左侧外边距 */
margin-left: 10rpx; margin-left: 10rpx;
} }
/* 产品栏样式 */
.prod-col { .prod-col {
/* 顶部外边距 */
margin-top: 20rpx; margin-top: 20rpx;
/* 白色背景 */
background: #fff; background: #fff;
/* 使用 Flexbox 布局 */
display: flex; display: flex;
/* 项目均匀分布 */
justify-content: space-around; justify-content: space-around;
/* 内边距 */
padding: 30rpx 0 10rpx 0; padding: 30rpx 0 10rpx 0;
/* 字体大小 */
font-size: 12px; font-size: 12px;
.col-item { .col-item {
/* 文本居中 */
text-align: center; text-align: center;
.num { .num {
/* 字体较大且加粗 */
font-size: 16px; font-size: 16px;
font-weight: 700; font-weight: 700;
/* 颜色为蓝色 */
color: #3a86b9; color: #3a86b9;
} }
.tit { .tit {
/* 行高 */
line-height: 34px; line-height: 34px;
} }
} }
} }
/* 登出按钮样式 */
.log-out { .log-out {
/* 内边距 */
padding: 20rpx; padding: 20rpx;
/* 文本居中 */
text-align: center; text-align: center;
/* 顶部外边距 */
margin-top: 20rpx; margin-top: 20rpx;
} }
.log-out-n { .log-out-n {
/* 字体大小 */
font-size: 30rpx; font-size: 30rpx;
/* 水平居中 */
margin: auto; margin: auto;
/* 固定宽度 */
width: 200rpx; width: 200rpx;
/* 内边距 */
padding: 20rpx; padding: 20rpx;
/* 圆角 */
border-radius: 10rpx; border-radius: 10rpx;
/* 红色背景 */
background: #e43130; background: #e43130;
/* 白色文字 */
color: #ffffff; color: #ffffff;
} }
/* 自定义菜单按钮样式 */
button.memu-btn.memu-item { button.memu-btn.memu-item {
/* 白色背景 */
background-color: #fff; background-color: #fff;
&:after { &:after {
/* 移除默认的按钮边框 */
border: 0; border: 0;
} }
} }

@ -1,221 +1,131 @@
<template> <template>
<view class="container"> <view class="container">
<!-- 用户信息 --> <!-- 用户信息模块 -->
<view <!-- 如果用户已授权并登录则显示用户信息 -->
v-if="isAuthInfo" <view v-if="isAuthInfo" class="userinfo">
class="userinfo"
>
<view class="userinfo-con"> <view class="userinfo-con">
<!-- 用户头像 -->
<view class="userinfo-avatar"> <view class="userinfo-avatar">
<image <image
:src=" :src="
loginResult.pic loginResult.pic
? ? (loginResult.pic.indexOf('http') === -1 ? picDomain + loginResult.pic : loginResult.pic)
(loginResult.pic.indexOf('http') === -1 ? picDomain + loginResult.pic : loginResult.pic) : '/static/images/icon/head04.png'
:
'/static/images/icon/head04.png'
" "
/> />
</view> </view>
<!-- 用户昵称 -->
<view class="userinfo-name"> <view class="userinfo-name">
<view>{{ loginResult.nickName ? loginResult.nickName : "用户昵称" }}</view> <view>{{ loginResult.nickName ? loginResult.nickName : "用户昵称" }}</view>
</view> </view>
</view> </view>
</view> </view>
<view <!-- 如果用户未登录则显示默认的登录提示 -->
v-if="!isAuthInfo" <view v-if="!isAuthInfo" class="userinfo-none">
class="userinfo-none" <view class="default-pic" @tap="toLogin">
>
<view
class="default-pic"
@tap="toLogin"
>
<image src="@/static/images/icon/head04.png" /> <image src="@/static/images/icon/head04.png" />
</view> </view>
<view <view class="none-login" @tap="toLogin">
class="none-login" <button class="unlogin">未登录</button>
@tap="toLogin" <button class="click-login">点击登录账号</button>
>
<button class="unlogin">
未登录
</button>
<button class="click-login">
点击登录账号
</button>
</view> </view>
</view> </view>
<!-- end 用户信息 --> <!-- end 用户信息模块 -->
<view class="list-cont"> <view class="list-cont">
<!-- 订单状态 --> <!-- 订单状态模块 -->
<view class="total-order"> <view class="total-order">
<view class="order-tit"> <view class="order-tit">
<text style="font-weight:bold"> <text style="font-weight:bold">我的订单</text>
我的订单 <!-- 查看全部订单按钮 -->
</text> <view class="checkmore" data-sts="0" @tap="toOrderListPage">
<view
class="checkmore"
data-sts="0"
@tap="toOrderListPage"
>
<text>查看全部</text> <text>查看全部</text>
<text class="arrowhead" /> <text class="arrowhead" />
</view> </view>
</view> </view>
<!-- 订单流程条 -->
<view class="procedure"> <view class="procedure">
<view <!-- 待支付订单 -->
class="items" <view class="items" data-sts="1" @tap="toOrderListPage">
data-sts="1"
@tap="toOrderListPage"
>
<image src="@/static/images/icon/toPay.png" /> <image src="@/static/images/icon/toPay.png" />
<text>待支付</text> <text>待支付</text>
<text <!-- 如果有待支付订单显示数量 -->
v-if="orderAmount.unPay>0" <text v-if="orderAmount.unPay > 0" class="num-badge">{{ orderAmount.unPay }}</text>
class="num-badge" </view>
> <!-- 待发货订单 -->
{{ orderAmount.unPay }} <view class="items" data-sts="2" @tap="toOrderListPage">
</text>
</view>
<view
class="items"
data-sts="2"
@tap="toOrderListPage"
>
<image src="@/static/images/icon/toDelivery.png" /> <image src="@/static/images/icon/toDelivery.png" />
<text>待发货</text> <text>待发货</text>
<text <!-- 如果有待发货订单显示数量 -->
v-if="orderAmount.payed>0" <text v-if="orderAmount.payed > 0" class="num-badge">{{ orderAmount.payed }}</text>
class="num-badge" </view>
> <!-- 待收货订单 -->
{{ orderAmount.payed }} <view class="items" data-sts="3" @tap="toOrderListPage">
</text>
</view>
<view
class="items"
data-sts="3"
@tap="toOrderListPage"
>
<image src="@/static/images/icon/toTake.png" /> <image src="@/static/images/icon/toTake.png" />
<text>待收货</text> <text>待收货</text>
<text <!-- 如果有待收货订单显示数量 -->
v-if="orderAmount.consignment>0" <text v-if="orderAmount.consignment > 0" class="num-badge">{{ orderAmount.consignment }}</text>
class="num-badge" </view>
> <!-- 已完成订单 -->
{{ orderAmount.consignment }} <view class="items" data-sts="5" @tap="toOrderListPage">
</text>
</view>
<view
class="items"
data-sts="5"
@tap="toOrderListPage"
>
<image src="@/static/images/icon/toComment.png" /> <image src="@/static/images/icon/toComment.png" />
<text>已完成</text> <text>已完成</text>
</view> </view>
</view> </view>
</view> </view>
<!--end 订单状态 --> <!-- end 订单状态模块 -->
<!-- 产品栏 -->
<view class="prod-col"> <view class="prod-col">
<view <!-- 我的收藏 -->
class="col-item" <view class="col-item" @tap="myCollectionHandle">
@tap="myCollectionHandle" <view v-if="loginResult" class="num">{{ collectionCount }}</view>
> <view v-else class="num">--</view>
<view <view class="tit">我的收藏</view>
v-if="loginResult"
class="num"
>
{{ collectionCount }}
</view>
<view
v-else
class="num"
>
--
</view>
<view class="tit">
我的收藏
</view>
</view>
<view
class="col-item"
@tap="handleTips"
>
<view
v-if="loginResult"
class="num"
>
5
</view>
<view
v-else
class="num"
>
--
</view>
<view class="tit">
我的消息
</view>
</view>
<view
class="col-item"
@tap="handleTips"
>
<view
v-if="loginResult"
class="num"
>
3
</view>
<view
v-else
class="num"
>
--
</view>
<view class="tit">
我的足迹
</view> </view>
<!-- 我的消息 -->
<view class="col-item" @tap="handleTips">
<view v-if="loginResult" class="num">5</view>
<view v-else class="num">--</view>
<view class="tit">我的消息</view>
</view>
<!-- 我的足迹 -->
<view class="col-item" @tap="handleTips">
<view v-if="loginResult" class="num">3</view>
<view v-else class="num">--</view>
<view class="tit">我的足迹</view>
</view> </view>
</view> </view>
<!-- 菜单列表 -->
<view class="my-menu"> <view class="my-menu">
<view <!-- 分销中心 -->
class="memu-item" <view class="memu-item" @tap="toDistCenter">
@tap="toDistCenter"
>
<view class="i-name"> <view class="i-name">
<image src="@/static/images/icon/promotion.png" /> <image src="@/static/images/icon/promotion.png" />
<text>分销中心</text> <text>分销中心</text>
</view> </view>
<view class="arrowhead" /> <view class="arrowhead" />
</view> </view>
<view <!-- 领券中心 -->
class="memu-item" <view class="memu-item" @tap="toCouponCenter">
@tap="toCouponCenter"
>
<view class="i-name"> <view class="i-name">
<image src="@/static/images/icon/getCoupon.png" /> <image src="@/static/images/icon/getCoupon.png" />
<text>领券中心</text> <text>领券中心</text>
</view> </view>
<view class="arrowhead" /> <view class="arrowhead" />
</view> </view>
<view <!-- 我的优惠券 -->
class="memu-item" <view class="memu-item" @tap="toMyCouponPage">
@tap="toMyCouponPage"
>
<view class="i-name"> <view class="i-name">
<image src="@/static/images/icon/myCoupon.png" /> <image src="@/static/images/icon/myCoupon.png" />
<text>我的优惠券</text> <text>我的优惠券</text>
</view> </view>
<view class="arrowhead" /> <view class="arrowhead" />
</view> </view>
<view <!-- 收货地址 -->
class="memu-item" <view class="memu-item" @tap="toAddressList">
@tap="toAddressList"
>
<view class="i-name"> <view class="i-name">
<image src="@/static/images/icon/myAddr.png" /> <image src="@/static/images/icon/myAddr.png" />
<text>收货地址</text> <text>收货地址</text>
@ -223,13 +133,10 @@
<view class="arrowhead" /> <view class="arrowhead" />
</view> </view>
</view> </view>
<!--end 列表 --> <!-- end 菜单列表 -->
<view <!-- 登出按钮仅在用户已登录时显示 -->
v-if="isAuthInfo" <view v-if="isAuthInfo" class="log-out" @tap="logout">
class="log-out"
@tap="logout"
>
<view class="log-out-n"> <view class="log-out-n">
<text>退出登录</text> <text>退出登录</text>
</view> </view>
@ -239,84 +146,100 @@
</template> </template>
<script setup> <script setup>
// URL
const picDomain = import.meta.env.VITE_APP_RESOURCES_URL const picDomain = import.meta.env.VITE_APP_RESOURCES_URL
const isAuthInfo = ref(false) //
const loginResult = ref('') const isAuthInfo = ref(false) //
const orderAmount = ref('') const loginResult = ref('') //
const orderAmount = ref('') //
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow(() => { onShow(() => {
//
loginResult.value = uni.getStorageSync('loginResult') loginResult.value = uni.getStorageSync('loginResult')
isAuthInfo.value = !!loginResult.value isAuthInfo.value = !!loginResult.value
// //
if (isAuthInfo.value) { if (isAuthInfo.value) {
uni.showLoading() uni.showLoading() //
http.request({ http.request({
url: '/p/myOrder/orderCount', url: '/p/myOrder/orderCount',
method: 'GET', method: 'GET',
data: {} data: {}
}) })
.then(({ data }) => { .then(({ data }) => {
uni.hideLoading() uni.hideLoading() //
orderAmount.value = data orderAmount.value = data //
}) })
showCollectionCount() showCollectionCount() //
} }
}) })
//
const toDistCenter = () => { const toDistCenter = () => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '该功能未开源' title: '该功能未开源'
}) })
} }
//
const toCouponCenter = () => { const toCouponCenter = () => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '该功能未开源' title: '该功能未开源'
}) })
} }
//
const toMyCouponPage = () => { const toMyCouponPage = () => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '该功能未开源' title: '该功能未开源'
}) })
} }
//
const handleTips = () => { const handleTips = () => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '该功能未开源' title: '该功能未开源'
}) })
} }
//
const toAddressList = () => { const toAddressList = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/delivery-address/delivery-address' url: '/pages/delivery-address/delivery-address'
}) })
} }
//
const toOrderListPage = (e) => { const toOrderListPage = (e) => {
const sts = e.currentTarget.dataset.sts const sts = e.currentTarget.dataset.sts //
uni.navigateTo({ uni.navigateTo({
url: '/pages/orderList/orderList?sts=' + sts url: '/pages/orderList/orderList?sts=' + sts //
}) })
} }
//
const collectionCount = ref(0) const collectionCount = ref(0)
/** /**
* 查询所有的收藏量 * 查询所有的收藏量
*/ */
const showCollectionCount = () => { const showCollectionCount = () => {
uni.showLoading() uni.showLoading() //
http.request({ http.request({
url: '/p/user/collection/count', url: '/p/user/collection/count',
method: 'GET', method: 'GET',
data: {} data: {}
}) })
.then(({ data }) => { .then(({ data }) => {
uni.hideLoading() uni.hideLoading() //
collectionCount.value = data collectionCount.value = data //
}) })
} }
@ -324,14 +247,14 @@ const showCollectionCount = () => {
* 我的收藏跳转 * 我的收藏跳转
*/ */
const myCollectionHandle = () => { const myCollectionHandle = () => {
let url = '/pages/prod-classify/prod-classify?sts=5' let url = '/pages/prod-classify/prod-classify?sts=5' //
const id = 0 const id = 0 // ID
const title = '我的收藏商品' const title = '我的收藏商品' //
if (id) { if (id) {
url += '&tagid=' + id + '&title=' + title url += '&tagid=' + id + '&title=' + title // ID
} }
uni.navigateTo({ uni.navigateTo({
url url //
}) })
} }
@ -340,7 +263,7 @@ const myCollectionHandle = () => {
*/ */
const toLogin = () => { const toLogin = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/accountLogin/accountLogin' url: '/pages/accountLogin/accountLogin' //
}) })
} }
@ -353,23 +276,23 @@ const logout = () => {
method: 'post' method: 'post'
}) })
.then(() => { .then(() => {
util.removeTabBadge() util.removeTabBadge() //
uni.removeStorageSync('loginResult') uni.removeStorageSync('loginResult') //
uni.removeStorageSync('token') uni.removeStorageSync('token') // token
uni.showToast({ uni.showToast({
title: '退出成功', title: '退出成功',
icon: 'none' icon: 'none'
}) })
orderAmount.value = '' orderAmount.value = '' //
setTimeout(() => { setTimeout(() => {
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/index/index' //
}) })
}, 1000) }, 1000) // 1
}) })
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use './user.scss'; @use './user.scss'; //
</style> </style>

Loading…
Cancel
Save