deming/pageB/photo/index.vue

508 lines
13 KiB
Vue
Raw Normal View History

2020-06-09 14:29:43 +08:00
<template>
<view class="photo">
2020-08-01 17:22:46 +08:00
<view class="status_bar"></view>
2020-06-09 14:29:43 +08:00
<view class="back">
2020-07-31 08:45:30 +08:00
<u-icon name="close" color="#999999" :size="30" @click="goBack"></u-icon>
2020-06-09 14:29:43 +08:00
</view>
2020-08-01 11:16:53 +08:00
<swiper class="swiper" circular autoplay @change="changeSwiper">
<swiper-item v-for="(simg,sindex) in list.photo" :key="sindex">
2020-08-04 19:39:31 +08:00
<image :src="simg.url" mode="widthFix" @tap="viewImage" :data-url="simg.url"></image>
2020-06-09 14:29:43 +08:00
</swiper-item>
</swiper>
2020-08-01 17:22:46 +08:00
<view class="bottom">
2020-06-09 14:29:43 +08:00
<view class="item">
<text>图片</text>
2020-08-01 11:16:53 +08:00
<view v-for="(item,index) in list.photo" :key="index" :style="{'background-color':index == swiper_id ? '#fff' : '#ede8e8'}"></view>
2020-06-09 14:29:43 +08:00
</view>
2020-08-01 11:16:53 +08:00
<view class="username">{{ list.member_nickname }}</view>
<view class="title">{{ list.article_title }}</view>
<view class="info">{{ list.article_content }}</view>
<view class="box">
<view class="label" v-for="(label,id) in list.label" :key="id">{{ label.name }}</view>
</view>
2020-08-01 17:22:46 +08:00
</view>
<!-- 用户操作 -->
2020-08-03 14:26:52 +08:00
<userinfo class="userinfo" :list="list" :cart="cart_type" :comment="is_comment" @openCart="openPopup"></userinfo>
2020-08-01 17:22:46 +08:00
<!-- 评论 -->
<u-popup v-model="is_comment" class="pl" mode="bottom" border-radius="10" height="700rpx">
<view class="top">
<text>评论</text>
2020-08-03 14:26:52 +08:00
<u-icon name="arrow-down" color="#333" size="28" @click="is_comment=false"></u-icon>
2020-08-01 17:22:46 +08:00
</view>
<scroll-view class="scroll-box" scroll-y="true" >
2020-08-03 14:26:52 +08:00
<block v-for="(item,index) in commentList" :key="index" v-if="commentList.length">
<view class="box">
2020-08-04 19:39:31 +08:00
<image :src="item.member_avatar" mode="aspectFill"></image>
2020-08-03 14:26:52 +08:00
<view class="info">
<text>{{ item.member_nickname }}</text>
<text class="time">{{ item.create_time }}</text>
</view>
2020-08-03 19:51:05 +08:00
<text class="reply" @click="openKeyInput(item,index)">回复</text>
2020-08-03 14:26:52 +08:00
</view>
<view class="content">
{{ item.content }}
</view>
2020-08-03 19:51:05 +08:00
<view class="child-content">
<view>
</view>
<view class="more-reply" v-if="item.reply_count">展开更多回复<u-icon name="arrow-down"></u-icon></view>
</view>
2020-08-03 14:26:52 +08:00
</block>
<view class="no-data" v-else>111</view>
2020-08-01 17:22:46 +08:00
</scroll-view>
2020-08-03 19:51:05 +08:00
<view class="editing" @click="openKeyInput">
2020-08-03 14:26:52 +08:00
<input type="text" value="" :placeholder="edit_text" disabled="disabled" />
2020-08-01 17:22:46 +08:00
<text>发送</text>
</view>
</u-popup>
2020-08-03 14:26:52 +08:00
<!-- 评论box -->
<u-popup v-model="is_edit" mode="bottom" border-radius="10" height="100rpx">
<view class="edit-box">
2020-08-04 14:36:35 +08:00
<input type="text" :placeholder="edit_text_other" :focus="is_focus" @focus="focus" v-model="send_value" autofocus>
2020-08-03 14:26:52 +08:00
<text @click="sendComment">发送</text>
</view>
</u-popup>
2020-08-01 17:22:46 +08:00
<!-- 购物车 -->
<u-popup v-if="cart_len > 1" class="cart" v-model="cart_type" mode="bottom" length="782" border-radius="20">
<view class="top">
<text>全部商品</text>
<u-icon name="close" color="#999999" :size="30" @click="cart_type = false"></u-icon>
</view>
<scroll-view :scroll-y="true" class="scroll-box">
<view v-for="(item,index) in list.goods" :key="index" class="item" @click="gotoInfo(item.goods_id)">
<image :src="item.goods_image" mode="aspectFill"></image>
<view>
<text class="title">{{ item.goods_advword }}</text>
<text class="name">{{ item.goods_name }}</text>
<text class="price">{{ item.goods_promotion_price }}</text>
</view>
</view>
</scroll-view>
</u-popup>
<!-- 单个 -->
<view class="good-one" v-else v-show="cart_type">
<view class="box" v-for="(item,index) in list.goods" :key="index" @click="gotoInfo(item.goods_id)">
2020-08-04 19:39:31 +08:00
<image :src="item.goods_image" mode="aspectFill"></image>
2020-08-01 17:22:46 +08:00
<view>
<view class="title u-line-1">{{ item.goods_advword }}</view>
<view class="content u-line-2">{{ item.goods_name }}</view>
<view class="price">{{ item.goods_promotion_price }}</view>
</view>
</view>
</view>
<!-- <shoplist :list="list.goods" v-show="list.goods.length > 1 && cart_type" @hideCart="hideCart"></shoplist> -->
2020-06-09 14:29:43 +08:00
</view>
</template>
<style lang="scss" scoped>
.photo{
width: 100%;
2020-08-01 17:22:46 +08:00
height: 100%;
2020-08-04 19:39:31 +08:00
background-color: #000000;
2020-06-09 14:29:43 +08:00
.back{
padding-top: 28rpx;
padding-right: 31rpx;
2020-07-29 15:04:57 +08:00
text-align: right;
2020-06-09 14:29:43 +08:00
}
.swiper{
2020-08-01 17:22:46 +08:00
width: 750rpx;
2020-08-04 19:39:31 +08:00
height: 700rpx;
margin-top: 140rpx;
2020-06-09 14:29:43 +08:00
image{
width: 100%;
height: 100%;
}
}
.bottom{
2020-08-04 19:39:31 +08:00
margin-top: 180rpx;
2020-06-09 14:29:43 +08:00
padding: 20rpx 30rpx;
2020-08-01 11:16:53 +08:00
background-color: #fff;
2020-06-09 14:29:43 +08:00
.item{
2020-08-01 11:16:53 +08:00
display: flex;
align-items: center;
2020-08-03 14:26:52 +08:00
width: 50%;
2020-06-09 14:29:43 +08:00
padding: 8rpx 16rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx;
2020-08-01 11:16:53 +08:00
background-color: #999;
2020-06-09 14:29:43 +08:00
>view{
width: 12rpx;
height: 12rpx;
border-radius: 50%;
margin-left: 10rpx;
}
}
.username{
2020-08-01 11:16:53 +08:00
margin: 20rpx 0;
2020-06-09 14:29:43 +08:00
font-size: 36rpx;
color: #333;
}
.title{
font-size: 26rpx;
color: #333;
}
.info{
2020-08-01 11:16:53 +08:00
margin: 20rpx 0;
2020-08-04 19:39:31 +08:00
line-height: 1.2;
2020-06-09 14:29:43 +08:00
font-size: 28rpx;
}
2020-08-01 11:16:53 +08:00
.box {
display: flex;
flex-wrap: wrap;
.label {
padding: 6rpx 10rpx;
margin: 0 10rpx 10rpx 0;
font-size: 24rpx;
color: #fff;
border-radius: 6rpx;
background-color: #000000;
opacity: 0.5;
}
}
2020-06-09 14:29:43 +08:00
}
.userinfo{
position: absolute;
2020-08-01 11:16:53 +08:00
right: 30rpx;
2020-06-09 14:29:43 +08:00
top: 50%;
transform: translateY(-285rpx);
}
2020-08-01 17:22:46 +08:00
.pl {
.top {
2020-08-03 14:26:52 +08:00
z-index: 1000;
2020-08-01 17:22:46 +08:00
position: fixed;
top: 0;
width: 100%;
height: 88rpx;
padding: 0 20rpx;
line-height: 88rpx;
background-color: #ECECEC;
& > text {
margin-right: 280rpx;
color: #333;
font-size: 30rpx;
font-weight: 500;
}
}
.scroll-box {
2020-08-03 14:26:52 +08:00
z-index: 99;
margin: 88rpx 0 150rpx 0;
2020-08-01 17:22:46 +08:00
height: 100%;
2020-08-03 14:26:52 +08:00
.box {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx;
& > image {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
margin-right: 10rpx;
}
.info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 60rpx;
font-size: 26rpx;
color: #333;
.time {
font-size: 22rpx;
color: #999;
}
}
.reply {
font-size: 26rpx;
color: #333;
}
}
.content {
padding: 0 20rpx 10rpx 90rpx;
}
2020-08-03 19:51:05 +08:00
.child-content {
margin: 6rpx 90rpx 6rpx;
.more-reply {
font-size: 22rpx;
color: #999;
}
}
2020-08-03 14:26:52 +08:00
}
.no-data {
margin-top: 100rpx;
2020-08-01 17:22:46 +08:00
}
.editing {
position: fixed;
bottom: 0;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
2020-08-03 14:26:52 +08:00
height: 88rpx;
2020-08-01 17:22:46 +08:00
padding: 0 30rpx;
2020-08-03 14:26:52 +08:00
border-top: 1px solid #ececec;
background-color: #fff;
2020-08-01 17:22:46 +08:00
& > input {
width: 80%;
2020-08-03 14:26:52 +08:00
height: 50rpx;
2020-08-01 17:22:46 +08:00
padding: 0 20rpx;
2020-08-03 14:26:52 +08:00
border-radius: 20rpx;
2020-08-01 17:22:46 +08:00
background-color: #fff;
}
}
}
2020-08-03 14:26:52 +08:00
// 弹出输入框
.edit-box {
display: flex;
align-items: center;
height: 90rpx;
& > input {
width: 80%;
padding: 4rpx 20rpx;
border-radius: 20rpx;
}
}
2020-08-01 17:22:46 +08:00
.cart {
.top{
z-index: 1000;
position: fixed;
top: 0;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 88rpx;
padding: 0 30rpx;
border-bottom: 1rpx solid #ececec;
background-color: #fff;
>text{
font-size: 30rpx;
color: #333;
}
}
.scroll-box {
margin-top: 88rpx;
.item {
display: flex;
padding: 20rpx;
border-bottom: 1px solid #ECECEC;
& > image {
flex-shrink: 0;
width: 160rpx;
height: 160rpx;
margin-right: 14rpx;
border-radius: 10rpx;
}
& > view {
display: flex;
flex-direction: column;
justify-content: space-between;
color: #333;
font-size: 28rpx;
.title {
}
.name {
width: 500rpx;
height: 80rpx;
font-size: 24rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.price {
color: #FF3131;
}
}
}
}
}
.good-one{
2020-06-09 14:29:43 +08:00
z-index: 999;
2020-08-01 11:16:53 +08:00
position: absolute;
2020-06-09 14:29:43 +08:00
right: 139rpx;
2020-08-01 11:16:53 +08:00
top: 54%;
2020-06-09 14:29:43 +08:00
transform: translateY(100rpx);
2020-08-01 17:22:46 +08:00
.box {
display: flex;
align-items: center;
width: 440rpx;
height: 200rpx;
padding: 20rpx;
font-size: 28rpx;
color: #fff;
border-radius: 10rpx;
background-color: rgba(0,0,0,0.5);
& > image {
flex-shrink: 0;
width: 160rpx;
height: 100%;
margin-right: 10rpx;
border-radius: 10rpx;
}
& > view {
width: 200rpx;
}
.title {}
.content {
height: 60rpx;
margin: 10rpx 0;
font-size: 24rpx;
}
.price {
color: #FF3131;
}
}
2020-06-09 14:29:43 +08:00
}
}
</style>
<script>
2020-08-01 11:16:53 +08:00
import userinfo from "../components/userinfo/index" // 点赞组件
2020-08-01 17:22:46 +08:00
import contentBox from "../components/shpoone/index" // 评论
// import shoplist from "../components/shoplist/index" // 商品列表
2020-06-09 14:29:43 +08:00
export default {
name:"photo",
components:{
2020-08-01 17:22:46 +08:00
userinfo
2020-07-20 08:43:13 +08:00
},
data(){
return {
2020-08-01 11:16:53 +08:00
list:{},
swiper_id: "",
2020-08-03 14:26:52 +08:00
cart_type: false, // 显示购物车
is_comment: false, // 显示评论
is_focus: false, // 聚焦
is_edit: false, // 输入框
send_value: "", // 输入的值
2020-08-01 17:22:46 +08:00
cartList: [],
cart_len: 0,
2020-08-03 14:26:52 +08:00
edit_text: "有爱评论,说点好听的 ~",
2020-08-03 19:51:05 +08:00
edit_text_other: "有爱评论,说点好听的 ~",
2020-08-03 14:26:52 +08:00
commentList: [], // 评论
2020-08-03 19:51:05 +08:00
allList: {}, // 全部子评论
2020-07-20 08:43:13 +08:00
}
},
2020-08-03 14:26:52 +08:00
onLoad(option){
this.article_id = option.id;
this.articleInfo(this.article_id);
2020-08-01 17:22:46 +08:00
},
2020-08-03 19:51:05 +08:00
// 监听返回按钮
onBackPress() {
if (this.cart_type) {
this.cart_type = !this.cart_type;
} else if (this.is_comment) {
this.is_comment = !this.is_comment;
} else if (this.is_edit) {
this.is_edit = !this.is_edit;
} else {
return false;
}
return true;
},
2020-07-20 08:43:13 +08:00
methods:{
2020-08-01 11:16:53 +08:00
// 发现详情
2020-07-20 08:43:13 +08:00
articleInfo(article_id){
this.$u.api.articleInfo({article_id}).then((res)=>{
2020-08-01 11:16:53 +08:00
this.list = res.data.info;
2020-08-01 17:22:46 +08:00
this.cart_len = res.data.info.goods.length;
2020-07-20 08:43:13 +08:00
})
2020-07-31 08:45:30 +08:00
},
2020-08-01 11:16:53 +08:00
// 改变swiper
changeSwiper(e) {
// console.log(e.detail.current);
this.swiper_id = e.detail.current; // 储存swiper id
},
// 更改购物车状态
2020-08-03 14:26:52 +08:00
openPopup(data) {
// console.log(data);
2020-08-01 17:22:46 +08:00
this.cart_type = data.cart;
this.is_comment = data.comment;
2020-08-03 14:26:52 +08:00
if (this.is_comment) {
this.getComment(this.article_id,0);
}
2020-08-01 11:16:53 +08:00
},
2020-08-03 14:26:52 +08:00
// 获取评论
getComment(id,page) {
this.$u.post("article/articleCommentList",{
article_id: id,
page: page,
}).then(res => {
console.log(res);
if (res.errCode == 0) {
this.commentList = res.data;
}
})
2020-08-01 17:22:46 +08:00
},
2020-08-03 14:26:52 +08:00
// 打开评论输入
2020-08-03 19:51:05 +08:00
openKeyInput(data,index) {
2020-08-03 14:26:52 +08:00
console.log(data);
this.is_edit = true;
this.is_focus = true;
2020-08-03 19:51:05 +08:00
this.comment_id = index;
if (data.id) {
this.edit_text_other = "回复@" + data.member_nickname;
this.pid = data.id;
this.reply_id = data.member_id;
} else {
this.edit_text_other = "有爱评论,说点好听的 ~";
this.pid = "";
this.reply_id = "";
}
// console.log(this.pid, this.edit_text_other);
2020-08-03 14:26:52 +08:00
},
// 发布评论
2020-08-03 19:51:05 +08:00
sendComment() {
2020-08-03 14:26:52 +08:00
this.$u.post("article/articleAddComment",{
article_id: this.article_id,
content: this.send_value,
2020-08-03 19:51:05 +08:00
pid: this.pid,
reply_id: this.reply_id,
2020-08-03 14:26:52 +08:00
}).then(res => {
2020-08-03 19:51:05 +08:00
// console.log(res.data.data);
2020-08-03 14:26:52 +08:00
if (res.errCode == 0) {
this.is_edit = false;
2020-08-03 19:51:05 +08:00
if (res.data.data.pid) {
this.commentList[this.comment_id].reply_count = true;
this.allList[this.comment_id].unshift(res.data.data);
} else {
this.commentList.unshift(res.data.data);
}
2020-08-03 14:26:52 +08:00
} else {
this.$u.toast(res.message);
}
})
2020-08-01 11:16:53 +08:00
},
// 预览图片
viewImage(e) {
2020-08-01 17:22:46 +08:00
let arr = [];
this.list.photo.forEach(item => {
arr.push(item.url);
})
uni.previewImage({
urls: arr,
current: e.currentTarget.dataset.url,
})
},
// 跳转到商品
gotoInfo(id) {
console.log(id);
uni.navigateTo({
url: "/pageB/sdetails/index?id=" + id + "&type=" + 1,
})
2020-08-01 11:16:53 +08:00
},
2020-07-31 08:45:30 +08:00
goBack() {
uni.navigateBack({
delta: 1
})
2020-08-03 14:26:52 +08:00
},
focus() {
setTimeout(function(){
uni.showSoftKeybord;
}, 200)
2020-07-31 08:45:30 +08:00
}
2020-07-20 08:43:13 +08:00
},
2020-06-09 14:29:43 +08:00
}
</script>