mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-23 21:36:38 +08:00
优化代码
This commit is contained in:
parent
bf286cc639
commit
12a11c7ea2
24
App.vue
24
App.vue
@ -1,15 +1,14 @@
|
||||
<script>
|
||||
//app.js
|
||||
const context = require("./context/Java110Context.js");
|
||||
const loginFactory = context.factory.login;
|
||||
const userFactory = context.factory.user;
|
||||
//app.js
|
||||
const context = require("./context/Java110Context.js");
|
||||
const loginFactory = context.factory.login;
|
||||
const userFactory = context.factory.user;
|
||||
|
||||
export default {
|
||||
export default {
|
||||
// 小程序启动生命周期
|
||||
onLaunch: function () {
|
||||
onLaunch: function() {
|
||||
let that = this; // 检查登录状态
|
||||
|
||||
|
||||
//loginFactory.checkLoginStatus(); // 获取用户地理位置
|
||||
|
||||
userFactory.getUserLocation();
|
||||
@ -19,8 +18,15 @@ export default {
|
||||
userInfo: null
|
||||
},
|
||||
methods: {}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@import "./app.css";
|
||||
@import "./app.css";
|
||||
|
||||
/* #ifdef H5 */
|
||||
uni-page-head {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
</style>
|
||||
@ -109,6 +109,11 @@ export function getCategoryList() {
|
||||
name: "合同费用",
|
||||
src: "/static/images/index_property.png",
|
||||
href: "/pages/contractFeeList/contractFeeList"
|
||||
},
|
||||
{
|
||||
name: "投票问卷",
|
||||
src: "/static/images/index_property.png",
|
||||
href: "/pages/questionAnswer/questionAnswer"
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
64
api/question/questionApi.js
Normal file
64
api/question/questionApi.js
Normal file
@ -0,0 +1,64 @@
|
||||
import {
|
||||
request
|
||||
} from '../java110Request.js'
|
||||
import
|
||||
url
|
||||
from '../../constant/url.js'
|
||||
|
||||
import
|
||||
mapping
|
||||
from '../../constant/MappingConstant.js'
|
||||
|
||||
/**
|
||||
* 投票问卷
|
||||
* @param {Object} _data 评价内容
|
||||
*/
|
||||
export function queryQuestionAnswer(_data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let moreRooms = [];
|
||||
request({
|
||||
url: url.queryQuestionAnswer,
|
||||
method: "GET",
|
||||
data: _data, //动态数据
|
||||
success: function(res) {
|
||||
let _data = res.data;
|
||||
if (_data.code == 0) {
|
||||
resolve(_data);
|
||||
return ;
|
||||
}
|
||||
reject(_data.msg);
|
||||
},
|
||||
fail: function(e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 投票问卷
|
||||
* @param {Object} _data 评价内容
|
||||
*/
|
||||
export function queryQuestionAnswerTitle(_data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let moreRooms = [];
|
||||
request({
|
||||
url: url.queryQuestionAnswerTitle,
|
||||
method: "GET",
|
||||
data: _data, //动态数据
|
||||
success: function(res) {
|
||||
let _data = res.data;
|
||||
if (_data.code == 0) {
|
||||
resolve(_data);
|
||||
return ;
|
||||
}
|
||||
reject(_data.msg);
|
||||
},
|
||||
fail: function(e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +114,8 @@ export default {
|
||||
queryRoomRenovationRecord: baseUrl + "app/roomRenovation/queryRoomRenovationRecord",
|
||||
queryRoomRenovationRecordDetail: baseUrl + "app/roomRenovation/queryRoomRenovationRecordDetail",
|
||||
queryContract:baseUrl + "app/contract/queryContract",
|
||||
queryQuestionAnswer:baseUrl + "app/questionAnswer/queryQuestionAnswer",
|
||||
queryQuestionAnswerTitle:baseUrl + "app/questionAnswer/queryQuestionAnswerTitle",
|
||||
|
||||
NEED_NOT_LOGIN_PAGE: [
|
||||
'/pages/login/login',
|
||||
|
||||
18
pages.json
18
pages.json
@ -523,6 +523,24 @@
|
||||
}
|
||||
|
||||
}
|
||||
,{
|
||||
"path" : "pages/questionAnswer/questionAnswer",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "投票问卷",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
||||
}
|
||||
,{
|
||||
"path" : "pages/questionAnswerDetail/questionAnswerDetail",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#272636",
|
||||
|
||||
97
pages/questionAnswer/questionAnswer.vue
Normal file
97
pages/questionAnswer/questionAnswer.vue
Normal file
@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<view class="user-container">
|
||||
<view class="cu-list menu" v-if="questions.length > 0" v-for="(question, idx) in questions" :key="idx" :data-item="question"
|
||||
@click="gotoDetail(question)">
|
||||
<view class="cu-item arrow">
|
||||
<view class="content padding-tb-sm">
|
||||
<view>
|
||||
<text class="cuIcon-notification text-cut text-green margin-right-xs"></text>
|
||||
<view class="text-cut" style="width:220px">{{question.qaName}}</view>
|
||||
</view>
|
||||
<view class="text-gray text-sm">
|
||||
<text class="margin-right-xs">结束时间:</text> {{question.endTime}}</view>
|
||||
</view>
|
||||
<view class="action" v-if="question.state == '0'">已结束</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-list menu" v-if="questions.length === 0">
|
||||
<view class="cu-item">
|
||||
<view class="content">
|
||||
<text class="cuIcon-notification text-grey"></text>
|
||||
<text class="text-grey">暂无投票问卷信息</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** index.js **/
|
||||
const context = require("../../context/Java110Context.js");
|
||||
const constant = context.constant; //获取app实例
|
||||
//获取app实例
|
||||
const app = getApp().globalData;
|
||||
import {queryQuestionAnswer} from '../../api/question/questionApi.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
communityId: "",
|
||||
questions: [],
|
||||
currPageIndex: 0,
|
||||
pageSize: 10
|
||||
};
|
||||
},
|
||||
onLoad: function(options) {
|
||||
let that = this;
|
||||
context.onLoad(options);
|
||||
that.communityId = context.getUserInfo().communityId;
|
||||
|
||||
queryQuestionAnswer({
|
||||
page:1,
|
||||
row:50,
|
||||
qaTypes:'1001,3003',
|
||||
objType:'3306',
|
||||
communityId:that.communityId
|
||||
})
|
||||
.then(_data=>{
|
||||
_data.data.forEach(function(item, index) {
|
||||
let _endTime = new Date(item.endTime);
|
||||
if(_endTime.getTime() > new Date().getTime()){
|
||||
item.state = '1';
|
||||
}else{
|
||||
item.state = '0'
|
||||
}
|
||||
item.startTime = item.startTime.replace(/:\d{1,2}$/, ' ');
|
||||
item.endTime = item.endTime.replace(/:\d{1,2}$/, ' ');
|
||||
});
|
||||
that.questions = _data.data;
|
||||
})
|
||||
},
|
||||
onShow: function() {
|
||||
let that = this;
|
||||
},
|
||||
methods: {
|
||||
gotoDetail: function(_question) {
|
||||
if(_question.state == '0'){
|
||||
uni.showToast({
|
||||
icon:'none',
|
||||
title:'此投票问卷已结束'
|
||||
})
|
||||
return ;
|
||||
}
|
||||
let that = this;
|
||||
this.vc.navigateTo({
|
||||
url: "/pages/questionAnswerDetail/questionAnswerDetail?qaId=" + _question.qaId+"&objType="+_question.objType
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.cu-list+.cu-list {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
148
pages/questionAnswerDetail/questionAnswerDetail.vue
Normal file
148
pages/questionAnswerDetail/questionAnswerDetail.vue
Normal file
@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="" v-for="(item,index) in titles" :key="index">
|
||||
<view class="block__title">{{item.qaTitle}}</view>
|
||||
<radio-group class="block" @change="radioChange($event,item)" v-if="item.titleType == '1001'">
|
||||
<view class="cu-form-group" v-for="(valueItem,valueIndex) in item.questionAnswerTitleValues"
|
||||
:key="valueIndex">
|
||||
<view class="title">{{valueItem.qaValue}}</view>
|
||||
<radio :class="item.radio==valueItem.valueId?'checked':''"
|
||||
:checked="item.radio==valueItem.valueId?true:false" :value="valueItem.valueId">
|
||||
</radio>
|
||||
</view>
|
||||
</radio-group>
|
||||
<checkbox-group class="block" @change="checkboxChange($event,item)" v-else-if="item.titleType == '2002'">
|
||||
<view class="cu-form-group " v-for="(valueItem,valueIndex) in item.questionAnswerTitleValues">
|
||||
<view class="title">{{valueItem.qaValue}}</view>
|
||||
<checkbox :class="item.radio[valueIndex].checked?'checked':''"
|
||||
:checked="item.radio[valueIndex].checked?true:false" :value="valueItem.valueId"></checkbox>
|
||||
</view>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="button_up_blank"></view>
|
||||
|
||||
<view class="flex flex-direction">
|
||||
<button class="cu-btn bg-green margin-tb-sm lg" @click="submitQuestionAnswer()">提交</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const context = require("../../context/Java110Context.js");
|
||||
const constant = context.constant;
|
||||
const factory = context.factory;
|
||||
|
||||
import {
|
||||
queryQuestionAnswerTitle
|
||||
} from '../../api/question/questionApi.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
titles: [],
|
||||
qaId: '',
|
||||
objType: ''
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
let that = this;
|
||||
context.onLoad(options);
|
||||
this.qaId = options.qaId;
|
||||
this.objType = options.objType
|
||||
|
||||
queryQuestionAnswerTitle({
|
||||
objType: this.objType,
|
||||
qaId: this.qaId,
|
||||
page: 1,
|
||||
row: 100
|
||||
})
|
||||
.then(_data => {
|
||||
_data.data.forEach(item => {
|
||||
if (item.titleType == '1001') {
|
||||
item.radio = ''
|
||||
} else if (item.titleType == '2002') {
|
||||
// checked: false
|
||||
item.radio = [];
|
||||
item.questionAnswerTitleValues.forEach(value => {
|
||||
item.radio.push({
|
||||
checked: false,
|
||||
valueId: value.valueId,
|
||||
selected:'0'
|
||||
})
|
||||
})
|
||||
} else {
|
||||
item.radio = ''
|
||||
}
|
||||
})
|
||||
that.titles = _data.data;
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {},
|
||||
methods: {
|
||||
radioChange: function(e, item) {
|
||||
console.log(e, item)
|
||||
item.radio = e.detail.value;
|
||||
},
|
||||
checkboxChange: function(e, item) {
|
||||
item.radio.forEach(value => {
|
||||
if (value.valueId == e.detail.value) {
|
||||
if(value.selected == '0'){
|
||||
value.selected = '1';
|
||||
}else{
|
||||
value.selected = '0';
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
submitQuestionAnswer: function(e) {
|
||||
|
||||
console.log(this.titles);
|
||||
let obj = {
|
||||
"repairName": this.bindRepairName,
|
||||
"repairType": this.repairType,
|
||||
"appointmentTime": this.bindDate + " " + this.bindTime + ":00",
|
||||
"tel": this.bindTel,
|
||||
"roomId": this.roomId,
|
||||
"photos": [],
|
||||
"context": this.context,
|
||||
"userId": this.userId,
|
||||
"userName": this.userName,
|
||||
"communityId": this.communityId,
|
||||
"bindDate": this.bindDate,
|
||||
"bindTime": this.bindTime,
|
||||
"repairObjType": this.repairObjType,
|
||||
"repairChannel": 'Z'
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.block__title {
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: rgba(69, 90, 100, .6);
|
||||
padding: 40rpx 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.button_up_blank {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user