提交 9745141f authored 作者: 刘旭's avatar 刘旭

优化商品属性

上级 3612a4e5
......@@ -49,7 +49,10 @@ export const collectAddordelete = (data: any) => request('/wx/collect/addordelet
export const getTax = () => request('/wx/config/tax', 'GET');
// 推送订单
export const pushOrder = (data: any) => request('/wx/order/push', 'GET', data)
export const pushOrder = (data: any) => request('/wx/order/push', 'GET', data);
// 获取商品配件
export const goodsParts = (data: any) => request('/wx/goods/parts', 'GET', data)
export const goodsParts = (data: any) => request('/wx/goods/parts', 'GET', data);
// 查询商品参数属性 ?productId=1
export const orderAttribute = (data: any) => request('/wx/cart/attribute', 'GET', data);
......@@ -20,3 +20,6 @@ export const resetAvatar = (data: any) => request('/wx/auth/reset_avatar', 'POST
// 客户-收货人
export const consigneeList = (data?: any) => request('/wx/address/consignee', 'GET', data);
// 查询每个状态订单数
export const orderCount = () => request('/wx/user/index', 'GET');
......@@ -42,9 +42,10 @@ let selectedGoodsSum = ref(1)
let emits = defineEmits(['selected', 'addProduct', 'close-sku','partsClose'])
watch([selectedGoodsItem, selectedGoodsSum],(newVal)=> {
// console.log(newVal);
emits('selected', newVal)
},{immediate:true})
if(newVal) {
if(newVal[0] !== undefined) emits('selected', newVal)
}
})
let onChange = (e: any) => {
selectedGoodsItem.value = e.sku_name_arr
......
......@@ -3,7 +3,7 @@
<!-- 轮播图 -->
<view class="wrap">
<u-swiper
:list="detailData?.info.gallery"
:list="detailData?.info.gallery ? detailData?.info.gallery : []"
img-mode="scaleToFill"
height="800"
></u-swiper>
......@@ -102,23 +102,23 @@
<u-popup v-model="attrPopup" mode="bottom" height="50%" closeable>
<view class="attr-content">
<view class="title">商品属性</view>
<view v-if="detailData?.attribute.length !== 0">
<view
v-for="(item, index) in detailData?.attribute"
:key="item.id"
class="details"
>
<text class="left">{{ item.attribute }}</text>
<text class="right">{{ item.value }}</text>
<u-line v-show="detailData?.attribute.length - 1 !== index" />
</view>
<view v-if="attributeData.length !== 0">
<u-row v-for="(item, index) in attributeData" :key="item.id">
<u-col :span="4">
<view class="left">{{ item.attribute }}</view>
</u-col>
<u-col :span="8">
<view class="right">{{ item.value }}</view>
</u-col>
<u-line v-show="attributeData.length - 1 !== index" />
</u-row>
</view>
<view v-else><u-empty text="暂无属性" mode="data" /></view>
</view>
</u-popup>
</view>
<goodsSku ref="goodsSkuRef" @selected="selected" @partsClose='partsClose'></goodsSku>
<goodsSku ref="goodsSkuRef" @selected="selected" @partsClose="partsClose"></goodsSku>
</template>
<script lang="ts" setup>
......@@ -127,7 +127,8 @@ import { onLoad } from '@dcloudio/uni-app';
import {
indexDetails,
collectAddordelete,
goodsParts
goodsParts,
orderAttribute
} from '@/api/index';
import goodsSku from './goodsSku'
......@@ -137,6 +138,7 @@ const detailData: any = ref();
const partsData = ref();
const tabButtons = ref(['商品详情']);
let current = ref(0);
let attributeData = ref([] as any)
const goodsInfo = ref({
id: 1,
......@@ -185,6 +187,21 @@ let selectedGoods = computed(() => {
const selected = (data: any) => {
selectedGoodsItem.value = data[0]
selectedGoodsSum.value = data[1]
let productId;
detailData.value?.productList.forEach((item: any) => {
// 判断是否相等
if(item.specifications.length === data[0].length) {
let bool = true
item.specifications.forEach((res: any) => {
if(data[0].indexOf(res) == -1) bool = false
})
if(bool) productId = item.id
bool = true
}
})
if(productId) initAttribute(productId)
else attributeData.value = null
}
// 点击分组
......@@ -242,6 +259,15 @@ const onClickItem = (e: any) => {
}
};
const initAttribute = (productId: number) => {
orderAttribute({ productId }).then((res: any) => {
if(res.data.code === 200) {
attributeData.value = res.data.data
console.log('Attribute', res);
}
})
}
// 初始化商品详情数据
const initDetails = (id: number) => {
indexDetails({
......@@ -517,7 +543,7 @@ const initParts = (id: number) => {
left: var(--window-left);
right: var(--window-right);
bottom: 0;
z-index: 99;
z-index: 099;
padding-bottom: constant(safe-area-inset-bottom);
background-color: #ffffff;
padding-bottom: env(safe-area-inset-bottom);
......@@ -529,22 +555,29 @@ const initParts = (id: number) => {
.title {
text-align: center;
margin-bottom: 100rpx;
margin-bottom: 50rpx;
}
.details {
width: 100%;
font-size: 14px;
.left {
display: inline-block;
width: 40%;
padding: 20rpx 0;
}
.left {
padding: 20rpx 0;
// overflow: hidden;
// text-overflow: ellipsis; /* 超出部分省略号 */
// word-break: break-all; /* break-all(允许在单词内换行。) */
// display: -webkit-box; /* 对象作为伸缩盒子模型显示 */
// -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
// -webkit-line-clamp: 2; /* 显示的行数 */
// max-height: 80rpx; /* 设置最大高度,根据行高,要几行乘以几倍 */
}
.right {
padding: 20rpx 0;
}
.right {
padding: 20rpx 0;
// overflow: hidden;
// text-overflow: ellipsis; /* 超出部分省略号 */
// word-break: break-all; /* break-all(允许在单词内换行。) */
// display: -webkit-box; /* 对象作为伸缩盒子模型显示 */
// -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
// -webkit-line-clamp: 2; /* 显示的行数 */
// max-height: 80rpx; /* 设置最大高度,根据行高,要几行乘以几倍 */
}
}
</style>
......@@ -62,16 +62,13 @@
<script lang="ts" setup>
import { ref } from 'vue';
const toLogin = () => {
uni.navigateTo({
url: '../login/login',
});
};
import { orderCount } from '@/api/profile';
let nickName = uni.getStorageSync('nickName');
const orderBtnList = ref([
let orderStatusCount = ref();
let orderBtnList = ref([
{
url: '/static/my/tuisongshezhi.png',
text: '待推送',
......@@ -98,7 +95,7 @@ const orderBtnList = ref([
},
]);
const expandBtnList = ref([
let expandBtnList = ref([
{
url: '/static/my/wodeshoucang.png',
text: '我的收藏',
......@@ -119,6 +116,18 @@ const expandBtnList = ref([
},
]);
let initOrderCount = () => {
orderCount().then((res: any) => {
if (res.data.code === 200) {
orderStatusCount.value = res.data.data.order;
orderBtnList.value[0].badge = orderStatusCount.value.unpush;
orderBtnList.value[1].badge = orderStatusCount.value.unproduction;
orderBtnList.value[2].badge = orderStatusCount.value.undeliver;
orderBtnList.value[3].badge = orderStatusCount.value.uncompleted;
}
});
};
initOrderCount();
let change = (e: any) => {
let index = e.detail.index;
switch (index) {
......@@ -139,11 +148,11 @@ let handleOrderTypeChange = (e: any) => {
uni.navigateTo({ url: '/pages/order/orderList?showType=' + index });
};
const showAllOrder = () => {
let showAllOrder = () => {
uni.navigateTo({ url: '/pages/order/orderList' });
};
const toSetting = () => {
let toSetting = () => {
uni.navigateTo({ url: './setting' });
};
</script>
......
import config from './config';
import { nextTick } from 'vue';
const baseUrl = config.baseUrl;
// 封装公共申请办法
......@@ -43,9 +42,16 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
title: res.data.msg,
icon: 'none',
});
} else if (res.error == 'invalid_token') {
console.log('token', res);
uni.clearStorage();
} else if (res.data.code == 911) {
uni.reLaunch({
url: '/pages/login/login',
success() {
uni.showToast({
title: '请登录',
icon: 'none',
});
},
});
} else {
console.log(res, '非200错误');
//其余异样
......@@ -60,15 +66,6 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
title: '连接服务器失败',
icon: 'none',
});
uni.reLaunch({
url: '/pages/login/login',
success() {
uni.showToast({
title: '请登录',
icon: 'none',
});
},
});
reject(err);
},
});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论