dynamic-items.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. export default {
  79. name: "dynamic-items",
  80. components: {DynamicTag, ImgThree, ImgTwo, ImgOne},
  81. props: {
  82. userId:{
  83. default:0
  84. },
  85. textColor:{
  86. type:String,
  87. default:'#fff'
  88. },
  89. tagColor:{
  90. type:String,
  91. default:'#282828'
  92. },
  93. tagBg:{
  94. type:String,
  95. default:'rgba(255,255,255,0.4)'
  96. },
  97. operateColor:{
  98. type:String,
  99. default:'#fff'
  100. },
  101. divisionColor:{
  102. type:String,
  103. default:'rgba(255,255,255,0.2)'
  104. },
  105. showAdd:{
  106. type:Boolean,
  107. default:false
  108. },
  109. },
  110. data() {
  111. return {
  112. list:[],
  113. isAjax:false,
  114. total:undefined,
  115. page:1,
  116. }
  117. },
  118. watch: {
  119. 'userId':function () {
  120. this.startList()
  121. }
  122. },
  123. mounted() {
  124. this.startList()
  125. },
  126. methods: {
  127. startList(){
  128. if(this.userId<=0){
  129. // return false
  130. }
  131. this.list=[]
  132. this.isAjax=false
  133. this.total=undefined
  134. this.page=1
  135. this.getMoments()
  136. },
  137. getMoments(){
  138. if(this.isAjax){
  139. return
  140. }
  141. this.isAjax=true
  142. let that=this
  143. getMoments({'userId':this.userId,'pageNo':this.page,'pageSize':20}).then((res)=>{
  144. this.isAjax=false
  145. if(res.code===0){
  146. res.data.data.forEach((item)=>{
  147. item.dateArr=tools.getDateArr(item.createdAt)
  148. that.list.push(item )
  149. })
  150. ++that.page
  151. that.total=res.data.total
  152. }
  153. })
  154. },
  155. setLike(index){
  156. this.dynamicList[index].liked=!this.dynamicList[index].liked
  157. if(this.dynamicListdynamicList[index].liked){
  158. ++this.dynamicList[index].likeCount
  159. }else {
  160. --this.dynamicList[index].likeCount
  161. }
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. @import "/static/css/en-iconfont.css";
  168. .dynamic-item-box{
  169. .dynamic-item{
  170. margin-top: 16rpx;
  171. .dynamic-title{
  172. display: flex;
  173. justify-content: space-between;
  174. .dynamic-title-left{
  175. display:table-cell;
  176. vertical-align:bottom;
  177. .dynamic-title-text{
  178. font-size: 28rpx;
  179. }
  180. .dynamic-title-text:first-child{
  181. font-size: 48rpx;
  182. margin-right: 12rpx;
  183. }
  184. }
  185. .dynamic-title-right{
  186. .dynamic-right-img{
  187. width: 6rpx;
  188. height: 26rpx;
  189. }
  190. }
  191. }
  192. .dynamic-data{
  193. margin-left: 26rpx;
  194. border-left: 1rpx solid rgba(255,255,255,0.2);
  195. padding: 4rpx 0 44rpx 40rpx;
  196. .data-issue{
  197. display: flex;
  198. justify-content: space-between;
  199. align-items: center;
  200. height: 92rpx;
  201. .issue-left{
  202. display: flex;
  203. justify-content: flex-start;
  204. .left-one{
  205. border-radius: 8rpx;
  206. height: 92rpx;
  207. width: 92rpx;
  208. margin-right: 22rpx;
  209. }
  210. .left-two{
  211. .two-title{
  212. font-size: 32rpx;
  213. }
  214. .two-text{
  215. font-size: 28rpx;
  216. }
  217. }
  218. }
  219. .issue-right{
  220. border: 2rpx solid #E0E0E0;
  221. border-radius: 200rpx;
  222. padding: 8rpx 24rpx;
  223. font-size: 28rpx;
  224. }
  225. }
  226. .data-text{
  227. .text-item{
  228. font-size: 28rpx;
  229. }
  230. }
  231. .data-img{
  232. margin-top: 30rpx;
  233. }
  234. .data-tag-list{
  235. margin-top: 28rpx;
  236. }
  237. .data-operation{
  238. margin-top: 40rpx;
  239. display: flex;
  240. justify-content: flex-start;
  241. .operation-item{
  242. width: 200rpx;
  243. display: flex;
  244. justify-content: flex-start;
  245. .operation-img{
  246. width: 40rpx;
  247. height: 40rpx;
  248. margin-right: 8rpx;
  249. }
  250. .operation-icon{
  251. width: 40rpx;
  252. height: 40rpx;
  253. margin-right: 8rpx;
  254. text{
  255. font-size: 40rpx;
  256. line-height: 40rpx;
  257. }
  258. }
  259. .operation-text{
  260. height: 40rpx;
  261. line-height: 41rpx;
  262. font-size: 26rpx;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. </style>