This commit is contained in:
2025-01-08 09:44:25 +08:00
parent 06f6e29972
commit 4d21314fc6
60 changed files with 5477 additions and 4495 deletions
+95 -153
View File
@@ -1,7 +1,7 @@
<template>
<view class="">
<view class="goods-info">
<uv-swiper :list="photo" indicator indicatorMode="line" circular height="750rpx" radius="0"></uv-swiper>
<uv-swiper :list="[form.image]" indicator indicatorMode="line" circular height="750rpx" radius="0"></uv-swiper>
</view>
<uni-card :border="false" :is-shadow="false" :padding="0">
<uv-cell-group :customStyle="{backgroundColor: '#ffffff'}" :border="false">
@@ -9,17 +9,17 @@
<template v-slot:title>
<view class="pirce-bar" style="display: flex;">
<view class="web-text-danger">¥</view>
<view class="web-text-danger" style="font-size: 40rpx;">{{ form.price }}</view>
<view class="web-text-danger" style="font-size: 40rpx;">{{ form.minPrice }}</view>
</view>
</template>
<template v-slot:right-icon>
<text class="web-text-secondary" style="text-decoration: line-through">划线价¥{{ form.price * 2 }}</text>
</template>
<!-- <template v-slot:right-icon>-->
<!-- <text class="web-text-secondary" style="text-decoration: line-through">划线价¥{{ form.price * 2 }}</text>-->
<!-- </template>-->
</uv-cell>
<uv-cell :cellStyle="{padding: '0px 5px 15px 5px'}">
<template v-slot:title>
<view class="flex">
<view class="web-text-heading font-bold" style="font-size: 26rpx; ">{{ form.goodsName }}</view>
<view class="web-text-heading font-bold" style="font-size: 26rpx; ">{{ form.title }}</view>
</view>
</template>
</uv-cell>
@@ -32,49 +32,49 @@
</uv-cell-group>
</uni-card>
<uni-card :border="false" :is-shadow="false" :padding="0">
<uv-cell :cellStyle="{padding: '10px 5px'}" :center="true" @click="openSpecForm">
<template v-slot:title>
<view class="flex" v-if="!skuText">
<view class="web-text-secondary w-15p">可选</view>
<view class="uv-page__tag-item" v-for="(item, index) in form.goodsSpecValue" :key="index">
<uv-tags :text="`${item.value}`" :plain="!item.checked" type="info" :name="index" class="mr-10"
@click="radioClick">
</uv-tags>
</view>
</view>
<view class="flex" v-else>
<view class="web-text-secondary w-15p">已选</view>
<uv-text class="web-text-heading" type="warning" plain :text="skuText" />
</view>
</template>
<template v-slot:value>
<uv-icon name="arrow-right" color="#cccccc"></uv-icon>
</template>
</uv-cell>
<uv-cell :cellStyle="{padding: '10px 5px'}">
<template v-slot:title>
<view class="flex">
<view class="web-text-secondary w-15p">配送</view>
<view class="web-text-heading">啦啦</view>
</view>
</template>
<template v-slot:value>
<uv-icon name="arrow-right" color="#cccccc"></uv-icon>
</template>
</uv-cell>
<uv-cell :border="false" :cellStyle="{padding: '10px 5px'}">
<template v-slot:title>
<view class="flex">
<view class="web-text-secondary w-15p">保障</view>
<view class="web-text-heading value">坏了包赔 假一赔十 七天无理由</view>
</view>
</template>
<template v-slot:value>
<uv-icon name="arrow-right" color="#cccccc"></uv-icon>
</template>
</uv-cell>
</uni-card>
<!-- <uni-card :border="false" :is-shadow="false" :padding="0">-->
<!-- <uv-cell :cellStyle="{padding: '10px 5px'}" :center="true" @click="openSpecForm">-->
<!-- <template v-slot:title>-->
<!-- <view class="flex" v-if="!skuText">-->
<!-- <view class="web-text-secondary w-15p">可选</view>-->
<!-- <view class="uv-page__tag-item" v-for="(item, index) in form.goodsSpecValue" :key="index">-->
<!-- <uv-tags :text="`${item.value}`" :plain="!item.checked" type="info" :name="index" class="mr-10"-->
<!-- @click="radioClick">-->
<!-- </uv-tags>-->
<!-- </view>-->
<!-- </view>-->
<!-- <view class="flex" v-else>-->
<!-- <view class="web-text-secondary w-15p">已选</view>-->
<!-- <uv-text class="web-text-heading" type="warning" plain :text="skuText"/>-->
<!-- </view>-->
<!-- </template>-->
<!-- <template v-slot:value>-->
<!-- <uv-icon name="arrow-right" color="#cccccc"></uv-icon>-->
<!-- </template>-->
<!-- </uv-cell>-->
<!-- <uv-cell :cellStyle="{padding: '10px 5px'}">-->
<!-- <template v-slot:title>-->
<!-- <view class="flex">-->
<!-- <view class="web-text-secondary w-15p">配送</view>-->
<!-- <view class="web-text-heading">啦啦</view>-->
<!-- </view>-->
<!-- </template>-->
<!-- <template v-slot:value>-->
<!-- <uv-icon name="arrow-right" color="#cccccc"></uv-icon>-->
<!-- </template>-->
<!-- </uv-cell>-->
<!-- <uv-cell :border="false" :cellStyle="{padding: '10px 5px'}">-->
<!-- <template v-slot:title>-->
<!-- <view class="flex">-->
<!-- <view class="web-text-secondary w-15p">保障</view>-->
<!-- <view class="web-text-heading value">坏了包赔 假一赔十 七天无理由</view>-->
<!-- </view>-->
<!-- </template>-->
<!-- <template v-slot:value>-->
<!-- <uv-icon name="arrow-right" color="#cccccc"></uv-icon>-->
<!-- </template>-->
<!-- </uv-cell>-->
<!-- </uni-card>-->
<uni-card title="商品详情" :is-shadow="false" :border="false" :padding="0">
<view class="web-text-heading booking-content">
@@ -202,6 +202,7 @@ import UvAvatar from "@/uni_modules/uv-avatar/components/uv-avatar/uv-avatar.vue
import UvGap from "@/uni_modules/uv-gap/components/uv-gap/uv-gap.vue";
import UvButton from "@/uni_modules/uv-button/components/uv-button/uv-button.vue";
import UvText from "@/uni_modules/uv-text/components/uv-text/uv-text.vue";
import {getThinkGoods} from "@/api/think/thinkGoods";
const cartStore = useCartStore();
const {
@@ -243,14 +244,17 @@ export default {
type,
isNew,
dateTime,
options: [{
icon: 'server-fill',
text: '客服'
}, {
icon: 'bag',
text: '购物车',
info: 0
}],
options: [
{
icon: 'server-fill',
text: '客服'
},
{
icon: 'bag',
text: '购物车',
info: 0
}
],
buttonGroup: [
{
text: '加入购物车',
@@ -291,37 +295,17 @@ export default {
}
}
});
this.form = await this.getGoods()
// this.form.content = this.formatRichText(this.form.content)
if (this.isLogin) {
this.cart = await this.listCart()
this.options[1].info = this.cart.reduce((sum, item) => sum + item.cartNum, 0)
}
// 请求数据
Promise.all([app.getGoods(), app.listCart()]).then(data => {
const form = data[0]
form.content = this.formatRichText(form.content)
app.form = form;
cartStore.merchantId = form.merchantId
cartStore.merchantName = form.merchantName
cartStore.merchantCode = form.merchantCode
// 修改标题
uni.setNavigationBarTitle({
title: form.goodsName
})
// 加载场馆相册
if (form.files) {
app.photo = JSON.parse(form.files)
}
// 购物车信息
app.cart = data[1]
console.log(app.cart.totalNums)
// 更新购物车角标
if (app.cart?.totalNums) {
app.options[1].info = app.cart.totalNums
}
})
},
getGoods() {
return new Promise((resolve, reject) => {
GoodsApi.getGoods(this.id).then(result => {
getThinkGoods(this.id).then(result => {
resolve(result)
}).catch(reject)
})
@@ -353,55 +337,6 @@ export default {
app.skuText = app.sku.join('、')
}
},
// openBookingTel() {
// // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
// this.$refs.popup.open('center')
// },
// closeBookingTel() {
// this.$refs.popup.close()
// },
callPhone(phone) {
uni.makePhoneCall({
phoneNumber: phone
});
},
onMap() {
uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function (res) {
console.log('返回可以用于uni.openLocation的经纬度: ', res);
const latitude = this.merchant.latitude;
const longitude = this.merchant.longitude;
uni.openLocation({
latitude: latitude,
longitude: longitude,
success: function () {
console.log('success');
}
});
}
});
},
formatRichText(html) {
let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/\<img/gi,
'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
return newContent;
},
openSpecForm(){
this.$refs.specForm.open('center');
},
onClick({index, content}) {
console.log(index, content)
// 客服按钮
@@ -418,13 +353,17 @@ export default {
}
// 前往购物车
if (index === 1) {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
}
uni.navigateTo({url: `/package/cart/index`})
}
},
save({index, content}) {
const app = this
const {form} = this
if (!app.isLogin && !cartStore.isLogin) {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
}
@@ -435,32 +374,34 @@ export default {
})
return false
}
console.log(index)
// 加入购物车
if (index === 0) {
form.cartNum = 1;
form.isNew = false;
form.price = form.minPrice;
cartStore.isNew = false;
// 单规格
if (form.specs === 0) {
CartApi.addCart(form).then(data => {
app.reload()
uni.showToast({
title: '添加成功',
icon: 'success'
});
}).catch(res => {
uni.showToast({
title: res.message,
icon: 'none'
});
})
return false
}
// if (form.specs === 0) {
CartApi.addCart(form).then(data => {
app.reload()
uni.showToast({
title: '添加成功',
icon: 'success'
});
}).catch(res => {
uni.showToast({
title: res.message,
icon: 'none'
});
})
return false
// }
// 多规格
if (form.specs === 1) {
this.$refs.specForm.open('center');
return false;
}
// if (form.specs === 1) {
// this.$refs.specForm.open('center');
// return false;
// }
return false;
}
// 立即购买
@@ -474,6 +415,7 @@ export default {
this.$refs.specForm.open('center');
return false;
}
form.price = form.minPrice;
CartApi.addCart(form).then(cartId => {
// 跳转页面
uni.navigateTo({