百富门答题小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

307 lines
5.7 KiB

<template>
<view class="page">
<image :src="configList.img_13"
class="page-bg"
mode="aspectFill"></image>
<image :src="configList.img_7"
class="logo"
mode="widthFix"></image>
<!-- next1 -->
<view class="content" v-if="question[index]">
<image :src="configList.img_11"
class="content-bg"
mode="aspectFill"></image>
<view class=""
v-html="$utils.stringFormatHtml(question[index].title)">
</view>
<view class="mian-btn"
v-for="(item, i) in question[index].answerObjectSkuList"
:class="{active : answerIds[index] == item.id}"
:key="i"
@click="select(item)">
{{ item.title }}
</view>
</view>
<!-- next2 -->
<view class="content" v-if="stop == 2">
<text class="font-bold mb-60">请选择您所在的区域</text>
<view class="">
<picker
mode="region"
:value="date"
class="u-w-440"
@change="bindTimeChange">
<view class="region">
<view class="">
{{ address.province}}
</view>
<view class="">
{{ address.city}}
</view>
<view class="">
{{ address.district}}
</view>
</view>
</picker>
</view>
</view>
<view class="an">
<view style="display: flex;gap: 30rpx;"
>
<view class="next-btn-2"
v-if="index > 0"
@click="ret">
上一题
</view>
<view class="next-btn"
@click="next1">
下一题
</view>
</view>
<!-- <view class="next-btn"
v-if="stop == 1"
@click="next">
下一题
</view>
<view class="next-btn"
v-if="stop == 2"
@click="next">
提交
</view> -->
<text class="second-color">{{ configList.bg_title }}</text>
</view>
</view>
</template>
<script>
import { mapState } from 'vuex'
export default {
data() {
return {
isActive : null,
stop : 1,
index : 0,
address : {
province : '',
city : '',
district : '',
},
question : [],
answerIds : [],
}
},
computed : {
...mapState(['configList']),
},
onLoad() {
this.firstQuestion()
},
onShow() {
},
methods: {
select(item){
this.answerIds.splice(this.index, 1, item.id)
if(item.isEnd != 'Y'){
this.isActive = item.toMainId
}
},
ret(){
this.index--
this.isActive = null
this.question[this.index]
.answerObjectSkuList.forEach(n => {
if(n.id == this.answerIds[this.index]){
this.isActive = n.toMainId
}
})
},
firstQuestion(){
this.$api('firstQuestion', res => {
if(res.code == 200){
this.question.push(res.result)
}
})
},
next1(){
if(!this.isActive){
uni.showToast({
title:'请选择后进行下一题',
icon: 'none'
})
return
}
let item = null
this.question[this.index]
.answerObjectSkuList.forEach(n => {
if(n.id == this.answerIds[this.index]){
item = n
}
})
if(item.isEnd == 'Y'){
this.$store.commit('getTitleByIds', item.toRuleId)
return
}
this.$api('getProblemById', {
id : this.isActive
}, res => {
if(res.code == 200){
this.index++
this.question.splice(this.index, 1, res.result)
}
})
// this.$api('submitLog', {
// topId : this.probleme[this.index].id,
// context : this.isActive,
// }, res => {
// this.isActive = null
// if(this.index == this.probleme.length - 1){
// this.stop = 2
// }else{
// uni.navigateTo({
// url: '/pages/index/preAppoint'
// })
// }
// })
},
next2(){
// this.stop = 3
if(!this.address.province){
uni.showToast({
title:'请选择地址后进行下一题',
icon: 'none'
})
return
}
uni.redirectTo({
url: '/pages_order/info/fillInfo'
})
},
// 获取省市区
bindTimeChange(e) {
this.address.province = e.detail.value[0];
this.address.city = e.detail.value[1];
this.address.district = e.detail.value[2];
this.address.provinceName = e.detail.value[0] + e.detail.value[1] + e.detail.value[2];
uni.setStorageSync('user_address', JSON.stringify(this.address))
},
}
}
</script>
<style lang="scss" scoped>
.page{
.logo{
width: 600rpx;
margin: 150rpx 75rpx;
}
.content{
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: 0 60rpx;
text-align: center;
width: 700rpx;
height: 650rpx;
margin: 0 25rpx;
.content-bg{
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
}
}
.region{
display: flex;
align-items: center;
&>view{
width: 140rpx;
height: 50rpx;
border-radius: 10rpx;
border: 1px solid #e6bf7f;
margin: 0 10rpx;
line-height: 50rpx;
text-align: center;
}
}
.b-btn{
width: 86%;
display: flex;
justify-content: center;
padding-top: 130rpx;
.pre-btn{
border: 4rpx solid #f1e0c6;
padding: 16rpx 90rpx;
border-radius: 66rpx;
color: #e6bf7f;
}
}
.next-btn{
width: 120rpx;
display: flex;
align-items: center;
justify-content: center;
color: white;
padding: 16rpx 90rpx;
background-color: $uni-color;
border-radius: 30rpx;
}
.next-btn-2{
width: 120rpx;
display: flex;
align-items: center;
justify-content: center;
color: white;
padding: 16rpx 90rpx;
background-color: $uni-color-primary;
border-radius: 30rpx;
}
.an{
position: fixed;
bottom: 300rpx;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.second-color{
margin-top: 20rpx;
}
</style>