Browse Source

资讯中心开发,分类全部标的

master
wanghongjun 2 years ago
parent
commit
a582c5e508
  1. 38
      api/category/index.js
  2. 7
      core/app.js
  3. 18
      pages.json
  4. 269
      pages/category/consulting/detail.vue
  5. 344
      pages/category/consulting/list.vue
  6. 159
      pages/category/index.vue

38
api/category/index.js

@ -2,10 +2,46 @@ import request from '@/utils/request'
// api地址
const api = {
list: 'category/list'
list: 'category/list',
consultingContextList: 'AgencyAddress/ConsultingContext/getList',
consultingContextSelection: 'AgencyAddress/ConsultingContext/getSelection',
consultingContextInfo: 'AgencyAddress/ConsultingContext/getInfo',
}
// 页面数据
export function list() {
return request.get(api.list)
}
// 资讯中心列表
export function consultingContextList(param) {
let paramArr = [];
for (let key in param) {
paramArr.push(key + '=' + param[key])
}
let paramStr = '?' + paramArr.join('&')
return request.get(api.consultingContextList + paramStr)
}
// 资讯信息详情
export function consultingContextInfo(contextId) {
return request.get(api.consultingContextInfo + '?contextId=' + contextId)
}
// 获取资讯中心列表分类
export function consultingContextSelection() {
return request.get(api.consultingContextSelection)
}
/**
* 加载更多列表数据
* @param {Object} resList 新列表数据
* @param {Object} oldList 旧列表数据
* @param {int} pageNo 当前页码
*/
export const getMoreListData = (resList, oldList, pageNo) => {
// 如果是第一页需手动制空列表
if (pageNo == 1) oldList = []
// 合并新数据
return oldList.concat(resList)
}

7
core/app.js

@ -105,7 +105,12 @@ export const navTo = (url, query = {}, modo = 'navigateTo') => {
return true
}
// 生成query参数
const queryStr = !util.isEmpty(query) ? '?' + util.urlEncode(query) : ''
let queryArr = [];
for (let key in query) {
queryArr.push(key + '=' + query[key])
}
let paramStr = queryArr.join('&')
const queryStr = !util.isEmpty(query) ? '?' + paramStr : ''
// 普通页面, 使用navigateTo
modo === 'navigateTo' && uni.navigateTo({
url: `/${url}${queryStr}`

18
pages.json

@ -37,7 +37,23 @@
{
"path": "pages/category/index",
"style": {
"navigationBarTitleText": "全部分类"
"navigationBarTitleText": "全部分类",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#1c223b"
}
},
{
"path": "pages/category/consulting/list",
"style": {
"navigationBarTitleText": "资讯中心",
"enablePullDownRefresh" : false
}
},
{
"path": "pages/category/consulting/detail",
"style": {
"navigationBarTitleText": "阅读全文",
"enablePullDownRefresh" : false
}
},
{

269
pages/category/consulting/detail.vue

@ -0,0 +1,269 @@
<template>
<view class="container">
<view class="secondary">
<!-- 二级分类 20 -->
<view class="cate-content">
<!-- 左侧 一级分类 -->
<scroll-view class="cate-left" scroll-y="true">
<view class="type-nav" :class="{ selected: curIndex == index }" v-for="(item, index) in informationList" :key="index"
@click="handleSelectNav(index,item.consultingId)">
<image class="cate-left-image" :src="'./static/tabbar/recommend-cate.png'"></image>
<text class="cate-left-text">{{ item.consultingName }}</text>
</view>
</scroll-view>
<!-- 右侧 二级分类 -->
<scroll-view class="cate-right" :scroll-top="scrollTop" :scroll-y="true" :style="{ height: `${scrollHeight}px` }">
<view v-if="list" class="cate-right-cont">
<view class="cate-two-box">
<view class="cate-cont-box">
<view class="flex-three">
<view class="cate-cont">
<view class="cate-cont-title">
<text v-if="list.contextTitle">{{list.contextTitle}}</text>
<text v-else>无标题信息</text>
</view>
<view class="cate-cont-context">
<rich-text :nodes="list.context"></rich-text>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 空白提示 -->
<view v-else class="cate-right-cont">
<view class="empty-content">
<view class="empty-icon">
<image class="image" src="/static/empty.png" mode="widthFix"></image>
</view>
<view class="tips">暂无数据</view>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
import MescrollCompMixin from '@/components/mescroll-uni/mixins/mescroll-comp'
import { PageCategoryStyleEnum } from '@/common/enum/store/page/category'
import * as CategoryApi from '@/api/category'
import Empty from '@/components/empty'
import Secondary from './../components/secondary'
import { rpx2px,base64ToUint8Array} from '@/utils/util'
//
let limit=4;
//
let lastRefreshTime;
export default {
components: {
Empty,
Secondary,
},
mixins: [MescrollCompMixin],
data() {
return {
//
PageCategoryStyleEnum,
//
informationList: [],
//
list: [],
//
setting: {},
//
isLoading: true,
//
curIndex: 0,
//
page:1,
//
scrollHeight: 0,
//
scrollTop: 0,
// id
contextId: '',
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.contextId = options.contextId
this.curIndex = options.curIndex ? options.curIndex : 0
//
this.onRefreshPage()
this.getConsultingContextSelection()
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 5
const curTime = new Date().getTime()
if ((curTime - lastRefreshTime) > 5 * 60 * 1000) {
this.onRefreshPage()
}
},
created() {
//
this.setListHeight()
},
methods: {
//
setListHeight() {
const { windowHeight } = uni.getSystemInfoSync()
this.scrollHeight = windowHeight - rpx2px(96)
},
//
onRefreshPage() {
//
lastRefreshTime = new Date().getTime()
//
this.getCatList()
},
//
handleSelectNav(curIndex, consultingId) {
this.$navTo('pages/category/consulting/list', { consultingId,curIndex })
},
//
getCatList(){
const app = this
CategoryApi.consultingContextInfo(app.contextId).then(res => {
if (res.resultCode === '00000000') {
app.list = res.data
}
})
},
//
getConsultingContextSelection() {
const app = this
CategoryApi.consultingContextSelection().then(res=>{
if (res.resultCode == '00000000') {
app.informationList = res.data
} else {
app.$error('获取资讯信息失败')
}
})
},
}
}
</script>
<style>
page {
background: #fff;
position: relative;
}
</style>
<style lang="scss" scoped>
.secondary{
z-index: 19;
height: 100vh;
}
//
.cate-content {
display: flex;
z-index: 1;
background: #fff;
padding-top: 6rpx;
height: 100%;
}
// + 20
.cate-left {
// height: 100%;
display: flex;
flex-direction: column;
flex: 0 0 26%;
background: #f8f8f8;
color: #444;
margin-right: 22rpx;
}
//
.flex-three {
float: left;
width: 100%;
.cate-cont {
width: 96%;
height: 100%;
padding: 16rpx;
margin-top: 20rpx;
margin-right: 60rpx;
color: #8e908e;
background-color: #f7f7f7;
display: block;
position: relative;
.cate-cont-context img {
width: 100%;
height: 100%;
margin-top: 20rpx;
}
.cate-cont-title {
width: 100%;
border-radius: 10rpx;
padding: 0rpx 20rpx 0rpx 20rpx;
color: #0b0b0b;
background-color: #a8a8a8;
text-align: center;
}
}
}
//
.type-nav {
position: relative;
height: 180rpx;
z-index: 10;
font-size: 26rpx;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
&.selected {
background: #fff;
color: #cec7bf;
border-right: none;
font-size: 28rpx;
font-weight: bold;
}
.cate-left-image{
position: absolute;
width: 50rpx;
height: 50rpx;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.cate-left-text{
position: absolute;
margin-top: 80rpx;
}
}
//
.cate-cont-box {
margin-bottom: 30rpx;
padding-bottom: 10rpx;
background: #fff;
overflow: hidden;
}
</style>

344
pages/category/consulting/list.vue

@ -0,0 +1,344 @@
<template>
<view class="container">
<view class="secondary">
<!-- 二级分类 20 -->
<view class="cate-content">
<!-- 左侧 一级分类 -->
<scroll-view class="cate-left" scroll-y="true">
<view class="type-nav" :class="{ selected: curIndex == index }" v-for="(item, index) in informationList" :key="index"
@click="handleSelectNav(index,item.consultingId)">
<image class="cate-left-image" :src="'./static/tabbar/recommend-cate.png'"></image>
<text class="cate-left-text">{{ item.consultingName }}</text>
</view>
</scroll-view>
<!-- 右侧 二级分类 -->
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }" @down="downCallback" :up="upOption" @up="upCallback">
<scroll-view class="cate-right" :scroll-top="scrollTop" :scroll-y="true" :style="{ height: `${scrollHeight}px` }">
<view v-if="list.length>0" class="cate-right-cont">
<view class="cate-two-box">
<view class="cate-cont-box">
<view class="flex-three" v-for="(item, idx) in list" :key="idx" >
<view class="cate-cont">
<view class="cate-title">
<text class="cate-title-label">标题名称</text>
{{item.contextTitle}}
</view>
<view class="cate-date">
<text class="cate-title-label">发布时间</text>
{{item.contextCreationTime}}
</view>
<view class="cate-bt">
<button @click="onConsulting(item.contextId,curIndex)">阅读全文</button>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 空白提示 -->
<view v-else class="cate-right-cont">
<view class="empty-content">
<view class="empty-icon">
<image class="image" src="/static/empty.png" mode="widthFix"></image>
</view>
<view class="tips">暂无数据</view>
</view>
</view>
</scroll-view>
</mescroll-body>
</view>
</view>
</view>
</template>
<script>
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import MescrollCompMixin from '@/components/mescroll-uni/mixins/mescroll-comp'
import { PageCategoryStyleEnum } from '@/common/enum/store/page/category'
import * as CategoryApi from '@/api/category'
import Empty from '@/components/empty'
import Secondary from './../components/secondary'
import { rpx2px,base64ToUint8Array} from '@/utils/util'
//
let pageSize = 10
//
let lastRefreshTime;
export default {
components: {
Empty,
Secondary,
//
MescrollBody
},
mixins: [MescrollCompMixin,MescrollMixin],
data() {
return {
//
PageCategoryStyleEnum,
//
informationList: [],
//
list: [],
//
setting: {},
//
isLoading: true,
//
curIndex: 0,
//
scrollHeight: 0,
//
scrollTop: 0,
// id
consultingId: '',
//
upOption: {
//
auto: true,
// ; 10
page: { size: pageSize },
// 4
noMoreSize: 4,
//
empty: {
tip: '暂无记录'
}
},
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.consultingId = options.consultingId
this.curIndex = options.curIndex ? options.curIndex : 0
//
this.onRefreshPage()
this.getConsultingContextSelection()
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 5
const curTime = new Date().getTime()
if ((curTime - lastRefreshTime) > 5 * 60 * 1000) {
this.onRefreshPage()
}
},
created() {
//
this.setListHeight()
},
methods: {
//
setListHeight() {
const { windowHeight } = uni.getSystemInfoSync()
this.scrollHeight = windowHeight - rpx2px(96)
},
//
onRefreshPage() {
//
lastRefreshTime = new Date().getTime()
//
this.getPageData()
//
this.getCatList()
},
//
getPageData() {
const app = this
app.isLoading = true
Promise.all([]).then(result => {}).finally(() => app.isLoading = false)
},
//
handleSelectNav(index,consultingId) {
this.curIndex = index
this.scrollTop = 0
this.consultingId = consultingId
this.getCatList()
},
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
//
app.getCatList(page.num).then(list => {
const curPageLen = list.length
const totalSize = list.total
app.mescroll.endBySize(curPageLen, totalSize)
})
.catch(() => app.mescroll.endErr())
},
//
getCatList(pageIndex = 1){
const app = this
let param = {
pageIndex : pageIndex,
pageRows : pageSize,
contextConsultingId : app.consultingId
}
return new Promise((resolve, reject) => {
CategoryApi.consultingContextList(param).then(res => {
if (res.resultCode === '00000000') {
let newList = res.data.pageDataList;
app.list = CategoryApi.getMoreListData(newList, app.list, pageIndex)
resolve(newList)
}
})
})
},
//
onConsulting(contextId,curIndex){
this.$navTo('pages/category/consulting/detail', { contextId,curIndex})
},
//
getConsultingContextSelection() {
const app = this
CategoryApi.consultingContextSelection().then(res=>{
if (res.resultCode == '00000000') {
app.informationList = res.data
} else {
app.$error('获取资讯信息失败')
}
})
},
}
}
</script>
<style>
page {
background: #fff;
position: relative;
}
</style>
<style lang="scss" scoped>
.secondary{
z-index: 19;
height: 100vh;
}
//
.cate-content {
display: flex;
z-index: 1;
background: #fff;
padding-top: 6rpx;
height: 100%;
}
// + 20
.cate-left {
// height: 100%;
display: flex;
flex-direction: column;
flex: 0 0 26%;
background: #f8f8f8;
color: #444;
margin-right: 22rpx;
}
//
.flex-three {
float: left;
width: 100%;
.cate-cont {
width: 96%;
height: 300rpx;
padding: 16rpx;
margin-top: 20rpx;
margin-right: 60rpx;
color: #8e908e;
background-color: #f7f7f7;
display: block;
position: relative;
.cate-title {
margin-right: 20rpx;
margin-top: 20rpx;
}
.cate-title-label {
color: #0b0b0b;
font-weight: bold;
}
.cate-date {
position: absolute;
top: 200rpx;
}
.cate-bt {
position: absolute;
top: 240rpx;
left: 385rpx;
width: 110rpx;
height: 50rpx;
border-radius: 5rpx;
border: 1rpx #8e908e solid;
background-color: #fff;
button {
padding-right: 0rpx;
padding-left: 0rpx;
font-size: 19rpx;
color: #8e908e;
}
}
}
}
//
.type-nav {
position: relative;
height: 180rpx;
z-index: 10;
font-size: 26rpx;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
&.selected {
background: #fff;
color: #cec7bf;
border-right: none;
font-size: 28rpx;
font-weight: bold;
}
.cate-left-image{
position: absolute;
width: 50rpx;
height: 50rpx;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.cate-left-text{
position: absolute;
margin-top: 80rpx;
}
}
//
.cate-cont-box {
margin-bottom: 30rpx;
padding-bottom: 10rpx;
background: #fff;
overflow: hidden;
}
</style>

159
pages/category/index.vue

@ -1,20 +1,25 @@
<template>
<view class="container">
<!-- 搜索框 -->
<search class="search" tips="搜索商品" @event="$navTo('pages/search/index')" />
<!-- 搜索 -->
<view class="sozone">
<search class="search" tips="请输入店铺/标的名称关键字"/>
</view>
<view class="secondary">
<!-- 二级分类 20 -->
<view class="cate-content">
<!-- 左侧 一级分类 -->
<scroll-view class="cate-left" scroll-y="true">
<text class="type-nav" :class="{ selected: curIndex == index }" v-for="(item, index) in menus" :key="index"
@click="handleSelectNav(index)">{{ item.name }}</text>
<view class="type-nav" :class="{ selected: curIndex == index }" v-for="(item, index) in menus" :key="index"
@click="handleSelectNav(index)">
<image class="cate-left-image" :src="'./static/tabbar/recommend-cate.png'"></image>
<text class="cate-left-text">{{ item.name }}</text>
</view>
</scroll-view>
<!-- 右侧 二级分类 -->
<scroll-view class="cate-right" :scroll-top="scrollTop" :scroll-y="true" :style="{ height: `${scrollHeight}px` }">
<!-- 有数据的时候 -->
<view v-if="list.length>0" class="cate-right-cont">
<view v-if="list.length>0 && type==0" class="cate-right-cont">
<view class="cate-two-box">
<view class="cate-cont-box">
<view class="flex-two" v-for="(item, idx) in list" :key="idx" @click="onTargetGoods(item.goods_islicode)">
@ -28,6 +33,17 @@
</view>
</view>
</view>
<view v-else-if="informationList.length>0 && type==2" class="cate-right-cont">
<view class="cate-two-box">
<view class="cate-cont-box">
<view class="flex-three" v-for="(item, idx) in informationList" :key="idx" @click="onConsulting(item.consultingId)">
<view class="cate-selected">
{{item.consultingName}}
</view>
</view>
</view>
</view>
</view>
<!-- 空白提示 -->
<view v-else class="cate-right-cont">
@ -62,17 +78,20 @@
import { rpx2px,base64ToUint8Array} from '@/utils/util'
import pako from '@/core/pako'
import {consultingContextSelection} from "../../api/category";
// ()
const menus = [
{ id: 'all', name: '全部标的数据', type:0},
{ id: 'rs', name: '文化资源数据', type: 1 },
{ id: 'rd', name: '文化数字内容', type: 2 },
{name: '全部标的', type:0 },
{name: '数据店铺', type: 1 },
{name: '资讯中心', type: 2 },
{name: '文化数据经纪商', type: 3 },
{name: '交易主体', type: 4 },
]
//
let limit=30;
let limit=4;
//
let lastRefreshTime;
@ -104,6 +123,8 @@
scrollTop: 0,
//
menus,
type: 0,
informationList: [], // selected
}
},
@ -130,13 +151,11 @@
this.setListHeight()
},
methods: {
//
setListHeight() {
const { windowHeight } = uni.getSystemInfoSync()
this.scrollHeight = windowHeight - rpx2px(96)
},
//
onRefreshPage() {
//
@ -145,7 +164,6 @@
this.getPageData()
//
this.getCatList()
},
//
@ -165,60 +183,49 @@
// app.initSetting(result[0])
//
// app.initCategory(result[1])
//
})
.finally(() => app.isLoading = false)
},
//
handleSelectNav(index) {
this.curIndex = index
this.scrollTop = 0
//
this.getCatList()
},
//
getAllGoods(){
let rd={"goods_status":1,"page":this.page,"limit":limit}
this.bindData(rd)
},
//
getCatList(){
console.log("curindex",this.curIndex)
let item = menus[this.curIndex]
// console.log(item)
let type= item.type
let type = item.type
this.type = type
if (type === 1) {
} else if (type === 2) {
this.getConsultingContextSelection()
} else if (type === 3) {
if(type>0){
let rd={"record_type":type,"goods_status":1,"page":this.page,"limit":limit}
} else if (type === 4) {
} else {
let rd={"goods_status":1,"page":this.page,"limit":limit}
this.bindData(rd)
}else{
this.getAllGoods()
}
},
//
onTargetGoods(gislicode){
// this.$toast(goodsId)
this.$navTo('pages/goods/detail', { gislicode })
},
//
//
onConsulting(consultingId){
this.$navTo('pages/category/consulting/list', { consultingId })
},
//
async bindData(rd){
GoodsApi.nbgoods(rd).then(res=>{
this.list = res.data.data
this.page=res.data.current_page
console.log("res",res)
this.getHomeListImage()
});
//
//this.initList(this.list)
},
async getHomeListImage() {
this.list.forEach((item, key) => {
@ -232,7 +239,17 @@
}
})
},
//
getConsultingContextSelection() {
const app = this
CategoryApi.consultingContextSelection().then(res=>{
if (res.resultCode == '00000000') {
app.informationList = res.data
} else {
app.$error('获取资讯信息失败')
}
});
},
//
initList(newList) {
newList.data.forEach(item => {
@ -240,17 +257,12 @@
})
return newList
},
},
filters:{
gdimg:function(value){
return pako.inflateRaw(base64ToUint8Array(value), {to: 'string'})
}
}
}
</script>
@ -262,12 +274,12 @@
</style>
<style lang="scss" scoped>
//
.search {
position: fixed;
top: var(--window-top);
left: var(--window-left);
right: var(--window-right);
z-index: 19;
.sozone{
position: relative;
z-index: 70;
width: 100%;
height: 120rpx;
background-color: #1c223b;
}
//
@ -282,7 +294,7 @@
display: flex;
z-index: 1;
background: #fff;
padding-top: 96rpx;
padding-top: 6rpx;
height: 100%;
}
@ -302,12 +314,31 @@
width: 50%;
}
//
.flex-three {
float: left;
width: 100%;
.cate-selected {
width: 100%;
height: 200rpx;
color: #8e908e;
background-color: #f7f7f7;
margin-top: 20rpx;
padding-top: 70rpx;
font-size: 45rpx;
text-align: center;
font-weight: 520;
}
}
.cate-right {
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
//
.cate-right-cont {
width: 100%;
display: flex;
@ -319,7 +350,6 @@
width: 100%;
padding: 0 10px;
}
//
.empty-content {
box-sizing: border-box;
@ -344,19 +374,32 @@
//
.type-nav {
position: relative;
height: 90rpx;
height: 180rpx;
z-index: 10;
display: block;
font-size: 26rpx;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
&.selected {
background: #fff;
color: #fa2209;
color: #cec7bf;
border-right: none;
font-size: 28rpx;
font-weight: bold;
}
.cate-left-image{
position: absolute;
width: 50rpx;
height: 50rpx;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.cate-left-text{
position: absolute;
margin-top: 80rpx;
}
}
@ -376,6 +419,8 @@
}
.cate-img-padding {
background-color: #f7f7f7;
margin-right: 20rpx;
padding: 16rpx 16rpx 4rpx 16rpx;
}

Loading…
Cancel
Save