diff --git a/app.json b/app.json index c82e400..ea47c53 100644 --- a/app.json +++ b/app.json @@ -6,6 +6,7 @@ "pages/topics/index", "pages/billboards/firm/index", "pages/billboards/park/index", + "pages/billboards/park/park-list/index", "pages/billboards/policy/index", "pages/billboards/policy/policy-list/index", "pages/article/index", diff --git a/components/card/index.js b/components/card/index.js index 172e4a6..60767bc 100644 --- a/components/card/index.js +++ b/components/card/index.js @@ -22,7 +22,7 @@ Component({ */ methods: { onTap () { - this.triggerEvent('clickCardItem', this.properties.cId) + this.triggerEvent('clickCardItem', {id: this.properties.cId}) } } }) diff --git a/components/segment/index.wxss b/components/segment/index.wxss index 124bebd..7a1b6db 100644 --- a/components/segment/index.wxss +++ b/components/segment/index.wxss @@ -6,7 +6,7 @@ padding: 5px; } .title { - width: 150rpx; + min-width: 150rpx; display: flex; align-items: center; justify-content: center; diff --git a/models/artice.js b/models/artice.js index f99467a..d649550 100644 --- a/models/artice.js +++ b/models/artice.js @@ -3,9 +3,8 @@ import { HTTP, Method } from '../utils/http.js' // 请求url常量 const ArticeConst = { artice_url: '/api/content/queryById', - artice_add_collect_url: '/api/content/addCollection', - artice_remove_collect_url: '/api/content/removeCollection', - artice_online_url: '', + artice_add_remove_collect_url: '/api/content/addOrDeleteCollection', + artice_online_url: '/api/content/signin', } class ArticeModel extends HTTP { @@ -16,8 +15,8 @@ class ArticeModel extends HTTP { getDetail(aId, success) { let params = { url: ArticeConst.artice_url, - sucess: success, - method: Method.POST, + success: success, + method: Method.GET, data: { id: aId } @@ -26,22 +25,11 @@ class ArticeModel extends HTTP { } // 设置收藏还是取消 // type: 0: 添加;1: 移除 - addCollect(aId, type, success) { - let params = { - url: artice_add_collect_url, - success: success, - method: Method.POST, - data: { - id: aId - } - } - this.request(params) - } - removeCollect(aId, success) { + addOrRemoveCollect(aId, success) { let params = { - url: artice_remove_collect_url, + url: ArticeConst.artice_add_remove_collect_url, success: success, - method: Method.POST, + method: Method.GET, data: { id: aId } @@ -49,13 +37,13 @@ class ArticeModel extends HTTP { this.request(params) } // 在线报名 - onlineSign (aId, type, success) { + onlineSign(aId, type, success) { let params = { - url: artice_online_url, + url: ArticeConst.artice_online_url, success: success, - method: Method.POST, + method: Method.GET, data: { - + contentId: aId } } this.request(params) diff --git a/models/auth.js b/models/auth.js index 40f06e7..0075c2f 100644 --- a/models/auth.js +++ b/models/auth.js @@ -58,7 +58,7 @@ class AuthModel extends HTTP { }, success: (data) => { // 将获取到的token存放起来 - let token = data + let token = 'test token' wx.setStorageSync(HTTPConst.TokenStoreKey, token) success(token) }, diff --git a/models/billboard.js b/models/billboard.js index ab353ef..2bff088 100644 --- a/models/billboard.js +++ b/models/billboard.js @@ -1,10 +1,36 @@ 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 { constructor () { 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} \ No newline at end of file diff --git a/models/home.js b/models/home.js index bfbe1a3..e5bf408 100644 --- a/models/home.js +++ b/models/home.js @@ -17,8 +17,6 @@ class HomeModel extends HTTP { method: Method.POST, data: { typeCode: 'sc-banner', - page: 1, - pageSize: 20, }, success: success } @@ -31,8 +29,6 @@ class HomeModel extends HTTP { method: Method.POST, data: { typeCode: 'sc-jdtz', - page: 1, - pageSize: 20, }, success: success } @@ -41,12 +37,10 @@ class HomeModel extends HTTP { // 首页列表 getHomeList(page, success){ let params = { - url: HOMEConst.home_list_url, + url: HOMEConst.home_list_url + '?pageNo=' + page, method: Method.POST, data: { typeCode: 'sc-tzgg', - page: page, - pageSize: 20, }, success: success } diff --git a/models/policy.js b/models/policy.js new file mode 100644 index 0000000..620badd --- /dev/null +++ b/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 } \ No newline at end of file diff --git a/pages/article/index.js b/pages/article/index.js index f45d0d5..b7b754b 100644 --- a/pages/article/index.js +++ b/pages/article/index.js @@ -1,106 +1,77 @@ // pages/article/index.js +import {ArticeModel} from '../../models/artice.js' +import dayjs from '../../utils/dayjs/index.js' +let artice = new ArticeModel() + Page({ /** * 页面的初始数据 */ data: { - nodes: ` - - - - - 便民举措 - - - - - - - - - - - - 当清晨的一缕阳光透过窗帘上的空隙映照在沉睡的脸庞时,微微张开的双眼朦胧地注视着周遭的一切,新的一天悄然而至。 - - - - - - - - - - -`, + nodes: '', + isStar: true, // 是否 + showBtn: true, + aId: '', + title: '', + date: '', + origin: '', unStar: '/images/common/star.png', star: '/images/common/star_light.png', - isStar: true, - showBtn: true, }, onClickCollect () { - this.setData({ - isStar: !this.data.isStar - }) // 收藏功能 + this.addOrRemoveCollectionApi() }, onlineSubmit () { console.log('在线报名') + this.onlineSignApi() // 在线报名 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - + console.log(options) + const {id} = options + this.setData({ + aId: id + }) + this.fetchArticeApi() }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - + fetchArticeApi () { + artice.getDetail(this.data.aId, (res) => { + console.log('artice detail') + console.log(res) + 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 + }) + }) }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - + addOrRemoveCollectionApi () { + artice.addOrRemoveCollect(this.data.aId, res => { + console.log(res) + this.setData({ + isStar: !this.data.isStar + }) + if (res.code == 200) { + wx.showToast({ + title: res.message, + icon: 'none' + }) + } + }) }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - + onlineSignApi () { + artice.onlineSign(this.data.aId, res => { + console.log(res) + }) }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } + }) \ No newline at end of file diff --git a/pages/article/index.wxml b/pages/article/index.wxml index 804237d..969de5b 100644 --- a/pages/article/index.wxml +++ b/pages/article/index.wxml @@ -1,10 +1,10 @@ - 市北区区情概况市北区区情概况市北区区情概况 + {{title}} - 市北区工作领导小组办公室 - 6月7日 + {{origin}} + {{date}} diff --git a/pages/billboards/firm/index.js b/pages/billboards/firm/index.js index bf30769..61f1778 100644 --- a/pages/billboards/firm/index.js +++ b/pages/billboards/firm/index.js @@ -1,78 +1,111 @@ // pages/billboards/firm/index.js +import { BillboardModel } from '../../../models/billboard.js' +let billboard = new BillboardModel() Page({ /** * 页面的初始数据 */ data: { - navs: [ - "千人计划", - "泰山学者", - "泰山学者", - "泰山学者", - "泰山学者", - "泰山学者", - ] + list: [], + navs: [], + curCode: '', + currPage: 1, + tags: [], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.fetchTags() // 获取Tags }, tapSegemnt (e) { console.log(e.detail) + const {index} = e.detail + this.setData({ + curCode: this.data.tags[index].code, + currPage: 1, + }) + this.fetchList() }, clickCardItem(e) { console.log(e.detail) + const { id } = e.detail + wx.navigateTo({ + url: `/pages/article/index?id=${id}`, + }) }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - + fetchList() { + const { curCode } = this.data + const page = this.data.currPage + billboard.fetchBailList(curCode, page, res => { + console.log(res) + const datas = res.list + let tempDatas = [] + datas.forEach(item => { + tempDatas.push({ + id: item.id, + title: item.title, + image: item.titlePic + }) + }) + 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() + }) }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - + // 获取分类Tags + fetchTags () { + billboard.fetchTagsByCode('sc-zdqy', res => { + console.log(res) + 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 () { - + this.setData({ + currPage: 1 + }) + this.fetchList() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + const page = this.data.currPage + 1 + this.setData({ + currPage: page + }) + this.fetchList() } }) \ No newline at end of file diff --git a/pages/billboards/firm/index.json b/pages/billboards/firm/index.json index f75e0d9..e2f938c 100644 --- a/pages/billboards/firm/index.json +++ b/pages/billboards/firm/index.json @@ -1,5 +1,6 @@ { "navigationBarTitleText": "重点企业", + "enablePullDownRefresh": true, "usingComponents": { "e-card": "/components/card/index", "e-segment": "/components/segment/index" diff --git a/pages/billboards/firm/index.wxml b/pages/billboards/firm/index.wxml index 6d048ce..6bfc840 100644 --- a/pages/billboards/firm/index.wxml +++ b/pages/billboards/firm/index.wxml @@ -4,8 +4,11 @@ - - + diff --git a/pages/billboards/park/index.js b/pages/billboards/park/index.js index a943efc..db71e1e 100644 --- a/pages/billboards/park/index.js +++ b/pages/billboards/park/index.js @@ -1,4 +1,5 @@ // pages/billboards/park/index.js + Page({ /** @@ -14,55 +15,11 @@ Page({ onLoad: function (options) { }, - clickCardItem (e) { - console.log(e.detail) - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - + onClickItem(e) { + const { code } = e.currentTarget.dataset + console.log(code) + wx.navigateTo({ + url: '/pages/billboards/park/park-list/index?code=' + code, + }) }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } }) \ No newline at end of file diff --git a/pages/billboards/park/index.json b/pages/billboards/park/index.json index d45d7fe..6b87fff 100644 --- a/pages/billboards/park/index.json +++ b/pages/billboards/park/index.json @@ -1,6 +1,4 @@ { "navigationBarTitleText": "平台载体", - "usingComponents": { - "e-card": "/components/card/index" - } + "usingComponents": {} } \ No newline at end of file diff --git a/pages/billboards/park/index.wxml b/pages/billboards/park/index.wxml index 739d871..692e750 100644 --- a/pages/billboards/park/index.wxml +++ b/pages/billboards/park/index.wxml @@ -1,8 +1,7 @@ - - - + + + + diff --git a/pages/billboards/park/index.wxss b/pages/billboards/park/index.wxss index b79b98c..18adec1 100644 --- a/pages/billboards/park/index.wxss +++ b/pages/billboards/park/index.wxss @@ -1,12 +1,13 @@ /* pages/billboards/park/index.wxss */ .container { - padding: 0 3vw; + height: 100vh; display: flex; - flex-direction: row; - justify-content: space-between; - flex-wrap: wrap; + flex-direction: column; + justify-content: center; + align-items: center; } -.e_card { - width: 45vw; - margin-bottom: 13px; +.billboard_item { + margin-top: 15px; + width: 90%; + height: 100px; } \ No newline at end of file diff --git a/pages/billboards/park/park-list/index.js b/pages/billboards/park/park-list/index.js new file mode 100644 index 0000000..8095d2e --- /dev/null +++ b/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() + }, +}) \ No newline at end of file diff --git a/pages/billboards/park/park-list/index.json b/pages/billboards/park/park-list/index.json new file mode 100644 index 0000000..4a1d953 --- /dev/null +++ b/pages/billboards/park/park-list/index.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "平台载体", + "enablePullDownRefresh": true, + "usingComponents": { + "e-card": "/components/card/index" + } +} \ No newline at end of file diff --git a/pages/billboards/park/park-list/index.wxml b/pages/billboards/park/park-list/index.wxml new file mode 100644 index 0000000..2e95c39 --- /dev/null +++ b/pages/billboards/park/park-list/index.wxml @@ -0,0 +1,9 @@ + + + + + + 暂无数据 + diff --git a/pages/billboards/park/park-list/index.wxss b/pages/billboards/park/park-list/index.wxss new file mode 100644 index 0000000..548a507 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/billboards/policy/components/tags/index.js b/pages/billboards/policy/components/tags/index.js index 434d6b9..08c9fe5 100644 --- a/pages/billboards/policy/components/tags/index.js +++ b/pages/billboards/policy/components/tags/index.js @@ -4,7 +4,10 @@ Component({ * 组件的属性列表 */ properties: { - + items: { + type: Array, + value: [] + } }, /** diff --git a/pages/billboards/policy/components/tags/index.wxml b/pages/billboards/policy/components/tags/index.wxml index e514a24..0e4de4b 100644 --- a/pages/billboards/policy/components/tags/index.wxml +++ b/pages/billboards/policy/components/tags/index.wxml @@ -1,8 +1,8 @@ - + - - 人才政策 + + {{item.name}} 全部 diff --git a/pages/billboards/policy/components/tags/index.wxss b/pages/billboards/policy/components/tags/index.wxss index 4687166..bbb1761 100644 --- a/pages/billboards/policy/components/tags/index.wxss +++ b/pages/billboards/policy/components/tags/index.wxss @@ -7,6 +7,7 @@ border-bottom: 1px solid #f7f7f7; } .tags-list { + flex:1; display: flex; flex-direction: row; align-items: center; diff --git a/pages/billboards/policy/index.js b/pages/billboards/policy/index.js index 7fb580f..bf37926 100644 --- a/pages/billboards/policy/index.js +++ b/pages/billboards/policy/index.js @@ -1,33 +1,19 @@ // 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: { - list: [ - { - id: '1', - title: '啦啦啦量阿拉蕾阿拉啦', - showTop: true, - time: '刚刚' - }, - { - id: '2', - title: '一条大河,向东流', - showTop: false, - time: '1分钟前' - }, - { - id: '3', - title: '啦啦啦量阿拉蕾阿拉啦', - showTop: false, - time: '1小时前' - }, - ] + list: [], + currPage: 1, + searchKey: '', + tags: [], }, clickListItem(e) { - console.log(e.detail) const {id} = e.detail wx.navigateTo({ url: `/pages/article/index?id=${id}`, @@ -37,55 +23,94 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.fetchPolicyTags() + this.fetchPolicyList() }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - + onSearchClear (e) { + this.setData({ + currPage: 1, + searchKey: '' + }) + console.log(e) + this.fetchPolicyList() }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - + onSearchInput (e) { + const key = e.detail.value + this.setData({ + searchKey: key, + currPage: 1, + }) + console.log(e) + this.fetchPolicyList() }, - /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { - + this.setData({ + currPage: 1 + }) + this.fetchPolicyList() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - + const page = this.data.currPage + 1 + this.setData({ + currPage: page + }) + this.fetchPolicyList() }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + // 获取 Tags + fetchPolicyTags () { + policy.fetchPolicyTags(res => { + const datas = res.result.records + 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() + }) } }) \ No newline at end of file diff --git a/pages/billboards/policy/index.json b/pages/billboards/policy/index.json index 1afbadd..5b07c78 100644 --- a/pages/billboards/policy/index.json +++ b/pages/billboards/policy/index.json @@ -1,5 +1,6 @@ { "navigationBarTitleText": "人才政策", + "enablePullDownRefresh": true, "usingComponents": { "w-searchbar": "/components/weui/searchbar/searchbar", "e-cell": "/components/cell/index", diff --git a/pages/billboards/policy/index.wxml b/pages/billboards/policy/index.wxml index 73f61c9..8cacdf2 100644 --- a/pages/billboards/policy/index.wxml +++ b/pages/billboards/policy/index.wxml @@ -1,11 +1,11 @@ - - + + - - + - - - - - 便民举措 - - - - - - - - - - - - 当清晨的一缕阳光透过窗帘上的空隙映照在沉睡的脸庞时,微微张开的双眼朦胧地注视着周遭的一切,新的一天悄然而至。 - - - - - - - - - - -`, - navs: [ - "千人计划", - "泰山学者", - "泰山学者", - "泰山学者", - "泰山学者", - "泰山学者", - ] + nodes: '', + navs: [], + tags: [], // 导航的原始数据 + curCode: '' }, /** @@ -50,60 +19,33 @@ Page({ */ onLoad: function (options) { console.log(options) + const tags = wx.getStorageSync('PolicyTags') + let navs = tags.map(item=> {return item.name}) const {index} = options + this.setData({ - navSelectIndex: index + tags: tags, + navSelectIndex: index, + navs: navs, + curCode: tags[index].code }) + this.fetchPolicyArtice() }, tapSegemnt (e) { console.log(e.detail) - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - + 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) + const list = res.list + this.setData({ + nodes: list[0].content + }) + }) } }) \ No newline at end of file diff --git a/pages/home/index.js b/pages/home/index.js index e032735..3a3846b 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -9,26 +9,7 @@ Page({ currPage: 1, banners: [], hots: [], - list: [ - { - id: '1', - title: '啦啦啦量阿拉蕾阿拉啦', - showTop: true, - time: '刚刚' - }, - { - id: '2', - title: '一条大河,向东流', - showTop: false, - time: '1分钟前' - }, - { - id: '3', - title: '啦啦啦量阿拉蕾阿拉啦', - showTop: false, - time: '1小时前' - }, - ] + list: [] }, onLoad: function () { console.log(dayjs().toNow()) @@ -62,7 +43,7 @@ Page({ let page = this.data.currPage homeModel.getHomeList(page, res => { console.log('啦啦啦') - const datas = res.result.records + const datas = res.list let tempDatas = [] datas.forEach(item => { tempDatas.push({ @@ -70,6 +51,7 @@ Page({ title: item.title, showTop: item.isTop == 1 ? true : false, time: dayjs(item.createTime).toNow(), + readed: item.isRead == 0 ? 'false' : 'true' }) }) if (page == 1) { @@ -101,7 +83,7 @@ Page({ homeModel.getHomeBanner(res => { console.log('Banner') console.log(res) - const datas = res.result.records + const datas = res.list let tempBanners = [] datas.forEach(item => { console.log(item) @@ -119,7 +101,7 @@ Page({ homeModel.getHomeHot(res => { console.log('Hot') console.log(res) - const datas = res.result.records + const datas = res.list let tempHots = [] datas.forEach(item => { tempHots.push({ diff --git a/utils/http.js b/utils/http.js index 81535b6..e00b0b1 100644 --- a/utils/http.js +++ b/utils/http.js @@ -15,26 +15,36 @@ class HTTP { // 从缓存中读取 token let token = wx.getStorageSync(HTTPConst.TokenStoreKey) || '' let url = this.baseUrl + params.url + console.log(params.url) if (!params.method) { params.method = Method.GET } // token 拼接到 请求体中 - let data = Object.assign({ token: token }, params.data) + let data = params.data console.log(data) wx.request({ url: url, data: data, header: { + 'token': token, 'content-type': 'application/json', }, method: params.method, dataType: 'json', success: function (res) { - // console.log(res) + console.log(res) let code = res.statusCode.toString() let startCode = code.charAt(0) if (startCode == '2') { - params.success && params.success(res.data) + if (res.data.code == 200) { + params.success && params.success(res.data) + } else { + console.log('数据请求失败') + wx.showToast({ + title: res.data.message, + icon: 'none' + }) + } } else { console.log('请求错误') params.error && params.error(res)
- 便民举措 -
- 当清晨的一缕阳光透过窗帘上的空隙映照在沉睡的脸庞时,微微张开的双眼朦胧地注视着周遭的一切,新的一天悄然而至。 -
- -