diff --git a/app.json b/app.json
index 7bf900e..ef8306b 100644
--- a/app.json
+++ b/app.json
@@ -12,7 +12,7 @@
}
},
"window": {
- "navigationStyle":"custom",
+ "navigationStyle": "custom",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "微信接口功能演示",
diff --git a/pages/answercomplete/answercomplete.js b/pages/answercomplete/answercomplete.js
index 99604bc..108e0ac 100644
--- a/pages/answercomplete/answercomplete.js
+++ b/pages/answercomplete/answercomplete.js
@@ -1,6 +1,8 @@
+const api = require('../../utils/api.js')
Page({
data: {
statusBarHeight: 44, // 导航高度
+ baseURL: api.baseURL
},
onLoad() {
const _this=this;
@@ -31,10 +33,17 @@ Page({
},
// 分享朋友
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);
},
@@ -45,10 +54,17 @@ 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);
},
diff --git a/pages/answercomplete/answercomplete.wxml b/pages/answercomplete/answercomplete.wxml
index 6b792be..3ef6ed1 100644
--- a/pages/answercomplete/answercomplete.wxml
+++ b/pages/answercomplete/answercomplete.wxml
@@ -3,7 +3,7 @@
答题完成
-
+
您的问卷调查已完成!
\ No newline at end of file
diff --git a/pages/authorization/authorization.js b/pages/authorization/authorization.js
index 9c2d14a..a0c655b 100644
--- a/pages/authorization/authorization.js
+++ b/pages/authorization/authorization.js
@@ -1,29 +1,64 @@
+const api = require('../../utils/api.js')
Page({
data: {
- statusBarHeight: 44
+ statusBarHeight: 44,
+ baseURL: api.baseURL
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '授权登录', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- this.setData({
- userInfo: res.userInfo,
- hasUserInfo: true
- })
- // 授权成功关闭当前页面,跳转至基础信息登记页面
- wx.redirectTo({
- url: '../basicInformation/basicInformation'
+ success: (data) => {
+ wx.login({
+ success({
+ code
+ }) {
+ if (code) {
+ //发起网络请求
+ api.post('/api/wxlogin', {
+ ...data,
+ code: code
+ }).then(({
+ data
+ }) => {
+ // 存储用户uid
+ wx.setStorage({
+ key: "userInfo",
+ data: {...data}
+ })
+
+ // 授权成功关闭当前页面,跳转至基础信息登记页面
+ wx.redirectTo({
+ url: '../basicInformation/basicInformation'
+ })
+ })
+
+ } else {
+ console.log('登录失败!' + res.errMsg)
+ }
+ }
})
}
- })
+ });
},
// 分享朋友
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);
},
@@ -34,10 +69,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);
},
@@ -46,16 +93,16 @@ Page({
}
}
},
- onShow(){
+ onShow() {
// 获取设备的信息
let systemInfo = wx.getSystemInfoSync();
// 获取信号区高度, 并设置标题高度
let statusBarHeight = systemInfo['statusBarHeight']
- if (systemInfo.platform === 'andorid' ) {
- statusBarHeight = statusBarHeight+1;
- }else if (systemInfo.platform === 'ios') {
- statusBarHeight = statusBarHeight+6;
- }else{
+ if (systemInfo.platform === 'andorid') {
+ statusBarHeight = statusBarHeight + 1;
+ } else if (systemInfo.platform === 'ios') {
+ statusBarHeight = statusBarHeight + 6;
+ } else {
statusBarHeight = statusBarHeight;
}
this.setData({
diff --git a/pages/authorization/authorization.wxml b/pages/authorization/authorization.wxml
index 8ac8468..4ac3acf 100644
--- a/pages/authorization/authorization.wxml
+++ b/pages/authorization/authorization.wxml
@@ -2,7 +2,7 @@
获取授权
-
+
赛思维物业服务评估咨询有限公司
信息化深耕物业全生命周期
diff --git a/pages/basicInformation/basicInformation.js b/pages/basicInformation/basicInformation.js
index 42968cf..4363556 100644
--- a/pages/basicInformation/basicInformation.js
+++ b/pages/basicInformation/basicInformation.js
@@ -1,45 +1,52 @@
+const api = require('../../utils/api.js')
Page({
data: {
+ style: `--bg:url('${api.baseURL}/public/uploadfile/basics.png')`,
+ baseURL: api.baseURL,
statusBarHeight: 44, // 导航高度
- addressList: [{
- buildingId: '1',
- descr: '世界大厦A座'
+ addressList: [], // 楼栋列表
+ unitList: [{
+ unitid: '1',
+ descr: '一单元'
+ },
+ {
+ unitid: '2',
+ descr: '二单元'
+ },
+ {
+ unitid: '3',
+ descr: '三单元'
},
{
- buildingId: '2',
- descr: '世界大厦B座'
+ unitid: '4',
+ descr: '四单元'
},
{
- buildingId: '3',
+ unitid: '5',
+ descr: '五单元'
+ },
+ {
+ unitid: '',
descr: '其他'
}
], // 楼栋列表
- unitList: [{
- buildingId: '1',
- descr: '1单元'
- },
- {
- buildingId: '2',
- descr: '2单元'
- },
- {
- buildingId: '3',
- descr: '其他'
- }
- ], // 楼栋列表
addressSelectItem: {}, // 当道选择的楼栋对象
unitItem: {}, // 单元号
houseNumber: "", // 门牌号
+ oneButton: [],
+ showOneButtonDialog: false, //
},
// 更新当前选择的单元
- setunitItem(e){
+ setunitItem(e) {
this.setData({
unitItem: this.data.unitList[e.detail.value]
})
},
// 更新门牌号的值
bindKeyHouseNumber(e) {
-
+ this.setData({
+ houseNumber: e.detail.value
+ })
},
// 更新选择的楼栋
bindPickerChange(e) {
@@ -47,61 +54,40 @@ Page({
addressSelectItem: this.data.addressList[e.detail.value]
})
},
- onLoad() {
- const _this = this;
- // 获取设备的信息
- let systemInfo = wx.getSystemInfoSync();
- // 获取信号区高度, 并设置标题高度
- let statusBarHeight = systemInfo['statusBarHeight'];
- if (systemInfo.platform === 'andorid') {
- statusBarHeight = statusBarHeight + 10;
- } else if (systemInfo.platform === 'ios') {
- statusBarHeight = statusBarHeight + 6;
- } else if (systemInfo.platform === 'devtools') {
- statusBarHeight = statusBarHeight + 8;
- } 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'
- })
- }
- }
- });
- // 失效页面
- // wx.reLaunch({
- // url: '/pages/pagefailure/pagefailure'
- // })
- },
+
// 跳转至答题页面
getUserProfile() {
// 信息登记完成,跳转至答题录页
+ wx.setStorage({
+ key: "basicInformation",
+ data: {
+ "buildingid": this.data.addressSelectItem.buildingid,
+ "unit": this.data.unitItem.unitid,
+ "room": this.data.houseNumber,
+ }
+ })
wx.navigateTo({
url: '/pages/questionnaire/questionnaire'
})
},
// 分享朋友
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);
},
@@ -112,10 +98,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);
},
@@ -124,4 +122,137 @@ Page({
}
}
},
+ // 获取楼栋信息
+ getBuildings(options) {
+ wx.showLoading({
+ title: '数据加载中',
+ })
+ // 获取楼栋信息
+ api.get(
+ '/api/getbuildings', {
+ cid: options.cid
+ }
+ ).then(({
+ data = []
+ }) => {
+ wx.hideLoading()
+ this.setData({
+ addressList: data
+ })
+ }).catch((error) => {
+ wx.hideLoading()
+ })
+ },
+ // 校验问卷是否过期
+ isFailure(options) {
+ api.get('/api/wx_surveysheet/checkbarcode', {
+ ...options
+ }).then(({
+ code,
+ data
+ }) => {
+ if (code === 200 && data == '已过期') {
+ wx.reLaunch({
+ url: '/pages/pagefailure/pagefailure'
+ })
+ }
+ })
+ },
+ onLoad(options) {
+ const _this = this;
+ // 获取设备的信息
+ let systemInfo = wx.getSystemInfoSync();
+ // 获取信号区高度, 并设置标题高度
+ let statusBarHeight = systemInfo['statusBarHeight'];
+ if (systemInfo.platform === 'andorid') {
+ statusBarHeight = statusBarHeight + 10;
+ } else if (systemInfo.platform === 'ios') {
+ statusBarHeight = statusBarHeight + 6;
+ } else if (systemInfo.platform === 'devtools') {
+ statusBarHeight = statusBarHeight + 9;
+ } else {
+ statusBarHeight = statusBarHeight;
+ }
+ _this.setData({
+ statusBarHeight
+ });
+ // 判断是否携带参数
+ if (options.cid && options.surveysheetid && options.lenDays) {
+ wx.setStorage({
+ key: "project",
+ data: options,
+ success() {
+ // 获取用户信息,防止数据不全
+ wx.getStorage({
+ key: 'userInfo',
+ success() {
+ _this.isFailure(options);
+ _this.getBuildings(options);
+ },
+ fail() {
+ // 如果授权信息丢失,跳转至授权登录页重新授权
+ wx.reLaunch({
+ url: '/pages/authorization/authorization'
+ })
+ }
+ })
+ },
+ fail() {
+ wx.showToast({
+ title: '请重新扫码登录',
+ icon: 'error',
+ duration: 3000
+ })
+ }
+ })
+
+ } else {
+ // 不是扫码登录时,分两种情况处理
+ wx.getStorage({
+ key: 'project',
+ success({
+ data
+ }) {
+ if (data.cid && data.surveysheetid && data.lenDays) {
+ // 扫码登录后,临时退出程序,重新进入
+ _this.isFailure(data);
+ _this.getBuildings(data);
+ } else {
+ // 非正常登录
+ _this.setData({
+ showOneButtonDialog: true
+ })
+ }
+ },
+ fail() {
+ // 非正常登录
+ _this.setData({
+ showOneButtonDialog: true
+ })
+ }
+ })
+ }
+ },
+ 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'
+ })
+ }
+ })
+ }
+ })
+ }
})
\ No newline at end of file
diff --git a/pages/basicInformation/basicInformation.json b/pages/basicInformation/basicInformation.json
index 8872128..dd7792f 100644
--- a/pages/basicInformation/basicInformation.json
+++ b/pages/basicInformation/basicInformation.json
@@ -2,6 +2,7 @@
"navigationBarTitleText": "基础信息",
"disableScroll": true,
"usingComponents": {
- "mp-icon": "weui-miniprogram/icon/icon"
+ "mp-icon": "weui-miniprogram/icon/icon",
+ "mp-dialog": "weui-miniprogram/dialog/dialog"
}
}
\ No newline at end of file
diff --git a/pages/basicInformation/basicInformation.wxml b/pages/basicInformation/basicInformation.wxml
index d6cb84d..97e7520 100644
--- a/pages/basicInformation/basicInformation.wxml
+++ b/pages/basicInformation/basicInformation.wxml
@@ -1,6 +1,6 @@
-
+
信息登记
@@ -22,18 +22,18 @@
-
+
-
+
请选择您的单元:
-
+
@@ -46,11 +46,14 @@
+
-
+
+ 请您扫码登录小程序!
+
\ No newline at end of file
diff --git a/pages/basicInformation/basicInformation.wxss b/pages/basicInformation/basicInformation.wxss
index 8237ed4..52702bf 100644
--- a/pages/basicInformation/basicInformation.wxss
+++ b/pages/basicInformation/basicInformation.wxss
@@ -7,7 +7,7 @@
.basicInformation-title-wrap{
width: 100%;
height: 544rpx;
- background: url('http://8.140.133.55:8096/public/uploadfile/basics.png') no-repeat;
+ background: var(--bg) no-repeat;
background-size: 100% 100%;
z-index: 0;
}
@@ -75,6 +75,9 @@
width: 100%;
margin-bottom: 48rpx;
}
+.information-bottom{
+ margin-bottom: 80rpx;
+}
.information-title{
font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC;
@@ -113,7 +116,7 @@
}
.information-title-text{
float: left;
- width: 48%;
+ width: 290rpx;
height: 44rpx;
font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC;
@@ -123,7 +126,7 @@
}
.information-title-input{
float: right;
- width: 51%;
+ width: calc( 100% - 290rpx);
height: 50rpx;
line-height: 50rpx;
font-size: 32rpx;
diff --git a/pages/pagefailure/pagefailure.js b/pages/pagefailure/pagefailure.js
index 5d68dc7..d789878 100644
--- a/pages/pagefailure/pagefailure.js
+++ b/pages/pagefailure/pagefailure.js
@@ -1,6 +1,8 @@
+const api = require('../../utils/api.js')
Page({
data: {
statusBarHeight: 44, // 导航高度
+ baseURL: api.baseURL
},
onLoad() {
const _this=this;
@@ -24,10 +26,17 @@ Page({
},
// 分享朋友
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);
},
@@ -38,10 +47,17 @@ 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);
},
diff --git a/pages/pagefailure/pagefailure.json b/pages/pagefailure/pagefailure.json
index adbcf52..2661b5a 100644
--- a/pages/pagefailure/pagefailure.json
+++ b/pages/pagefailure/pagefailure.json
@@ -1,5 +1,5 @@
{
- "navigationBarTitleText": "页面失效",
+ "navigationBarTitleText": "问卷已失效",
"disableScroll": true,
"usingComponents": {}
}
\ No newline at end of file
diff --git a/pages/pagefailure/pagefailure.wxml b/pages/pagefailure/pagefailure.wxml
index 6aee26f..33bf722 100644
--- a/pages/pagefailure/pagefailure.wxml
+++ b/pages/pagefailure/pagefailure.wxml
@@ -1,9 +1,9 @@
- 页面失效
+ 问卷已失效
-
- 页面失效
+
+ 问卷已失效
\ No newline at end of file
diff --git a/pages/questionnaire/questionnaire.js b/pages/questionnaire/questionnaire.js
index e1146c1..c34a94b 100644
--- a/pages/questionnaire/questionnaire.js
+++ b/pages/questionnaire/questionnaire.js
@@ -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'
+ })
+ }
+ })
+ }
+ })
+ }
})
\ No newline at end of file
diff --git a/pages/questionnaire/questionnaire.wxml b/pages/questionnaire/questionnaire.wxml
index 918cec5..aa974a8 100644
--- a/pages/questionnaire/questionnaire.wxml
+++ b/pages/questionnaire/questionnaire.wxml
@@ -1,6 +1,6 @@
-
+
问卷调查
@@ -10,14 +10,14 @@
问卷调查
-
+
- {{parentTndex+1}}、{{item.questionnaireDesc}}
-
+
+ color="{{grade.optionid >= item.questionNaireItem.optionid && item.questionNaireItem.optionid?'#FFAE00':'#D8D8D8'}}" size="{{26}}">
{{item.questionNaireItem.optiontext}}