diff --git a/api/conflict.js b/api/conflict.js new file mode 100644 index 0000000..0f6e4e4 --- /dev/null +++ b/api/conflict.js @@ -0,0 +1,16 @@ +var fly = require('../utils/request.js') +module.exports = { + submitConflict: submitConflict, + getHistory:getHistory, + getHistoryById:getHistoryById +} + +function submitConflict(param) { + return fly.post('work/property/conflict/submit', param) +} +function getHistory(param) { + return fly.get('work/property/conflict/listHistory', param) +} +function getHistoryById(id) { + return fly.get('work/property/conflict/getById/'+id) +} diff --git a/api/consult.js b/api/consult.js new file mode 100644 index 0000000..3045c57 --- /dev/null +++ b/api/consult.js @@ -0,0 +1,18 @@ +var fly = require('../utils/request.js') +module.exports = { + getQuestionList: getQuestionList, + getMyQuestionList:getMyQuestionList, + submitAnswer:submitAnswer +} +// 工作端--待解答的心理咨询问题列表 +function getQuestionList(param) { + return fly.get('work/property/psychology/listQuestion', param) +} +// 工作端--我解答的心理咨询问题列表 +function getMyQuestionList(param) { + return fly.get('work/property/psychology/listMyQuestion', param) +} +// 工作端--心理咨询-提交问题的回答 +function submitAnswer(param) { + return fly.post('work/property/psychology/submitAnswer', param) +} \ No newline at end of file diff --git a/app.json b/app.json index f0edc9f..f1bff44 100644 --- a/app.json +++ b/app.json @@ -64,6 +64,21 @@ "pages/monthlyIndex/monthlyIndex", "pages/monthlyDetail/monthlyDetail" ] + }, + { + "root": "subpages/consult", + "name": "consult", + "pages": [ + "pages/consultIndex/consultIndex" + ] + }, + { + "root": "subpages/conflictMediation", + "name": "conflictMediation", + "pages": [ + "pages/index/index", + "pages/historyDetail/historyDetail" + ] } ], "preloadRule": { diff --git a/pages/index/index.js b/pages/index/index.js index 74ba87d..7323bed 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -123,6 +123,7 @@ Page({ console.log('e', JSON.stringify(e)) let tmp = e.currentTarget.dataset.tmp let state = e.currentTarget.dataset.state + let navCode= e.currentTarget.dataset.navcode switch (tmp) { case 'tmp-1': let childNav = []; @@ -201,7 +202,18 @@ Page({ // }) // } break - + case 'tmp-6': + if(navCode==10031){ + wx.navigateTo({ + url: '/subpages/consult/pages/consultIndex/consultIndex', + }) + } + if(navCode==10032){ + wx.navigateTo({ + url: '/subpages/conflictMediation/pages/index/index', + }) + } + break default: let c_childNav = []; for (let i = 0; i < this.data.panel.length; i++) { diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 99c04aa..99a25aa 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -40,7 +40,7 @@ {{itemPanel.mainLabel}} - + {{itemChild.label}} diff --git a/subpages/conflictMediation/components/loadMore/loadMore.js b/subpages/conflictMediation/components/loadMore/loadMore.js new file mode 100644 index 0000000..bde42e0 --- /dev/null +++ b/subpages/conflictMediation/components/loadMore/loadMore.js @@ -0,0 +1,14 @@ +Component({ + data: { + }, + properties: { + loadMoreVisible: { + type: Boolean, + value: false + }, + loadMoreType: { + type: String, + value: 'loading' + } + } +}) \ No newline at end of file diff --git a/subpages/conflictMediation/components/loadMore/loadMore.json b/subpages/conflictMediation/components/loadMore/loadMore.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/conflictMediation/components/loadMore/loadMore.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/conflictMediation/components/loadMore/loadMore.wxml b/subpages/conflictMediation/components/loadMore/loadMore.wxml new file mode 100644 index 0000000..573e607 --- /dev/null +++ b/subpages/conflictMediation/components/loadMore/loadMore.wxml @@ -0,0 +1,7 @@ + + + + 正在加载中... + + 没有更多了~ + \ No newline at end of file diff --git a/subpages/conflictMediation/components/loadMore/loadMore.wxss b/subpages/conflictMediation/components/loadMore/loadMore.wxss new file mode 100644 index 0000000..dbb07cd --- /dev/null +++ b/subpages/conflictMediation/components/loadMore/loadMore.wxss @@ -0,0 +1,18 @@ +.load-more { + width: 100%; + height: 100rpx; + background: #f7f7f7; + display: flex; + justify-content: center; + align-items: center; +} +.load-more .load-text { + color: #999; + font-size: 26rpx; +} +.load-more .load-image { + width: 30rpx; + height: 30rpx; + object-fit: cover; + margin-right: 10rpx; +} \ No newline at end of file diff --git a/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.js b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.js new file mode 100644 index 0000000..b76e2ec --- /dev/null +++ b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.js @@ -0,0 +1,70 @@ +Component({ + data: { + lastY: '', + translateHeight: 0, + state: -1, + scrollTop: 0, + enablePulldownFresh: false + }, + options: { + multipleSlots: true + }, + properties: { + upperDistance: { + type: Number, + value: 80 + } + }, + methods: { + onPageScroll (e) { + this.data.scrollTop = e.scrollTop + this.data.enablePulldownFresh = false + }, + touchstart (e) { + this.data.lastY = e.touches[0].clientY + if (this.data.scrollTop === 0) { + this.data.enablePulldownFresh = true + } else { + this.data.enablePulldownFresh = false + } + }, + touchmove (e) { + let clientY = e.touches[0].clientY + let offset = clientY - this.data.lastY + if (this.data.scrollTop > 0 || offset < 0) { + return false + } + this.data.translateHeight = offset + this.data.state = 1 + + if (this.data.enablePulldownFresh) { + if (this.data.translateHeight > this.data.upperDistance) { + this.data.state = 2 + } + this.setData({ + translateHeight: this.data.translateHeight > 100 ? 100 : this.data.translateHeight, + state: this.data.state + }) + } + }, + touchend (e) { + if (this.data.translateHeight > this.data.upperDistance) { + if (this.data.enablePulldownFresh) { + this.setData({ + translateHeight: 100, + state: 3 + }) + this.triggerEvent('pullDownRefresh') + } + } else if (this.data.scrollTop <= 0) { + this.stopRefresh() + } + }, + stopRefresh () { + this.setData({ + translateHeight: 0, + state: -1 + }) + } + } +}) \ No newline at end of file diff --git a/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.json b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxml b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxml new file mode 100644 index 0000000..cf6780f --- /dev/null +++ b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxml @@ -0,0 +1,9 @@ + + + + {{state == 1 ? '下拉刷新' : state == 2 ? '松开刷新' : '刷新中...'}} + + + + + \ No newline at end of file diff --git a/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxss b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxss new file mode 100644 index 0000000..7ee6289 --- /dev/null +++ b/subpages/conflictMediation/components/pullDownRefresh/pullDownRefresh.wxss @@ -0,0 +1,27 @@ +.pulldown-refresh { + width:100%; + background: #f7f7f7; +} +.pulldown-refresh .pulldown-state { + width:100%; + height: 100rpx; + display:flex; + justify-content: center; + align-items: center; + margin-bottom: -100rpx; +} +.pulldown-refresh .pulldown-state .loading { + width: 30rpx; + height: 30rpx; + margin-right: 10rpx; +} +.pulldown-refresh .pulldown-state .loading-state { + font-size: 25rpx; + color:#666; +} + +.pulldown-refresh .pulldown-content { + width:100%; + height:auto; + transition: transform 0.05s linear; +} \ No newline at end of file diff --git a/subpages/conflictMediation/images/input.png b/subpages/conflictMediation/images/input.png new file mode 100644 index 0000000..eda2e42 Binary files /dev/null and b/subpages/conflictMediation/images/input.png differ diff --git a/subpages/conflictMediation/images/loading.gif b/subpages/conflictMediation/images/loading.gif new file mode 100644 index 0000000..915c198 Binary files /dev/null and b/subpages/conflictMediation/images/loading.gif differ diff --git a/subpages/conflictMediation/pages/historyDetail/historyDetail.js b/subpages/conflictMediation/pages/historyDetail/historyDetail.js new file mode 100644 index 0000000..017e189 --- /dev/null +++ b/subpages/conflictMediation/pages/historyDetail/historyDetail.js @@ -0,0 +1,28 @@ +const app = getApp() +const api = require('../../../../api/conflict') +Page({ + data: { + detail:{} + }, + onHide:function(){ + + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + let id = options.id; + api.getHistoryById(id).then(res=>{ + this.setData({ + detail:res.data + }) + }) + }, + // this.getRecommend(); + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, +}) \ No newline at end of file diff --git a/subpages/conflictMediation/pages/historyDetail/historyDetail.json b/subpages/conflictMediation/pages/historyDetail/historyDetail.json new file mode 100644 index 0000000..caf3a8a --- /dev/null +++ b/subpages/conflictMediation/pages/historyDetail/historyDetail.json @@ -0,0 +1,5 @@ +{ + "navigationBarTitleText": "详情", + "usingComponents": { + } +} \ No newline at end of file diff --git a/subpages/conflictMediation/pages/historyDetail/historyDetail.wxml b/subpages/conflictMediation/pages/historyDetail/historyDetail.wxml new file mode 100644 index 0000000..c0cb123 --- /dev/null +++ b/subpages/conflictMediation/pages/historyDetail/historyDetail.wxml @@ -0,0 +1,42 @@ + + + 矛盾纠纷类型 + + + + 形成原因 + + + + 涉及人数 + + + + 挑头骨干人员 + + + + 责任单位 + + + + 责任人 + + + + 主要采取措施 + + + + 目前稳控情况 + + + + 备注 + + + + 提报时间 + + + \ No newline at end of file diff --git a/subpages/conflictMediation/pages/historyDetail/historyDetail.wxss b/subpages/conflictMediation/pages/historyDetail/historyDetail.wxss new file mode 100644 index 0000000..b6a3520 --- /dev/null +++ b/subpages/conflictMediation/pages/historyDetail/historyDetail.wxss @@ -0,0 +1,55 @@ +page { + width: 100%; + height: auto; + overflow-y: scroll; + background: #f7f7f7; +} +.toptabs{ + border-bottom: 1px solid #EDEFF0; + position: fixed; + top: 0; + z-index: 999999; + width: 100%; + background: #ffffff; +} +.wux-tabs__tab { + font-size:32rpx!important; + color: #8393A0!important; +} +.wux-tabs__tab--current { + color:#333333!important; + font-weight: bold; + font-size: 40rpx!important; +} +.wux-tabs__tab-bar{ + background: #ffffff!important; +} +.newhot-tabs{ + display: flex; + width: 100%; + margin: 10px; + height: 50rpx; +} +.edit{ + width: 100%; +} +.edit .edit-item{ + width: 100%; + background-color: #fff; + margin-top: 15rpx; +} +.edit .edit-item .title{ + color: #333333; + font-size: 32rpx; + margin:0 20rpx; + padding: 20rpx 0; + border-bottom: 0.5px solid #E7EEEE; +} +.edit .edit-item .textarea{ + color: #333333; + font-size: 32rpx; + margin:0 20rpx; + padding: 20rpx 0; + border-bottom: 0.5px solid #E7EEEE; + width: 96%; +} \ No newline at end of file diff --git a/subpages/conflictMediation/pages/index/index.js b/subpages/conflictMediation/pages/index/index.js new file mode 100644 index 0000000..8c10cba --- /dev/null +++ b/subpages/conflictMediation/pages/index/index.js @@ -0,0 +1,278 @@ +const api = require('../../../../api/conflict') +import { formatTimestamp } from '../../../../utils/util' +Page({ + + /** + * 页面的初始数据 + */ + data: { + loadMoreType: 'loading', + loadMoreVisible: true, + tabList:['编辑上报','历史上报'],//tab列表 + currentTabIndex:0, + pageNo: 1, // 分页页码 + pageSize: 20, // 分页页长 + isLoading: true, + timestamp:'', + conflictType:'', + reason:'', + peopleNumber:'', + peopleLeader:'', + dutyUnit:'', + dutyPerson:'', + mainMeasure:'', + statusNow:'', + remark:'', + temp_datetime:[], + datetime:'', + historyList:[], + pickerVisible:false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + let date=new Date(); + this.setData({ + temp_datetime:[date.getFullYear().toString(),date.getMonth().toString(),date.getDate().toString()] + }) + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + if(this.data.currentTabIndex ==='1' && !this.data.isLoading && this.data.loadMoreType!='none'){ + this.setData({ + loadMoreType:'loading', + loadMoreVisible:true, + pageNo:this.data.pageNo+1, + isLoading:true + }) + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp + } + this.getHistory(param) + } + }, + onConfirmDatetime(e){ + console.log(e.detail) + this.setData({ + datetime:e.detail.label, + pickerVisible:false + }) + }, + changeTab(e){ + this.setData({ + currentTabIndex:e.detail.key + }) + if(e.detail.key==="1"){ + this.setData({ + loadMoreType:'loading', + loadMoreVisible:true, + pageNo:1, + historyList:[], + isLoading:true, + timestamp:formatTimestamp(new Date()) + }) + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp + } + this.getHistory(param) + } + }, + getHistory(param){ + api.getHistory(param).then((res)=>{ + this.setData({ + historyList:this.data.historyList.concat(res.data), + isLoading:false + }) + if(res.data.length<20){ + this.setData({ + loadMoreType:'none', + loadMoreVisible:true, + }) + }else{ + this.setData({ + loadMoreType:"more", + loadMoreVisible:false + }) + } + }) + }, + handleConflictType(e){ + this.setData({ + conflictType:e.detail.value + }) + }, + handleReason(e){ + this.setData({ + reason:e.detail.value + }) + }, + handlePeopleNumber(e){ + this.setData({ + peopleNumber:e.detail.value + }) + }, + handlePeopleLeader(e){ + this.setData({ + peopleLeader:e.detail.value + }) + } + , + handleDutyUnit(e){ + this.setData({ + dutyUnit:e.detail.value + }) + }, + handleDutyPerson(e){ + this.setData({ + dutyPerson:e.detail.value + }) + }, + handleMainMeasure(e){ + this.setData({ + mainMeasure:e.detail.value + }) + }, + handleStatusNow(e){ + this.setData({ + statusNow:e.detail.value + }) + }, + handleRemark(e){ + this.setData({ + remark:e.detail.value + }) + }, + showPicker(){ + this.setData({ + pickerVisible:!this.data.pickerVisible + }) + }, + navigateToDetail(e){ + wx.navigateTo({ + url: '../historyDetail/historyDetail?id='+e.currentTarget.dataset.id, + }) + }, + submit(){ + if(this.data.conflictType===''){ + wx.showToast({ + title: '请输入矛盾纠纷类型', + icon:"none" + }) + return false + } + if(this.data.reason===''){ + wx.showToast({ + title: '请输入形成原因', + icon:"none" + }) + return false + } + if(this.data.peopleNumber===''){ + wx.showToast({ + title: '请输入涉及人数', + icon:"none" + }) + return false + } + if(this.data.peopleLeader===''){ + wx.showToast({ + title: '请输入挑头骨干人员', + icon:"none" + }) + return false + } + if(this.data.dutyUnit===''){ + wx.showToast({ + title: '请输入责任单位', + icon:"none" + }) + return false + } + if(this.data.dutyPerson===''){ + wx.showToast({ + title: '请输入责任人', + icon:"none" + }) + return false + } + if(this.data.mainMeasure===''){ + wx.showToast({ + title: '请输入主要采取措施', + icon:"none" + }) + return false + } + if(this.data.statusNow===''){ + wx.showToast({ + title: '请输入目前稳控状况', + icon:"none" + }) + return false + } + if(this.data.datetime===''){ + wx.showToast({ + title: '请选择提报时间', + icon:"none" + }) + return false + } + let num = new Number(this.data.peopleNumber) + if(isNaN(num)||num<0 || this.data.peopleNumber.indexOf('.')!=-1){ + wx.showToast({ + title: '请输入正确的人数', + icon:"none" + }) + return false + } + let param = { + conflictType:this.data.conflictType, + conflictReason:this.data.reason, + involvedNum:parseInt(this.data.peopleNumber), + mainstayLeader:this.data.peopleLeader, + responsibleDept:this.data.dutyUnit, + responsiblePeople:this.data.dutyPerson, + majorMeasures:this.data.mainMeasure, + currentSituation:this.data.statusNow, + remark:this.data.remark, + submitTime:this.data.datetime + } + wx.showLoading({ + title:'提交中' + }) + api.submitConflict(param).then(()=>{ + this.setData({ + conflictType:'', + reason:'', + peopleNumber:'', + peopleLeader:'', + dutyUnit:'', + dutyPerson:'', + mainMeasure:'', + statusNow:'', + remark:'', + datetime:'' + }) + wx.hideLoading({ + complete: (res) => { + wx.showToast({ + title: '上报成功', + icon:'none' + })}, + }) + + }).catch(err=>{ + wx.hideLoading({ + + }) + }) + } +}) \ No newline at end of file diff --git a/subpages/conflictMediation/pages/index/index.json b/subpages/conflictMediation/pages/index/index.json new file mode 100644 index 0000000..2a78e22 --- /dev/null +++ b/subpages/conflictMediation/pages/index/index.json @@ -0,0 +1,11 @@ +{ + "navigationBarTitleText": "综治矛调", + "usingComponents": { + "load-more": "../../components/loadMore/loadMore", + "pulldown-refresh": "../../components/pullDownRefresh/pullDownRefresh", + "wux-tabs": "../../../../dist/tabs/index", + "wux-tab": "../../dist/tab/index", + "wux-date-picker":"../../../../dist/date-picker/index", + "wux-cell":"../../../../dist/cell/index" + } +} \ No newline at end of file diff --git a/subpages/conflictMediation/pages/index/index.wxml b/subpages/conflictMediation/pages/index/index.wxml new file mode 100644 index 0000000..8416523 --- /dev/null +++ b/subpages/conflictMediation/pages/index/index.wxml @@ -0,0 +1,80 @@ + + + + + + + + + + 矛盾纠纷类型 + + {{util.length(conflictType)}}/50 + + + 形成原因 + + {{util.length(reason)}}/200 + + + 涉及人数 + + + + 挑头骨干人员 + + {{util.length(peopleLeader)}}/100 + + + 责任单位 + + {{util.length(dutyUnit)}}/150 + + + 责任人 + + {{util.length(dutyPerson)}}/150 + + + 主要采取措施 + + {{util.length(mainMeasure)}}/500 + + + 目前稳控情况 + + {{util.length(statusNow)}}/500 + + + 备注 + + {{util.length(remark)}}/500 + + + + + 提报时间 + + + + 提交 + + + + 上报时间:{{item.submitTime}} + + + + + + +function length(str){ + return str.length +} +module.exports = { + length: length +} + + diff --git a/subpages/conflictMediation/pages/index/index.wxss b/subpages/conflictMediation/pages/index/index.wxss new file mode 100644 index 0000000..96f0b68 --- /dev/null +++ b/subpages/conflictMediation/pages/index/index.wxss @@ -0,0 +1,93 @@ +page { + width: 100%; + height: auto; + overflow-y: scroll; + background: #f7f7f7; +} +.toptabs{ + border-bottom: 1px solid #EDEFF0; + position: fixed; + top: 0; + z-index: 999999; + width: 100%; + background: #ffffff; +} +.wux-tabs__tab { + font-size:32rpx!important; + color: #8393A0!important; +} +.wux-tabs__tab--current { + color:#333333!important; + font-weight: bold; + font-size: 40rpx!important; +} +.wux-tabs__tab-bar{ + background: #ffffff!important; +} +.newhot-tabs{ + display: flex; + width: 100%; + margin: 10px; + height: 50rpx; +} +.edit{ + margin-top: 100rpx; + width: 100%; + height: calc(100vh - 100rpx); +} +.edit .edit-item{ + width: 100%; + background-color: #fff; + margin-bottom: 15rpx; +} +.edit .edit-item .title{ + color: #333333; + font-size: 32rpx; + margin:0 20rpx; + padding: 20rpx 0; + border-bottom: 0.5px solid #E7EEEE; +} +.edit .edit-item .textarea{ + color: #333333; + font-size: 32rpx; + margin:0 20rpx; + padding: 20rpx 0; + border-bottom: 0.5px solid #E7EEEE; + padding-bottom: 45rpx; + width: 96%; +} +.history{ + margin-top: 100rpx; + width: 100%; +} +.history .history-item{ + width: 100%; + background-color: #fff; + margin-top: 15rpx; + height: 80rpx; + line-height: 80rpx; +} +.history .history-item .title{ + color: #333333; + font-size: 32rpx; + margin:0 20rpx; +} + +.submit{ + width: 70%; + height: 100rpx; + margin: 30rpx auto; + background-color: #fa2626; + border-radius: 36rpx; + line-height: 100rpx; + text-align: center; + font-size: 34rpx; + color: #FFF; +} +.text-limit{ + float:right; + margin-top:-48rpx; + margin-right:20rpx; + font-size:30rpx; + color:#999; +} \ No newline at end of file diff --git a/subpages/consult/components/loadMore/loadMore.js b/subpages/consult/components/loadMore/loadMore.js new file mode 100644 index 0000000..bde42e0 --- /dev/null +++ b/subpages/consult/components/loadMore/loadMore.js @@ -0,0 +1,14 @@ +Component({ + data: { + }, + properties: { + loadMoreVisible: { + type: Boolean, + value: false + }, + loadMoreType: { + type: String, + value: 'loading' + } + } +}) \ No newline at end of file diff --git a/subpages/consult/components/loadMore/loadMore.json b/subpages/consult/components/loadMore/loadMore.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/consult/components/loadMore/loadMore.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/consult/components/loadMore/loadMore.wxml b/subpages/consult/components/loadMore/loadMore.wxml new file mode 100644 index 0000000..573e607 --- /dev/null +++ b/subpages/consult/components/loadMore/loadMore.wxml @@ -0,0 +1,7 @@ + + + + 正在加载中... + + 没有更多了~ + \ No newline at end of file diff --git a/subpages/consult/components/loadMore/loadMore.wxss b/subpages/consult/components/loadMore/loadMore.wxss new file mode 100644 index 0000000..dbb07cd --- /dev/null +++ b/subpages/consult/components/loadMore/loadMore.wxss @@ -0,0 +1,18 @@ +.load-more { + width: 100%; + height: 100rpx; + background: #f7f7f7; + display: flex; + justify-content: center; + align-items: center; +} +.load-more .load-text { + color: #999; + font-size: 26rpx; +} +.load-more .load-image { + width: 30rpx; + height: 30rpx; + object-fit: cover; + margin-right: 10rpx; +} \ No newline at end of file diff --git a/subpages/consult/components/pullDownRefresh/pullDownRefresh.js b/subpages/consult/components/pullDownRefresh/pullDownRefresh.js new file mode 100644 index 0000000..b76e2ec --- /dev/null +++ b/subpages/consult/components/pullDownRefresh/pullDownRefresh.js @@ -0,0 +1,70 @@ +Component({ + data: { + lastY: '', + translateHeight: 0, + state: -1, + scrollTop: 0, + enablePulldownFresh: false + }, + options: { + multipleSlots: true + }, + properties: { + upperDistance: { + type: Number, + value: 80 + } + }, + methods: { + onPageScroll (e) { + this.data.scrollTop = e.scrollTop + this.data.enablePulldownFresh = false + }, + touchstart (e) { + this.data.lastY = e.touches[0].clientY + if (this.data.scrollTop === 0) { + this.data.enablePulldownFresh = true + } else { + this.data.enablePulldownFresh = false + } + }, + touchmove (e) { + let clientY = e.touches[0].clientY + let offset = clientY - this.data.lastY + if (this.data.scrollTop > 0 || offset < 0) { + return false + } + this.data.translateHeight = offset + this.data.state = 1 + + if (this.data.enablePulldownFresh) { + if (this.data.translateHeight > this.data.upperDistance) { + this.data.state = 2 + } + this.setData({ + translateHeight: this.data.translateHeight > 100 ? 100 : this.data.translateHeight, + state: this.data.state + }) + } + }, + touchend (e) { + if (this.data.translateHeight > this.data.upperDistance) { + if (this.data.enablePulldownFresh) { + this.setData({ + translateHeight: 100, + state: 3 + }) + this.triggerEvent('pullDownRefresh') + } + } else if (this.data.scrollTop <= 0) { + this.stopRefresh() + } + }, + stopRefresh () { + this.setData({ + translateHeight: 0, + state: -1 + }) + } + } +}) \ No newline at end of file diff --git a/subpages/consult/components/pullDownRefresh/pullDownRefresh.json b/subpages/consult/components/pullDownRefresh/pullDownRefresh.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/consult/components/pullDownRefresh/pullDownRefresh.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxml b/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxml new file mode 100644 index 0000000..cf6780f --- /dev/null +++ b/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxml @@ -0,0 +1,9 @@ + + + + {{state == 1 ? '下拉刷新' : state == 2 ? '松开刷新' : '刷新中...'}} + + + + + \ No newline at end of file diff --git a/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxss b/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxss new file mode 100644 index 0000000..7ee6289 --- /dev/null +++ b/subpages/consult/components/pullDownRefresh/pullDownRefresh.wxss @@ -0,0 +1,27 @@ +.pulldown-refresh { + width:100%; + background: #f7f7f7; +} +.pulldown-refresh .pulldown-state { + width:100%; + height: 100rpx; + display:flex; + justify-content: center; + align-items: center; + margin-bottom: -100rpx; +} +.pulldown-refresh .pulldown-state .loading { + width: 30rpx; + height: 30rpx; + margin-right: 10rpx; +} +.pulldown-refresh .pulldown-state .loading-state { + font-size: 25rpx; + color:#666; +} + +.pulldown-refresh .pulldown-content { + width:100%; + height:auto; + transition: transform 0.05s linear; +} \ No newline at end of file diff --git a/subpages/consult/components/questionList/questionList.js b/subpages/consult/components/questionList/questionList.js new file mode 100644 index 0000000..5b73271 --- /dev/null +++ b/subpages/consult/components/questionList/questionList.js @@ -0,0 +1,59 @@ +Component({ + /** + * 组件的属性列表 + */ + properties: { + questionList:{ + type:Array + }, + currentTab:{ + type:Number + }, + currentQuestion:{ + type:String + } + }, + /** + * 组件的初始数据 + */ + data: { + answerInput:'' + }, + + /** + * 组件的方法列表 + */ + methods: { + clearInput(){ + this.setData({ + answerInput:'' + }) + }, + handleInput(e){ + this.setData({ + answerInput:e.detail.value + }) + }, + openInput(e){ + if(this.data.currentQuestion != e.currentTarget.dataset.index){ + this.setData({ + answerInput:'' + }) + } + this.triggerEvent("changeCurrentQuestion",e.currentTarget.dataset.index); + }, + submitAnswer(e){ + if(this.data.answerInput===''){ + wx.showToast({ + title: '请输入回答', + icon:"none" + }) + return false + } + this.triggerEvent("submitAnswer",{id:e.currentTarget.dataset.questionid,answer:this.data.answerInput}); + }, + changeCollapse(e){ + this.triggerEvent("changeCollapse",e); + }, + } +}) diff --git a/subpages/consult/components/questionList/questionList.json b/subpages/consult/components/questionList/questionList.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/subpages/consult/components/questionList/questionList.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/subpages/consult/components/questionList/questionList.wxml b/subpages/consult/components/questionList/questionList.wxml new file mode 100644 index 0000000..f873f59 --- /dev/null +++ b/subpages/consult/components/questionList/questionList.wxml @@ -0,0 +1,49 @@ + + + + + {{item.questionContent}} + {{item.collapse?'全文':'收起'}} + + + + {{item.questionTime}} + + + 回复 + + + + + + + {{tools.length(answerInput)|0}}/500 + 确定 + + + + {{answer.answerContent}} + {{answer.collapse?'全文':'收起'}} + + + {{answer.psychologistName + ' | 心理咨询师 ' +answer.answerTime}} + + + + + +function toString(a){ + return a.toString(); +} +function length(str){ + return str.length; +} +module.exports = { + toString: toString, + length:length +} + \ No newline at end of file diff --git a/subpages/consult/components/questionList/questionList.wxss b/subpages/consult/components/questionList/questionList.wxss new file mode 100644 index 0000000..82cdacf --- /dev/null +++ b/subpages/consult/components/questionList/questionList.wxss @@ -0,0 +1,117 @@ +/* subpages/consult/components/questionList.wxss */ +.home{ + width: 100%; +} +.list-item{ + background-color: #fff; + margin-top: 20rpx; + padding: 0 20rpx; +} +.list-item .item-header{ + display: inline-block; + width: 100%; +} +.list-item .item-header .index{ + display: inline-block; + width: 4%; + height: 100rpx; + line-height: 100rpx; + font-size: 30rpx; +} +.list-item .item-header .question{ + display: inline-block; + line-height: 50rpx; + font-size: 35rpx; + letter-spacing: 2rpx; +} +.list-item .item-button .time{ + display: inline-block; + width: 40%; + font-size: 25rpx; + color: #AAA; +} +.list-item .item-button{ + height: 60rpx; + width: 100%; + padding-top: 20rpx; +} + +.list-item .item-button .reply{ + height: 50rpx; + width: 20%; + font-size: 30rpx; + line-height: 50rpx; + text-align: center; + float: right; +} +.list-item .item-button .reply .button-img{ + height: 25rpx; + width: 25rpx; + margin-left: -5rpx; +} +.list-item .item-button .reply .button-text{ + color: #F71A1A; + font-size: 30rpx; + display: inline-block; + margin-left: 10rpx; +} +.item-reply{ + width: 100%; + min-height: 300rpx; +} +.item-reply .textarea{ + width: 100%; + min-height: 300rpx; + background-color: #f2f2f2; +} +.answer-content{ + width: 100%; + font-size: 30rpx; + color: #777; +} +.reply-button{ + border-radius: 35rpx; + background-color: #e02d22; + height: 55rpx; + width: 120rpx; + color: #fff; + line-height: 50rpx; + text-align: center; + margin-right: 20rpx; + float: right; + font-size: 30rpx; +} +.answer-footer{ + padding: 20rpx 0; + font-size: 30rpx; + color: #c3c3c3; +} +.answer-content text{ + line-height: 50rpx; + display: block; +} +.question text{ + line-height: 50rpx; +} + +.answer-content text.text-collapse{ + display:-webkit-box; + -webkit-box-orient:vertical; + -webkit-line-clamp:3; + overflow: hidden; + text-overflow: ellipsis; +} +.text-collapse{ + display:-webkit-box; + -webkit-box-orient:vertical; + -webkit-line-clamp:2; + overflow: hidden; + text-overflow: ellipsis; +} + +.coll-p{ + font-size: 30rpx; + color: #5064A3; + margin-top: 10rpx; + margin-right: 20rpx; +} \ No newline at end of file diff --git a/subpages/consult/images/input.png b/subpages/consult/images/input.png new file mode 100644 index 0000000..eda2e42 Binary files /dev/null and b/subpages/consult/images/input.png differ diff --git a/subpages/consult/images/loading.gif b/subpages/consult/images/loading.gif new file mode 100644 index 0000000..915c198 Binary files /dev/null and b/subpages/consult/images/loading.gif differ diff --git a/subpages/consult/pages/consultIndex/consultIndex.js b/subpages/consult/pages/consultIndex/consultIndex.js new file mode 100644 index 0000000..3804fe9 --- /dev/null +++ b/subpages/consult/pages/consultIndex/consultIndex.js @@ -0,0 +1,234 @@ +const app = getApp() +const api = require('../../../../api/consult') +import { formatTimestamp } from '../../../../utils/util' +Page({ + data: { + loadMoreType: 'loading', + loadMoreVisible: true, + tabList:['我的待回答','公共待回答','已经回答'],//tab列表 + currentTabIndex:0, + currentQuestion:'', + pageNo: 1, // 分页页码 + pageSize: 10, // 分页页长 + isLoading: true, + timestamp:'', + answerInput:'', + questionList:[], + }, + onHide:function(){ + + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + timestamp:formatTimestamp(new Date()) + }) + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp, + designatedFlag:this.data.currentTabIndex==0?'1':'0' + } + this.getQuestionList(param) + }, + getQuestionList(param){ + api.getQuestionList(param).then((res)=>{ + this.setData({ + questionList:this.data.questionList.concat(res.data), + isLoading:false + }) + this.setCollapse(); + if(res.data.length<10){ + this.setData({ + loadMoreType:'none', + loadMoreVisible:true, + }) + }else{ + this.setData({ + loadMoreType:"more", + loadMoreVisible:false + }) + } + }).catch(err=>{ + this.setData({ + questionList:[], + isLoading:false, + loadMoreType:'none', + loadMoreVisible:true + }) + }) + }, + getMyQuestionList(param){ + api.getMyQuestionList(param).then((res)=>{ + this.setData({ + questionList:this.data.questionList.concat(res.data), + isLoading:false + }) + this.setCollapse(); + if(res.data.length<10){ + this.setData({ + loadMoreType:'none', + loadMoreVisible:true, + }) + }else{ + this.setData({ + loadMoreType:"more", + loadMoreVisible:false + }) + } + }).catch(err=>{ + this.setData({ + questionList:[], + isLoading:false, + loadMoreType:'none', + loadMoreVisible:true + }) + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + onReachBottom(){ + if(!this.data.isLoading && this.data.loadMoreType!='none'){ + this.setData({ + isLoading:true, + loadMoreVisible:true, + loadMoreType:'loading', + pageNo:this.data.pageNo+1 + }) + if(this.data.currentTabIndex!=2){ + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp, + designatedFlag:this.data.currentTabIndex==0?'1':'0' + } + this.getQuestionList(param) + }else{ + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp, + } + this.getMyQuestionList(param) + } + } + }, + handleInput(e){ + this.setData({ + answerInput:e.detail.value + }) + }, + changeTab(e){ + if(this.data.isLoading){ + return false; + } + this.setData({ + questionList:[], + currentQuestion:'', + answerInput:'', + currentTabIndex:e.detail.key, + loadMoreType:'loading', + loadMoreVisible:true, + isLoading:true, + pageSize:10, + pageNo:1, + timestamp:formatTimestamp(new Date()) + }) + this.selectComponent("#question-list").clearInput(); + if(e.detail.key!=2){ + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp, + designatedFlag:this.data.currentTabIndex==0?'1':'0' + } + this.getQuestionList(param) + }else{ + let param = { + pageIndex:this.data.pageNo, + pageSize:this.data.pageSize, + timestamp:this.data.timestamp, + } + this.getMyQuestionList(param) + } + }, + openInput(e){ + this.setData({ + currentQuestion:e.detail, + answerInput:'' + }) + }, + submitAnswer(e){ + let param = { + questionId:e.detail.id, + answerContent:e.detail.answer + } + api.submitAnswer(param).then(()=>{ + this.data.questionList.splice(this.data.currentQuestion,1); + this.selectComponent("#question-list").clearInput(); + wx.showToast({ + title: '回复成功', + icon:"none" + }) + this.setData({ + questionList:this.data.questionList, + currentQuestion:'' + }) + }).catch(err=>{ + + }) + }, + setCollapse: function() { + var query = wx.createSelectorQuery(); + var that = this; + query.in(this.selectComponent('#question-list')).selectAll('#questionContent').boundingClientRect(function (rect) { + rect.forEach((v, i) => { + if (v.height > 60) { //判断高度,根据各种高度取折中 + var set = "questionList[" + i + "].collapse"; + var set1 = "questionList[" + i + "].showCollapse"; + that.setData({ + [set]: true, + [set1]: true, + }) + } + }) + }).exec(); + query.in(this.selectComponent('#question-list')).selectAll('#answerContent').boundingClientRect(function (rect) { + rect.forEach((v, i) => { + console.log(v) + console.log(v.dataset.question) + if (v.height > 70) { + var set = "questionList[" + v.dataset.question + "].answerList[0].collapse"; + var set1 = "questionList[" + v.dataset.question + "].answerList[0].showCollapse"; + that.setData({ + [set]: true, + [set1]: true, + }) + } + }) + }).exec(); + }, + //点击全文收起 + changeCollapse: function(e){ + var index = e.detail.currentTarget.dataset.index; + var questionIndex=e.detail.currentTarget.dataset.questionindex; + if(questionIndex===undefined){ + var set = "questionList[" + index + "].collapse"; + this.setData({ + [set]: !this.data.questionList[index].collapse + }) + }else{ + var set = "questionList[" + questionIndex + "].answerList[0].collapse"; + console.log(set) + this.setData({ + [set]: !this.data.questionList[questionIndex].answerList[0].collapse + }) + } + } +}) \ No newline at end of file diff --git a/subpages/consult/pages/consultIndex/consultIndex.json b/subpages/consult/pages/consultIndex/consultIndex.json new file mode 100644 index 0000000..159baf3 --- /dev/null +++ b/subpages/consult/pages/consultIndex/consultIndex.json @@ -0,0 +1,10 @@ +{ + "navigationBarTitleText": "心理咨询", + "usingComponents": { + "load-more": "../../components/loadMore/loadMore", + "pulldown-refresh": "../../components/pullDownRefresh/pullDownRefresh", + "wux-tabs": "../../../../dist/tabs/index", + "wux-tab": "../../dist/tab/index", + "question-list":"../../components/questionList/questionList" + } +} \ No newline at end of file diff --git a/subpages/consult/pages/consultIndex/consultIndex.wxml b/subpages/consult/pages/consultIndex/consultIndex.wxml new file mode 100644 index 0000000..d683eb1 --- /dev/null +++ b/subpages/consult/pages/consultIndex/consultIndex.wxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + diff --git a/subpages/consult/pages/consultIndex/consultIndex.wxss b/subpages/consult/pages/consultIndex/consultIndex.wxss new file mode 100644 index 0000000..37c0f2b --- /dev/null +++ b/subpages/consult/pages/consultIndex/consultIndex.wxss @@ -0,0 +1,128 @@ +page { + width: 100%; + height: auto; + overflow-y: scroll; + background: #f7f7f7; +} +.toptabs{ + border-bottom: 1px solid #EDEFF0; + position: fixed; + top: 0; + z-index: 999999; + width: 100%; + background: #ffffff; +} +.wux-tabs__tab { + font-size:32rpx!important; + color: #8393A0!important; +} +.wux-tabs__tab--current { + color:#333333!important; + font-weight: bold; + font-size: 40rpx!important; +} +.wux-tabs__tab-bar{ + background: #ffffff!important; +} +.newhot-tabs{ + display: flex; + width: 100%; + margin: 10px; + height: 50rpx; +} +.header { + position: fixed; + width: 100%; + top: 0; + left: 0; + z-index: 1000; +} +.header .header-bg { + width: 100%; + height: 100%; + position: absolute; + z-index: 10; + left: 0; + top: 0; +} +.header .navigation { + width: 100%; + display: flex; + align-items: center; + justify-content: center; + color: rgba(255,255,255, 0.9); + font-size: 32rpx; + position: relative; + z-index: 100; +} +.home { + width: 100%; + overflow-y: scroll; +} +.nothing-to-show{ + width: 100%; + height: 100vh; + background: #f7f7f7; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} +.nothing-img{ + width: 500rpx; + height:245rpx; + object-fit: cover; + +} +.tab{ + width: 100%; + height: 100rpx; + background: #fff; + overflow-x: scroll; + display: inline-block; + white-space: nowrap; + margin:0 auto; + -webkit-overflow-scrolling: touch; + position: fixed; + top: 0; +} +.tab-item{ + height: 100%; + min-width: 33%; + margin:0 auto; + display: inline-block; + box-sizing: border-box; +} +.tab-name{ + text-align: center; + margin:0 auto; + height: 80%; + font-size: 25rpx; + line-height: 100rpx; + padding: 0 20rpx; + color: #999; +} +.tab-name.active{ + text-align: center; + margin:0 auto; + height: 80%; + font-size: 30rpx; + line-height: 100rpx; + padding: 0 20rpx; + color: #BB0300; +} +.tab-line.active{ + border-top: 4rpx solid #BB0300; + width: 30%; + margin: 0 auto; + margin-top: 10rpx; +} +.list{ + margin: 0 auto; + margin-top: 120rpx; +} +.questionList{ + width: 100%; +} + +