|
|
@ -1,189 +1,13 @@ |
|
|
|
const api = require('../../utils/api.js') |
|
|
|
Page({ |
|
|
|
data: { |
|
|
|
style: `--bg:url('${api.baseURL}/public/uploadfile/questionnaire.png')`, |
|
|
|
statusBarHeight: 44, // 导航高度
|
|
|
|
questionnaireList: [{ |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
},{ |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分?', |
|
|
|
questionnaireOptionList: [{ |
|
|
|
optionid: 'E', |
|
|
|
optiontext: '非常不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'D', |
|
|
|
optiontext: '不满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'C', |
|
|
|
optiontext: '一般' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'B', |
|
|
|
optiontext: '满意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
optionid: 'A', |
|
|
|
optiontext: '非常满意' |
|
|
|
} |
|
|
|
], |
|
|
|
subjecttype: '单选题', |
|
|
|
questionNaireItem: {} |
|
|
|
}, { |
|
|
|
questionnaireDesc: '请您对物业管理公司提供的整体服务评分', |
|
|
|
subjecttype: '简述题', |
|
|
|
questionNaireItem: {} |
|
|
|
// #FFAE00
|
|
|
|
}], // 题目列表
|
|
|
|
questionNaireObj: {}, // 题目对象信息
|
|
|
|
isCalibrationScore: false, // 是否开启评分校验
|
|
|
|
scrollTop: 0 |
|
|
|
scrollTop: 0, // 滚动条高度
|
|
|
|
basicInformation: {}, // 基础信息界面填写的参数
|
|
|
|
userInfo: {} // 用户信息
|
|
|
|
}, |
|
|
|
// 所有题目完成后跳转至答题完成页面
|
|
|
|
getUserProfile() { |
|
|
@ -193,50 +17,118 @@ Page({ |
|
|
|
isCalibrationScore: true |
|
|
|
}) |
|
|
|
// 校验是否有未答题项,如果有则滚动至第一个未答题项目位置
|
|
|
|
const filterIndex = _this.data.questionnaireList.findIndex(e => !e.questionNaireItem.optiontext) |
|
|
|
const filterIndex = _this.data.questionNaireObj.valst.findIndex(e => !e.questionNaireItem.optiontext) |
|
|
|
if (filterIndex > -1) { |
|
|
|
wx.createSelectorQuery().selectAll('.content-details-list').boundingClientRect(function (rect) { |
|
|
|
const domList = rect.filter((e, index) => index < filterIndex); |
|
|
|
console.log(domList); |
|
|
|
_this.setData({ |
|
|
|
scrollTop: domList.reduce(function (sum, item) { //sum2 前两个数的和
|
|
|
|
return sum + (item.height+48); // 48代表元素margin-bottom值的一半
|
|
|
|
return sum + (item.height + 48); // 48代表元素margin-bottom值的一半
|
|
|
|
}, 0) |
|
|
|
}) |
|
|
|
}).exec() |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 提交问卷成功,跳转至答题完成页面
|
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/answercomplete/answercomplete' |
|
|
|
// 整理答案集合
|
|
|
|
const parms = { |
|
|
|
...this.data.basicInformation, |
|
|
|
...this.data.questionNaireObj, |
|
|
|
uid: this.data.userInfo.uid, |
|
|
|
valst: this.data.questionNaireObj.valst.map(e => { |
|
|
|
if (e.subjecttype == "单选题") { |
|
|
|
e = { |
|
|
|
"subjectid": e.subjectid, |
|
|
|
"optioninput": '', |
|
|
|
"selected_options": e.questionNaireItem.optionid |
|
|
|
} |
|
|
|
} else { |
|
|
|
e = { |
|
|
|
"subjectid": e.subjectid, |
|
|
|
"optioninput": e.questionNaireItem.optiontext, |
|
|
|
"selected_options": '' |
|
|
|
} |
|
|
|
} |
|
|
|
return e; |
|
|
|
}) |
|
|
|
} |
|
|
|
api.post( |
|
|
|
'/api/wx_surveysheet/addinfo', { |
|
|
|
...parms |
|
|
|
} |
|
|
|
).then(({ |
|
|
|
code |
|
|
|
}) => { |
|
|
|
if (code === 200) { |
|
|
|
this.reLaunchAnswercomplete(); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 更新开放性问题输入的值
|
|
|
|
setGradeValue(e) { |
|
|
|
const index = e.currentTarget.dataset['index']; |
|
|
|
if (e.detail.value.replace(/\s/g, "")) { |
|
|
|
this.data.questionnaireList[index].questionNaireItem = { |
|
|
|
this.data.questionNaireObj.valst[index].questionNaireItem = { |
|
|
|
optionid: true, |
|
|
|
optiontext: e.detail.value.replace(/\s/g, "") |
|
|
|
}; |
|
|
|
} else { |
|
|
|
this.data.questionnaireList[index].questionNaireItem = { |
|
|
|
this.data.questionNaireObj.valst[index].questionNaireItem = { |
|
|
|
optionid: false, |
|
|
|
optiontext: "" |
|
|
|
}; |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
questionnaireList: [...this.data.questionnaireList] |
|
|
|
questionNaireObj: { |
|
|
|
...this.data.questionNaireObj |
|
|
|
} |
|
|
|
}) |
|
|
|
if (this.timer) { |
|
|
|
clearTimeout(this.timer) |
|
|
|
} |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
// 更新缓存
|
|
|
|
const parms = { |
|
|
|
cid: this.data.questionNaireObj.cid, |
|
|
|
surveysheetid: this.data.questionNaireObj.surveysheetid, |
|
|
|
subjectid: this.data.questionNaireObj.valst[index].subjectid, |
|
|
|
uid: this.data.userInfo.uid, |
|
|
|
valst: [{ |
|
|
|
"subjectid": this.data.questionNaireObj.valst[index].subjectid, |
|
|
|
"optioninput": e.detail.value.replace(/\s/g, ""), |
|
|
|
"selected_options": '' |
|
|
|
}] |
|
|
|
} |
|
|
|
api.post('/api/wx_surveysheet/addinfocache', { |
|
|
|
...parms |
|
|
|
}).then(() => {}) |
|
|
|
}, 300) |
|
|
|
|
|
|
|
}, |
|
|
|
// 更新评分
|
|
|
|
setGrade(e) { |
|
|
|
const index = e.currentTarget.dataset['index']; |
|
|
|
const item = e.currentTarget.dataset['value']; |
|
|
|
this.data.questionnaireList[index].questionNaireItem = item; |
|
|
|
this.data.questionNaireObj.valst[index].questionNaireItem = item; |
|
|
|
this.setData({ |
|
|
|
questionnaireList: [...this.data.questionnaireList] |
|
|
|
questionNaireObj: { |
|
|
|
...this.data.questionNaireObj |
|
|
|
} |
|
|
|
}) |
|
|
|
// 更新缓存
|
|
|
|
const parms = { |
|
|
|
cid: item.cid, |
|
|
|
surveysheetid: item.surveysheetid, |
|
|
|
subjectid: item.subjectid, |
|
|
|
uid: this.data.userInfo.uid, |
|
|
|
valst: [{ |
|
|
|
"subjectid": item.subjectid, |
|
|
|
"optioninput": '', |
|
|
|
"selected_options": item.optionid |
|
|
|
}] |
|
|
|
} |
|
|
|
api.post('/api/wx_surveysheet/addinfocache', { |
|
|
|
...parms |
|
|
|
}).then(() => {}) |
|
|
|
}, |
|
|
|
// 返回信息登记页面
|
|
|
|
navigateBack() { |
|
|
@ -244,46 +136,25 @@ Page({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
// 获取设备的信息
|
|
|
|
let systemInfo = wx.getSystemInfoSync(); |
|
|
|
// 获取信号区高度, 并设置标题高度
|
|
|
|
let statusBarHeight = systemInfo['statusBarHeight'] |
|
|
|
if (systemInfo.platform === 'andorid') { |
|
|
|
statusBarHeight = statusBarHeight + 1; |
|
|
|
} else if (systemInfo.platform === 'ios') { |
|
|
|
statusBarHeight = statusBarHeight + 6; |
|
|
|
} else { |
|
|
|
statusBarHeight = statusBarHeight; |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
statusBarHeight |
|
|
|
}); |
|
|
|
wx.getSetting({ |
|
|
|
success(res) { |
|
|
|
// 校验用户是否已经授权
|
|
|
|
if (res.authSetting['scope.userInfo']) { |
|
|
|
// 必须是在用户已经授权的情况下调用
|
|
|
|
wx.getUserInfo({ |
|
|
|
success: function (res) { |
|
|
|
// console.log(res)
|
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 如果未授权则关闭所有页面,跳转至授权登录页
|
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/authorization/authorization' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 分享朋友
|
|
|
|
onShareAppMessage: (res) => { |
|
|
|
let data = ''; |
|
|
|
wx.getStorage({ |
|
|
|
key: 'project', |
|
|
|
success({ |
|
|
|
data: { |
|
|
|
surveysheetid = '', |
|
|
|
cid = '' |
|
|
|
} |
|
|
|
}) { |
|
|
|
data = `?surveysheetid=${surveysheetid}&cid=${cid}` |
|
|
|
} |
|
|
|
}) |
|
|
|
return { |
|
|
|
title: '业主思维', |
|
|
|
path: '/pages/basicInformation/basicInformation', |
|
|
|
imageUrl: "http://8.140.133.55:8096/public/uploadfile/logo.png", |
|
|
|
path: '/pages/basicInformation/basicInformation' + data, |
|
|
|
imageUrl: api.baseURL+"/public/uploadfile/logo.png", |
|
|
|
success: (res) => { |
|
|
|
console.log("转发成功", res); |
|
|
|
}, |
|
|
@ -294,10 +165,22 @@ Page({ |
|
|
|
}, |
|
|
|
// 分享朋友圈
|
|
|
|
onShareTimeline: (res) => { |
|
|
|
let data = ''; |
|
|
|
wx.getStorage({ |
|
|
|
key: 'project', |
|
|
|
success({ |
|
|
|
data: { |
|
|
|
surveysheetid = '', |
|
|
|
cid = '' |
|
|
|
} |
|
|
|
}) { |
|
|
|
data = `?surveysheetid=${surveysheetid}&cid=${cid}` |
|
|
|
} |
|
|
|
}) |
|
|
|
return { |
|
|
|
title: '业主思维', |
|
|
|
path: '/pages/basicInformation/basicInformation', |
|
|
|
imageUrl: "http://8.140.133.55:8096/public/uploadfile/logo.png", |
|
|
|
path: '/pages/basicInformation/basicInformation' + data, |
|
|
|
imageUrl: api.baseURL+"/public/uploadfile/logo.png", |
|
|
|
success: (res) => { |
|
|
|
console.log("转发成功", res); |
|
|
|
}, |
|
|
@ -306,4 +189,145 @@ Page({ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 跳转至已答题界面
|
|
|
|
reLaunchAnswercomplete() { |
|
|
|
// 提交问卷成功,跳转至答题完成页面
|
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/answercomplete/answercomplete' |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取问卷信息
|
|
|
|
getSelectinfo(options) { |
|
|
|
// 先校验是否已经完成答题
|
|
|
|
api.get('/api/wx_surveysheet/checkresult', { |
|
|
|
...this.data.userInfo, |
|
|
|
...options |
|
|
|
}).then(({ |
|
|
|
code, |
|
|
|
data |
|
|
|
}) => { |
|
|
|
if (code == 200 && data) { |
|
|
|
this.reLaunchAnswercomplete(); |
|
|
|
} else { |
|
|
|
// 获取问卷列表
|
|
|
|
api.get( |
|
|
|
'/api/wx_surveysheet/selectinfo', { |
|
|
|
...options, |
|
|
|
uid: this.data.userInfo.uid |
|
|
|
} |
|
|
|
).then(({ |
|
|
|
data |
|
|
|
}) => { |
|
|
|
// 整合简述题放在末尾
|
|
|
|
const newValst = [...(data.valst || []).filter(e => e.subjecttype == '单选题').concat((data.valst || []).filter(e => e.subjecttype == '简述题'))].map(e => { |
|
|
|
// 添加存储答案的对象
|
|
|
|
e.questionNaireItem = { |
|
|
|
...e.questionNaireItem |
|
|
|
} |
|
|
|
return e; |
|
|
|
}); |
|
|
|
this.setData({ |
|
|
|
questionNaireObj: { |
|
|
|
...data, |
|
|
|
valst: newValst.map(e => { |
|
|
|
if (e.subjecttype == "单选题") { |
|
|
|
e.questionNaireItem.optionid = e.questionNaireItem['selected_options']; |
|
|
|
if(e.questionNaireItem['selected_options']){ |
|
|
|
e.questionNaireItem.optiontext = (e.valst.find(item => item.optionid == e.questionNaireItem['selected_options'])).optiontext; |
|
|
|
}else{ |
|
|
|
e.questionNaireItem.optiontext = ''; |
|
|
|
} |
|
|
|
} else { |
|
|
|
e.questionNaireItem.optionid = ''; |
|
|
|
e.questionNaireItem.optiontext = e.questionNaireItem.optioninput; |
|
|
|
} |
|
|
|
return e; |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
const _this = this; |
|
|
|
// 获取设备的信息
|
|
|
|
let systemInfo = wx.getSystemInfoSync(); |
|
|
|
// 获取信号区高度, 并设置标题高度
|
|
|
|
let statusBarHeight = systemInfo['statusBarHeight'] |
|
|
|
if (systemInfo.platform === 'andorid') { |
|
|
|
statusBarHeight = statusBarHeight + 1; |
|
|
|
} else if (systemInfo.platform === 'ios') { |
|
|
|
statusBarHeight = statusBarHeight + 6; |
|
|
|
} else { |
|
|
|
statusBarHeight = statusBarHeight; |
|
|
|
} |
|
|
|
_this.setData({ |
|
|
|
statusBarHeight |
|
|
|
}); |
|
|
|
// 获取用户信息
|
|
|
|
wx.getStorage({ |
|
|
|
key: 'userInfo', |
|
|
|
success({ |
|
|
|
data |
|
|
|
}) { |
|
|
|
_this.setData({ |
|
|
|
userInfo: data |
|
|
|
}, () => { |
|
|
|
// 获取问卷信息
|
|
|
|
wx.getStorage({ |
|
|
|
key: 'project', |
|
|
|
success({ |
|
|
|
data |
|
|
|
}) { |
|
|
|
_this.getSelectinfo(data); |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
fail(){ |
|
|
|
// 如果授权信息丢失,跳转至授权登录页重新授权
|
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/authorization/authorization' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
// 获取基础信息界面添写的参数
|
|
|
|
wx.getStorage({ |
|
|
|
key: 'basicInformation', |
|
|
|
success({ |
|
|
|
data |
|
|
|
}) { |
|
|
|
_this.setData({ |
|
|
|
basicInformation: { |
|
|
|
...data |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
wx.getStorage({ |
|
|
|
key: 'project', |
|
|
|
success({ |
|
|
|
data |
|
|
|
}) { |
|
|
|
// 校验问卷是否过期
|
|
|
|
api.get('/api/wx_surveysheet/checkbarcode', { |
|
|
|
...data |
|
|
|
}).then(({ |
|
|
|
code, |
|
|
|
data |
|
|
|
}) => { |
|
|
|
if (code === 200 && data == '已过期') { |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/pagefailure/pagefailure' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |