支持文章

master
gongfuxiang 2021-11-10 13:02:58 +08:00
parent a23a0a3962
commit fb8a702647
7 changed files with 431 additions and 7 deletions

View File

@ -71,9 +71,9 @@
"path": "pages/goods-detail/goods-detail",
"style": {
// #ifdef MP-WEIXIN
"usingComponents": {
"share-button": "plugin://goodsSharePlugin/share-button"
},
// "usingComponents": {
// "share-button": "plugin://goodsSharePlugin/share-button"
// },
// #endif
"enablePullDownRefresh": true,
"navigationBarTitleText": "商品详情",
@ -207,6 +207,20 @@
"navigationBarTitleText": "页面设计"
}
},
{
"path": "pages/article-category/article-category",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "所有文章"
}
},
{
"path": "pages/article-detail/article-detail",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "文章详情"
}
},
{
"path": "pages/plugins/seckill/index/index",
"style": {

View File

@ -0,0 +1,14 @@
/**
*
*/
.nav-list {
height: 80rpx;
line-height: 80rpx;
}
/**
*
*/
.scroll-box {
height: calc(100vh - 80rpx);
}

View File

@ -0,0 +1,245 @@
<template>
<view>
<!-- 分类 -->
<scroll-view v-if="(category_list || null) != null && category_list.length > 0" class="nav-list scroll-view-horizontal bg-white oh" scroll-x="true">
<view :class="'item cr-gray dis-inline-block padding-horizontal-main ' + (nav_active_value == 0 ? 'cr-main' : '')" @tap="nav_event" data-value="0">全部</view>
<block v-for="(item, index) in category_list" :key="index">
<view :class="'item cr-gray dis-inline-block padding-horizontal-main ' + (nav_active_value == item.id ? 'cr-main' : '')" @tap="nav_event" :data-value="item.id">{{item.name}}</view>
</block>
</scroll-view>
<!-- 列表 -->
<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="30">
<view v-if="(data_list || null) != null && data_list.length > 0" class="data-list padding-horizontal-main padding-top-main oh">
<block v-for="(item, index) in data_list" :key="index">
<view class="item padding-main border-radius-main bg-white oh spacing-mb">
<navigator :url="item.url" hover-class="none">
<view class="cr-base fw-b" :style="(item.title_color || null) != null ? 'color:'+item.title_color+' !important;' : ''">{{item.title}}</view>
<view class="cr-grey oh margin-top-sm">
<text class="fl">{{item.add_time}}</text>
<text class="fr">浏览量 {{item.access_count}}</text>
</view>
</navigator>
</view>
</block>
</view>
<view v-else>
<!-- 提示信息 -->
<component-no-data :prop-status="data_list_loding_status" :prop-msg="data_list_loding_msg"></component-no-data>
</view>
<!-- 结尾 -->
<component-bottom-line :prop-status="data_bottom_line_status"></component-bottom-line>
</scroll-view>
</view>
</template>
<script>
const app = getApp();
import componentNoData from "../../components/no-data/no-data";
import componentBottomLine from "../../components/bottom-line/bottom-line";
export default {
data() {
return {
data_list_loding_status: 1,
data_list_loding_msg: '',
data_bottom_line_status: false,
data_list: [],
data_total: 0,
data_page_total: 0,
data_page: 1,
params: null,
category_list: [],
nav_active_value: 0
};
},
components: {
componentNoData,
componentBottomLine
},
props: {},
onLoad(params) {
//
params = app.globalData.launch_params_handle(params);
this.setData({
params: params,
nav_active_value: params.id || 0
});
//
this.get_data();
//
app.globalData.show_share_menu();
},
//
onPullDownRefresh() {
this.setData({
data_page: 1
});
this.get_data_list(1);
},
//
onShareAppMessage() {
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
return {
title: this.data_base.seo_title || this.data_base.application_name || app.globalData.data.application_title,
desc: this.data_base.seo_desc || app.globalData.data.application_describe,
path: '/pages/article-category/article-category?id='+this.nav_active_value+'&referrer=' + user_id
};
},
//
onShareTimeline() {
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
return {
title: this.data_base.seo_title || this.data_base.application_name || app.globalData.data.application_title,
query: 'id='+this.nav_active_value+'&referrer=' + user_id
};
},
methods: {
//
get_data() {
uni.showLoading({
title: "加载中..."
});
uni.request({
url: app.globalData.get_request_url("index", "article"),
method: "POST",
data: {},
dataType: "json",
success: res => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
this.setData({
category_list: data.category_list || []
});
//
this.get_data_list(1);
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: res.data.msg
});
app.globalData.showToast(res.data.msg);
}
},
fail: () => {
uni.hideLoading();
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2
});
app.globalData.showToast("服务器请求出错");
}
});
},
//
get_data_list(is_mandatory) {
//
if ((is_mandatory || 0) == 0) {
if (this.data_bottom_line_status == true) {
uni.stopPullDownRefresh();
return false;
}
}
// loding
uni.showLoading({
title: "加载中..."
});
//
uni.request({
url: app.globalData.get_request_url("datalist", "article"),
method: "POST",
data: {
page: this.data_page,
id: this.nav_active_value || 0
},
dataType: "json",
success: res => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
if (data.data.length > 0) {
if (this.data_page <= 1) {
var temp_data_list = data.data;
} else {
var temp_data_list = this.data_list;
var temp_data = data.data;
for (var i in temp_data) {
temp_data_list.push(temp_data[i]);
}
}
this.setData({
data_list: temp_data_list,
data_total: data.total,
data_page_total: data.page_total,
data_list_loding_status: 3,
data_page: this.data_page + 1
});
//
this.setData({
data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
});
} else {
this.setData({
data_list_loding_status: 0
});
if (this.data_page <= 1) {
this.setData({
data_list: [],
data_bottom_line_status: false
});
}
}
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: res.data.msg
});
app.globalData.showToast(res.data.msg);
}
},
fail: () => {
uni.hideLoading();
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2
});
app.globalData.showToast("服务器请求出错");
}
});
},
//
scroll_lower(e) {
this.get_data_list();
},
//
nav_event(e) {
this.setData({
nav_active_value: e.currentTarget.dataset.value || 0,
data_page: 1
});
this.get_data_list(1);
}
}
};
</script>
<style>
@import './article-category.css';
</style>

View File

@ -0,0 +1,3 @@
.last-next-data navigator {
width: calc(100% - 105rpx);
}

View File

@ -0,0 +1,150 @@
<template>
<view>
<view v-if="(data || null) != null" class="padding-main">
<view class="padding-main border-radius-main bg-white spacing-mb">
<view class="fw-b text-size-xl">{{data.title}}</view>
<view class="cr-grey margin-top-lg oh br-t padding-top-main">
<view class="fl">
<text>发布时间</text>
<text>{{data.add_time}}</text>
</view>
<view class="fr">
<text class="margin-left-xxxl">浏览次数</text>
<text>{{data.access_count}}</text>
</view>
</view>
</view>
<view v-if="(data.content || null) != null" class="padding-main border-radius-main bg-white oh spacing-mb">
<rich-text :nodes="data.content"></rich-text>
</view>
<view v-if="(last_next || null) != null" class="last-next-data spacing-mb">
<view v-if="(last_next.last || null) != null">
<text class="cr-gray va-m">上一篇</text>
<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>
</view>
<view v-if="(last_next.next || null) != null" class="margin-top-sm">
<text class="cr-gray va-m">下一篇</text>
<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>
</view>
</view>
</view>
<view v-else>
<!-- 提示信息 -->
<component-no-data :prop-status="data_list_loding_status" :prop-msg="data_list_loding_msg"></component-no-data>
</view>
</view>
</template>
<script>
const app = getApp();
import componentNoData from "../../components/no-data/no-data";
import componentBottomLine from "../../components/bottom-line/bottom-line";
export default {
data() {
return {
data_list_loding_status: 1,
data_list_loding_msg: '',
data_bottom_line_status: false,
params: null,
data: null,
last_next: null
};
},
components: {
componentNoData,
componentBottomLine
},
props: {},
onLoad(params) {
//
params = app.globalData.launch_params_handle(params);
this.setData({
params: params
});
//
this.get_data();
//
app.globalData.show_share_menu();
},
//
onPullDownRefresh() {
this.get_data();
},
//
onShareAppMessage() {
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
var article_id = this.params.id || 0;
return {
title: this.data.seo_title || this.data.title || app.globalData.data.application_title,
desc: this.data.seo_desc || app.globalData.data.application_describe,
path: '/pages/article-detail/article-detail?id='+article_id+'&referrer=' + user_id
};
},
//
onShareTimeline() {
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
var article_id = this.params.id || 0;
return {
title: this.data.seo_title || this.data.title || app.globalData.data.application_title,
query: 'id='+article_id+'&referrer=' + user_id
};
},
methods: {
//
get_data() {
uni.showLoading({
title: "加载中..."
});
uni.request({
url: app.globalData.get_request_url("detail", "article"),
method: "POST",
data: {
id: this.params.id || 0,
},
dataType: "json",
success: res => {
uni.hideLoading();
uni.stopPullDownRefresh();
var data = res.data.data;
if (res.data.code == 0 && (data.data || null) != null) {
this.setData({
data_bottom_line_status: true,
data_list_loding_status: 3,
data: data.data,
last_next: data.last_next || null
});
//
uni.setNavigationBarTitle({title: data.data.title});
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: res.data.msg
});
app.globalData.showToast(res.data.msg);
}
},
fail: () => {
uni.hideLoading();
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2
});
app.globalData.showToast("服务器请求出错");
}
});
}
}
};
</script>
<style>
@import './article-detail.css';
</style>

View File

@ -784,9 +784,7 @@
});
//
uni.setNavigationBarTitle({
title: data.goods.title
});
uni.setNavigationBarTitle({title: data.goods.title});
//
this.setData({

View File

@ -15,7 +15,7 @@
</scroll-view>
<!-- 列表 -->
<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="30">
<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="30" :style="slider_list.length > 0 ? 'height:calc(100vh - 320rpx);' : ''">
<view v-if="(data_list || null) != null && data_list.length > 0" class="data-list padding-horizontal-main padding-top-main oh">
<block v-for="(item, index) in data_list" :key="index">
<view class="item border-radius-main bg-white oh spacing-mb">