deming/pageB/photo/index.vue

468 lines
11 KiB
Vue
Raw Normal View History

2020-06-09 06:29:43 +00:00
<template>
<view class="photo">
2020-08-01 09:22:46 +00:00
<view class="status_bar"></view>
2020-06-09 06:29:43 +00:00
<view class="back">
2020-07-31 00:45:30 +00:00
<u-icon name="close" color="#999999" :size="30" @click="goBack"></u-icon>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00:00
<swiper class="swiper" circular autoplay @change="changeSwiper">
<swiper-item v-for="(simg,sindex) in list.photo" :key="sindex">
2020-08-01 09:22:46 +00:00
<image :src="simg.url" mode="aspectFill" @tap="viewImage" :data-url="simg.url"></image>
2020-06-09 06:29:43 +00:00
</swiper-item>
</swiper>
2020-08-01 09:22:46 +00:00
<view class="bottom">
2020-06-09 06:29:43 +00:00
<view class="item">
<text>图片</text>
2020-08-01 03:16:53 +00:00
<view v-for="(item,index) in list.photo" :key="index" :style="{'background-color':index == swiper_id ? '#fff' : '#ede8e8'}"></view>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00: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 09:22:46 +00:00
</view>
<!-- 用户操作 -->
2020-08-03 06:26:52 +00:00
<userinfo class="userinfo" :list="list" :cart="cart_type" :comment="is_comment" @openCart="openPopup"></userinfo>
2020-08-01 09:22:46 +00:00
<!-- 评论 -->
<u-popup v-model="is_comment" class="pl" mode="bottom" border-radius="10" height="700rpx">
<view class="top">
<text>评论</text>
2020-08-03 06:26:52 +00:00
<u-icon name="arrow-down" color="#333" size="28" @click="is_comment=false"></u-icon>
2020-08-01 09:22:46 +00:00
</view>
<scroll-view class="scroll-box" scroll-y="true" >
2020-08-03 06:26:52 +00:00
<block v-for="(item,index) in commentList" :key="index" v-if="commentList.length">
<view class="box">
<image :src="item.member_avatar" mode=""></image>
<view class="info">
<text>{{ item.member_nickname }}</text>
<text class="time">{{ item.create_time }}</text>
</view>
<text class="reply" @click="openKeyInput(item)">回复</text>
</view>
<view class="content">
{{ item.content }}
</view>
</block>
<view class="no-data" v-else>111</view>
2020-08-01 09:22:46 +00:00
</scroll-view>
2020-08-03 06:26:52 +00:00
<view class="editing" @click="openKeyInput()">
<input type="text" value="" :placeholder="edit_text" disabled="disabled" />
2020-08-01 09:22:46 +00:00
<text>发送</text>
</view>
</u-popup>
2020-08-03 06:26:52 +00:00
<!-- 评论box -->
<u-popup v-model="is_edit" mode="bottom" border-radius="10" height="100rpx">
<view class="edit-box">
<input type="text" :placeholder="edit_text" :focus="is_focus" @focus="focus" v-model="send_value">
<text @click="sendComment">发送</text>
</view>
</u-popup>
2020-08-01 09:22:46 +00: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)">
<image :src="item.goods_image" mode=""></image>
<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 06:29:43 +00:00
</view>
</template>
<style lang="scss" scoped>
.photo{
width: 100%;
2020-08-01 09:22:46 +00:00
height: 100%;
background-color: #ececec;
2020-06-09 06:29:43 +00:00
.back{
padding-top: 28rpx;
padding-right: 31rpx;
2020-07-29 07:04:57 +00:00
text-align: right;
2020-06-09 06:29:43 +00:00
}
.swiper{
2020-08-01 09:22:46 +00:00
width: 750rpx;
2020-06-09 06:29:43 +00:00
height: 702rpx;
margin-top: 102rpx;
image{
width: 100%;
height: 100%;
}
}
.bottom{
2020-08-01 09:22:46 +00:00
width: 100%;
margin-top: 150rpx;
2020-06-09 06:29:43 +00:00
padding: 20rpx 30rpx;
2020-08-01 03:16:53 +00:00
background-color: #fff;
2020-06-09 06:29:43 +00:00
.item{
2020-08-01 03:16:53 +00:00
display: flex;
align-items: center;
2020-08-03 06:26:52 +00:00
width: 50%;
2020-06-09 06:29:43 +00:00
padding: 8rpx 16rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx;
2020-08-01 03:16:53 +00:00
background-color: #999;
2020-06-09 06:29:43 +00:00
>view{
width: 12rpx;
height: 12rpx;
border-radius: 50%;
margin-left: 10rpx;
}
}
.username{
2020-08-01 03:16:53 +00:00
margin: 20rpx 0;
2020-06-09 06:29:43 +00:00
font-size: 36rpx;
color: #333;
}
.title{
font-size: 26rpx;
color: #333;
}
.info{
2020-08-01 03:16:53 +00:00
margin: 20rpx 0;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
2020-06-09 06:29:43 +00:00
font-size: 28rpx;
}
2020-08-01 03:16:53 +00: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 06:29:43 +00:00
}
.userinfo{
position: absolute;
2020-08-01 03:16:53 +00:00
right: 30rpx;
2020-06-09 06:29:43 +00:00
top: 50%;
transform: translateY(-285rpx);
}
2020-08-01 09:22:46 +00:00
.pl {
.top {
2020-08-03 06:26:52 +00:00
z-index: 1000;
2020-08-01 09:22:46 +00: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 06:26:52 +00:00
z-index: 99;
margin: 88rpx 0 150rpx 0;
2020-08-01 09:22:46 +00:00
height: 100%;
2020-08-03 06:26:52 +00: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;
border-bottom: 1px solid #ececec;
}
}
.no-data {
margin-top: 100rpx;
2020-08-01 09:22:46 +00:00
}
.editing {
position: fixed;
bottom: 0;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
2020-08-03 06:26:52 +00:00
height: 88rpx;
2020-08-01 09:22:46 +00:00
padding: 0 30rpx;
2020-08-03 06:26:52 +00:00
border-top: 1px solid #ececec;
background-color: #fff;
2020-08-01 09:22:46 +00:00
& > input {
width: 80%;
2020-08-03 06:26:52 +00:00
height: 50rpx;
2020-08-01 09:22:46 +00:00
padding: 0 20rpx;
2020-08-03 06:26:52 +00:00
border-radius: 20rpx;
2020-08-01 09:22:46 +00:00
background-color: #fff;
}
}
}
2020-08-03 06:26:52 +00:00
// 弹出输入框
.edit-box {
display: flex;
align-items: center;
height: 90rpx;
& > input {
width: 80%;
padding: 4rpx 20rpx;
border-radius: 20rpx;
}
}
2020-08-01 09:22:46 +00: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 06:29:43 +00:00
z-index: 999;
2020-08-01 03:16:53 +00:00
position: absolute;
2020-06-09 06:29:43 +00:00
right: 139rpx;
2020-08-01 03:16:53 +00:00
top: 54%;
2020-06-09 06:29:43 +00:00
transform: translateY(100rpx);
2020-08-01 09:22:46 +00: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 06:29:43 +00:00
}
}
</style>
<script>
2020-08-01 03:16:53 +00:00
import userinfo from "../components/userinfo/index" // 点赞组件
2020-08-01 09:22:46 +00:00
import contentBox from "../components/shpoone/index" // 评论
// import shoplist from "../components/shoplist/index" // 商品列表
2020-06-09 06:29:43 +00:00
export default {
name:"photo",
components:{
2020-08-01 09:22:46 +00:00
userinfo
2020-07-20 00:43:13 +00:00
},
data(){
return {
2020-08-01 03:16:53 +00:00
list:{},
swiper_id: "",
2020-08-03 06:26:52 +00:00
cart_type: false, // 显示购物车
is_comment: false, // 显示评论
is_focus: false, // 聚焦
is_edit: false, // 输入框
send_value: "", // 输入的值
2020-08-01 09:22:46 +00:00
cartList: [],
cart_len: 0,
2020-08-03 06:26:52 +00:00
edit_text: "有爱评论,说点好听的 ~",
commentList: [], // 评论
2020-07-20 00:43:13 +00:00
}
},
2020-08-03 06:26:52 +00:00
onLoad(option){
this.article_id = option.id;
this.articleInfo(this.article_id);
2020-08-01 09:22:46 +00:00
},
2020-07-20 00:43:13 +00:00
methods:{
2020-08-01 03:16:53 +00:00
// 发现详情
2020-07-20 00:43:13 +00:00
articleInfo(article_id){
this.$u.api.articleInfo({article_id}).then((res)=>{
2020-08-01 03:16:53 +00:00
this.list = res.data.info;
2020-08-01 09:22:46 +00:00
this.cart_len = res.data.info.goods.length;
2020-07-20 00:43:13 +00:00
})
2020-07-31 00:45:30 +00:00
},
2020-08-01 03:16:53 +00:00
// 改变swiper
changeSwiper(e) {
// console.log(e.detail.current);
this.swiper_id = e.detail.current; // 储存swiper id
},
// 更改购物车状态
2020-08-03 06:26:52 +00:00
openPopup(data) {
// console.log(data);
2020-08-01 09:22:46 +00:00
this.cart_type = data.cart;
this.is_comment = data.comment;
2020-08-03 06:26:52 +00:00
if (this.is_comment) {
this.getComment(this.article_id,0);
}
2020-08-01 03:16:53 +00:00
},
2020-08-03 06:26:52 +00: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 09:22:46 +00:00
},
2020-08-03 06:26:52 +00:00
// 打开评论输入
openKeyInput(data) {
console.log(data);
this.is_edit = true;
this.is_focus = true;
},
// 发布评论
sendComment(data) {
this.$u.post("article/articleAddComment",{
article_id: this.article_id,
content: this.send_value,
pid: data.id,
reply_id: data.member_id,
}).then(res => {
console.log(res);
if (res.errCode == 0) {
this.is_edit = false;
} else {
this.$u.toast(res.message);
}
})
2020-08-01 03:16:53 +00:00
},
// 预览图片
viewImage(e) {
2020-08-01 09:22:46 +00: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 03:16:53 +00:00
},
2020-07-31 00:45:30 +00:00
goBack() {
uni.navigateBack({
delta: 1
})
2020-08-03 06:26:52 +00:00
},
focus() {
setTimeout(function(){
uni.showSoftKeybord;
}, 200)
2020-07-31 00:45:30 +00:00
}
2020-07-20 00:43:13 +00:00
},
2020-06-09 06:29:43 +00:00
}
</script>