dynamic-items.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="dynamic-item-box">
  3. <view class="dynamic-item" v-show="showAdd">
  4. <view class="dynamic-title">
  5. <view class="dynamic-title-left">
  6. <text class="dynamic-title-text sys-weight-600" :style="{'color':textColor}">今天</text>
  7. </view>
  8. </view>
  9. <view class="dynamic-data" :style="{'border-left':' 1rpx solid '+divisionColor}">
  10. <view class="data-issue">
  11. <view class="issue-left">
  12. <image class="left-one" mode="aspectFill" src="/static/img/temporary/2.png" ></image>
  13. <view class="left-two">
  14. <view class="two-title sys-color-black sys-weight-600">发布动态</view>
  15. <view class="two-text sys-color-gray-9">认识更多朋友</view>
  16. </view>
  17. </view>
  18. <view class="issue-right sys-color-black sys-weight-600">去发布</view>
  19. </view>
  20. </view>
  21. </view>
  22. {{list.length}}
  23. <view class="dynamic-item" v-for="(item,itemIndex) in list">
  24. <view class="dynamic-title">
  25. <view class="dynamic-title-left" v-if="item.dateArr.length>0">
  26. <text class="dynamic-title-text sys-weight-600" :style="{'color':textColor}">{{item.dateArr[2]}}</text>
  27. <text class="dynamic-title-text sys-weight-400" :style="{'color':textColor}">{{item.dateArr[1]}}月</text>
  28. <text class="dynamic-title-text sys-weight-400" :style="{'color':textColor}">{{item.dateArr[0]}}年</text>
  29. </view>
  30. <view class="dynamic-title-right">
  31. <image class="dynamic-right-img" mode="aspectFill" src="/static/img/index/dynamic-all.png" ></image>
  32. </view>
  33. </view>
  34. <view class="dynamic-data" :style="{'border-left':' 1rpx solid '+divisionColor}">
  35. <view class="data-text">
  36. <text class="text-item" :style="{'color':textColor}">{{item.content}}</text>
  37. </view>
  38. <view class="data-img" v-if="item.galleryUrls">
  39. <view class="one-img" v-if="item.galleryUrls.length===1">
  40. <img-one :file-list="item.galleryUrls"></img-one>
  41. </view>
  42. <view class="two-img" v-else-if="item.galleryUrls.length===2 || item.galleryUrls.length===4">
  43. <img-two :file-list="item.galleryUrls"></img-two>
  44. </view>
  45. <view class="three-img" v-else>
  46. <img-three :file-list="item.galleryUrls"></img-three>
  47. </view>
  48. </view>
  49. <view class="data-tag-list" v-if="false" >
  50. <dynamic-tag :list="item.tag" :tag-bg="tagBg" :tag-color="tagColor"></dynamic-tag>
  51. </view>
  52. <view class="data-operation">
  53. <view class="operation-item" @click="setLike(itemIndex)">
  54. <!-- <image class="operation-img" mode="aspectFill" :src="'/static/img/index/like-'+(item.isLike?'ok':'no')+'.png'" ></image>-->
  55. <view class="operation-icon">
  56. <text class="iconfont icon-dianzan" v-if="!item.liked" :style="{'color':operateColor}"> &#xe8ad;</text>
  57. <text class="iconfont icon-dianzan1" v-else :style="{'color':'#ED301D'}"> &#xe8c3;</text>
  58. </view>
  59. <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.likeCount>0?item.likeCount:'点赞'}}</view>
  60. </view>
  61. <view class="operation-item">
  62. <!-- <image class="operation-img" mode="aspectFill" src="/static/img/index/evaluate.png" ></image>-->
  63. <view class="operation-icon"><text class="iconfont icon-pinglun" :style="{'color':operateColor}">&#xe891;</text></view>
  64. <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.commentCount>0?item.commentCount:'评论'}}</view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import ImgOne from "@/pages/common/img/img-one";
  73. import ImgTwo from "@/pages/common/img/img-two";
  74. import ImgThree from "@/pages/common/img/img-three";
  75. import DynamicTag from "@/pages/common/tag/dynamic-tag";
  76. import {getMoments} from "@/api/discovery";
  77. import tools from "@/service/tools";
  78. import {setLike, setUnLike} from "@/api/community";
  79. export default {
  80. name: "dynamic-items",
  81. components: {DynamicTag, ImgThree, ImgTwo, ImgOne},
  82. props: {
  83. userId:{
  84. default:0
  85. },
  86. textColor:{
  87. type:String,
  88. default:'#fff'
  89. },
  90. tagColor:{
  91. type:String,
  92. default:'#282828'
  93. },
  94. tagBg:{
  95. type:String,
  96. default:'rgba(255,255,255,0.4)'
  97. },
  98. operateColor:{
  99. type:String,
  100. default:'#fff'
  101. },
  102. divisionColor:{
  103. type:String,
  104. default:'rgba(255,255,255,0.2)'
  105. },
  106. showAdd:{
  107. type:Boolean,
  108. default:false
  109. },
  110. },
  111. data() {
  112. return {
  113. list:[],
  114. isAjax:false,
  115. total:undefined,
  116. page:1,
  117. }
  118. },
  119. watch: {
  120. 'userId':function () {
  121. this.startList()
  122. }
  123. },
  124. mounted() {
  125. this.startList()
  126. },
  127. methods: {
  128. startList(){
  129. if(this.userId<=0){
  130. // return false
  131. }
  132. this.list=[]
  133. this.isAjax=false
  134. this.total=undefined
  135. this.page=1
  136. this.getMoments()
  137. },
  138. getMoments(){
  139. if(this.isAjax){
  140. return
  141. }
  142. this.isAjax=true
  143. let that=this
  144. getMoments({'userId':this.userId,'pageNo':this.page,'pageSize':20}).then((res)=>{
  145. this.isAjax=false
  146. if(res.code===0){
  147. res.data.data.forEach((item)=>{
  148. item.dateArr=tools.getDateArr(item.createdAt)
  149. that.list.push(item )
  150. })
  151. ++that.page
  152. that.total=res.data.total
  153. }
  154. })
  155. },
  156. setLike(index){
  157. this.list[index].liked=!this.list[index].liked
  158. if(this.list[index].liked){
  159. ++this.list[index].likeCount
  160. setLike( this.list[index].id).then((res)=>{})
  161. }else {
  162. --this.list[index].likeCount
  163. setUnLike( this.list[index].id).then((res)=>{})
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. @import "/static/css/en-iconfont.css";
  171. .dynamic-item-box{
  172. .dynamic-item{
  173. margin-top: 16rpx;
  174. .dynamic-title{
  175. display: flex;
  176. justify-content: space-between;
  177. .dynamic-title-left{
  178. display:table-cell;
  179. vertical-align:bottom;
  180. .dynamic-title-text{
  181. font-size: 28rpx;
  182. }
  183. .dynamic-title-text:first-child{
  184. font-size: 48rpx;
  185. margin-right: 12rpx;
  186. }
  187. }
  188. .dynamic-title-right{
  189. .dynamic-right-img{
  190. width: 6rpx;
  191. height: 26rpx;
  192. }
  193. }
  194. }
  195. .dynamic-data{
  196. margin-left: 26rpx;
  197. border-left: 1rpx solid rgba(255,255,255,0.2);
  198. padding: 4rpx 0 44rpx 40rpx;
  199. .data-issue{
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. height: 92rpx;
  204. .issue-left{
  205. display: flex;
  206. justify-content: flex-start;
  207. .left-one{
  208. border-radius: 8rpx;
  209. height: 92rpx;
  210. width: 92rpx;
  211. margin-right: 22rpx;
  212. }
  213. .left-two{
  214. .two-title{
  215. font-size: 32rpx;
  216. }
  217. .two-text{
  218. font-size: 28rpx;
  219. }
  220. }
  221. }
  222. .issue-right{
  223. border: 2rpx solid #E0E0E0;
  224. border-radius: 200rpx;
  225. padding: 8rpx 24rpx;
  226. font-size: 28rpx;
  227. }
  228. }
  229. .data-text{
  230. .text-item{
  231. font-size: 28rpx;
  232. }
  233. }
  234. .data-img{
  235. margin-top: 30rpx;
  236. }
  237. .data-tag-list{
  238. margin-top: 28rpx;
  239. }
  240. .data-operation{
  241. margin-top: 40rpx;
  242. display: flex;
  243. justify-content: flex-start;
  244. .operation-item{
  245. width: 200rpx;
  246. display: flex;
  247. justify-content: flex-start;
  248. .operation-img{
  249. width: 40rpx;
  250. height: 40rpx;
  251. margin-right: 8rpx;
  252. }
  253. .operation-icon{
  254. width: 40rpx;
  255. height: 40rpx;
  256. margin-right: 8rpx;
  257. text{
  258. font-size: 40rpx;
  259. line-height: 40rpx;
  260. }
  261. }
  262. .operation-text{
  263. height: 40rpx;
  264. line-height: 41rpx;
  265. font-size: 26rpx;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. </style>