topicDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view>
  3. <scroll-view class="container">
  4. <scroll-view class="content">
  5. <!-- <template is="wxParse" :data="wxParseData:topicDetail.nodes"/> -->
  6. <mp-html :content="article_topicDetail"></mp-html>
  7. </scroll-view>
  8. <scroll-view class="sv-goods" v-if="topicGoods.length > 0">
  9. <view class="topic-goods">
  10. <view class="h">
  11. <text class="t">专题商品</text>
  12. </view>
  13. <view class="b">
  14. <view class="item" v-for="(item, index) in topicGoods" :key="index">
  15. <navigator :url="'/pages/goods/goods?id=' + item.id">
  16. <image class="img" :src="item.picUrl" background-size="cover"></image>
  17. <view class="right">
  18. <view class="text">
  19. <text class="name">{{ item.name }}</text>
  20. <text class="desc">{{ item.brief }}</text>
  21. <text class="price">¥{{ item.retailPrice }}</text>
  22. </view>
  23. </view>
  24. </navigator>
  25. </view>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. <scroll-view class="comments">
  30. <view class="h">
  31. <text class="t">精选留言</text>
  32. <van-icon @tap.native="postComment" class="i" name="comment-o" />
  33. </view>
  34. <view class="has-comments" v-if="commentList.length > 0">
  35. <view class="b">
  36. <view class="item" v-for="(item, index) in commentList" :key="index">
  37. <view class="info">
  38. <view class="user">
  39. <image class="avatar" :src="item.userInfo.avatarUrl"></image>
  40. <text class="nickname">{{ item.userInfo.nickName }}</text>
  41. </view>
  42. <view class="time">{{ item.addTime }}</view>
  43. </view>
  44. <view class="comment">
  45. {{ item.content }}
  46. </view>
  47. </view>
  48. </view>
  49. <view class="load" v-if="commentCount > 5">
  50. <navigator :url="'/pages/topicComment/topicComment?valueId=' + topic.id + '&type=1'">查看更多</navigator>
  51. </view>
  52. </view>
  53. <view class="no-comments" v-if="commentList.length <= 0">
  54. <text class="txt">等你来留言</text>
  55. </view>
  56. </scroll-view>
  57. <scroll-view class="rec-box">
  58. <view class="h">
  59. <text class="txt">专题推荐</text>
  60. </view>
  61. <view class="b">
  62. <navigator class="item" :url="'../topicDetail/topicDetail?id=' + item.id" v-for="(item, index) in topicList" :key="index">
  63. <image class="img" :src="item.picUrl"></image>
  64. <text class="title">{{ item.title }}</text>
  65. </navigator>
  66. </view>
  67. </scroll-view>
  68. </scroll-view>
  69. </view>
  70. </template>
  71. <script>
  72. var app = getApp();
  73. var WxParse = require('../../../lib/wxParse/wxParse.vue');
  74. var util = require('../../../utils/util.js');
  75. var api = require('../../../config/api.js');
  76. export default {
  77. data() {
  78. return {
  79. id: 0,
  80. topic: {
  81. id: ''
  82. },
  83. topicList: [],
  84. commentCount: 0,
  85. commentList: [],
  86. topicGoods: [],
  87. article_topicDetail: 0
  88. };
  89. },
  90. onLoad: function (options) {
  91. // 页面初始化 options为页面跳转所带来的参数
  92. var that = this;
  93. that.setData({
  94. id: options.id
  95. });
  96. util.request(api.TopicDetail, {
  97. id: that.id
  98. }).then(function (res) {
  99. if (res.errno === 0) {
  100. that.setData({
  101. topic: res.data.topic,
  102. topicGoods: res.data.goods
  103. });
  104. that.article_topicDetail = that.escape2Html(res.data.topic.content);
  105. }
  106. });
  107. util.request(api.TopicRelated, {
  108. id: that.id
  109. }).then(function (res) {
  110. if (res.errno === 0) {
  111. that.setData({
  112. topicList: res.data.list
  113. });
  114. }
  115. });
  116. },
  117. onReady: function () {},
  118. onShow: function () {
  119. // 页面显示
  120. this.getCommentList();
  121. },
  122. onHide: function () {
  123. // 页面隐藏
  124. },
  125. onUnload: function () {
  126. // 页面关闭
  127. },
  128. methods: {
  129. getCommentList() {
  130. let that = this;
  131. util.request(api.CommentList, {
  132. valueId: that.id,
  133. type: 1,
  134. showType: 0,
  135. page: 1,
  136. limit: 5
  137. }).then(function (res) {
  138. if (res.errno === 0) {
  139. that.setData({
  140. commentList: res.data.list,
  141. commentCount: res.data.total
  142. });
  143. }
  144. });
  145. },
  146. postComment() {
  147. if (!app.globalData.hasLogin) {
  148. uni.navigateTo({
  149. url: '/pages/auth/login/login'
  150. });
  151. } else {
  152. uni.navigateTo({
  153. url: '/pages/topicCommentPost/topicCommentPost?valueId=' + this.id + '&type=1'
  154. });
  155. }
  156. }
  157. }
  158. };
  159. </script>
  160. <style>
  161. .content {
  162. width: 100%;
  163. height: auto;
  164. font-size: 0;
  165. }
  166. .content image {
  167. display: inline-block;
  168. width: 100%;
  169. }
  170. .comments {
  171. width: 100%;
  172. height: auto;
  173. padding-left: 30rpx;
  174. background: #fff;
  175. margin-top: 20rpx;
  176. }
  177. .comments .h {
  178. height: 93rpx;
  179. line-height: 93rpx;
  180. width: 720rpx;
  181. padding-right: 30rpx;
  182. border-bottom: 1px solid #d9d9d9;
  183. }
  184. .comments .h .t {
  185. display: block;
  186. float: left;
  187. width: 50%;
  188. font-size: 29rpx;
  189. color: #333;
  190. }
  191. .comments .h .i {
  192. display: block;
  193. float: right;
  194. width: 33rpx;
  195. height: 33rpx;
  196. }
  197. .comments .b {
  198. height: auto;
  199. width: 720rpx;
  200. }
  201. .comments .item {
  202. height: auto;
  203. width: 720rpx;
  204. overflow: hidden;
  205. border-bottom: 1px solid #d9d9d9;
  206. }
  207. .comments .info {
  208. height: 127rpx;
  209. width: 100%;
  210. padding: 33rpx 0 27rpx 0;
  211. }
  212. .comments .user {
  213. float: left;
  214. width: auto;
  215. height: 67rpx;
  216. line-height: 67rpx;
  217. font-size: 0;
  218. }
  219. .comments .user .avatar {
  220. display: block;
  221. float: left;
  222. width: 67rpx;
  223. height: 67rpx;
  224. margin-right: 17rpx;
  225. border-radius: 50%;
  226. }
  227. .comments .user .nickname {
  228. display: block;
  229. width: auto;
  230. float: left;
  231. height: 66rpx;
  232. overflow: hidden;
  233. font-size: 29rpx;
  234. line-height: 66rpx;
  235. }
  236. .comments .time {
  237. display: block;
  238. float: right;
  239. width: auto;
  240. height: 67rpx;
  241. line-height: 67rpx;
  242. color: #7f7f7f;
  243. font-size: 25rpx;
  244. margin-right: 30rpx;
  245. }
  246. .comments .comment {
  247. width: 720rpx;
  248. padding-right: 30rpx;
  249. line-height: 45.8rpx;
  250. margin-bottom: 30rpx;
  251. font-size: 29rpx;
  252. color: #333;
  253. }
  254. .comments .load {
  255. width: 720rpx;
  256. height: 108rpx;
  257. line-height: 108rpx;
  258. text-align: center;
  259. font-size: 38.5rpx;
  260. }
  261. .no-comments {
  262. height: 297rpx;
  263. }
  264. .no-comments .txt {
  265. height: 43rpx;
  266. line-height: 43rpx;
  267. display: block;
  268. width: 100%;
  269. text-align: center;
  270. font-size: 29rpx;
  271. color: #7f7f7f;
  272. padding-top: 150rpx;
  273. }
  274. .sv-goods {
  275. width: 100%;
  276. height: auto;
  277. padding-left: 30rpx;
  278. background: #fff;
  279. margin-top: 20rpx;
  280. }
  281. .topic-goods .h {
  282. height: 93rpx;
  283. line-height: 93rpx;
  284. width: 720rpx;
  285. padding-right: 30rpx;
  286. border-bottom: 1px solid #d9d9d9;
  287. }
  288. .topic-goods .h .t {
  289. display: block;
  290. float: left;
  291. width: 50%;
  292. font-size: 29rpx;
  293. color: #333;
  294. }
  295. .topic-goods .b .item {
  296. border-top: 1px solid #d9d9d9;
  297. margin: 0 20rpx;
  298. height: 244rpx;
  299. width: 710rpx;
  300. }
  301. .topic-goods .b .img {
  302. margin-top: 12rpx;
  303. margin-right: 12rpx;
  304. float: left;
  305. width: 220rpx;
  306. height: 220rpx;
  307. }
  308. .topic-goods .b .right {
  309. float: left;
  310. height: 244rpx;
  311. width: 476rpx;
  312. display: flex;
  313. flex-flow: row nowrap;
  314. }
  315. .topic-goods .b .text {
  316. display: flex;
  317. flex-wrap: nowrap;
  318. flex-direction: column;
  319. justify-content: center;
  320. overflow: hidden;
  321. height: 244rpx;
  322. width: 476rpx;
  323. }
  324. .topic-goods .b .name {
  325. float: left;
  326. width: 330rpx;
  327. display: block;
  328. color: #333;
  329. line-height: 50rpx;
  330. font-size: 30rpx;
  331. }
  332. .topic-goods .b .desc {
  333. width: 476rpx;
  334. display: block;
  335. color: #999;
  336. line-height: 50rpx;
  337. font-size: 25rpx;
  338. }
  339. .topic-goods .b .price {
  340. width: 476rpx;
  341. display: flex;
  342. color: #b4282d;
  343. line-height: 50rpx;
  344. font-size: 33rpx;
  345. }
  346. .rec-box {
  347. width: 690rpx;
  348. height: auto;
  349. margin: 0 30rpx;
  350. }
  351. .rec-box .h {
  352. position: relative;
  353. width: 690rpx;
  354. height: 96rpx;
  355. /*border-bottom: 1px solid #d0d0d0;*/
  356. margin-bottom: 32rpx;
  357. }
  358. .rec-box .h .txt {
  359. display: inline-block;
  360. position: absolute;
  361. background: #f4f4f4;
  362. top: 59rpx;
  363. left: 200rpx;
  364. width: 290rpx;
  365. height: 45rpx;
  366. line-height: 45rpx;
  367. font-size: 30rpx;
  368. color: #999;
  369. text-align: center;
  370. }
  371. .rec-box .b .item {
  372. width: 690rpx;
  373. height: 397rpx;
  374. padding: 24rpx 24rpx 30rpx 24rpx;
  375. background: #fff;
  376. margin-bottom: 30rpx;
  377. }
  378. .rec-box .b .item .img {
  379. height: 278rpx;
  380. width: 642rpx;
  381. }
  382. .rec-box .b .item .title {
  383. display: block;
  384. margin-top: 30rpx;
  385. height: 30rpx;
  386. width: 642rpx;
  387. font-size: 28rpx;
  388. }
  389. </style>