detail.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view>
  3. <view v-if="(data || null) != null" class="padding-top-main">
  4. <view class="padding-horizontal-main">
  5. <view class="padding-main border-radius-main bg-white spacing-mb">
  6. <view class="fw-b text-size-xl">{{data.title}}</view>
  7. <view class="cr-grey margin-top-lg oh br-t padding-top-main text-size-xs">
  8. <view class="fl">
  9. <text>时间:</text>
  10. <text>{{data.add_time}}</text>
  11. </view>
  12. <view class="fr">
  13. <text class="margin-left-xxxl">浏览:</text>
  14. <text>{{data.access_count}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="padding-main border-radius-main bg-white oh web-html-content spacing-mb">
  19. <view v-if="(data.video_url || null) != null && (data.is_live_play || 0) == 0">
  20. <video :src="data.video_url" class="wh-auto" :autoplay="false" :controls="true"></video>
  21. </view>
  22. <mp-html :content="data.content" />
  23. </view>
  24. </view>
  25. <!-- 评论内容 -->
  26. <component-blog-comments :propData="data" :propDataBase="data_base" :propEmojiList="emoji_list"></component-blog-comments>
  27. <view class="padding-horizontal-main">
  28. <!-- 上一篇、下一篇 -->
  29. <view v-if="(last_next || null) != null" class="last-next-data spacing-mb">
  30. <view v-if="(last_next.last || null) != null">
  31. <text class="cr-gray va-m">上一篇:</text>
  32. <navigator :url="last_next.last.url" open-type="redirect" hover-class="none" class="dis-inline-block va-m cr-blue">{{last_next.last.title}}</navigator>
  33. </view>
  34. <view v-if="(last_next.next || null) != null" class="margin-top-sm">
  35. <text class="cr-gray va-m">下一篇:</text>
  36. <navigator :url="last_next.next.url" open-type="redirect" hover-class="none" class="dis-inline-block va-m cr-blue">{{last_next.next.title}}</navigator>
  37. </view>
  38. </view>
  39. <!-- 推荐博文 -->
  40. <view v-if="right_list.length > 0" class="plugins-blog-list">
  41. <view class="spacing-nav-title">
  42. <text class="text-wrapper">推荐{{blog_main_name}}</text>
  43. <navigator url="/pages/plugins/blog/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  44. </view>
  45. <view v-for="(item, index) in right_list" class="item oh padding-main border-radius-main bg-white spacing-mb">
  46. <navigator :url="item.url" hover-class="none">
  47. <image class="blog-img fl radius" :src="item.cover" mode="aspectFill"></image>
  48. <view class="base fr">
  49. <view class="single-text">{{item.title}}</view>
  50. <view class="cr-gray margin-top-sm">{{item.add_time_date_cn}}</view>
  51. <view class="cr-grey multi-text margin-top-sm">{{item.describe}}</view>
  52. </view>
  53. </navigator>
  54. </view>
  55. </view>
  56. <!-- 相关商品 -->
  57. <view v-if="(data.goods_list || null) != null && data.goods_list.length > 0">
  58. <view class="spacing-nav-title">
  59. <text class="text-wrapper">相关商品</text>
  60. <navigator url="/pages/goods-search/goods-search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  61. </view>
  62. <component-goods-list :propData="{style_type: 1, goods_list: data.goods_list}" :propCurrencySymbol="currency_symbol"></component-goods-list>
  63. </view>
  64. </view>
  65. </view>
  66. <view v-else>
  67. <!-- 提示信息 -->
  68. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  69. </view>
  70. <!-- 结尾 -->
  71. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  72. </view>
  73. </template>
  74. <script>
  75. const app = getApp();
  76. import componentNoData from "../../../../components/no-data/no-data";
  77. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  78. import componentBlogComments from "../../../../components/blog-comments/blog-comments";
  79. import componentGoodsList from "../../../../components/goods-list/goods-list";
  80. var common_static_url = app.globalData.get_static_url('common');
  81. export default {
  82. data() {
  83. return {
  84. common_static_url: common_static_url,
  85. data_list_loding_status: 1,
  86. data_list_loding_msg: '',
  87. data_bottom_line_status: false,
  88. currency_symbol: app.globalData.data.currency_symbol,
  89. params: null,
  90. data_base: null,
  91. data: null,
  92. right_list: [],
  93. last_next: null,
  94. emoji_list: [],
  95. blog_main_name: '博文',
  96. // 自定义分享信息
  97. share_info: {}
  98. };
  99. },
  100. components: {
  101. componentNoData,
  102. componentBottomLine,
  103. componentBlogComments,
  104. componentGoodsList
  105. },
  106. props: {},
  107. onLoad(params) {
  108. this.setData({
  109. params: params
  110. });
  111. // 初始化配置
  112. this.init_config();
  113. // 数据加载
  114. this.get_data();
  115. },
  116. // 下拉刷新
  117. onPullDownRefresh() {
  118. this.get_data();
  119. },
  120. methods: {
  121. // 初始化配置
  122. init_config(status) {
  123. if ((status || false) == true) {
  124. this.setData({
  125. currency_symbol: app.globalData.get_config('currency_symbol'),
  126. });
  127. } else {
  128. app.globalData.is_config(this, 'init_config');
  129. }
  130. },
  131. // 初始化
  132. get_data() {
  133. uni.showLoading({
  134. title: '加载中...'
  135. });
  136. uni.request({
  137. url: app.globalData.get_request_url("detail", "index", "blog"),
  138. method: 'POST',
  139. data: {
  140. id: this.params.id || 0,
  141. },
  142. dataType: 'json',
  143. success: res => {
  144. uni.hideLoading();
  145. uni.stopPullDownRefresh();
  146. var data = res.data.data;
  147. if (res.data.code == 0 && (data.data || null) != null) {
  148. var blog = data.data;
  149. this.setData({
  150. data_bottom_line_status: true,
  151. data_list_loding_status: 3,
  152. data_base: data.base || null,
  153. data: blog,
  154. right_list: data.right_list || [],
  155. last_next: data.last_next || null,
  156. emoji_list: data.emoji_list || [],
  157. blog_main_name: ((data.base || null) == null) ? '博文' : (data.base.blog_main_name || '博文')
  158. });
  159. // 基础自定义分享
  160. this.setData({
  161. share_info: {
  162. title: this.data.seo_title || this.data.title,
  163. desc: this.data.seo_desc || this.data.describe,
  164. path: '/pages/plugins/blog/detail/detail',
  165. query: 'id='+this.data.id,
  166. img: this.data.cover
  167. }
  168. });
  169. // 标题
  170. uni.setNavigationBarTitle({title: this.data.title});
  171. } else {
  172. this.setData({
  173. data_list_loding_status: 0,
  174. data_list_loding_msg: res.data.msg
  175. });
  176. app.globalData.showToast(res.data.msg);
  177. }
  178. // 分享菜单处理
  179. app.globalData.page_share_handle(this.share_info);
  180. },
  181. fail: () => {
  182. uni.hideLoading();
  183. uni.stopPullDownRefresh();
  184. this.setData({
  185. data_list_loding_status: 2
  186. });
  187. app.globalData.showToast('服务器请求出错');
  188. }
  189. });
  190. }
  191. }
  192. };
  193. </script>
  194. <style>
  195. </style>