123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view>
- <view v-if="(data_base || null) != null">
- <!-- 搜索框 -->
- <view class="nav-search padding-horizontal-main padding-top-main">
- <component-search propBrColor="#efefef" propBgColor="#fff" propUrl="/pages/plugins/blog/search/search"></component-search>
- </view>
- <!-- 轮播 -->
- <view v-if="slide_list.length > 0" class="padding-horizontal-main padding-top-main">
- <component-banner :propData="slide_list"></component-banner>
- </view>
-
- <!-- 分类导航 -->
- <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">
- <block v-for="(item, index) in category" :key="index">
- <view class="item oh padding-main margin-bottom-main radius bg-white bs-bb" :data-value="item.url" @tap="url_event">
- <image v-if="(item.icon || null) != null" :src="item.icon" mode="aspectFill" class="fl icon radius"></image>
- <view v-else class="fl radius icon-text tc">{{item.name.substr(0, 1)}}</view>
- <view class="fr right-base">
- <view class="single-text cr-base">
- <text class="fw">{{item.name}}</text>
- <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>
- </view>
- <view v-if="(item.blog_data || null) != null" class="single-text cr-gray text-size-xs">
- <text>{{blog_main_name}}: {{item.blog_data.blog_count}}</text>
- <text v-if="(data_base.is_blog_comments_show || 0) == 1" class="margin-left">评论: {{item.blog_data.comments_count}}</text>
- <text v-if="(data_base.is_blog_give_thumbs || 0) == 1" class="margin-left">点赞: {{item.blog_data.give_thumbs_count}}</text>
- </view>
- </view>
- </view>
-
- </block>
- </view>
- <!-- 分类 -->
- <view class="spacing-nav-title padding-horizontal-main">
- <text class="text-wrapper va-m">所有{{blog_main_name}}</text>
- <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">
- <block v-for="(item, index) in category" :key="index">
- <view class="item cr-base dis-inline-block padding-horizontal-main" :data-value="item.url" @tap="url_event">{{item.name}}</view>
- </block>
- </scroll-view>
- </view>
- <!-- 博文列表 -->
- <view v-if="data_list.length > 0" class="plugins-blog-list padding-horizontal-main">
- <view v-for="(item, index) in data_list" class="item oh padding-main border-radius-main bg-white spacing-mb">
- <navigator :url="item.url" hover-class="none">
- <image class="blog-img fl radius" :src="item.cover" mode="aspectFill"></image>
- <view class="base fr">
- <view class="single-text text-size">{{item.title}}</view>
- <view class="cr-grey margin-top-sm">{{item.add_time_date_cn}}</view>
- <view class="cr-base text-size-sm multi-text margin-top-sm">{{item.describe}}</view>
- </view>
- </navigator>
- </view>
- </view>
- <!-- 热门博文-滚动 -->
- <view v-if="hot_list.length > 0" class="padding-horizontal-main spacing-mb">
- <view class="spacing-nav-title">
- <text class="text-wrapper">热门{{blog_main_name}}</text>
- <navigator url="/pages/plugins/blog/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
- </view>
- <view class="rolling-horizontal border-radius-main oh">
- <view class="plugins-blog-rolling-list scroll-view-horizontal">
- <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">
- <block v-for="(item, index) in hot_list" :key="index">
- <swiper-item>
- <view class="item bg-white border-radius-main margin-right-main oh pr ht-auto pr">
- <navigator :url="item.url" hover-class="none">
- <image class="blog-img dis-block wh-auto" :src="item.cover" mode="aspectFill"></image>
- <view class="blog-title pa single-text cr-white padding-horizontal-main padding-top-sm padding-bottom-sm">{{item.title}}</view>
- </navigator>
- </view>
- </swiper-item>
- </block>
- </swiper>
- </view>
- </view>
- </view>
-
- <!-- 推荐博文 -->
- <view v-if="right_list.length > 0" class="padding-horizontal-main spacing-mb">
- <view class="spacing-nav-title">
- <text class="text-wrapper">推荐{{blog_main_name}}</text>
- <navigator url="/pages/plugins/blog/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
- </view>
- <view class="right-list padding-horizontal-main border-radius-main bg-white">
- <block v-for="(item, index) in right_list" :key="index">
- <view :class="'item padding-vertical-main oh '+(index > 0 ? 'br-t' : '')">
- <navigator :url="item.url" hover-class="none">
- <view class="blog-title single-text fl">{{item.title}}</view>
- <text class="cr-grey fr">浏览{{item.access_count}}次</text>
- </navigator>
- </view>
- </block>
- </view>
- </view>
- <!-- 推荐商品 -->
- <view v-if="goods_list.length > 0" class="goods-list oh padding-horizontal-main">
- <view class="spacing-nav-title">
- <text class="text-wrapper">推荐商品</text>
- <navigator url="/pages/goods-search/goods-search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
- </view>
- <component-goods-list :propData="{style_type: 1, goods_list: goods_list}" :propCurrencySymbol="currency_symbol"></component-goods-list>
- </view>
- <!-- 结尾 -->
- <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
- </view>
- <view v-else>
- <!-- 提示信息 -->
- <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
- </view>
- </view>
- </template>
- <script>
- const app = getApp();
- import componentSearch from "../../../../components/search/search";
- import componentBanner from "../../../../components/slider/slider";
- import componentCountdown from "../../../../components/countdown/countdown";
- import componentNoData from "../../../../components/no-data/no-data";
- import componentBottomLine from "../../../../components/bottom-line/bottom-line";
- import componentGoodsList from "../../../../components/goods-list/goods-list";
- export default {
- data() {
- return {
- data_bottom_line_status: false,
- data_list_loding_status: 1,
- data_list_loding_msg: '',
- currency_symbol: app.globalData.data.currency_symbol,
- data_base: null,
- category: [],
- data_list: [],
- slide_list: [],
- goods_list: [],
- hot_list: [],
- right_list: [],
- blog_main_name: '博文',
- // 自定义分享信息
- share_info: {}
- };
- },
- components: {
- componentSearch,
- componentBanner,
- componentCountdown,
- componentNoData,
- componentBottomLine,
- componentGoodsList
- },
- props: {},
- onLoad() {},
- onShow() {
- // 初始化配置
- this.init_config();
- // 获取数据
- this.get_data();
- },
- // 下拉刷新
- onPullDownRefresh() {
- this.get_data();
- },
- methods: {
- // 初始化配置
- init_config(status) {
- if ((status || false) == true) {
- this.setData({
- currency_symbol: app.globalData.get_config('currency_symbol'),
- });
- } else {
- app.globalData.is_config(this, 'init_config');
- }
- },
- // 获取数据
- get_data() {
- uni.request({
- url: app.globalData.get_request_url("index", "index", "blog"),
- method: 'POST',
- data: {},
- dataType: 'json',
- success: res => {
- uni.stopPullDownRefresh();
- if (res.data.code == 0) {
- var data = res.data.data;
- this.setData({
- data_base: data.base || null,
- category: data.category || [],
- data_list: data.data_list || [],
- slide_list: data.slide_list || [],
- goods_list: data.goods_list || [],
- hot_list: data.hot_list || [],
- right_list: data.right_list || [],
- blog_main_name: ((data.base || null) == null) ? '博文' : (data.base.blog_main_name || '博文'),
- data_list_loding_msg: '',
- data_list_loding_status: 0,
- data_bottom_line_status: true
- });
- // 基础自定义分享
- var title = this.data_base.seo_title || this.data_base.application_name;
- this.setData({
- share_info: {
- title: title,
- desc: this.data_base.seo_desc,
- path: '/pages/plugins/blog/index/index',
- img: ((this.slide_list || null) != null && this.slide_list.length > 0) ? this.slide_list[0]['images_url'] : ''
- }
- });
- } else {
- this.setData({
- data_bottom_line_status: false,
- data_list_loding_status: 2,
- data_list_loding_msg: res.data.msg
- });
- }
- // 标题
- uni.setNavigationBarTitle({title: title});
- // 分享菜单处理
- app.globalData.page_share_handle(this.share_info);
- },
- fail: () => {
- uni.stopPullDownRefresh();
- this.setData({
- data_bottom_line_status: false,
- data_list_loding_status: 2,
- data_list_loding_msg: '服务器请求出错'
- });
- app.globalData.showToast('服务器请求出错');
- }
- });
- },
-
- // url事件
- url_event(e) {
- app.globalData.url_event(e);
- }
- }
- };
- </script>
- <style>
- @import './index.css';
- </style>
|