deming/pageB/components/userinfo/index.vue

162 lines
4.4 KiB
Vue
Raw Normal View History

2020-06-09 06:29:43 +00:00
<template>
<view class="userinfo">
<view class="userhead">
2020-08-01 03:16:53 +00:00
<image :src="item.member_avatar"></image>
<text class="follow" v-if="!is_follow" @click="following(item.member_id)">+</text>
2020-08-01 09:22:46 +00:00
<u-icon v-else name="checkmark" color="#ffffff" :size="28" class="follow" @click="following(item.member_id)"></u-icon>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00:00
<!-- 点赞 -->
<view class="operat zan">
<u-icon name="thumb-up-fill" :color=" is_like ? '#FF7807' : '#ffffff' " :size="50" @click="likeType(item.article_id)"></u-icon>
<text>{{item.like_num}}</text>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00:00
<!-- 收藏 -->
<view class="operat shoucang">
<u-icon name="star-fill" :color=" is_collect ? '#FF7807' : '#ffffff' " :size="50" @click="collecting(item.article_id)"></u-icon>
<text>{{item.collect_num}}</text>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00:00
<!-- 评论 -->
<view class="operat pinglun">
2020-08-01 09:22:46 +00:00
<u-icon name="more-circle-fill" :color=" is_content ? '#FF7807' : '#ffffff' " :size="50" @click="editing()"></u-icon>
2020-08-07 11:56:47 +00:00
<text>{{ comment_num }}</text>
2020-06-09 06:29:43 +00:00
</view>
2020-08-01 03:16:53 +00:00
<!-- 购物车 -->
<view class="operat gouwu">
<u-icon name="shopping-cart-fill" :color=" is_cart ? '#FF7807' : '#ffffff' " :size="50" @click="carting()"></u-icon>
2020-06-09 06:29:43 +00:00
</view>
</view>
</template>
<style lang="scss" scoped>
.userinfo{
width: 110rpx;
height: 570rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
2020-08-01 03:16:53 +00:00
.userhead{
position: relative;
2020-06-09 06:29:43 +00:00
display: flex;
position: relative;
align-items: center;
2020-08-01 03:16:53 +00:00
&>image{
width: 110rpx;
height: 110rpx;
border-radius: 50%;
border: 2rpx solid #fff;
}
.follow {
position: absolute;
top: 90rpx;
left: 35%;
width: 36rpx;
height: 36rpx;
text-align: center;
line-height: 36rpx;
font-size: 36rpx;
border-radius: 50%;
color: #fff;
background-color: #FF780F;
}
2020-06-09 06:29:43 +00:00
}
2020-08-01 03:16:53 +00:00
.operat {
display: flex;
align-items: center;
flex-direction: column;
& > text {
margin-top: 10rpx;
font-size: 28rpx;
color: #fff;
}
}
2020-06-09 06:29:43 +00:00
}
</style>
<script>
export default {
name:'userinfo',
2020-08-07 11:56:47 +00:00
props:['list','cart','comment','num'],
2020-06-09 06:29:43 +00:00
data(){
return {
2020-08-01 03:16:53 +00:00
is_follow: this.list.is_attention || false,
is_like: this.list.is_like || false,
is_collect: this.list.is_collect || false,
is_content: false,
2020-08-01 09:22:46 +00:00
is_cart: false,
2020-08-07 11:56:47 +00:00
comment_num: this.list.comment_num || 0,
2020-08-01 09:22:46 +00:00
item: this.list || {}
2020-06-09 06:29:43 +00:00
}
2020-07-20 00:43:13 +00:00
},
2020-08-01 03:16:53 +00:00
watch: {
list(newValue,old) {
2020-08-01 09:22:46 +00:00
// console.log(newValue,old);
this.item = newValue || {};
this.is_follow = this.list.is_attention || false;
this.is_like = this.list.is_like || false;
this.is_collect = this.list.is_collect || false;
2020-08-07 11:56:47 +00:00
this.comment_num = this.list.comment_num || 0;
2020-08-01 03:16:53 +00:00
},
cart(newValue,old) {
2020-08-07 11:56:47 +00:00
// console.log(newValue);
2020-08-01 03:16:53 +00:00
this.is_cart = newValue;
},
2020-08-01 09:22:46 +00:00
comment(newValue,old) {
2020-08-03 06:26:52 +00:00
// console.log(newValue,old);
2020-08-01 09:22:46 +00:00
this.is_content = newValue;
},
2020-08-07 11:56:47 +00:00
num(newVal,old) {
// console.log(newVal);
this.comment_num = newVal;
// this.item.comment_num = newVal;
},
2020-08-01 03:16:53 +00:00
deep: true
},
methods: {
// 关注
following(id) {
this.$u.api.attentionMember({member_id: id}).then(res => {
if (res.errCode == 0) {
2020-08-06 12:42:03 +00:00
this.is_follow = !this.is_follow;
2020-08-01 03:16:53 +00:00
this.$u.toast(res.message);
}
})
},
// 点赞
likeType(id) {
// console.log(id);
this.$u.post("article/articleLike",{article_id: id}).then(res => {
if (res.errCode == 0) {
// console.log(res);
2020-08-06 12:42:03 +00:00
this.is_like = !this.is_like;
2020-08-01 03:16:53 +00:00
this.list.like_num = res.data.num;
} else {
this.$u.toast(res.message);
}
})
},
// 收藏
collecting(id) {
this.$u.post("article/articleCollect",{article_id: id}).then(res => {
if (res.errCode == 0) {
// console.log(res);
2020-08-06 12:42:03 +00:00
this.is_collect = !this.is_collect;
2020-08-01 03:16:53 +00:00
this.list.collect_num = res.data.num;
} else {
this.$u.toast(res.message);
}
})
},
// 评论
2020-08-01 09:22:46 +00:00
editing() {
this.is_content = !this.is_content;
// console.log(this.is_content);
this.$emit("openCart",{ comment: this.is_content, cart: this.is_cart});
},
2020-08-01 03:16:53 +00:00
// 购物车
carting() {
this.is_cart = !this.is_cart;
// console.log(this.is_cart);
2020-08-01 09:22:46 +00:00
this.$emit("openCart",{ comment: this.is_content, cart: this.is_cart});
2020-08-01 03:16:53 +00:00
},
}
2020-06-09 06:29:43 +00:00
}
</script>