formform提交

master
lion 3 years ago
parent aa988a3d8a
commit b6238835ef

@ -28,6 +28,9 @@
}, },
{ {
"path": "pages/visit/study" "path": "pages/visit/study"
},
{
"path": "pages/visit/testStudy"
} }
], ],
"globalStyle": { "globalStyle": {

@ -48,8 +48,8 @@
url = "/pages/visit/addrecord?type=2" url = "/pages/visit/addrecord?type=2"
break; break;
case 3: case 3:
// url = "/pages/visit/addrecord?type=3" url = "/pages/visit/addrecord?type=3"
url = "/pages/visit/study?type=3" // url = "/pages/visit/study?type=3"
break; break;
case 4: case 4:
url = "/pages/index/login" url = "/pages/index/login"

@ -10,7 +10,7 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="到访时段" required name="visit_time_id"> <uni-forms-item label="到访时段" required name="visit_time_id">
<uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime" <uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime"
:map="{text:'vititTimeRange',value:'id'}" /> :map="{text:'visitTimeRange',value:'id'}" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="前往区域" required name="visit_area_id"> <uni-forms-item label="前往区域" required name="visit_area_id">
<uni-data-checkbox v-model="form.visit_area_id" :localdata="visitArea" <uni-data-checkbox v-model="form.visit_area_id" :localdata="visitArea"
@ -214,35 +214,9 @@
}, },
}, },
// //
visitTime: [{ visitTime: [],
vititTimeRange: '9-10', visitArea: [],
id: 0 reasonList: [],
}, {
vititTimeRange: '10-11',
id: 1
}, {
vititTimeRange: '11-12',
id: 2
}],
visitArea: [{
name: '9-10',
id: 0
}, {
name: '10-11',
id: 1
}, {
name: '11-12',
id: 2
}],
reasonList: [{
value: 0,
text: "开会"
},
{
value: 1,
text: "洽谈"
}
],
credentList: [{ credentList: [{
value: 1, value: 1,
text: "身份证" text: "身份证"
@ -265,12 +239,87 @@
}, },
onLoad(options) { onLoad(options) {
this.form.type = options.type this.form.type = options.type
this.getVisitArea()
this.getVisitTime()
this.getReason()
this.getAdminList()
}, },
onReady() {}, onReady() {},
methods: { methods: {
// //
async getVisitArea() {
let that = this
// util.request()
this.util.request({
api: '/api/mobile/visit/visit-area',
data: {},
utilSuccess: function(res) {
console.log(res)
that.visitArea = res
},
utilFail: function(res) {}
})
},
async getVisitTime() { async getVisitTime() {
let that = this
// util.request() // util.request()
this.util.request({
api: '/api/mobile/visit/visit-time',
data: {},
utilSuccess: function(res) {
for (var m of res) {
m.visitTimeRange = m.start_time + "-" + m.end_time
}
console.log(res)
that.visitTime = res
},
utilFail: function(res) {}
})
},
async getReason() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/parameter/show',
data: {
number: 'reasonList'
},
utilSuccess: function(res) {
let arr = []
console.log(res)
for (var m of res.detail) {
arr.push({
text: m.value,
value: m.id
})
}
that.reasonList = arr
},
utilFail: function(res) {}
})
},
async getAdminList() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/other/admin-user-list',
data: {
page_size: 99,
page: 1
},
utilSuccess: function(res) {
let arr = []
for (var m of res.data) {
arr.push({
text: m.name,
value: m.id
})
}
that.adminList = arr
},
utilFail: function(res) {}
})
}, },
// //
chooseCredent(e) { chooseCredent(e) {
@ -300,7 +349,7 @@
saveFormgoStudy() { saveFormgoStudy() {
console.log("form", this.form) console.log("form", this.form)
this.$refs['formdata'].validate().then(res => { this.$refs['formdata'].validate().then(res => {
uni.setStorageSync('formdata', this.form) uni.setStorageSync('formdata',this.form)
uni.navigateTo({ uni.navigateTo({
url: '/pages/visit/study?type=' + this.form.type url: '/pages/visit/study?type=' + this.form.type
}) })

@ -7,8 +7,7 @@
<view class="service-show"> <view class="service-show">
<swiper class="service-show-swiper" :indicator-dots="true"> <swiper class="service-show-swiper" :indicator-dots="true">
<swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index"> <swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index">
<u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit" <u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit">
>
</u-image> </u-image>
</swiper-item> </swiper-item>
</swiper> </swiper>
@ -21,16 +20,19 @@
</view> </view>
<button @click="goTest" size="mini" type="primary" <button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
>去测验({{studyInfo.minute?studyInfo.minute:""}})</button> <text v-if="studyMin==-1"></text>
<text v-else>{{studyInfo.minute?studyInfo.minute:""}}({{studyTime}})</text>
</button>
</view> </view>
</template> </template>
<script> <script>
export default{ export default {
data(){ data() {
return{ return {
type:1, type: 1,
steps: [{ steps: [{
title: '填报' title: '填报'
}, { }, {
@ -39,128 +41,94 @@
title: '完成' title: '完成'
}], }],
stepActive: 1, stepActive: 1,
studyInfo:{}, studyInfo: {},
studyTime:"" studyTime: "00:00", //
studyMin: -1, //
timer: null,
} }
}, },
onLoad(options) { onLoad(options) {
let that = this
this.type = options.type this.type = options.type
this.getStudy() this.getStudy()
if (this.timer) {
clearInterval(this.timer)
} else {
this.timer = setInterval(function() {
that.loadTime()
}, 1000)
}
}, },
methods:{ methods: {
async getStudy(){ async getStudy() {
let that = this let that = this
this.util.request({ this.util.request({
api: '/api/mobile/visit/get-ask', api: '/api/mobile/visit/get-ask',
data:{ data: {
type:that.type type: that.type
}, },
utilSuccess: function(res) { utilSuccess: function(res) {
that.studyInfo = res that.studyInfo = res
that.studyMin = res.minute * 60
}, },
utilFail: function(res) {} utilFail: function(res) {}
}) })
}, },
loadTime(min){ loadTime() {
let time = min*60*1000 if (this.studyMin >= 0) {
let minutes = Math.floor(this.studyMin / 60);
let seconds = Math.floor(this.studyMin % 60);
minutes = minutes < 10 ? "0" + minutes : minutes
seconds = seconds < 10 ? "0" + seconds : seconds
this.studyTime = minutes + ":" + seconds
--this.studyMin;
} else {
clearInterval(this.timer);
}
}, },
goTest(){ goTest() {
uni.navigateTo({
url: '/pages/visit/testStudy?type=' + this.type
})
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped>
.containers { .containers {
background-color: #fff; background-color: #fff;
min-height: 100vh; min-height: 100vh;
padding: 20rpx; padding: 20rpx;
padding-bottom: 60rpx; padding-bottom: 60rpx;
}
.steps {
margin-bottom: 40rpx
}
.service-show {
width: 100%;
height: 360rpx;
position: relative; position: relative;
&>video {
width: 100%;
height: 100%;
} }
.containers>button{
&-swiper {
width: 100%;
height: 100%;
}
&-btn {
display: flex;
z-index: 3;
position: absolute; position: absolute;
bottom: 30rpx; bottom:60rpx;
right: 33rpx; margin:20rpx;
width:90%;
&-img {
color: #fff;
height: 47rpx;
background: #252526;
border-radius: 16rpx;
opacity: 0.3;
display: flex;
align-items: center;
margin-right: 14rpx;
&>image {
width: 24rpx;
height: 21rpx;
padding-left: 20rpx;
padding-right: 10rpx;
}
&__num {
font-size: 24rpx;
color: #FFFFF0;
font-weight: 400;
padding-right: 20rpx;
} }
.steps {
margin-bottom: 40rpx
} }
&-video { .goTest {
background-color: #044ed7;
color: #fff; color: #fff;
height: 47rpx; }
background: #252526;
border-radius: 16rpx;
opacity: 0.3;
display: flex;
align-items: center;
&>image {
width: 24rpx;
height: 21rpx;
padding-left: 20rpx; .noTest {
padding-right: 10rpx; background-color: #ddd;
color: #000
} }
&__num { .service-show {
font-size: 24rpx; width: 100%;
color: #FFFFF0; height: 360rpx;
font-weight: 400;
padding-right: 20rpx; position: relative;
}
}
}
} }
</style> </style>

@ -0,0 +1,210 @@
<template>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
<view class="asks">
<view v-for="(item,index) in askList">
<view>{{index}}{{item.title}}({{item.type==1?'单选':'多选'}})</view>
<view v-if="item.type==1">
<uni-data-checkbox v-model="result[index]" @change="e=>radioAnswer(e,index)"
:localdata="item.answer" :wrap='true' :map="{text:'content',value:'content'}" />
</view>
<view v-if="item.type==2">
<uni-data-checkbox v-model="resultArr[index]" @change="e=>chenckAnswer(e,item,index)"
:localdata="item.answer" :wrap='true' multiple :map="{text:'content',value:'content'}" />
</view>
</view>
</view>
<view disabled class="justify-between submitBtn">
<text>需要正确率达{{rate}}%</text>
<text @click="submitAnswer"></text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
type: 1,
steps: [{
title: '填报'
}, {
title: '测验'
}, {
title: '完成'
}],
stepActive: 1,
studyInfo: {},
rate: 0,
askList: [],
correctNum: {},
answerList: [],
result: {},
resultArr: [
[],
[],
[],
[],
[],
[],
[],
[],
[]
],
formData: {}
}
},
onLoad(options) {
let that = this
this.type = options.type
this.getFormdata()
this.getStudy()
},
methods: {
getFormdata(){
let res = uni.getStorageSync('formdata')
this.formData = res
},
async getStudy() {
let that = this
this.util.request({
api: '/api/mobile/visit/get-ask',
data: {
type: that.type
},
utilSuccess: function(res) {
that.studyInfo = res
that.askList = res.asks
that.rate = parseInt(res.rate)
},
utilFail: function(res) {}
})
},
//
radioAnswer(item, index) {
this.correctNum[index] = item.detail.data.result
},
chenckAnswer(e, item, index) {
let answer = item.answer
let correctLength = 0
let data = e.detail.data
for (var k of answer) {
if (k.result == 1) {
correctLength++
}
}
// 0
if (data.length < correctLength) {
console.log(correctLength)
this.correctNum[index] = 0
return
} else {
for (var m of data) {
if (m.result == 0) {
this.correctNum[index] = 0
} else {
this.correctNum[index] = 1
}
}
}
},
//
submitAnswer() {
console.log(this.correctNum)
let correctLength = 0
for (var key in this.correctNum) {
if (this.correctNum[key] == 1) {
correctLength++
}
}
let per = parseFloat(correctLength / this.askList.length) * 100
if (per < this.rate) {
this.util.alert("正确率不达标")
} else {
this.submitForm()
}
},
submitForm() {
let that = this
this.util.request({
api: '/api/mobile/visit/visit-save',
method: "POST",
data: that.formData,
utilSuccess: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
},
utilFail: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
}
})
}
}
}
</script>
<style scoped>
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
position: relative;
}
.asks {}
.asks>view,
.asks>view>view {
margin-bottom: 20rpx
}
.containers>.submitBtn {
position: absolute;
bottom: 60rpx;
margin: 20rpx;
width: 90%;
}
.containers>.submitBtn text {
display: inline-block;
padding: 0 10px;
text-align: center;
width: 70%;
background-color: #f8f8f8;
font-size: 36rpx;
border-radius: 10rpx;
padding: 28rpx;
}
.containers>.submitBtn text:first-child {
border-radius: 10rpx 0 0 10rpx;
}
.containers>.submitBtn text:last-child {
width: 30%;
background-color: #044ed7;
color: #fff;
display: inline-block;
border-radius: 0 10rpx 10rpx 0;
}
.steps {
margin-bottom: 40rpx
}
</style>
Loading…
Cancel
Save