y-DiaryItem.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="cu-card dynamic no-card">
  3. <view class="cu-item shadow">
  4. <view class="cu-list menu-avatar">
  5. <view class="cu-item">
  6. <image :src="item.user.avatar" mode="widthFix" class="cu-avatar round lg"></image>
  7. <view class="content flex-sub">
  8. <view>{{ item.user.username }}</view>
  9. <view class="text-gray text-sm flex justify-between">
  10. {{ item.cdate_string }}
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="text-content">
  16. {{ item.content }}
  17. </view>
  18. <view v-if="item.pic.length > 0">
  19. <view class="grid flex-sub padding-lr col-1" v-if="item.pic.length == 1 && item.pic[0]">
  20. <view @tap.stop @tap="Dever.viewPic(item.pic, child)" class="bg-img only-img" :style="{backgroundImage: 'url('+child+')'}"
  21. v-for="(child, idx) in item.pic" :key="idx" v-if="child">
  22. </view>
  23. </view>
  24. <view class="grid flex-sub padding-lr col-3 grid-square" v-if="item.pic.length > 1">
  25. <view @tap.stop @tap="Dever.viewPic(item.pic, child)" class="bg-img" :style="{backgroundImage: 'url('+child+')'}"
  26. v-for="(child, idx) in item.pic" :key="idx">
  27. </view>
  28. </view>
  29. </view>
  30. <view class="text-gray text-sm text-right padding">
  31. <view class="icon-display" @click="updateOppose(item)">
  32. <text class="cuIcon-flashbuyfill margin-lr-xs" :class="item.is_oppose ? 'text-red' : ''"></text> {{item.num_oppose}}
  33. </view>
  34. <view class="icon-display" @click="updateUp(item)">
  35. <text class="cuIcon-appreciatefill margin-lr-xs" :class="item.is_up ? 'text-red' : ''"></text> {{item.num_up}}
  36. </view>
  37. <view class="icon-display" @click="updateComment(item.id)">
  38. <text class="cuIcon-messagefill margin-lr-xs"></text> {{item.num_comment}}
  39. </view>
  40. </view>
  41. <view class="cu-list menu-avatar comment solids-top" v-if="item.child.length">
  42. <view class="cu-item" v-for="(v, k) in item.child" :key="k">
  43. <image :src="v.user.avatar" mode="widthFix" class="cu-avatar round"></image>
  44. <view class="content">
  45. <view class="text-grey">{{v.user.username}}</view>
  46. <view class="text-content text-df text-content-margin">
  47. <text class="text-grey" v-if="v.to_uid > 0">回复@{{v.to_user.username}}:</text> {{v.content}}
  48. </view>
  49. <view class="margin-top-sm flex justify-between">
  50. <view class="text-gray text-df">{{v.cdate_string}}</view>
  51. <view class="text-gray">
  52. <view class="icon-display" @click="updateOppose(v)">
  53. <text class="cuIcon-flashbuyfill margin-lr-xs" :class="v.is_oppose ? 'text-red' : ''"></text> {{v.num_oppose}}
  54. </view>
  55. <view class="icon-display" @click="updateUp(v)">
  56. <text class="cuIcon-appreciatefill margin-lr-xs" :class="v.is_up ? 'text-red' : ''"></text> {{v.num_up}}
  57. </view>
  58. <view class="icon-display" @click="updateComment(item.id, v.id, v.uid)">
  59. <text class="cuIcon-messagefill margin-lr-xs"></text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="text-grey flex solid-bottom padding justify-center more" @click="getMore" v-if="item.child_total > 1">{{more}}</view>
  66. </view>
  67. </view>
  68. <view v-if="show">
  69. <publish :title="title" :is_upload="false" @hideModal="hideModal" @getRefresh="getRefresh" :cate_id="cate_id" :type="type" :type_id="type_id" :to_id="to_id" :to_uid="to_uid"></publish>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import publish from '@/lib/dever/components/publish.vue';
  75. export default {
  76. props: {
  77. item: {
  78. type: Object
  79. },
  80. radius:{
  81. type: Boolean,
  82. default: false
  83. },
  84. cate_id : null,
  85. },
  86. components:{
  87. publish
  88. },
  89. created() {
  90. this.more = '展开'+(this.item.child_total-1)+'条回复';
  91. if (this.item.child_total > 0) {
  92. this.id = this.item.child[0].id;
  93. }
  94. this.child = this.item.child;
  95. },
  96. data() {
  97. return {
  98. title : '回复话题',
  99. show : false,
  100. showPop: false,
  101. type : 20,
  102. type_id : 0,
  103. to_id : 0,
  104. to_uid : 0,
  105. page : 1,
  106. num : 5,
  107. more : '',
  108. id : 0,
  109. child : [],
  110. };
  111. },
  112. methods: {
  113. getRefresh : function(cate_id, type, type_id) {
  114. this.item.num_comment++;
  115. this.getMore(1, 1);
  116. },
  117. getMore : function(page, push) {
  118. var self = this;
  119. if (page && typeof(page) != 'object') {
  120. self.page = page;
  121. }
  122. if (self.page > 1 && self.more == '收起') {
  123. // 收起
  124. self.item.child = self.child;
  125. self.more = '展开'+(self.item.child_total-1)+'条回复';
  126. self.page = 1;
  127. return;
  128. }
  129. var send = {cate_id:self.cate_id, type:self.type, type_id:self.item.id, pg:self.page, noconcat:true};
  130. send.id = self.id;
  131. this.Dever.get(this, 'app/community/?l=api.info', send, function(t) {
  132. if (self.page == 1) {
  133. self.item.child = self.child;
  134. }
  135. if (t.info && t.info.length > 0) {
  136. self.item.child = self.item.child.concat(t.info);
  137. self.page = self.page + 1;
  138. }
  139. if (self.Dever.pageData.status == 0) {
  140. self.more = '收起';
  141. } else {
  142. self.more = '展开更多回复';
  143. }
  144. self.hideModal();
  145. });
  146. },
  147. updateUp : function(item) {
  148. var self = this;
  149. if (item.is_oppose) {
  150. return;
  151. }
  152. if (item.is_up) {
  153. item.num_up--;
  154. item.is_up = false;
  155. } else {
  156. item.num_up++;
  157. item.is_up = true;
  158. }
  159. self.Dever.post('app/community/?l=api.up', {id:item.id,noloading:1});
  160. },
  161. updateOppose : function(item) {
  162. var self = this;
  163. if (item.is_up) {
  164. return;
  165. }
  166. if (item.is_oppose) {
  167. item.num_oppose--;
  168. item.is_oppose = false;
  169. } else {
  170. item.num_oppose++;
  171. item.is_oppose = true;
  172. }
  173. self.Dever.post('app/community/?l=api.oppose', {id:item.id,noloading:1});
  174. },
  175. updateComment : function (type_id, to_id, to_uid) {
  176. this.type = this.type;
  177. this.type_id = type_id;
  178. if (to_id) {
  179. this.to_id = to_id;
  180. } else {
  181. this.to_id = 0;
  182. }
  183. if (to_uid) {
  184. this.to_uid = to_uid;
  185. } else {
  186. this.to_uid = 0;
  187. }
  188. this.show = true;
  189. },
  190. hideModal : function () {
  191. this.show = false;
  192. }
  193. }
  194. };
  195. </script>
  196. <style lang="less" scoped>
  197. .cu-card {
  198. }
  199. .cu-list.menu-avatar>.cu-item:after, .cu-list.menu>.cu-item:after {
  200. border: 0px;
  201. }
  202. .text-content-margin {
  203. margin-top:10rpx;
  204. }
  205. .icon-display {
  206. display: inline;
  207. margin-left: 20rpx;
  208. }
  209. .more {
  210. margin-top:-40rpx;
  211. }
  212. </style>