detail.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view v-if="pageloading">
  3. <view class="echo-article-title bg-white">
  4. {{article.title}}
  5. </view>
  6. <view class="echo-article-meta bg-white">
  7. <view class="echo-article-meta-left">
  8. <text>{{article.createtime_text}}</text>
  9. <text>{{article.articleCate.title}}</text>
  10. <text>{{article.author}}</text>
  11. </view>
  12. <view class="echo-article-meta-right">
  13. <text>浏览 {{article.volume}}</text>
  14. </view>
  15. </view>
  16. <view class="echo-article-details bg-white">
  17. <u-parse :content="article.details" noData="详情内容..." @navigate="navigate"></u-parse>
  18. </view>
  19. <view class="cu-bar bg-white solid-bottom margin-top-sm">
  20. <view class="action">
  21. <text class="cuIcon-titles text-blue"></text> 用户评论
  22. </view>
  23. <view class="action" @click="goPage('/pages/article/comment?articleid='+article.id)">
  24. <text class="text-df">共{{article.article_comment_count}}条评论 </text>
  25. <view class="cuIcon-right"></view>
  26. </view>
  27. </view>
  28. <view class="cu-list menu-avatar comment solids-top">
  29. <block v-for="(item,index) in commentlist" :key="item.id">
  30. <view class="cu-item" :data-puserid="item.userid" :data-nickname="item.user.nickname">
  31. <view class="cu-avatar round" :style="'background-image:url('+item.user.avatar+');'"></view>
  32. <view class="content">
  33. <view class="padding-bottom-sm flex justify-between">
  34. <view class="text-grey">{{item.user.nickname}}</view>
  35. <view class="text-gray">{{item.createtime}}</view>
  36. </view>
  37. <view class="text-content padding-bottom-xs">
  38. <text v-if="item.puserid">回复 <text class="text-red">{{item.puser.nickname}}</text>:</text>
  39. {{item.details}}
  40. </view>
  41. </view>
  42. </view>
  43. </block>
  44. </view>
  45. <view class="cu-bar bg-white solid-bottom margin-top-sm">
  46. <view class="action">
  47. <text class="cuIcon-titles text-blue"></text> 相关推荐
  48. </view>
  49. <view class="action" @click="goPage('/pages/article/article')">
  50. <text class="text-df">全部文章 </text>
  51. <view class="cuIcon-right"></view>
  52. </view>
  53. </view>
  54. <block v-for="(item,index) in articlelist" :key="index">
  55. <view class="cu-card article no-card solid-bottom">
  56. <view class="cu-item shadow" @tap="goArticle(item.atype, item.id, item.tilurl)">
  57. <view class="title"><view class="text-cut">{{item.title}}</view></view>
  58. <view class="content">
  59. <image :src="item.tilpic" mode="aspectFill"></image>
  60. <view class="desc">
  61. <view class="text-content">{{item.summary}}</view>
  62. <view class="flex justify-between">
  63. <view class="text-sm text-gray">{{item.createtime_text}}</view>
  64. <view class="text-sm text-gray text-right" v-if="item.atype==1">
  65. <text class="cuIcon-attentionfill margin-lr-xs"></text> {{item.volume}}
  66. <text class="cuIcon-appreciatefill margin-lr-xs"></text> {{item.article_thumb_count}}
  67. <text class="cuIcon-messagefill margin-lr-xs"></text> {{item.article_comment_count}}
  68. </view>
  69. <view class="text-sm text-gray text-right" v-else>
  70. <text class="cuIcon-attentionfill margin-lr-xs"></text> {{item.volume}}
  71. <text class="cuIcon-discoverfill margin-lr-xs"></text> 链接
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </block>
  79. <view class="padding"></view>
  80. <view class="padding"></view>
  81. <view class="cu-bar bg-white tabbar input foot">
  82. <input placeholder="说点什么吧..." @tap="goPage('/pages/article/comment?articleid='+article.id+'&modalname=commentModal')" disabled class="solid-bottom"></input>
  83. <view class="action text-gray" @click="goPage('/pages/article/comment?articleid='+article.id)">
  84. <view class="cuIcon-commentfill"></view>
  85. {{article.article_comment_count}}
  86. </view>
  87. <view class="action text-gray" v-if="mythumb==0" @click="setThumb">
  88. <view class="cuIcon-appreciatefill"></view>
  89. {{article.article_thumb_count}}
  90. </view>
  91. <view class="action text-orange" v-else @click="setThumb">
  92. <view class="cuIcon-appreciatefill"></view>
  93. {{article.article_thumb_count}}
  94. </view>
  95. <view class="action text-gray" v-if="mycollect==0" @click="setCollect">
  96. <view class="cuIcon-favorfill"></view>
  97. 收藏
  98. </view>
  99. <view class="action text-orange" v-else @click="setCollect">
  100. <view class="cuIcon-favorfill"></view>
  101. 已收藏
  102. </view>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import uParse from '@/components/gaoyia-parse/parse.vue';
  108. var _this;
  109. export default {
  110. components: {
  111. uParse
  112. },
  113. data() {
  114. return {
  115. pageloading: false,
  116. userinfo: {},
  117. article: {},
  118. mythumb: 0,
  119. mycollect: 0,
  120. articlelist: [],
  121. commentlist: []
  122. }
  123. },
  124. onLoad: function(option) {
  125. _this = this;
  126. var articleid = option.articleid || 0;
  127. _this.userinfo = uni.getStorageSync('userinfo');
  128. _this.$req.ajax({
  129. path: "article/getarticle",
  130. data: {
  131. articleid: articleid,
  132. userid: _this.userinfo.id || 0
  133. }
  134. }).then((data) => {
  135. _this.article = data.article;
  136. _this.mythumb = data.mythumb;
  137. _this.mycollect = data.mycollect;
  138. _this.articlelist = data.articlelist;
  139. _this.commentlist = data.commentlist;
  140. if (_this.article.atype==2) {
  141. uni.redirectTo({
  142. url: _this.article.tilurl
  143. });
  144. } else if (_this.article.atype==3) {
  145. // #ifdef H5
  146. location.href = _this.article.tilurl;
  147. // #endif
  148. // #ifndef H5
  149. uni.redirectTo({
  150. url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(_this.article.tilurl)
  151. });
  152. // #endif
  153. }
  154. _this.pageloading = true;
  155. }).catch((err) => {
  156. uni.showModal({
  157. title: '信息提示',
  158. content: err,
  159. showCancel: false
  160. });
  161. });
  162. },
  163. onShareAppMessage: function(res) {
  164. return {
  165. title: _this.article.title,
  166. path: "/pages/article/detail?articleid="+_this.article.id
  167. }
  168. },
  169. methods: {
  170. setThumb: function() {
  171. _this.userinfo = _this.checkLogin("/pages/article/detail?articleid="+_this.article.id);
  172. if (_this.userinfo===false){
  173. return false;
  174. }
  175. _this.$req.ajax({
  176. path: "article/setthumb",
  177. data: {
  178. articleid: _this.article.id,
  179. userid: _this.userinfo.id || 0
  180. }
  181. }).then((data) => {
  182. _this.mythumb = data.mythumb;
  183. _this.article.article_thumb_count = data.thumbcount;
  184. }).catch((err) => {
  185. uni.showModal({
  186. title: '信息提示',
  187. content: err,
  188. showCancel: false
  189. });
  190. });
  191. },
  192. setCollect: function() {
  193. _this.userinfo = _this.checkLogin("/pages/article/detail?articleid="+_this.article.id);
  194. if (_this.userinfo===false){
  195. return false;
  196. }
  197. _this.$req.ajax({
  198. path: "article/setcollect",
  199. data: {
  200. articleid: _this.article.id,
  201. userid: _this.userinfo.id || 0
  202. }
  203. }).then((data) => {
  204. _this.mycollect = data.mycollect;
  205. }).catch((err) => {
  206. uni.showModal({
  207. title: '信息提示',
  208. content: err,
  209. showCancel: false
  210. });
  211. });
  212. },
  213. goPage: function(pageurl) {
  214. uni.navigateTo({
  215. url: pageurl
  216. });
  217. },
  218. goArticle: function(atype, articleid, tilurl) {
  219. if (atype==1){
  220. uni.navigateTo({
  221. url: '/pages/article/detail?articleid=' + articleid
  222. });
  223. }else{
  224. _this.$req.ajax({
  225. path: "article/getarticle",
  226. data: {
  227. articleid: articleid
  228. }
  229. }).then((data) => {
  230. if (atype==2) {
  231. uni.navigateTo({
  232. url: tilurl
  233. });
  234. } else{
  235. // #ifdef H5
  236. location.href = tilurl;
  237. // #endif
  238. // #ifndef H5
  239. uni.navigateTo({
  240. url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(tilurl)
  241. });
  242. // #endif
  243. }
  244. }).catch((err) => {
  245. uni.showModal({
  246. title: '信息提示',
  247. content: err,
  248. showCancel: false
  249. });
  250. });
  251. }
  252. },
  253. navigate: function(href, e) {
  254. // #ifdef H5
  255. location.href = href;
  256. // #endif
  257. // #ifndef H5
  258. uni.navigateTo({
  259. url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(href)
  260. });
  261. // #endif
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. .cu-bar.tabbar .action{ -webkit-box-flex: 0.4 !important; -webkit-flex: 0.4 !important; -ms-flex: 0.4 !important; flex: 0.4 !important; margin: 0 !important; }
  268. </style>