dynamic-items.vue 8.8 KB

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