y-DiaryItem.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view :class="['card-item',radius ? 'radius' : '']">
  3. <view class="item-head">
  4. <view class="left-info">
  5. <view class="img-wrap flex-center" @tap="toOthers(item.id)">
  6. <image :src="item.avatarUrl" mode="widthFix" class="avatar"></image>
  7. </view>
  8. <view class="head-name">{{ item.nickName }}</view>
  9. </view>
  10. <text class="color-nine">{{item.createTime}}</text>
  11. </view>
  12. <view class="content" @tap="toDetails(item.id)">
  13. <view class="text-content">{{ item.title }}</view>
  14. <view class="img-wrap padding-bottom-lg" v-if="item.imgList.length == 1">
  15. <view class="img-box">
  16. <image v-for="(child, idx) in item.imgList" :key="idx" :src="child" mode="widthFix" class="img" @tap.stop @tap="Dever.viewPic([child], child)"></image>
  17. </view>
  18. </view>
  19. <view class="img-list padding-bottom-lg" v-if="item.imgList.length > 1">
  20. <view class="img-box" v-for="(child, idx) in item.imgList" :key="idx">
  21. <image :src="child" mode="widthFix" class="img" @tap.stop @tap="Dever.viewPic(item.imgList, child)"></image>
  22. </view>
  23. </view>
  24. <view class="bottom-btn padding-bottom-sm">
  25. <view class="btn-item flex-center">
  26. <image class="img" src="@/static/img/diary/img_say.png" mode="widthFix"></image>
  27. <text>{{ item.commentNum }}</text>
  28. </view>
  29. <view class="btn-item flex-center" @tap.stop @tap="handleLike(item.id, item.isLike, item.likeNum)">
  30. <image class="img" v-if="!item.isLike" src="@/static/img/diary/img_zan.png" mode="widthFix"></image>
  31. <image class="img" v-else src="@/static/img/diary/img_zan_1.png" mode="widthFix"></image>
  32. <text>{{ item.likeNum }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. props: {
  41. obj: {
  42. type: Object
  43. },
  44. radius:{
  45. type: Boolean,
  46. default: false
  47. }
  48. },
  49. data() {
  50. return {
  51. item: this.obj,
  52. showPop: false,
  53. commentList: []
  54. };
  55. },
  56. watch: {
  57. obj(val) {
  58. this.list = val;
  59. }
  60. },
  61. methods: {
  62. handleFollow(id) {
  63. let that = this;
  64. that.item.follow = !that.item.follow;
  65. },
  66. toDetails(id) {
  67. uni.navigateTo({
  68. url: '../../pages/diary/details?id=' + id
  69. });
  70. },
  71. handleLike(id, isLike, likeNum) {
  72. let that = this;
  73. if (that.item.isLike) {
  74. that.item.likeNum--;
  75. } else {
  76. that.item.likeNum++;
  77. }
  78. that.item.isLike = !that.item.isLike;
  79. },
  80. toOthers() {
  81. uni.navigateTo({
  82. url: '../../pages/mine/other'
  83. });
  84. },
  85. }
  86. };
  87. </script>
  88. <style lang="less" scoped>
  89. .flex-center {
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. }
  94. .bottom-btn {
  95. display: flex;
  96. .btn-item {
  97. flex: 1;
  98. color: var(--mainColor);
  99. .img {
  100. width: 50rpx;
  101. height: 50rpx;
  102. margin-right: 20rpx;
  103. }
  104. }
  105. }
  106. .padding-bottom-sm {
  107. padding-bottom: 9px;
  108. text-align: center;
  109. padding-top: 12px;
  110. }
  111. .radius{
  112. border-radius: 16rpx;
  113. }
  114. .card-item {
  115. padding: 20rpx 40rpx 0rpx;
  116. background-color: #ffffff;
  117. box-shadow: 0 20rpx 40rpx 0 rgba(0, 0, 0, 0.1);
  118. .item-head {
  119. display: flex;
  120. align-items: center;
  121. width: 100%;
  122. justify-content: space-between;
  123. .left-info {
  124. display: flex;
  125. align-items: center;
  126. .img-wrap {
  127. width: 80rpx;
  128. height: 80rpx;
  129. overflow: hidden;
  130. border-radius: 50%;
  131. .avatar {
  132. width: 100%;
  133. height: 80rpx;
  134. }
  135. }
  136. .head-name {
  137. padding-left: 40rpx;
  138. color: #666666;
  139. font-size: 32rpx;
  140. }
  141. }
  142. .follow-btn {
  143. width: 140rpx;
  144. height: 60rpx;
  145. border: 1rpx solid var(--mainColor);
  146. color: var(--mainColor);
  147. border-radius: 40rpx;
  148. }
  149. .followed {
  150. color: #fff;
  151. background: var(--activeColor);
  152. border: 1rpx solid var(--activeColor);
  153. }
  154. }
  155. .content {
  156. .text-content {
  157. padding: 40rpx 0;
  158. justify-content: space-between;
  159. color: var(--mainColor);
  160. font-size: 30rpx;
  161. text-align: justify;
  162. }
  163. .img-list {
  164. display: flex;
  165. flex-flow: row wrap;
  166. .img-box {
  167. flex: 0 0 30%;
  168. margin: 0 1% 1%;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. overflow: hidden;
  173. height: 200rpx;
  174. border-radius: 4px;
  175. background-color: #ececec;
  176. .img {
  177. width: 100%;
  178. }
  179. }
  180. }
  181. .img-wrap {
  182. .img-box {
  183. width: 100%;
  184. max-height: 400rpx;
  185. overflow: hidden;
  186. display: flex;
  187. align-items: center;
  188. }
  189. }
  190. }
  191. }
  192. .cont {
  193. --color: var(--activeColor);
  194. --count: 1;
  195. }
  196. </style>