y-DiaryItem.vue 6.9 KB

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