Browse Source

数据逻辑

master
lqq 6 years ago
parent
commit
67cdac07ed
  1. 1
      app.json
  2. 2
      components/card/index.js
  3. 2
      components/segment/index.wxss
  4. 34
      models/artice.js
  5. 2
      models/auth.js
  6. 28
      models/billboard.js
  7. 8
      models/home.js
  8. 50
      models/policy.js
  9. 131
      pages/article/index.js
  10. 6
      pages/article/index.wxml
  11. 121
      pages/billboards/firm/index.js
  12. 1
      pages/billboards/firm/index.json
  13. 7
      pages/billboards/firm/index.wxml
  14. 57
      pages/billboards/park/index.js
  15. 4
      pages/billboards/park/index.json
  16. 9
      pages/billboards/park/index.wxml
  17. 15
      pages/billboards/park/index.wxss
  18. 60
      pages/billboards/park/park-list/index.js
  19. 7
      pages/billboards/park/park-list/index.json
  20. 9
      pages/billboards/park/park-list/index.wxml
  21. 20
      pages/billboards/park/park-list/index.wxss
  22. 5
      pages/billboards/policy/components/tags/index.js
  23. 6
      pages/billboards/policy/components/tags/index.wxml
  24. 1
      pages/billboards/policy/components/tags/index.wxss
  25. 141
      pages/billboards/policy/index.js
  26. 1
      pages/billboards/policy/index.json
  27. 8
      pages/billboards/policy/index.wxml
  28. 112
      pages/billboards/policy/policy-list/index.js
  29. 28
      pages/home/index.js
  30. 15
      utils/http.js

1
app.json

@ -6,6 +6,7 @@
"pages/topics/index", "pages/topics/index",
"pages/billboards/firm/index", "pages/billboards/firm/index",
"pages/billboards/park/index", "pages/billboards/park/index",
"pages/billboards/park/park-list/index",
"pages/billboards/policy/index", "pages/billboards/policy/index",
"pages/billboards/policy/policy-list/index", "pages/billboards/policy/policy-list/index",
"pages/article/index", "pages/article/index",

2
components/card/index.js

@ -22,7 +22,7 @@ Component({
*/ */
methods: { methods: {
onTap () { onTap () {
this.triggerEvent('clickCardItem', this.properties.cId) this.triggerEvent('clickCardItem', {id: this.properties.cId})
} }
} }
}) })

2
components/segment/index.wxss

@ -6,7 +6,7 @@
padding: 5px; padding: 5px;
} }
.title { .title {
width: 150rpx; min-width: 150rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

34
models/artice.js

@ -3,9 +3,8 @@ import { HTTP, Method } from '../utils/http.js'
// 请求url常量 // 请求url常量
const ArticeConst = { const ArticeConst = {
artice_url: '/api/content/queryById', artice_url: '/api/content/queryById',
artice_add_collect_url: '/api/content/addCollection', artice_add_remove_collect_url: '/api/content/addOrDeleteCollection',
artice_remove_collect_url: '/api/content/removeCollection', artice_online_url: '/api/content/signin',
artice_online_url: '',
} }
class ArticeModel extends HTTP { class ArticeModel extends HTTP {
@ -16,8 +15,8 @@ class ArticeModel extends HTTP {
getDetail(aId, success) { getDetail(aId, success) {
let params = { let params = {
url: ArticeConst.artice_url, url: ArticeConst.artice_url,
sucess: success, success: success,
method: Method.POST, method: Method.GET,
data: { data: {
id: aId id: aId
} }
@ -26,22 +25,11 @@ class ArticeModel extends HTTP {
} }
// 设置收藏还是取消 // 设置收藏还是取消
// type: 0: 添加;1: 移除 // type: 0: 添加;1: 移除
addCollect(aId, type, success) { addOrRemoveCollect(aId, success) {
let params = {
url: artice_add_collect_url,
success: success,
method: Method.POST,
data: {
id: aId
}
}
this.request(params)
}
removeCollect(aId, success) {
let params = { let params = {
url: artice_remove_collect_url, url: ArticeConst.artice_add_remove_collect_url,
success: success, success: success,
method: Method.POST, method: Method.GET,
data: { data: {
id: aId id: aId
} }
@ -49,13 +37,13 @@ class ArticeModel extends HTTP {
this.request(params) this.request(params)
} }
// 在线报名 // 在线报名
onlineSign (aId, type, success) { onlineSign(aId, type, success) {
let params = { let params = {
url: artice_online_url, url: ArticeConst.artice_online_url,
success: success, success: success,
method: Method.POST, method: Method.GET,
data: { data: {
contentId: aId
} }
} }
this.request(params) this.request(params)

2
models/auth.js

@ -58,7 +58,7 @@ class AuthModel extends HTTP {
}, },
success: (data) => { success: (data) => {
// 将获取到的token存放起来 // 将获取到的token存放起来
let token = data let token = 'test token'
wx.setStorageSync(HTTPConst.TokenStoreKey, token) wx.setStorageSync(HTTPConst.TokenStoreKey, token)
success(token) success(token)
}, },

28
models/billboard.js

@ -1,10 +1,36 @@
import {HTTP, Method} from '../utils/http.js' import {HTTP, Method} from '../utils/http.js'
const BaillConst = {
bail_list_url:'/api/content/getListByCode',
bail_tag_url: '/api/apicategory/childList', // 获取子分类和标题
}
class BillboardModel extends HTTP { class BillboardModel extends HTTP {
constructor () { constructor () {
super() super()
} }
// 根据不同的code获取 列表
fetchBailList (code, page, success) {
const params = {
url: BaillConst.bail_list_url + '?pageNo=' + page,
method: Method.POST,
success: success,
data: {
typeCode: code
}
}
this.request(params)
}
fetchTagsByCode(code, success) {
const params = {
url: BaillConst.bail_tag_url,
success: success,
method: Method.POST,
data: {
code: code
}
}
this.request(params)
}
} }
export {BillboardModel} export {BillboardModel}

8
models/home.js

@ -17,8 +17,6 @@ class HomeModel extends HTTP {
method: Method.POST, method: Method.POST,
data: { data: {
typeCode: 'sc-banner', typeCode: 'sc-banner',
page: 1,
pageSize: 20,
}, },
success: success success: success
} }
@ -31,8 +29,6 @@ class HomeModel extends HTTP {
method: Method.POST, method: Method.POST,
data: { data: {
typeCode: 'sc-jdtz', typeCode: 'sc-jdtz',
page: 1,
pageSize: 20,
}, },
success: success success: success
} }
@ -41,12 +37,10 @@ class HomeModel extends HTTP {
// 首页列表 // 首页列表
getHomeList(page, success){ getHomeList(page, success){
let params = { let params = {
url: HOMEConst.home_list_url, url: HOMEConst.home_list_url + '?pageNo=' + page,
method: Method.POST, method: Method.POST,
data: { data: {
typeCode: 'sc-tzgg', typeCode: 'sc-tzgg',
page: page,
pageSize: 20,
}, },
success: success success: success
} }

50
models/policy.js

@ -0,0 +1,50 @@
import { HTTP, Method } from '../utils/http.js'
const PolicyConst = {
policy_tag_url: '/api/apicategory/childList',
policy_list_url: '/api/content/getListByCode',
policy_artice_url: '/api/content/getOneListByCode'
}
class PolicyModel extends HTTP {
constructor() {
super()
}
// 获取人才政策 Tags
fetchPolicyTags(success) {
const params = {
url: PolicyConst.policy_tag_url,
success: success,
method: Method.POST,
data: {
code: 'sc-rczc'
}
}
this.request(params)
}
// 获取政策相关文章列表
fetchPolicyList (page, title='', success) {
const params = {
url: PolicyConst.policy_list_url + '?pageNo=' + page,
success: success,
method: Method.POST,
data: {
typeCode: 'sc-rczc',
title: title
}
}
this.request(params)
}
fetchPolicyArtice (code, success) {
const params = {
url: PolicyConst.policy_artice_url,
success: success,
method: Method.POST,
data: {
typeCode: code
}
}
this.request(params)
}
}
export { PolicyModel }

131
pages/article/index.js

@ -1,106 +1,77 @@
// pages/article/index.js // pages/article/index.js
import {ArticeModel} from '../../models/artice.js'
import dayjs from '../../utils/dayjs/index.js'
let artice = new ArticeModel()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
nodes: `<section class="_editor" data-support="96编辑器" data-style-id="24818"> nodes: '',
<section style="text-align: center;margin:10px 0px;"> isStar: true, // 是否
<section style="width:4px;height:24px;background-color:#ffc100;display:inline-block;vertical-align: middle;transform: rotatez(0deg);"></section> showBtn: true,
<section style="margin-right: -2px; margin-left: -2px; border-style: solid; border-width: 1px; border-color: #000000; padding: 2px 10px; display: inline-block; vertical-align: middle;"> aId: '',
<p style="letter-spacing: 2px;"> title: '',
便民举措<br/> date: '',
</p> origin: '',
</section>
<section style="width:4px;height:24px;background-color:#ffc100;display:inline-block;vertical-align: middle;"></section>
</section>
</section>
<section class="_editor" data-support="96编辑器" data-style-id="24804">
<section style="margin:10px 0px;">
<section style="width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin-top: -12px; margin-left: auto; width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin:-6px 6px;border-style:solid;border-width:1px;border-color:#ffcc9c;background-color:#fefefe;padding:15px;display:inline-block;transform: rotateZ(0deg);-webkit-transform: rotateZ(0deg);-moz-transform: rotateZ(0deg);-ms-transform: rotateZ(0deg);-o-transform: rotateZ(0deg);">
<p style="letter-spacing: 2px;">
<span style="font-size: 14px;">当清晨的一缕阳光透过窗帘上的空隙映照在沉睡的脸庞时微微张开的双眼朦胧地注视着周遭的一切新的一天悄然而至</span>
</p>
</section>
<section style="width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin-top: -12px; margin-left: auto; width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
</section>
</section>
<section class="_editor">
<p>
<br/>
</p>
</section>`,
unStar: '/images/common/star.png', unStar: '/images/common/star.png',
star: '/images/common/star_light.png', star: '/images/common/star_light.png',
isStar: true,
showBtn: true,
}, },
onClickCollect () { onClickCollect () {
this.setData({
isStar: !this.data.isStar
})
// 收藏功能 // 收藏功能
this.addOrRemoveCollectionApi()
}, },
onlineSubmit () { onlineSubmit () {
console.log('在线报名') console.log('在线报名')
this.onlineSignApi() // 在线报名
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options)
}, const {id} = options
this.setData({
/** aId: id
* 生命周期函数--监听页面初次渲染完成 })
*/ this.fetchArticeApi()
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
}, },
fetchArticeApi () {
/** artice.getDetail(this.data.aId, (res) => {
* 生命周期函数--监听页面卸载 console.log('artice detail')
*/ console.log(res)
onUnload: function () { const data = res.result
const date = dayjs(data.createTime).format('MM月DD日')
this.setData({
nodes: data.content,
title: data.title,
date: date,
origin: data.source,
isStar: data.isCollection ? true : false,
showBtn: data.typeFlag == 0 ? false : true
})
})
}, },
addOrRemoveCollectionApi () {
/** artice.addOrRemoveCollect(this.data.aId, res => {
* 页面相关事件处理函数--监听用户下拉动作 console.log(res)
*/ this.setData({
onPullDownRefresh: function () { isStar: !this.data.isStar
})
if (res.code == 200) {
wx.showToast({
title: res.message,
icon: 'none'
})
}
})
}, },
onlineSignApi () {
/** artice.onlineSign(this.data.aId, res => {
* 页面上拉触底事件的处理函数 console.log(res)
*/ })
onReachBottom: function () {
}, },
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
}) })

6
pages/article/index.wxml

@ -1,10 +1,10 @@
<!--pages/article/index.wxml--> <!--pages/article/index.wxml-->
<view class="container"> <view class="container">
<view class="page_hd"> <view class="page_hd">
<view class="artice_title">市北区区情概况市北区区情概况市北区区情概况</view> <view class="artice_title">{{title}}</view>
<view class="artice_info"> <view class="artice_info">
<text class="artice_origin">市北区工作领导小组办公室</text> <text class="artice_origin">{{origin}}</text>
<text class="artice_time">6月7日</text> <text class="artice_time">{{date}}</text>
<image class="artice_collect" src="{{isStar ? star : unStar}}" bindtap="onClickCollect"></image> <image class="artice_collect" src="{{isStar ? star : unStar}}" bindtap="onClickCollect"></image>
</view> </view>
</view> </view>

121
pages/billboards/firm/index.js

@ -1,78 +1,111 @@
// pages/billboards/firm/index.js // pages/billboards/firm/index.js
import { BillboardModel } from '../../../models/billboard.js'
let billboard = new BillboardModel()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
navs: [ list: [],
"千人计划", navs: [],
"泰山学者", curCode: '',
"泰山学者", currPage: 1,
"泰山学者", tags: [],
"泰山学者",
"泰山学者",
]
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.fetchTags() // 获取Tags
}, },
tapSegemnt (e) { tapSegemnt (e) {
console.log(e.detail) console.log(e.detail)
const {index} = e.detail
this.setData({
curCode: this.data.tags[index].code,
currPage: 1,
})
this.fetchList()
}, },
clickCardItem(e) { clickCardItem(e) {
console.log(e.detail) console.log(e.detail)
const { id } = e.detail
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
})
}, },
/** fetchList() {
* 生命周期函数--监听页面初次渲染完成 const { curCode } = this.data
*/ const page = this.data.currPage
onReady: function () { billboard.fetchBailList(curCode, page, res => {
console.log(res)
}, const datas = res.list
let tempDatas = []
/** datas.forEach(item => {
* 生命周期函数--监听页面显示 tempDatas.push({
*/ id: item.id,
onShow: function () { title: item.title,
image: item.titlePic
}, })
})
/** if (page == 1) {
* 生命周期函数--监听页面隐藏 this.setData({
*/ list: tempDatas
onHide: function () { })
} else {
if (tempDatas.length > 0) {
const list = [...this.data.list, ...tempDatas]
this.setData({
list: list
})
} else {
const page = this.data.currPage - 1
this.setData({
currPage: page
})
wx.showToast({
title: '已加载全部',
icon: 'none'
})
}
}
wx.stopPullDownRefresh()
})
}, },
// 获取分类Tags
/** fetchTags () {
* 生命周期函数--监听页面卸载 billboard.fetchTagsByCode('sc-zdqy', res => {
*/ console.log(res)
onUnload: function () { const tags = res.result.records
const navs = tags.map(item => item.name)
this.setData({
navs: navs,
tags: tags,
curCode: tags.length > 0 ? tags[0].code : ''
})
this.fetchList()
})
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
this.setData({
currPage: 1
})
this.fetchList()
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
const page = this.data.currPage + 1
}, this.setData({
currPage: page
/** })
* 用户点击右上角分享 this.fetchList()
*/
onShareAppMessage: function () {
} }
}) })

1
pages/billboards/firm/index.json

@ -1,5 +1,6 @@
{ {
"navigationBarTitleText": "重点企业", "navigationBarTitleText": "重点企业",
"enablePullDownRefresh": true,
"usingComponents": { "usingComponents": {
"e-card": "/components/card/index", "e-card": "/components/card/index",
"e-segment": "/components/segment/index" "e-segment": "/components/segment/index"

7
pages/billboards/firm/index.wxml

@ -4,8 +4,11 @@
<e-segment headerTitles="{{navs}}" bind:tapSegment="tapSegemnt"/> <e-segment headerTitles="{{navs}}" bind:tapSegment="tapSegemnt"/>
</view> </view>
<view class="page_bd"> <view class="page_bd">
<block wx:for="{{[1,3,4]}}" wx:key="*this"> <block wx:for="{{list}}" wx:key="firm-{{index}}">
<e-card cId="{{index}}" <e-card
cId="{{item.id}}"
title="{{item.title}}"
image="{{item.image}}"
tag-class="e_card" tag-class="e_card"
bind:clickCardItem="clickCardItem"/> bind:clickCardItem="clickCardItem"/>
</block> </block>

57
pages/billboards/park/index.js

@ -1,4 +1,5 @@
// pages/billboards/park/index.js // pages/billboards/park/index.js
Page({ Page({
/** /**
@ -14,55 +15,11 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
clickCardItem (e) { onClickItem(e) {
console.log(e.detail) const { code } = e.currentTarget.dataset
}, console.log(code)
/** wx.navigateTo({
* 生命周期函数--监听页面初次渲染完成 url: '/pages/billboards/park/park-list/index?code=' + code,
*/ })
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
}, },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
}) })

4
pages/billboards/park/index.json

@ -1,6 +1,4 @@
{ {
"navigationBarTitleText": "平台载体", "navigationBarTitleText": "平台载体",
"usingComponents": { "usingComponents": {}
"e-card": "/components/card/index"
}
} }

9
pages/billboards/park/index.wxml

@ -1,8 +1,7 @@
<!--pages/billboards/park/index.wxml--> <!--pages/billboards/park/index.wxml-->
<view class="container"> <view class="container">
<block wx:for="{{[1,3,4]}}" wx:key="*this"> <image bindtap="onClickItem" data-code="park-cbd" class="billboard_item" src="/images/billboard/1.png"></image>
<e-card cId="{{index}}" <image bindtap="onClickItem" data-code="park-bhxq" class="billboard_item" src="/images/billboard/2.png"></image>
tag-class="e_card" <image bindtap="onClickItem" data-code="park-cxzy" class="billboard_item" src="/images/billboard/3.png"></image>
bind:clickCardItem="clickCardItem"/> <image bindtap="onClickItem" data-code="park-lswh" class="billboard_item" src="/images/billboard/3.png"></image>
</block>
</view> </view>

15
pages/billboards/park/index.wxss

@ -1,12 +1,13 @@
/* pages/billboards/park/index.wxss */ /* pages/billboards/park/index.wxss */
.container { .container {
padding: 0 3vw; height: 100vh;
display: flex; display: flex;
flex-direction: row; flex-direction: column;
justify-content: space-between; justify-content: center;
flex-wrap: wrap; align-items: center;
} }
.e_card { .billboard_item {
width: 45vw; margin-top: 15px;
margin-bottom: 13px; width: 90%;
height: 100px;
} }

60
pages/billboards/park/park-list/index.js

@ -0,0 +1,60 @@
// pages/billboards/park/index.js
import { BillboardModel } from '../../../../models/billboard.js'
let billboard = new BillboardModel()
Page({
/**
* 页面的初始数据
*/
data: {
list: [],
curCode: '',
curPage:1,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const {code} = options
console.log(code)
this.setData({
curCode: code
})
this.fetchList()
},
clickCardItem (e) {
console.log(e.detail)
const { id } = e.detail
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
})
},
fetchList () {
const {curCode} = this.data
const page = this.data.curPage
billboard.fetchBailList(curCode, page, res => {
console.log(res)
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
curPage: 1,
})
this.fetchList()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
const page = this.data.curPage + 1
this.setData({
curPage: page
})
this.fetchList()
},
})

7
pages/billboards/park/park-list/index.json

@ -0,0 +1,7 @@
{
"navigationBarTitleText": "平台载体",
"enablePullDownRefresh": true,
"usingComponents": {
"e-card": "/components/card/index"
}
}

9
pages/billboards/park/park-list/index.wxml

@ -0,0 +1,9 @@
<!--pages/billboards/park/index.wxml-->
<view class="container">
<block wx:for="{{list}}" wx:key="park-list-{{index}}">
<e-card cId="{{index}}"
tag-class="e_card"
bind:clickCardItem="clickCardItem"/>
</block>
<view wx:if="{{list.length <= 0}}" class="page_empty">暂无数据</view>
</view>

20
pages/billboards/park/park-list/index.wxss

@ -0,0 +1,20 @@
/* pages/billboards/park/index.wxss */
.container {
padding: 0 3vw;
display: flex;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
}
.e_card {
width: 45vw;
margin-bottom: 13px;
}
.page_empty {
width: 100%;
height: 100px;
margin-top: 100px;
font-size: 14px;
color: #aaa;
text-align: center;
}

5
pages/billboards/policy/components/tags/index.js

@ -4,7 +4,10 @@ Component({
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
items: {
type: Array,
value: []
}
}, },
/** /**

6
pages/billboards/policy/components/tags/index.wxml

@ -1,8 +1,8 @@
<!--pages/billboards/policy/tags/index.wxml--> <!--pages/billboards/policy/tags/index.wxml-->
<view class="tags"> <view class="tags" wx:if="{{items.length > 0}}">
<view class="tags-list"> <view class="tags-list">
<block wx:for="{{[1,2,3,4,5,6]}}" wx:key="*this"> <block wx:for="{{items}}" wx:key="tags-{{index}}">
<view class="tag-item" bindtap="onTap" data-index="{{index}}">人才政策</view> <view class="tag-item" bindtap="onTap" data-index="{{index}}">{{item.name}}</view>
</block> </block>
</view> </view>
<view class="tag-all" bindtap="onTap" data-index="0">全部</view> <view class="tag-all" bindtap="onTap" data-index="0">全部</view>

1
pages/billboards/policy/components/tags/index.wxss

@ -7,6 +7,7 @@
border-bottom: 1px solid #f7f7f7; border-bottom: 1px solid #f7f7f7;
} }
.tags-list { .tags-list {
flex:1;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;

141
pages/billboards/policy/index.js

@ -1,33 +1,19 @@
// pages/billboards/policy/index.js // pages/billboards/policy/index.js
Page({ import {PolicyModel} from '../../../models/policy.js'
import dayjs from '../../../utils/dayjs/index.js'
let policy = new PolicyModel()
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list: [ list: [],
{ currPage: 1,
id: '1', searchKey: '',
title: '啦啦啦量阿拉蕾阿拉啦', tags: [],
showTop: true,
time: '刚刚'
},
{
id: '2',
title: '一条大河,向东流',
showTop: false,
time: '1分钟前'
},
{
id: '3',
title: '啦啦啦量阿拉蕾阿拉啦',
showTop: false,
time: '1小时前'
},
]
}, },
clickListItem(e) { clickListItem(e) {
console.log(e.detail)
const {id} = e.detail const {id} = e.detail
wx.navigateTo({ wx.navigateTo({
url: `/pages/article/index?id=${id}`, url: `/pages/article/index?id=${id}`,
@ -37,55 +23,94 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.fetchPolicyTags()
}, this.fetchPolicyList()
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
}, },
onSearchClear (e) {
/** this.setData({
* 生命周期函数--监听页面隐藏 currPage: 1,
*/ searchKey: ''
onHide: function () { })
console.log(e)
this.fetchPolicyList()
}, },
onSearchInput (e) {
/** const key = e.detail.value
* 生命周期函数--监听页面卸载 this.setData({
*/ searchKey: key,
onUnload: function () { currPage: 1,
})
console.log(e)
this.fetchPolicyList()
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
this.setData({
currPage: 1
})
this.fetchPolicyList()
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
const page = this.data.currPage + 1
this.setData({
currPage: page
})
this.fetchPolicyList()
}, },
// 获取 Tags
/** fetchPolicyTags () {
* 用户点击右上角分享 policy.fetchPolicyTags(res => {
*/ const datas = res.result.records
onShareAppMessage: function () { this.setData({
tags: datas
})
wx.setStorageSync('PolicyTags', datas)
})
},
// 获取列表,搜索列表
fetchPolicyList () {
const {searchKey} = this.data
const page = this.data.currPage
policy.fetchPolicyList(page, searchKey, res => {
console.log(res)
const datas = res.list
let tempDatas = []
datas.forEach(item => {
tempDatas.push({
id: item.id,
title: item.title,
showTop: item.isTop == 1 ? true : false,
time: dayjs(item.createTime).toNow(),
})
})
if (page == 1) {
this.setData({
list: tempDatas
})
} else {
if (tempDatas.length > 0) {
const list = [...this.data.list, ...tempDatas]
this.setData({
list: list
})
} else {
const page = this.data.currPage - 1
this.setData({
currPage: page
})
wx.showToast({
title: '已加载全部',
icon: 'none'
})
}
}
wx.stopPullDownRefresh()
})
} }
}) })

1
pages/billboards/policy/index.json

@ -1,5 +1,6 @@
{ {
"navigationBarTitleText": "人才政策", "navigationBarTitleText": "人才政策",
"enablePullDownRefresh": true,
"usingComponents": { "usingComponents": {
"w-searchbar": "/components/weui/searchbar/searchbar", "w-searchbar": "/components/weui/searchbar/searchbar",
"e-cell": "/components/cell/index", "e-cell": "/components/cell/index",

8
pages/billboards/policy/index.wxml

@ -1,11 +1,11 @@
<!--pages/billboards/policy/index.wxml--> <!--pages/billboards/policy/index.wxml-->
<view class="container"> <view class="container">
<view class="page_hd"> <view class="page_hd">
<w-searchbar /> <w-searchbar search="{{search}}" cancel="{{false}}" bindclear="onSearchClear" bindinput="onSearchInput"/>
<e-tags/> <e-tags items="{{tags}}"/>
</view> </view>
<block wx:for="{{list}}" wx:key="*this"> <block wx:for="{{list}}" wx:key="policy-{{index}}">
<e-cell cId="{{index}}" <e-cell cId="{{item.id}}"
title="{{item.title}}" title="{{item.title}}"
time="{{item.time}}" time="{{item.time}}"
showTop="{{item.showTop}}" showTop="{{item.showTop}}"

112
pages/billboards/policy/policy-list/index.js

@ -1,4 +1,6 @@
// pages/billboards/policy/policy-list/index.js // pages/billboards/policy/policy-list/index.js
import { PolicyModel } from '../../../../models/policy.js'
let policy = new PolicyModel()
Page({ Page({
/** /**
@ -6,43 +8,10 @@ Page({
*/ */
data: { data: {
navSelectIndex: 0, navSelectIndex: 0,
nodes: `<section class="_editor" data-support="96编辑器" data-style-id="24818"> nodes: '',
<section style="text-align: center;margin:10px 0px;"> navs: [],
<section style="width:4px;height:24px;background-color:#ffc100;display:inline-block;vertical-align: middle;transform: rotatez(0deg);"></section> tags: [], // 导航的原始数据
<section style="margin-right: -2px; margin-left: -2px; border-style: solid; border-width: 1px; border-color: #000000; padding: 2px 10px; display: inline-block; vertical-align: middle;"> curCode: ''
<p style="letter-spacing: 2px;">
便民举措<br/>
</p>
</section>
<section style="width:4px;height:24px;background-color:#ffc100;display:inline-block;vertical-align: middle;"></section>
</section>
</section>
<section class="_editor" data-support="96编辑器" data-style-id="24804">
<section style="margin:10px 0px;">
<section style="width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin-top: -12px; margin-left: auto; width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin:-6px 6px;border-style:solid;border-width:1px;border-color:#ffcc9c;background-color:#fefefe;padding:15px;display:inline-block;transform: rotateZ(0deg);-webkit-transform: rotateZ(0deg);-moz-transform: rotateZ(0deg);-ms-transform: rotateZ(0deg);-o-transform: rotateZ(0deg);">
<p style="letter-spacing: 2px;">
<span style="font-size: 14px;">当清晨的一缕阳光透过窗帘上的空隙映照在沉睡的脸庞时微微张开的双眼朦胧地注视着周遭的一切新的一天悄然而至</span>
</p>
</section>
<section style="width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
<section style="margin-top: -12px; margin-left: auto; width: 12px; height: 12px; background-color: #ffc81c; border-radius: 50%; box-sizing: border-box;"></section>
</section>
</section>
<section class="_editor">
<p>
<br/>
</p>
</section>`,
navs: [
"千人计划",
"泰山学者",
"泰山学者",
"泰山学者",
"泰山学者",
"泰山学者",
]
}, },
/** /**
@ -50,60 +19,33 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options) console.log(options)
const tags = wx.getStorageSync('PolicyTags')
let navs = tags.map(item=> {return item.name})
const {index} = options const {index} = options
this.setData({ this.setData({
navSelectIndex: index tags: tags,
navSelectIndex: index,
navs: navs,
curCode: tags[index].code
}) })
this.fetchPolicyArtice()
}, },
tapSegemnt (e) { tapSegemnt (e) {
console.log(e.detail) console.log(e.detail)
const index = e.detail.index
this.setData({
curCode: this.data.tags[index].code
})
this.fetchPolicyArtice()
}, },
/** fetchPolicyArtice () {
* 生命周期函数--监听页面初次渲染完成 policy.fetchPolicyArtice(this.data.curCode, res => {
*/ console.log(res)
onReady: function () { const list = res.list
this.setData({
}, nodes: list[0].content
})
/** })
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
} }
}) })

28
pages/home/index.js

@ -9,26 +9,7 @@ Page({
currPage: 1, currPage: 1,
banners: [], banners: [],
hots: [], hots: [],
list: [ list: []
{
id: '1',
title: '啦啦啦量阿拉蕾阿拉啦',
showTop: true,
time: '刚刚'
},
{
id: '2',
title: '一条大河,向东流',
showTop: false,
time: '1分钟前'
},
{
id: '3',
title: '啦啦啦量阿拉蕾阿拉啦',
showTop: false,
time: '1小时前'
},
]
}, },
onLoad: function () { onLoad: function () {
console.log(dayjs().toNow()) console.log(dayjs().toNow())
@ -62,7 +43,7 @@ Page({
let page = this.data.currPage let page = this.data.currPage
homeModel.getHomeList(page, res => { homeModel.getHomeList(page, res => {
console.log('啦啦啦') console.log('啦啦啦')
const datas = res.result.records const datas = res.list
let tempDatas = [] let tempDatas = []
datas.forEach(item => { datas.forEach(item => {
tempDatas.push({ tempDatas.push({
@ -70,6 +51,7 @@ Page({
title: item.title, title: item.title,
showTop: item.isTop == 1 ? true : false, showTop: item.isTop == 1 ? true : false,
time: dayjs(item.createTime).toNow(), time: dayjs(item.createTime).toNow(),
readed: item.isRead == 0 ? 'false' : 'true'
}) })
}) })
if (page == 1) { if (page == 1) {
@ -101,7 +83,7 @@ Page({
homeModel.getHomeBanner(res => { homeModel.getHomeBanner(res => {
console.log('Banner') console.log('Banner')
console.log(res) console.log(res)
const datas = res.result.records const datas = res.list
let tempBanners = [] let tempBanners = []
datas.forEach(item => { datas.forEach(item => {
console.log(item) console.log(item)
@ -119,7 +101,7 @@ Page({
homeModel.getHomeHot(res => { homeModel.getHomeHot(res => {
console.log('Hot') console.log('Hot')
console.log(res) console.log(res)
const datas = res.result.records const datas = res.list
let tempHots = [] let tempHots = []
datas.forEach(item => { datas.forEach(item => {
tempHots.push({ tempHots.push({

15
utils/http.js

@ -15,25 +15,36 @@ class HTTP {
// 从缓存中读取 token // 从缓存中读取 token
let token = wx.getStorageSync(HTTPConst.TokenStoreKey) || '' let token = wx.getStorageSync(HTTPConst.TokenStoreKey) || ''
let url = this.baseUrl + params.url let url = this.baseUrl + params.url
console.log(params.url)
if (!params.method) { if (!params.method) {
params.method = Method.GET params.method = Method.GET
} }
// token 拼接到 请求体中 // token 拼接到 请求体中
let data = Object.assign({ token: token }, params.data) let data = params.data
console.log(data)
wx.request({ wx.request({
url: url, url: url,
data: data, data: data,
header: { header: {
'token': token,
'content-type': 'application/json', 'content-type': 'application/json',
}, },
method: params.method, method: params.method,
dataType: 'json', dataType: 'json',
success: function (res) { success: function (res) {
// console.log(res) console.log(res)
let code = res.statusCode.toString() let code = res.statusCode.toString()
let startCode = code.charAt(0) let startCode = code.charAt(0)
if (startCode == '2') { if (startCode == '2') {
if (res.data.code == 200) {
params.success && params.success(res.data) params.success && params.success(res.data)
} else {
console.log('数据请求失败')
wx.showToast({
title: res.data.message,
icon: 'none'
})
}
} else { } else {
console.log('请求错误') console.log('请求错误')
params.error && params.error(res) params.error && params.error(res)

Loading…
Cancel
Save