动态关联商品

version/0412
wangdong 6 months ago
parent 4fd3d5de63
commit 4a4844512c
  1. 21
      pages/goods/list.vue
  2. 63
      pages/squareDynamic/index.vue
  3. 31
      pages/squareDynamic/publish.vue
  4. 2
      project.config.json

@ -75,7 +75,7 @@
<view class="goods-list clearfix" :class="['column-' + (showView ? '1' : '2')]">
<view v-if="showView">
<view class="goods-item" v-for="(item, index) in list.data" :key="index"
@click="onTargetDetail(item.goods_id)">
@click="onTargetDetail(item)">
<!-- 单列显示 -->
<view v-if="showView" class="dis-flex">
<!-- 商品图片 -->
@ -112,7 +112,7 @@
<u-waterfall v-model="list.data" ref="uWaterfall1">
<template v-slot:left="{leftList}">
<view class="goods-item goods-item1" v-for="(item, index) in leftList" :key="index"
@click="onTargetDetail(item.goods_id)">
@click="onTargetDetail(item)">
<!-- 多列显示 -->
<view class="">
<!-- 商品图片 -->
@ -168,7 +168,7 @@
</template>
<template v-slot:right="{rightList}">
<view class="goods-item goods-item1" v-for="(item, index) in rightList" :key="index"
@click="onTargetDetail(item.goods_id)">
@click="onTargetDetail(item)">
<!-- 多列显示 -->
<view class="">
<!-- 商品图片 -->
@ -301,6 +301,7 @@
}],
multiIndex: -1,
blheight: 0,
from: ''
}
},
@ -311,6 +312,8 @@
// options
this.options = options
this.searchText = options.search
this.from = options.from || '';
console.log(this.from, 316);
//
this.setShowView()
//
@ -497,10 +500,18 @@
},
//
onTargetDetail(goodsId) {
onTargetDetail(item) {
console.log(item);
if (this.from === 'dynamic') {
let pages = getCurrentPages(); //
let prevPage = pages[pages.length - 2].$vm; //
prevPage.good = item;
uni.navigateBack();
} else {
this.$navTo('pages/goods/detail', {
goodsId
goodsId: item.goods_id
})
}
},
/**

@ -24,6 +24,18 @@
<view v-if="item.imgs && item.imgs.length > 0" class="pic-list">
<image v-for="(pic, k) in item.imgs" :key="k" :src="pic.external_url" mode="aspectFill" @click="previewImage(k, item.imgs)"></image>
</view>
<view class="goods">
<view class="goods-box">
<image :src="item.goods_image" mode="aspectFill"></image>
<view class="goods-info">
<view class="name">{{ item.goods_name }}</view>
<view class="price">
<text>{{ item.goods_price_min>0?Number(item.goods_price_min):0.00 }}</text>
<text @click="toGoodsDetail(item)">加购</text>
</view>
</view>
</view>
</view>
<view class="btns">
<view class="btn" v-if="item.content" @click="clipCont(item.content)">
<image src="/static/copy.png" mode="aspectFill"></image>
@ -341,6 +353,11 @@
urls: arr,
})
},
toGoodsDetail(item) {
this.$navTo('pages/goods/detail', {
goodsId: item.goods_id
})
}
},
};
</script>
@ -450,6 +467,52 @@
}
}
}
.goods {
background: #f5f5f5;
padding: 20rpx;
margin-top: 24rpx;
}
.goods-box {
display: flex;
background: #fff;
padding: 20rpx 0;
>image {
width: 100rpx;
height: 100rpx;
margin-right: 20rpx;
}
.goods-info {
width: calc(100% - 120rpx);
display: flex;
flex-direction: column;
justify-content: space-between;
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.price {
display: flex;
>text {
&:first-child {
color: #F34A40;
}
&:last-child {
height: 40rpx;
line-height: 40rpx;
text-align: center;
padding: 0 20rpx;
background: #F34A40;
border-radius: 20rpx;
margin-left: auto;
color: #FFFFFF;
font-size: 22rpx;
flex-shrink: 0;
}
}
}
}
}
.btns {
margin-top: 20rpx;
display: flex;

@ -17,6 +17,10 @@
<textarea placeholder="请输入您想发布的内容哦~" placeholder-class="textarea-placeholer" id="" cols="30" rows="10" v-model="content" maxlength="3000"></textarea>
<view class="text-num">已写<text>{{ content.length }}</text>/3000个字</view>
</view>
<view class="good">
<view class="label">关联商品:</view>
<view class="content els" :style="{ color: !good.goods_name ? '#999999' : ''}" @click="selectGood">{{ good.goods_name || '请选择' }}</view>
</view>
<view class="cate">
<view class="label">文章类别:</view>
<view class="content">
@ -52,8 +56,17 @@ import * as Api from '@/api/squareDynamic/index.js'
cateIndex: -1,
isPublish: false,
loading: false,
good: {},
};
},
watch: {
good: {
deep: true,
handler() {
console.log(this.good.goods_name);
},
},
},
methods: {
addImage() {
const that = this;
@ -121,6 +134,7 @@ import * as Api from '@/api/squareDynamic/index.js'
imgs: this.uploadImages.join(','),
content: this.content,
cate: this.cateList[this.cateIndex],
goods_id: this.good.goods_id,
})
.then(res => {
console.log(res);
@ -135,6 +149,11 @@ import * as Api from '@/api/squareDynamic/index.js'
back() {
uni.navigateBack();
},
selectGood() {
uni.navigateTo({
url: `/pages/goods/list?from=dynamic`
})
},
},
};
</script>
@ -225,7 +244,7 @@ import * as Api from '@/api/squareDynamic/index.js'
}
}
}
.cate {
.cate, .good {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
@ -244,6 +263,16 @@ import * as Api from '@/api/squareDynamic/index.js'
.content {
display: flex;
align-items: center;
flex: 1;
justify-content: flex-end;
margin-left: 40rpx;
height: 100%;
}
}
.good {
height: fit-content;
.content {
padding: 30rpx 0;
}
}
.submit {

@ -1,5 +1,5 @@
{
"appid": "wxe843b6d7a4bd3389",
"appid": "wxa3127ed5c3542a28",
"compileType": "miniprogram",
"libVersion": "3.3.3",
"packOptions": {

Loading…
Cancel
Save