formform提交

master
lion 3 years ago
parent aa988a3d8a
commit b6238835ef

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

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

@ -10,7 +10,7 @@
</uni-forms-item>
<uni-forms-item label="到访时段" required name="visit_time_id">
<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 label="前往区域" required name="visit_area_id">
<uni-data-checkbox v-model="form.visit_area_id" :localdata="visitArea"
@ -214,35 +214,9 @@
},
},
//
visitTime: [{
vititTimeRange: '9-10',
id: 0
}, {
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: "洽谈"
}
],
visitTime: [],
visitArea: [],
reasonList: [],
credentList: [{
value: 1,
text: "身份证"
@ -265,12 +239,87 @@
},
onLoad(options) {
this.form.type = options.type
this.getVisitArea()
this.getVisitTime()
this.getReason()
this.getAdminList()
},
onReady() {},
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() {
let that = this
// 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) {
@ -300,7 +349,7 @@
saveFormgoStudy() {
console.log("form", this.form)
this.$refs['formdata'].validate().then(res => {
uni.setStorageSync('formdata', this.form)
uni.setStorageSync('formdata',this.form)
uni.navigateTo({
url: '/pages/visit/study?type=' + this.form.type
})

@ -1,166 +1,134 @@
<template>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
<view class="study">
<view class="service-show">
<swiper class="service-show-swiper" :indicator-dots="true">
<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>
</swiper-item>
</swiper>
</view>
<view>
{{studyInfo.content?studyInfo.content:""}}
</view>
</view>
<view class="asks">
</view>
<button @click="goTest" size="mini" type="primary"
>去测验({{studyInfo.minute?studyInfo.minute:""}})</button>
</view>
</template>
<script>
export default{
data(){
return{
type:1,
steps: [{
title: '填报'
}, {
title: '学习'
}, {
title: '完成'
}],
stepActive: 1,
studyInfo:{},
studyTime:""
}
},
onLoad(options) {
this.type = options.type
this.getStudy()
},
methods:{
async getStudy(){
let that = this
this.util.request({
api: '/api/mobile/visit/get-ask',
data:{
type:that.type
},
utilSuccess: function(res) {
that.studyInfo = res
},
utilFail: function(res) {}
})
},
loadTime(min){
let time = min*60*1000
},
goTest(){
}
}
}
</script>
<style scoped lang="scss">
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
}
.steps {
margin-bottom: 40rpx
}
.service-show {
width: 100%;
height: 360rpx;
position: relative;
&>video {
width: 100%;
height: 100%;
}
&-swiper {
width: 100%;
height: 100%;
}
&-btn {
display: flex;
z-index: 3;
position: absolute;
bottom: 30rpx;
right: 33rpx;
&-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;
}
}
&-video {
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;
padding-right: 10rpx;
}
&__num {
font-size: 24rpx;
color: #FFFFF0;
font-weight: 400;
padding-right: 20rpx;
}
}
}
}
</style>
<template>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
<view class="study">
<view class="service-show">
<swiper class="service-show-swiper" :indicator-dots="true">
<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>
</swiper-item>
</swiper>
</view>
<view>
{{studyInfo.content?studyInfo.content:""}}
</view>
</view>
<view class="asks">
</view>
<button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
<text v-if="studyMin==-1"></text>
<text v-else>{{studyInfo.minute?studyInfo.minute:""}}({{studyTime}})</text>
</button>
</view>
</template>
<script>
export default {
data() {
return {
type: 1,
steps: [{
title: '填报'
}, {
title: '学习'
}, {
title: '完成'
}],
stepActive: 1,
studyInfo: {},
studyTime: "00:00", //
studyMin: -1, //
timer: null,
}
},
onLoad(options) {
let that = this
this.type = options.type
this.getStudy()
if (this.timer) {
clearInterval(this.timer)
} else {
this.timer = setInterval(function() {
that.loadTime()
}, 1000)
}
},
methods: {
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.studyMin = res.minute * 60
},
utilFail: function(res) {}
})
},
loadTime() {
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() {
uni.navigateTo({
url: '/pages/visit/testStudy?type=' + this.type
})
}
}
}
</script>
<style scoped>
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
position: relative;
}
.containers>button{
position: absolute;
bottom:60rpx;
margin:20rpx;
width:90%;
}
.steps {
margin-bottom: 40rpx
}
.goTest {
background-color: #044ed7;
color: #fff;
}
.noTest {
background-color: #ddd;
color: #000
}
.service-show {
width: 100%;
height: 360rpx;
position: relative;
}
</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