index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view>
  3. <view v-if="(data_base || null) != null">
  4. <!-- 搜索框 -->
  5. <view class="nav-search padding-horizontal-main padding-top-main">
  6. <component-search propBrColor="#efefef" propBgColor="#fff" propUrl="/pages/plugins/blog/search/search"></component-search>
  7. </view>
  8. <!-- 轮播 -->
  9. <view v-if="slide_list.length > 0" class="padding-horizontal-main padding-top-main">
  10. <component-banner :propData="slide_list"></component-banner>
  11. </view>
  12. <!-- 分类导航 -->
  13. <view v-if="(data_base.is_home_category_main_nav || 0) == 1 && (category || null) != null && category.length > 0" class="nav-blog-category padding-horizontal-main oh">
  14. <block v-for="(item, index) in category" :key="index">
  15. <view class="item oh padding-main margin-bottom-main radius bg-white bs-bb" :data-value="item.url" @tap="url_event">
  16. <image v-if="(item.icon || null) != null" :src="item.icon" mode="aspectFill" class="fl icon radius"></image>
  17. <view v-else class="fl radius icon-text tc">{{item.name.substr(0, 1)}}</view>
  18. <view class="fr right-base">
  19. <view class="single-text cr-base">
  20. <text class="fw">{{item.name}}</text>
  21. <text v-if="(item.blog_data || null) != null && item.blog_data.day_comments_count > 0" class="margin-left-sm cr-red fw">({{item.blog_data.day_comments_count}})</text>
  22. </view>
  23. <view v-if="(item.blog_data || null) != null" class="single-text cr-gray text-size-xs">
  24. <text>{{blog_main_name}}: {{item.blog_data.blog_count}}</text>
  25. <text v-if="(data_base.is_blog_comments_show || 0) == 1" class="margin-left">评论: {{item.blog_data.comments_count}}</text>
  26. <text v-if="(data_base.is_blog_give_thumbs || 0) == 1" class="margin-left">点赞: {{item.blog_data.give_thumbs_count}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </block>
  31. </view>
  32. <!-- 分类 -->
  33. <view class="spacing-nav-title padding-horizontal-main">
  34. <text class="text-wrapper va-m">所有{{blog_main_name}}</text>
  35. <scroll-view v-if="(category || null) != null && category.length > 0" class="nav-list scroll-view-horizontal dis-inline-block oh va-m margin-left-sm" scroll-x="true">
  36. <block v-for="(item, index) in category" :key="index">
  37. <view class="item cr-base dis-inline-block padding-horizontal-main" :data-value="item.url" @tap="url_event">{{item.name}}</view>
  38. </block>
  39. </scroll-view>
  40. </view>
  41. <!-- 博文列表 -->
  42. <view v-if="data_list.length > 0" class="plugins-blog-list padding-horizontal-main">
  43. <view v-for="(item, index) in data_list" class="item oh padding-main border-radius-main bg-white spacing-mb">
  44. <navigator :url="item.url" hover-class="none">
  45. <image class="blog-img fl radius" :src="item.cover" mode="aspectFill"></image>
  46. <view class="base fr">
  47. <view class="single-text text-size">{{item.title}}</view>
  48. <view class="cr-grey margin-top-sm">{{item.add_time_date_cn}}</view>
  49. <view class="cr-base text-size-sm multi-text margin-top-sm">{{item.describe}}</view>
  50. </view>
  51. </navigator>
  52. </view>
  53. </view>
  54. <!-- 热门博文-滚动 -->
  55. <view v-if="hot_list.length > 0" class="padding-horizontal-main spacing-mb">
  56. <view class="spacing-nav-title">
  57. <text class="text-wrapper">热门{{blog_main_name}}</text>
  58. <navigator url="/pages/plugins/blog/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  59. </view>
  60. <view class="rolling-horizontal border-radius-main oh">
  61. <view class="plugins-blog-rolling-list scroll-view-horizontal">
  62. <swiper :vertical="false" :autoplay="(data_base.is_home_hot_auto_play || 0) == 1" :circular="false" :display-multiple-items="hot_list.length < 3 ? hot_list.length : 3" interval="3000">
  63. <block v-for="(item, index) in hot_list" :key="index">
  64. <swiper-item>
  65. <view class="item bg-white border-radius-main margin-right-main oh pr ht-auto pr">
  66. <navigator :url="item.url" hover-class="none">
  67. <image class="blog-img dis-block wh-auto" :src="item.cover" mode="aspectFill"></image>
  68. <view class="blog-title pa single-text cr-white padding-horizontal-main padding-top-sm padding-bottom-sm">{{item.title}}</view>
  69. </navigator>
  70. </view>
  71. </swiper-item>
  72. </block>
  73. </swiper>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 推荐博文 -->
  78. <view v-if="right_list.length > 0" class="padding-horizontal-main spacing-mb">
  79. <view class="spacing-nav-title">
  80. <text class="text-wrapper">推荐{{blog_main_name}}</text>
  81. <navigator url="/pages/plugins/blog/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  82. </view>
  83. <view class="right-list padding-horizontal-main border-radius-main bg-white">
  84. <block v-for="(item, index) in right_list" :key="index">
  85. <view :class="'item padding-vertical-main oh '+(index > 0 ? 'br-t' : '')">
  86. <navigator :url="item.url" hover-class="none">
  87. <view class="blog-title single-text fl">{{item.title}}</view>
  88. <text class="cr-grey fr">浏览{{item.access_count}}次</text>
  89. </navigator>
  90. </view>
  91. </block>
  92. </view>
  93. </view>
  94. <!-- 推荐商品 -->
  95. <view v-if="goods_list.length > 0" class="goods-list oh padding-horizontal-main">
  96. <view class="spacing-nav-title">
  97. <text class="text-wrapper">推荐商品</text>
  98. <navigator url="/pages/goods-search/goods-search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  99. </view>
  100. <component-goods-list :propData="{style_type: 1, goods_list: goods_list}" :propCurrencySymbol="currency_symbol"></component-goods-list>
  101. </view>
  102. <!-- 结尾 -->
  103. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  104. </view>
  105. <view v-else>
  106. <!-- 提示信息 -->
  107. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. const app = getApp();
  113. import componentSearch from "../../../../components/search/search";
  114. import componentBanner from "../../../../components/slider/slider";
  115. import componentCountdown from "../../../../components/countdown/countdown";
  116. import componentNoData from "../../../../components/no-data/no-data";
  117. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  118. import componentGoodsList from "../../../../components/goods-list/goods-list";
  119. export default {
  120. data() {
  121. return {
  122. data_bottom_line_status: false,
  123. data_list_loding_status: 1,
  124. data_list_loding_msg: '',
  125. currency_symbol: app.globalData.data.currency_symbol,
  126. data_base: null,
  127. category: [],
  128. data_list: [],
  129. slide_list: [],
  130. goods_list: [],
  131. hot_list: [],
  132. right_list: [],
  133. blog_main_name: '博文',
  134. // 自定义分享信息
  135. share_info: {}
  136. };
  137. },
  138. components: {
  139. componentSearch,
  140. componentBanner,
  141. componentCountdown,
  142. componentNoData,
  143. componentBottomLine,
  144. componentGoodsList
  145. },
  146. props: {},
  147. onLoad() {},
  148. onShow() {
  149. // 初始化配置
  150. this.init_config();
  151. // 获取数据
  152. this.get_data();
  153. },
  154. // 下拉刷新
  155. onPullDownRefresh() {
  156. this.get_data();
  157. },
  158. methods: {
  159. // 初始化配置
  160. init_config(status) {
  161. if ((status || false) == true) {
  162. this.setData({
  163. currency_symbol: app.globalData.get_config('currency_symbol'),
  164. });
  165. } else {
  166. app.globalData.is_config(this, 'init_config');
  167. }
  168. },
  169. // 获取数据
  170. get_data() {
  171. uni.request({
  172. url: app.globalData.get_request_url("index", "index", "blog"),
  173. method: 'POST',
  174. data: {},
  175. dataType: 'json',
  176. success: res => {
  177. uni.stopPullDownRefresh();
  178. if (res.data.code == 0) {
  179. var data = res.data.data;
  180. this.setData({
  181. data_base: data.base || null,
  182. category: data.category || [],
  183. data_list: data.data_list || [],
  184. slide_list: data.slide_list || [],
  185. goods_list: data.goods_list || [],
  186. hot_list: data.hot_list || [],
  187. right_list: data.right_list || [],
  188. blog_main_name: ((data.base || null) == null) ? '博文' : (data.base.blog_main_name || '博文'),
  189. data_list_loding_msg: '',
  190. data_list_loding_status: 0,
  191. data_bottom_line_status: true
  192. });
  193. // 基础自定义分享
  194. var title = this.data_base.seo_title || this.data_base.application_name;
  195. this.setData({
  196. share_info: {
  197. title: title,
  198. desc: this.data_base.seo_desc,
  199. path: '/pages/plugins/blog/index/index',
  200. img: ((this.slide_list || null) != null && this.slide_list.length > 0) ? this.slide_list[0]['images_url'] : ''
  201. }
  202. });
  203. } else {
  204. this.setData({
  205. data_bottom_line_status: false,
  206. data_list_loding_status: 2,
  207. data_list_loding_msg: res.data.msg
  208. });
  209. }
  210. // 标题
  211. uni.setNavigationBarTitle({title: title});
  212. // 分享菜单处理
  213. app.globalData.page_share_handle(this.share_info);
  214. },
  215. fail: () => {
  216. uni.stopPullDownRefresh();
  217. this.setData({
  218. data_bottom_line_status: false,
  219. data_list_loding_status: 2,
  220. data_list_loding_msg: '服务器请求出错'
  221. });
  222. app.globalData.showToast('服务器请求出错');
  223. }
  224. });
  225. },
  226. // url事件
  227. url_event(e) {
  228. app.globalData.url_event(e);
  229. }
  230. }
  231. };
  232. </script>
  233. <style>
  234. @import './index.css';
  235. </style>