dynamic-items.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. {{dynamicList.length}}
  23. <view class="dynamic-item" v-for="(item,itemIndex) in dynamicList">
  24. 12121
  25. <view class="dynamic-title">
  26. <view class="dynamic-title-left">
  27. <text class="dynamic-title-text sys-weight-600" :style="{'color':textColor}">item.dateArr[2]</text>
  28. <text class="dynamic-title-text sys-weight-400" :style="{'color':textColor}">item.dateArr[1]月</text>
  29. <text class="dynamic-title-text sys-weight-400" :style="{'color':textColor}">item.dateArr[0]年</text>
  30. </view>
  31. <view class="dynamic-title-right">
  32. <image class="dynamic-right-img" mode="aspectFill" src="/static/img/index/dynamic-all.png" ></image>
  33. </view>
  34. </view>
  35. <view class="dynamic-data" :style="{'border-left':' 1rpx solid '+divisionColor}">
  36. <view class="data-text">
  37. <text class="text-item" :style="{'color':textColor}">{{item.content}}</text>
  38. </view>
  39. <view class="data-img" v-if="item.galleryUrls.length>0">
  40. <view class="one-img" v-if="item.galleryUrls.length===1">
  41. <img-one :file-list="item.galleryUrls"></img-one>
  42. </view>
  43. <view class="two-img" v-else-if="item.galleryUrls.length===2 || item.galleryUrls.length===4">
  44. <img-two :file-list="item.galleryUrls"></img-two>
  45. </view>
  46. <view class="three-img" v-else>
  47. <img-three :file-list="item.galleryUrls"></img-three>
  48. </view>
  49. </view>
  50. <view class="data-tag-list" v-if="false" >
  51. <dynamic-tag :list="item.tag" :tag-bg="tagBg" :tag-color="tagColor"></dynamic-tag>
  52. </view>
  53. <view class="data-operation">
  54. <view class="operation-item" @click="setLike(itemIndex)">
  55. <!-- <image class="operation-img" mode="aspectFill" :src="'/static/img/index/like-'+(item.isLike?'ok':'no')+'.png'" ></image>-->
  56. <view class="operation-icon">
  57. <text class="iconfont icon-dianzan" v-if="!item.liked" :style="{'color':operateColor}"> &#xe8ad;</text>
  58. <text class="iconfont icon-dianzan1" v-else :style="{'color':'#ED301D'}"> &#xe8c3;</text>
  59. </view>
  60. <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.likeCount>0?item.likeCount:'点赞'}}</view>
  61. </view>
  62. <view class="operation-item">
  63. <!-- <image class="operation-img" mode="aspectFill" src="/static/img/index/evaluate.png" ></image>-->
  64. <view class="operation-icon"><text class="iconfont icon-pinglun" :style="{'color':operateColor}">&#xe891;</text></view>
  65. <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.commentCount>0?item.commentCount:'评论'}}</view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import ImgOne from "@/pages/common/img/img-one";
  74. import ImgTwo from "@/pages/common/img/img-two";
  75. import ImgThree from "@/pages/common/img/img-three";
  76. import DynamicTag from "@/pages/common/tag/dynamic-tag";
  77. import {getMoments} from "@/api/discovery";
  78. import tools from "@/service/tools";
  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. page:1,
  114. total:undefined,
  115. isAjax:false,
  116. dynamicList:[]
  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.dynamicList=[]
  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. // console.log(this.dynamicList)
  148. res.data.data.forEach((item)=>{
  149. item.dateArr=tools.getDateArr(item.createdAt)
  150. console.log(that.dynamicList)
  151. that.dynamicList.push(item)
  152. })
  153. // console.log( this.dynamicList)
  154. // console.log( this.dynamicList.length)
  155. ++that.page
  156. that.total=res.data.total
  157. }
  158. })
  159. },
  160. setLike(index){
  161. this.dynamicList[index].liked=!this.dynamicList[index].liked
  162. if(this.dynamicListdynamicList[index].liked){
  163. ++this.dynamicList[index].likeCount
  164. }else {
  165. --this.dynamicList[index].likeCount
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. @import "/static/css/en-iconfont.css";
  173. .dynamic-item-box{
  174. .dynamic-item{
  175. margin-top: 16rpx;
  176. .dynamic-title{
  177. display: flex;
  178. justify-content: space-between;
  179. .dynamic-title-left{
  180. display:table-cell;
  181. vertical-align:bottom;
  182. .dynamic-title-text{
  183. font-size: 28rpx;
  184. }
  185. .dynamic-title-text:first-child{
  186. font-size: 48rpx;
  187. margin-right: 12rpx;
  188. }
  189. }
  190. .dynamic-title-right{
  191. .dynamic-right-img{
  192. width: 6rpx;
  193. height: 26rpx;
  194. }
  195. }
  196. }
  197. .dynamic-data{
  198. margin-left: 26rpx;
  199. border-left: 1rpx solid rgba(255,255,255,0.2);
  200. padding: 4rpx 0 44rpx 40rpx;
  201. .data-issue{
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. height: 92rpx;
  206. .issue-left{
  207. display: flex;
  208. justify-content: flex-start;
  209. .left-one{
  210. border-radius: 8rpx;
  211. height: 92rpx;
  212. width: 92rpx;
  213. margin-right: 22rpx;
  214. }
  215. .left-two{
  216. .two-title{
  217. font-size: 32rpx;
  218. }
  219. .two-text{
  220. font-size: 28rpx;
  221. }
  222. }
  223. }
  224. .issue-right{
  225. border: 2rpx solid #E0E0E0;
  226. border-radius: 200rpx;
  227. padding: 8rpx 24rpx;
  228. font-size: 28rpx;
  229. }
  230. }
  231. .data-text{
  232. .text-item{
  233. font-size: 28rpx;
  234. }
  235. }
  236. .data-img{
  237. margin-top: 30rpx;
  238. }
  239. .data-tag-list{
  240. margin-top: 28rpx;
  241. }
  242. .data-operation{
  243. margin-top: 40rpx;
  244. display: flex;
  245. justify-content: flex-start;
  246. .operation-item{
  247. width: 200rpx;
  248. display: flex;
  249. justify-content: flex-start;
  250. .operation-img{
  251. width: 40rpx;
  252. height: 40rpx;
  253. margin-right: 8rpx;
  254. }
  255. .operation-icon{
  256. width: 40rpx;
  257. height: 40rpx;
  258. margin-right: 8rpx;
  259. text{
  260. font-size: 40rpx;
  261. line-height: 40rpx;
  262. }
  263. }
  264. .operation-text{
  265. height: 40rpx;
  266. line-height: 41rpx;
  267. font-size: 26rpx;
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. </style>