cgc非遗
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

799 lines
19 KiB

5 months ago
<template>
<view class="bg">
5 months ago
<view class="search-header" :style="{'height': height+'px','padding-top':statusBarHeight+'px'}">
<uni-icons type="left" size="20" @click="goBack" style="flex-shrink: 0;"></uni-icons>
<view class="input-model">
<uni-icons style="height: 1.4rem;line-height: 1.4rem;" type="search" size="15" color="#ABAAAD" ></uni-icons>
5 months ago
<input class="input-text" placeholder="请输入商品名称" v-model="searchText" @confirm="search()" @keyup.enter="search()"></text>
5 months ago
</view>
</view>
5 months ago
<div :style="{'height':height+'px','flex-shrink':0}"></div>
5 months ago
5 months ago
<!-- 正常产品 -->
<template v-if="searchText.trim().length<=0">
<img :src="showImg(headImg)" class="topImg" />
5 months ago
5 months ago
<view class="goods-container">
<scroll-view class="left-container no-scrollbar" :scroll-y="true">
<view :class="['type-item',typeIndex==i?'active':'']"
v-for="(item,i) in typeParam" :key="i" @click="changeType(item,i)">
5 months ago
{{item.title}}
5 months ago
<view class="active-type-bar" v-if="typeIndex==i"></view>
</view>
<view style="height: 148rpx;width: 1rpx;"></view>
</scroll-view>
<scroll-view class="right-container no-scrollbar" :scroll-y="true" @scrolltolower="scrollLow()">
<view class="item" v-for="item in list" :key="item.goods.id" @click="viewDetail(item.goods)">
<image class="item-img" :src="showImg(item.goods.image)" mode=""></image>
<view class="content">
<view class="title text-overflowRows">{{item.goods.title}}</view>
<view class="bottom">
<view class="price">
{{item.goods.money/100}}
</view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
</view>
</view>
</view>
<view style="height: 148rpx;width: 1rpx;"></view>
</scroll-view>
</view>
</template>
5 months ago
5 months ago
<!-- 搜索 -->
<view v-else>
<view v-if="searchList.length<=0" class="flex-center" style="width: 100%;height: 100%;flex-direction: column;">
<!-- <image style="width: 328rpx;height: 450.67rpx;"></image> -->
<view style="font-weight: 500;font-size: 28rpx;color: #666666;
text-align: center;margin-top: 67rpx;">暂无搜索结果</view>
</view>
<view style="padding:0 26rpx;background: #FFFFFF;" v-else>
<view class="flex" style="justify-content: space-between;">
<view class="search-result" >
<view v-for="(item,i) in searchList" >
<view v-if="i%2==1" class="search-item" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view>
<view class="flex-between" style="padding-top: 20rpx;">
<view>
<text class="price">{{item.goods.money/100}}</text>
<text class="oldPrice">{{item.goods.price/100}}</text>
</view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
</view>
</view>
5 months ago
</view>
5 months ago
</view>
</view>
<view class="search-result" >
<view v-for="(item,i) in searchList">
<view class="search-item" v-if="i%2==0" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view>
<view class="flex-between" style="padding-top: 20rpx;">
<view>
<text class="price">{{item.goods.money/100}}</text>
<text class="oldPrice">{{item.goods.price/100}}</text>
</view>
<view class="buy-cart" @click.stop="showOrderCart(item.goods)">+</view>
</view>
</view>
5 months ago
</view>
5 months ago
</view>
</view>
</view>
5 months ago
</view>
<view style="height: 148rpx;width: 1rpx;"></view>
5 months ago
</view>
5 months ago
<!-- 购物车 -->
<view class="btn-bottom" >
5 months ago
<cartDataVue ref="cartDataVueRef" :paramData="paramData" @changeParamData="changeParamData" style="width: 100%;height: 100%;">
<template class="btn-list" slot="content">
<view class="left-box">
<uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small"
5 months ago
:custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}">
5 months ago
<view class="img-box" @click.stop="showCartClick">
5 months ago
<image :src="showImg('/uploads/20250513/cc33cde475ce45c274cb304e20805aa1.png')" mode="aspectFill"></image>
5 months ago
</view>
</uni-badge>
<view class="bottom-price">
5 months ago
<text style="color: #000000;">总计</text>
5 months ago
<view class="bottom-price-yuan">{{paramData.iNum}}</view>
<view>.{{paramData.fNum}}</view>
</view>
<view class="bottom-detail-icon" @click.stop="showCartClick">
明细
5 months ago
<view v-if="!paramData.showCart" style="transform: rotate(-90deg);"><uni-icons color="#0B898E" type="left" size="15"></uni-icons></view>
<view v-else style="transform: rotate(90deg);"><uni-icons color="#0B898E" type="left" size="15"></uni-icons></view>
5 months ago
</view>
</view>
<view class="btn-buy" @click="goCartOrder">
5 months ago
去结算
5 months ago
</view>
</template>
</cartDataVue>
</view>
<uni-popup ref="popup" type="bottom" :safe-area="true">
<view class="popup-content" v-if="sku.length>0">
<view @click="closePopup" style="padding: 31rpx 0 0 639rpx;width: 50rpx;height: 80rpx;">
<uni-icons type="closeempty" size="24"></uni-icons>
</view>
<view class="bottom-productImg">
<img :src="showImg(sku[productIndex].image)" alt="">
<view class="right-content">
<view class="bottom-productPrice com-price">{{(sku[productIndex].money||0)/100}}</view>
<view class="bottom-content text-overflow">已选择{{sku[productIndex].title}}</view>
</view>
</view>
<view>
<view style="display: flex;align-items: center;justify-content: space-between;flex-wrap: wrap;">
<view style="position:relative;" v-for="(botItem,botIndex) in sku" :key="botIndex">
<view :class="['botProduct','text-overflow',{'noStore':botItem.store==0},{'botProducts':productIndex==botIndex}]"
@click="changeProduct(botItem,botIndex)">
{{botItem.title}}
</view>
<view class="noStore-text" v-if="botItem.store==0">
不可购买
</view>
5 months ago
<!-- <view class="noStore-text" v-else-if="botItem.is_post!=1">不可加购</view> -->
5 months ago
</view>
</view>
</view>
<view class="buy-num com-flex-tao">
数量
<view class="number-btn">
<view>
<text @click="delNumber">-</text>
</view>
<view style="width: 96rpx;height: 69rpx;margin: 0 14rpx;">{{ buyNum }}</view>
<view>
<text @click="addNumber">+</text>
</view>
</view>
</view>
</view>
<view class="placeholder-content">
<view style="height: 100rpx;"></view>
<view class="btn-cover">
<view class="btn" @click.stop="order">加入购物车</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
5 months ago
import cartDataVue from '../../components/cartData.vue'
5 months ago
export default {
components: {cartDataVue},
data() {
return {
5 months ago
// 导航栏参数
height: 0,
statusBarHeight: 0,
5 months ago
headImg: "https://cgc.js-dyyj.com/uploads/20250513/f8b255f965efcd71b6843e4b72c3f1f3.png",
5 months ago
5 months ago
typeParam: [
5 months ago
{id: 45, title: '味 | WEI'},
{id: 46, title: '服 | FU'},
{id: 47, title: '器 | QI'},
{id: 48, title: '香 | XIANG'},
{id: 49, title: '饰 | SHI'},
{id: 50, title: '艺 | YI'},
5 months ago
],
typeIndex: 0,
5 months ago
list:[],
finished: false,
paramData: {allPrice: 0,iNum:0, fNum:'00', showCart: false, num: 0},
currentGoods: {},
sku: [],
productIndex: 0,
buyNum: 1,
5 months ago
cartDataVueShow: false,
searchText: '',
5 months ago
searchList: [],
searchFinish: false,
5 months ago
}
},
onLoad(options) {
5 months ago
// this.getHeadImg("techan").then(res => {this.headImg = res})
if (options.idIndex) {
try {
this.typeIndex = Number(options.idIndex)
} catch(e) {
this.typeIndex = 0
}
}
5 months ago
},
onReady() {
5 months ago
this.initRectInfo()
5 months ago
this.getList()
},
methods: {
5 months ago
initRectInfo () {
const sysInfo = uni.getSystemInfoSync()
this.statusBarHeight = sysInfo.statusBarHeight
// 默认高度
this.height = sysInfo.statusBarHeight + 40
},
5 months ago
changeType (item, i) {
if (this.typeIndex!== i) {
this.typeIndex=i
this.finished = false
5 months ago
this.list = []
this.getList()
}
},
// 根据产品分类获取产品列表
getList(){
this.Post({
5 months ago
tag_id: this.typeParam[this.typeIndex].id,
5 months ago
offset: this.list.length,
limit: 10,
},'/api/tag/getGoodsByTagId').then(res => {
this.list = [...this.list, ...res.data];
if (res.data.length < 10) {
this.finished = true
}
})
},
5 months ago
scrollLow () {
if (!this.finished) {
this.getList()
}
},
5 months ago
viewDetail(item) {
5 months ago
// this.goOtherDetail(item)
5 months ago
if(!item.link_type) {
uni.navigateTo({
url: '/subPackages/techan/detail?id=' + item.id
})
}
},
showCartClick () {
if (this.paramData.showCart) {
this.$refs.cartDataVueRef.closePopup()
} else {
this.$refs.cartDataVueRef.openPop()
}
},
changeParamData (data) {
for(let key in this.paramData) {
this.paramData[key] = data[key]
}
},
// 购物车相关
showOrderCart (item) {
console.log(item)
this.sku = []
this.productIndex = 0
this.buyNum = 1
this.currentGoods = JSON.parse(JSON.stringify(item))
this.getSpecificationsByGoodsId(item.id)
},
changeProduct(item,index) {
if (item.store==0) {
uni.showToast({
title:"库存不足!",
icon:'none'
})
return
}
this.productIndex = index
},
getSpecificationsByGoodsId(goods_id) {
this.Post({goods_id: goods_id},'/api/goods/getSpecificationsByGoodsId'
).then(res => {
if (res) {
this.sku = res.data;
if (!this.sku||this.sku.length<=0) {
uni.showToast({
title:'暂无可选规格',
icon:'none'
})
return
}
this.openPop()
}
});
},
//数量加减
addNumber() {
this.buyNum += 1;
},
delNumber() {
if (this.buyNum <= 1) {
return;
}
this.buyNum -= 1;
},
closePopup() {
this.$refs.popup.close()
},
openPop(){
this.$refs.popup.open()
},
order() {
let goods = this.sku[this.productIndex]
if(goods.is_post!=1) {
uni.showToast({
title: '此规格不支持加入购物车',
icon: 'none'
})
return
}
goods.buyNum = this.buyNum
let goodsInfo = {goodsInfo:this.currentGoods, skuInfo: goods, isSelected: true}
this.Post({good_id: this.currentGoods.id, specifications_id: goods.id,num: this.buyNum },
'/api/shopping/addShopping').then(res => {
if (res) {
let selectedData = []
try {
selectedData = JSON.parse(uni.getStorageSync('cartDataInfo'));
} catch(e) {
selectedData = []
}
let currentGoods = selectedData.find(v =>v==goods.id)
if (!currentGoods) {
selectedData.push(goods.id)
}
uni.setStorageSync('cartDataInfo', JSON.stringify(selectedData));
uni.$emit("updateDataByConnect", {msgType:'updateCartDataInfo',data:null})
this.closePopup()
// this.$refs.cartDataVueRef.openPop()
}
});
},
goCartOrder () {
this.$refs.cartDataVueRef.goCartOrder()
},
5 months ago
//搜索
search () {
this.searchFinish = false
this.searchList = []
// todo 请求
this.searchList = [...this.list,...this.list,...this.list,...this.list]
},
5 months ago
},
onReachBottom() {
5 months ago
if (!this.searchFinish) {
this.search()
}
console.log(1)
5 months ago
}
}
</script>
<style lang="scss" scoped>
view {
box-sizing: border-box;
}
5 months ago
.search-header{
width: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
background: white;
5 months ago
display: flex;
5 months ago
align-items: center;
padding-left: 10rpx;
padding-right: 120px;
.input-model{
flex: 1;
width: 1rpx;
height: 64rpx;
background: #FFFFFF;
border-radius: 55rpx;
border: 1rpx solid #20898D;
margin-left: 12rpx;
display: flex;
align-items: center;
font-weight: 400;
font-size: 24rpx;
color: #ABAAAD;
padding-left: 24rpx;
}
.input-text{
height:19px;
padding-left: 14rpx;
font-weight: 400;
font-size: 24rpx;
5 months ago
color: #030000;
5 months ago
}
5 months ago
}
5 months ago
.bg {
height: 100vh;
padding-bottom: 26rpx;
5 months ago
display: flex;
flex-direction: column;
5 months ago
background: #F8FAFB;
5 months ago
}
5 months ago
.topImg {
width: 750rpx;
height: 344rpx;
flex-shrink: 0;
5 months ago
}
5 months ago
.goods-container{
height: 1rpx;
flex: 1;
5 months ago
display: flex;
}
5 months ago
.left-container{
width: 214rpx;
flex-shrink: 0;
.type-item{
font-weight: 400;
font-size: 24rpx;
color: #000000;
text-align: center;
width: 216rpx;
height: 120rpx;
line-height: 120rpx;
position: relative;
.active-type-bar{
position: absolute;
left: 0;
top: 0;
bottom: 0;
height: 100%;
width: 12rpx;
background: #74A5AA;
}
}
.type-item.active{
background: linear-gradient( 90deg, rgba(32,137,141,0.4) 0%, rgba(32,137,141,0) 100%);
font-weight: 600;
font-size: 28rpx;
5 months ago
}
}
5 months ago
.right-container{
flex: 1;
width: 1rpx;
background: white;
padding-top: 32rpx;
.item {
5 months ago
width: 100%;
5 months ago
padding:0 32rpx 32rpx 32rpx;
5 months ago
display: flex;
5 months ago
.item-img {
width: 148rpx;
height: 148rpx;
border-radius: 15rpx;
5 months ago
flex-shrink: 0;
5 months ago
}
.content {
height: 148rpx;
padding-left: 24rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
flex: 1;
}
.title {
5 months ago
font-weight: 500;
font-size: 28rpx;
5 months ago
color: #000000;
width: 100%;
}
.bottom {
5 months ago
display: flex;
5 months ago
justify-content: space-between;
5 months ago
align-items: center;
5 months ago
.price {
font-size: 40rpx;
color: #FA0000;
font-weight: 400;
}
.price::before {
content: '¥';
font-size: 24rpx;
5 months ago
}
}
5 months ago
5 months ago
}
}
5 months ago
.buy-cart{
width: 44rpx;
height: 44rpx;
color: #FFFFFF;
background: #74A5AA;
line-height: 44rpx;
font-size: 30rpx;
text-align: center;
border-radius: 50%;
}
5 months ago
.btn-list {
z-index: 99;
position: fixed;
bottom: 0;
width: 750rpx;
height: 148rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(6, 0, 1, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
5 months ago
padding: 0 26rpx;
5 months ago
.left-box {
display: flex;
align-items: center;
.bottom-price{
display: flex;
align-items: baseline;
font-family: PingFang SC;
font-weight: bold;
font-size: 27rpx;
5 months ago
color: #D70000;
padding: 0 12rpx;
5 months ago
.bottom-price-yuan{
font-size: 40rpx;
}
}
.bottom-detail-icon{
font-size: 24rpx;
display: flex;
align-items: center;
5 months ago
color: #0B898E;
5 months ago
}
.img-box {
image {
width: 78rpx;
height: 78rpx;
}
}
}
.btn-buy {
5 months ago
width: 240rpx;
5 months ago
height: 78rpx;
5 months ago
background: #74A5AA;
5 months ago
border-radius: 40rpx;
text-align: center;
line-height: 78rpx;
font-size: 32rpx;
font-family: PingFangSC;
font-weight: 500;
color: #FFFFFF;
}
}
// 规格弹框
.popup-content {
background-color: white;
padding: 0rpx 39rpx 51rpx 39rpx;
height: auto;
border-radius: 20rpx 20rpx 0 0;
.bottom-productImg {
display: flex;
5 months ago
margin-bottom: 48rpx;
5 months ago
}
.bottom-productImg img {
width: 218rpx;
height: 179rpx;
background: #666666;
border-radius: 13rpx;
}
.right-content {
margin: 10rpx 0 0 41rpx;
}
.bottom-productPrice {
font-size: 40rpx;
color: #C3282E;
&:before {
content: "¥";
font-size: 26rpx;
}
}
.bottom-content {
width: 331rpx;
font-size: 27rpx;
font-family: PingFang SC;
font-weight: 400;
color: #666666;
}
.botProduct {
width: 320rpx;
// height: 78rpx;
border-radius: 13rpx;
5 months ago
background-color: #EFEFEF;
5 months ago
font-size: 29rpx;
font-family: PingFang SC;
font-weight: 400;
color: #333333;
line-height: 78rpx;
text-align: center;
margin-bottom: 25rpx;
display: inline-block;
position: relative;
padding: 0 40rpx;
}
.noStore{
background-color: rgba(239, 239, 239, 1);
color: rgba(153, 153, 153, 1);
}
.noStore-text{
width: 113rpx;
height: 43rpx;
background: #C0C0C0;
border-radius: 7rpx 0rpx 7rpx 0rpx;
text-align: center;
line-height: 43rpx;
position: absolute;
right: -14rpx;
top: -20rpx;
font-size: 23rpx;
font-family: PingFangSC;
font-weight: 400;
color: #FFFFFF;
}
.botProducts {
5 months ago
background: #74A5AA;
5 months ago
color: #FFFFFF;
}
.buy-num {
font-size: 29rpx;
font-family: PingFang SC;
font-weight: 400;
color: #333333;
// border-top: 1rpx solid #CCCCCC;
padding: 39rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
5 months ago
border-top: 1px solid #CCCCCC;
5 months ago
}
.buy-num .number-btn {
display: flex;
}
.buy-num .number-btn view {
display: flex;
justify-content: center;
align-items: center;
width: 69rpx;
height: 69rpx;
border: 1rpx solid #CCCCCC;
border-radius: 7rpx;
}
.buy-num .number-btn>view text {
font-size: 46rpx;
}
.btn-box {
width: 750rpx;
height: 151rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(6, 0, 1, 0.1);
display: flex;
align-items: center;
justify-content: center;
}
}
.placeholder-content{
background: white;
position: relative;
.btn-cover{
z-index: 200;
position: fixed;
bottom: 0;
width: 750rpx;
height: 148rpx;
background: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
5 months ago
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(6,0,1,0.1);
5 months ago
.btn{
width: 670rpx;
height: 78rpx;
text-align: center;
line-height: 78rpx;
5 months ago
background: #74A5AA;
5 months ago
border-radius: 40rpx;
font-size: 34rpx;
font-family: PingFangSC;
font-weight: 500;
color: #FFFFFF;
}
}
}
5 months ago
.search-result{
display: flex;
flex-direction: column;
width: 100%;
flex: 1;
flex-shrink: 0;
.search-item{
width: 337rpx;
box-shadow: 0rpx 0rpx 9rpx 0rpx rgba(153,153,153,0.33);
border-radius: 13rpx;
flex-shrink: 0;
margin-bottom: 20rpx;
height: fit-content;
image{
width: 100%;
border-radius: 13rpx;
}
.search-container{
padding: 20rpx;
.title{
font-weight: 500;
font-size: 27rpx;
color: #000000;
}
.price{
font-weight: 400;
font-size: 33rpx;
color: #D70000;
}
.price:before{
content: "¥";
font-size: 23rpx;
}
.oldPrice{
font-weight: 400;
font-size: 21rpx;
color: #999999;
text-decoration-line: line-through;
padding-left: 12rpx;
}
}
}
}
5 months ago
</style>