info-detail.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="info-detail">
  3. <u-navbar :title="title" :autoBack="true" placeholder>
  4. <view class="u-nav-slot" slot="right">
  5. <u-icon name="more-dot-fill" size="22" @click="open"></u-icon>
  6. </view>
  7. </u-navbar>
  8. <view class="cover">
  9. <image :src="detail.image" mode="aspectFill" v-if="type == 'info' || type == 'article'"></image>
  10. <view class="video hflex acenter jbetween" v-if="type == 'video'">
  11. <image :src="detail.image" mode="aspectFill" class="img"></image>
  12. <text class="text_hide2">{{detail.video_title}}</text>
  13. <image src="../static/images/arrow-right.png" mode="aspectFill" class="icon"></image>
  14. </view>
  15. <view v-if="type == 'post'">
  16. <u-swiper :indicator="true" indicatorMode="dot" :list="detail.images" height="452rpx" radius="12rpx" v-if="detail.images.length > 0">
  17. </u-swiper>
  18. </view>
  19. <view class="title" v-if="detail.title">{{detail.title}}</view>
  20. <view class="user hflex acenter jbetween" v-if="detail.user">
  21. <view class="hflex acenter" >
  22. <image :src="detail.user.avatar" mode="aspectFill"></image>
  23. <view class="user-name">{{detail.user.username}}</view>
  24. </view>
  25. <view class="user-btn hflex acenter jcenter" v-if="detail.user.id == userid">
  26. <image src="./static/like.png" mode="aspectFill"></image>
  27. <text>{{item.is_like == 0 ? '关注' : '已关注'}}</text>
  28. </view>
  29. </view>
  30. <view class="detail">
  31. <u-parse :content="detail.content"></u-parse>
  32. </view>
  33. <view class="time hflex jend">发布于{{detail.created_at}}</view>
  34. <view class="circle hflex acenter" v-if="detail.topic_id != 0 && detail.topic">
  35. <text>{{detail.topic.title}}</text>
  36. </view>
  37. <comment-list :show_jianpan="show_jianpan" :type="type" :id="detail.id" :user="detail.user" v-if="detail.user"></comment-list>
  38. </view>
  39. <view style="height: 166rpx;"></view>
  40. <view class="bottom hflex acneter jbetween">
  41. <u--input v-model="comment" border="none" placeholder="添加新评论"></u--input>
  42. <view class="hflex acenter jbetween bottom-right">
  43. <view class="vflex acenter jbetween bottom-item" @click="tolike">
  44. <image src="/static/images/dianzan.png" mode="aspectFill" v-if="detail.is_like == 0"></image>
  45. <image src="/static/images/dianzan2.png" mode="aspectFill" v-else></image>
  46. <text>{{detail.like_count || 0}}</text>
  47. </view>
  48. <view class="vflex acenter jbetween bottom-item">
  49. <image src="/static/images/pinglun.png" mode="aspectFill"></image>
  50. <text>{{detail.comment_count || 0}}</text>
  51. </view>
  52. <view class="vflex acenter jbetween bottom-item" @click="tocollect">
  53. <image src="/static/images/shoucang.png" mode="aspectFill" v-if="detail.is_collect == 0"></image>
  54. <image src="/static/images/shoucang2.png" mode="aspectFill" v-else></image>
  55. <text>{{detail.collect_count || 0}}</text>
  56. </view>
  57. </view>
  58. </view>
  59. <u-popup :show="show" mode="bottom" :round="10" @close="toclose">
  60. <view class="popu">
  61. <view class="top hflex acenter">
  62. <view class="vflex acenter jcenter top-item" @click="copy">
  63. <view class="img-bg vflex acenter jcenter">
  64. <image src="@/static/images/lianjie.png" mode="aspectFill"></image>
  65. </view>
  66. <text>复制链接</text>
  67. </view>
  68. <view class="vflex acenter jcenter top-item">
  69. <view class="img-bg vflex acenter jcenter" style="background: #E9E9E9;">
  70. <image src="/pageA/static/warn.png" mode="aspectFill"></image>
  71. </view>
  72. <text>举报</text>
  73. </view>
  74. </view>
  75. <view class="btn hflex acenter jcenter" @click="toclose">取消</view>
  76. </view>
  77. </u-popup>
  78. </view>
  79. </template>
  80. <script>
  81. import commentList from '@/components/comment/index.vue'
  82. import $api from '@/static/js/api.js'
  83. export default {
  84. components: {
  85. commentList
  86. },
  87. data() {
  88. return {
  89. id: '',
  90. detail: {},
  91. title: '资讯',
  92. comment: '',
  93. show_jianpan: false,
  94. type: '',
  95. userid: '',
  96. show: false
  97. }
  98. },
  99. onLoad(option) {
  100. this.userid = uni.getStorageSync('id')
  101. if(option.id) {
  102. this.id = option.id
  103. }
  104. if(option.type) {
  105. this.type = option.type
  106. if(this.type == 'info') {
  107. this.title = '资讯'
  108. }
  109. if(this.type == 'article') {
  110. this.title = '文章'
  111. }
  112. if(this.type == 'video') {
  113. this.title = '视频'
  114. }
  115. if(this.type == 'post') {
  116. this.title = '论坛'
  117. }
  118. }
  119. this.getdata()
  120. uni.onKeyboardHeightChange(this.onKeyboardHeightChange);
  121. },
  122. onUnload() {
  123. uni.offKeyboardHeightChange(this.onKeyboardHeightChange);
  124. },
  125. methods: {
  126. copy() {
  127. uni.setClipboardData({
  128. data: '/pageA/info-detail?id=' + this.id + '&type=' + this.type,
  129. success() {
  130. uni.$u.toast('复制成功')
  131. }
  132. })
  133. },
  134. open() {
  135. this.show = true
  136. },
  137. toclose() {
  138. this.show = false
  139. },
  140. tocollect() {
  141. var _this = this
  142. $api.req({
  143. url: 'collect',
  144. method: 'POST',
  145. data: {
  146. source_type: _this.type,
  147. source_id: _this.id
  148. }
  149. }, function(res) {
  150. if(res.code == 10000) {
  151. uni.$u.toast(res.msg)
  152. setTimeout(() => {
  153. _this.getdata()
  154. },800)
  155. }
  156. })
  157. },
  158. tolike() {
  159. var _this = this
  160. $api.req({
  161. url: 'like',
  162. method: 'POST',
  163. data: {
  164. source_type: _this.type,
  165. source_id: _this.id
  166. }
  167. }, function(res) {
  168. if(res.code == 10000) {
  169. uni.$u.toast(res.msg)
  170. setTimeout(() => {
  171. _this.getdata()
  172. },800)
  173. }
  174. })
  175. },
  176. onKeyboardHeightChange(e) {
  177. const { height, duration } = e;
  178. if(height > 0) {
  179. this.show_jianpan = true
  180. } else {
  181. this.show_jianpan = false
  182. }
  183. },
  184. getdata() {
  185. var _this = this
  186. $api.req({
  187. url: _this.type + '/' + _this.id,
  188. method: 'GET',
  189. /* data: {
  190. id: this.id
  191. } */
  192. }, function(res) {
  193. _this.detail = res.data
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. .info-detail::v-deep {
  201. background: #FFFFFF;
  202. min-height: 100vh;
  203. .popu {
  204. background: #FFFFFF;
  205. border-radius: 20rpx 20rpx 0rpx 0rpx;
  206. padding: 82rpx 0;
  207. .btn {
  208. padding: 24rpx 0 0;
  209. font-size: 32rpx;
  210. font-family: PingFangSC, PingFang SC;
  211. font-weight: 400;
  212. color: #444444;
  213. }
  214. .top {
  215. padding-bottom: 40rpx;
  216. border-bottom: 1px solid #F7F7F7;
  217. .top-item {
  218. padding: 0 0 0 108rpx;
  219. .img-bg {
  220. width: 96rpx;
  221. height: 96rpx;
  222. background: #00B0B0;
  223. border-radius: 50%;
  224. image {
  225. width: 36rpx;
  226. height: 36rpx;
  227. }
  228. }
  229. text {
  230. padding: 16rpx 0 0;
  231. font-size: 22rpx;
  232. font-family: PingFangSC, PingFang SC;
  233. font-weight: 400;
  234. color: #444444;
  235. }
  236. }
  237. }
  238. }
  239. .bottom {
  240. width: 100%;
  241. position: fixed;
  242. bottom: 0;
  243. left: 0;
  244. background: #FFFFFF;
  245. box-shadow: 0rpx 0rpx 0rpx 0rpx rgba(0,0,0,0.1);
  246. padding: 14rpx 24rpx 80rpx;
  247. box-sizing: border-box;
  248. .bottom-right {
  249. .bottom-item {
  250. margin-left: 38rpx;
  251. height: 72rpx;
  252. image {
  253. width: 40rpx;
  254. height: 38rpx;
  255. }
  256. text {
  257. padding-top: 8rpx;
  258. font-size: 20rpx;
  259. font-family: SFPro, SFPro;
  260. font-weight: 400;
  261. color: #7C7C7C;
  262. }
  263. }
  264. }
  265. .u-input {
  266. background: #F5F5F5;
  267. border-radius: 40rpx;
  268. width: 446rpx !important;
  269. height: 72rpx ;
  270. padding: 0 32rpx !important;
  271. }
  272. }
  273. .cover {
  274. width: 100%;
  275. .video {
  276. width: 100%;
  277. box-sizing: border-box;
  278. padding: 28rpx;
  279. // height: 182rpx;
  280. background: #F5F5F5;
  281. .img {
  282. width: 224rpx;
  283. height: 126rpx;
  284. }
  285. text {
  286. font-size: 28rpx;
  287. font-family: SFPro, SFPro;
  288. font-weight: 500;
  289. color: #333333;
  290. width: 354rpx;
  291. }
  292. .icon {
  293. width: 24rpx;
  294. height: 24rpx;
  295. }
  296. }
  297. image {
  298. width: 100%;
  299. }
  300. .title {
  301. padding: 28rpx 32rpx;
  302. font-size: 36rpx;
  303. font-family: PingFangSC, PingFang SC;
  304. font-weight: 600;
  305. color: #333333;
  306. }
  307. .user {
  308. padding: 0 28rpx 30rpx;
  309. image {
  310. width: 68rpx;
  311. height: 68rpx;
  312. border-radius: 50%;
  313. }
  314. .user-name {
  315. font-size: 28rpx;
  316. font-family: PingFangSC, PingFang SC;
  317. font-weight: 600;
  318. color: #333333;
  319. padding-left: 20rpx;
  320. }
  321. .user-btn {
  322. width: 140rpx;
  323. height: 60rpx;
  324. background: #00B0B0;
  325. border-radius: 30rpx;
  326. image {
  327. width: 36rpx;
  328. height: 36rpx;
  329. }
  330. text {
  331. font-size: 28rpx;
  332. font-family: PingFangSC, PingFang SC;
  333. font-weight: 500;
  334. color: #FFFFFF;
  335. padding-left: 8rpx;
  336. }
  337. }
  338. }
  339. .detail {
  340. padding: 0 28rpx;
  341. }
  342. .time {
  343. padding: 32rpx 28rpx;
  344. font-size: 28rpx;
  345. font-family: SFPro, SFPro;
  346. font-weight: 400;
  347. color: #999999;
  348. }
  349. .circle {
  350. margin: 0 28rpx 48rpx;
  351. background: rgba(0, 176, 176, .1);
  352. border-radius: 34rpx;
  353. padding: 14rpx 20rpx;
  354. max-width: max-content;
  355. image {
  356. width: 40rpx;
  357. height: 40rpx;
  358. }
  359. text {
  360. font-size: 28rpx;
  361. font-family: AppleColorEmoji;
  362. color: #00B0B0;
  363. }
  364. }
  365. }
  366. }
  367. </style>