i
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="app">
|
||||
<view class="head-wrapper" :style="`top:${BarHeight}px`">
|
||||
<view class="head-wrapper" :style="{ top: BarHeight + 'px' }">
|
||||
<view class="head-menu">
|
||||
<Left class="iconfont" @click="returns" />
|
||||
<Home class="iconfont" @click="goHome" />
|
||||
@@ -14,7 +14,7 @@
|
||||
auto-play="3000"
|
||||
>
|
||||
<nut-swiper-item v-for="(itm, idx) in swiperList" :key="idx">
|
||||
<img :src="itm.url" :alt="itm.id.toString()" />
|
||||
<img :src="itm" :alt="idx.toString()" />
|
||||
</nut-swiper-item>
|
||||
</nut-swiper>
|
||||
<!-- 标题价格 -->
|
||||
@@ -28,14 +28,21 @@
|
||||
/>
|
||||
</view>
|
||||
<view class="title">{{ goodInfo.name }} </view>
|
||||
<view class="sub">{{ goodInfo.profile }} </view>
|
||||
</view>
|
||||
<nut-cell title="请选择规格: " is-link @click="openSku"></nut-cell>
|
||||
<!-- 产品介绍 -->
|
||||
<view class="rich-box">
|
||||
<view class="title">产品介绍</view>
|
||||
<view v-if="goodInfo.details" v-html="goodInfo.details"></view>
|
||||
<rich-text
|
||||
v-if="goodInfo.details"
|
||||
class="rich"
|
||||
:nodes="goodInfo.details"
|
||||
></rich-text>
|
||||
<nut-empty v-else description="暂无产品介绍"></nut-empty>
|
||||
|
||||
</view>
|
||||
<view style="height: 9vh"></view>
|
||||
<!-- 底部 -->
|
||||
<view class="bottom-box">
|
||||
<view class="left">
|
||||
@@ -43,7 +50,11 @@
|
||||
<Home />
|
||||
<view>首页</view>
|
||||
</view>
|
||||
<view class="icon" v-if="payType === 'jf'" @click="toPage('/pages/cart/index')">
|
||||
<view
|
||||
class="icon"
|
||||
v-if="payType === 'jf'"
|
||||
@click="toPage('/pages/cart/index')"
|
||||
>
|
||||
<Cart />
|
||||
<view>购物车</view>
|
||||
</view>
|
||||
@@ -53,7 +64,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 占位 -->
|
||||
<view style="height: 155px"></view>
|
||||
|
||||
<view>
|
||||
<nut-button
|
||||
v-if="payType === 'jf'"
|
||||
@@ -62,7 +73,10 @@
|
||||
@click="add_cart()"
|
||||
>加入购物车
|
||||
</nut-button>
|
||||
<nut-button :style="payType === 'wx' ? 'width: 200px':''" type="primary" @click="toOrderDetail()"
|
||||
<nut-button
|
||||
:style="payType === 'wx' ? 'width: 200px' : ''"
|
||||
type="primary"
|
||||
@click="toOrderDetail()"
|
||||
>{{ payType === "jf" ? "立即兑换" : "立即购买" }}
|
||||
</nut-button>
|
||||
</view>
|
||||
@@ -118,37 +132,19 @@ import {
|
||||
getActiveGoodsDetail,
|
||||
addCart,
|
||||
createOrder,
|
||||
payOrder,
|
||||
createActiveOrder,
|
||||
} from "@/api/goods";
|
||||
import Pay from "@/components/Pay.vue";
|
||||
|
||||
const BarHeight = ref((statusBarHeight as number) + 7);
|
||||
|
||||
const swiperList = ref([
|
||||
{
|
||||
id: 1,
|
||||
url: "https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
url: "https://storage.360buyimg.com/jdc-article/NutUItaro2.jpg",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
url: "https://storage.360buyimg.com/jdc-article/welcomenutui.jpg",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
url: "https://storage.360buyimg.com/jdc-article/fristfabu.jpg",
|
||||
},
|
||||
]);
|
||||
const swiperList = ref([]);
|
||||
|
||||
const isSkuShow = ref(false);
|
||||
|
||||
const isShowPay = ref(false);
|
||||
|
||||
const sku = ref([]);
|
||||
// const sku = ref([]);
|
||||
|
||||
const payType = ref("");
|
||||
|
||||
@@ -164,6 +160,7 @@ interface GoodInfo {
|
||||
details?: string;
|
||||
sku?: any[];
|
||||
stock?: number;
|
||||
profile?: string;
|
||||
}
|
||||
|
||||
const goodInfo = ref<GoodInfo>({});
|
||||
@@ -177,11 +174,15 @@ const get_good_detail = async (gid: string) => {
|
||||
try {
|
||||
let res: any;
|
||||
if (payType.value === "jf") {
|
||||
res = await getGoodsDetail({ gid: Number(gid) });
|
||||
res = await getGoodsDetail({ gid: gid });
|
||||
} else {
|
||||
res = await getActiveGoodsDetail({ gid: gid });
|
||||
}
|
||||
goodInfo.value = res.data.data;
|
||||
|
||||
swiperList.value = res.data.data.rotation.split(",");
|
||||
|
||||
console.log(goodInfo.value);
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
@@ -217,13 +218,13 @@ const openSku = () => {
|
||||
isSkuShow.value = true;
|
||||
};
|
||||
|
||||
const selectSku = () => {};
|
||||
const clickBtnOperate = () => {};
|
||||
const close = () => {};
|
||||
// const selectSku = () => {};
|
||||
// const clickBtnOperate = () => {};
|
||||
// const close = () => {};
|
||||
const add_cart = async () => {
|
||||
if (isSkuShow.value === false) return openSku();
|
||||
try {
|
||||
await addCart({ gid: Number(goodInfo.value.gid) });
|
||||
await addCart({ gid: goodInfo.value.gid });
|
||||
Taro.showToast({
|
||||
title: "加入购物车成功",
|
||||
icon: "success",
|
||||
@@ -248,20 +249,22 @@ const toOrderDetail = async () => {
|
||||
if (payType.value === "jf") {
|
||||
res = await createOrder([
|
||||
{
|
||||
gid: Number(goodInfo.value.gid),
|
||||
gid: goodInfo.value.gid,
|
||||
count: Number(count.value),
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
res = await createActiveOrder({
|
||||
gid: goodInfo.value.gid,
|
||||
stock: count.value,
|
||||
stock: Number(count.value),
|
||||
});
|
||||
}
|
||||
|
||||
orderData.value = res.data.data;
|
||||
|
||||
isShowPay.value = true;
|
||||
|
||||
count.value = 1;
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
@@ -334,7 +337,7 @@ const toPage = (url: string, type: number = 1) => {
|
||||
|
||||
.nut-swiper-item img {
|
||||
width: 100%;
|
||||
height: 450px;
|
||||
height: 550px;
|
||||
}
|
||||
|
||||
.card {
|
||||
@@ -346,6 +349,11 @@ const toPage = (url: string, type: number = 1) => {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sub {
|
||||
font-size: 24px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.rich-box {
|
||||
@@ -361,6 +369,17 @@ const toPage = (url: string, type: number = 1) => {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.rich {
|
||||
box-sizing: border-box;
|
||||
// &[img] {
|
||||
// max-width: 100%;
|
||||
// }
|
||||
|
||||
// &[alt] {
|
||||
// max-width: 100%;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
.nut-sku {
|
||||
|
||||
Reference in New Issue
Block a user