123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- <template>
- <view class="bg">
- <view class="question_box">
- <view class="process">
- <view class="process_bar" :style="{'width': percentage}"></view>
- </view>
- <view style="display: flex; justify-content: space-between;align-items: center;">
- <view class="question_num">
- <text class="num_front">出题{{currentIndex + 1}}</text><text class="num_behond">/{{maxLength}}</text>
- </view>
- <view class="tips">请选择你的答案进入下一题</view>
- </view>
- <view class="qs_txt">{{currentQuestion.answer}}</view>
- <view class="answer_list">
- <view :class="['answer', checkActive(item)]" v-for="(item, index) in currentAnswerList"
- @click="nextHandle(item)">
- <text>
- {{item}}
- </text>
- </view>
- </view>
- </view>
- <view class="contral_box">
- <view class="prev_btn" v-if="currentIndex > 0" @click="prevHandle">
- <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/prev_btn.png"
- mode="widthFix"></image>
- </view>
- <view class="prev_btn" v-if="userAnswerList.length >= maxLength" @click="submitResult">
- <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/submit_btn.png"
- mode="widthFix"></image>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getResult,
- queryPromotionBySubjectId,
- } from "@/api/index.js";
- export default {
- data() {
- return {
- isChecked: true,
- isShake: false,
- scaleDetail: {},
- questionList: [],
- currentQuestion: {},
- currentAnswerList: [],
- currentIndex: 0,
- userAnswerList: [],
- resultId: '',
- isLoading: false,
- isDisbale: false,
- maxLength: 0,
- userInfo: {},
- canPrev: false
- }
- },
- computed: {
- percentage() {
- return ((this.userAnswerList.length / this.maxLength) * 648) + 'rpx'
- }
- },
- created() {
- this.loadData();
- this.userInfo = uni.getStorageSync('user');
- },
- methods: {
- loadData() {
- this.$request
- .get({
- url: `scaleInfo/20210714221054`,
- loadingTip: "加载中...",
- data: {},
- }).then((res) => {
- this.questionList = JSON.parse(JSON.stringify(res.data));
- this.maxLength = this.questionList.length;
- this.currentQuestion = this.questionList[this.currentIndex];
- this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
- })
- },
- nextHandle(str) {
- if (this.isDisbale) {
- return;
- }
- this.isDisbale = true;
- this.userAnswerList[this.currentIndex] = JSON.parse(JSON.stringify(this.currentQuestion));
- this.userAnswerList[this.currentIndex].checkItems = str;
- if (this.currentIndex >= this.questionList.length - 1) {
- this.isDisbale = false;
- // this.submitResult();
- } else {
- setTimeout(() => {
- this.currentIndex++;
- this.currentQuestion = this.questionList[this.currentIndex];
- this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
- this.isDisbale = false;
- }, 150)
- }
- },
- prevHandle() {
- if (this.canPrev || this.currentIndex == 0) {
- return;
- }
- this.canPrev = true;
- setTimeout(() => {
- this.canPrev = false;
- this.currentIndex--;
- this.currentQuestion = this.questionList[this.currentIndex];
- this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
- }, 300)
- },
- submitResult() {
- let _this = this;
- if (_this.isLoading) {
- return
- }
- _this.isLoading = true;
- let params = {
- testPlanId: "",
- scale_result: _this.userAnswerList,
- userId: uni.getStorageSync('user').id
- };
- uni.showLoading({
- title: "测试结果生成中",
- });
- _this.$request
- .post({
- url: `${getResult}/20210714221054`,
- loadingTip: "加载中...",
- data: params,
- })
- .then((res) => {
- _this.isLoading = false;
- _this.resultId = res.data;
- // _this.$request.post({
- // url: `scaleExternalSource/save`,
- // loadingTip: "加载中...",
- // data: {
- // currentUserId: _this.userInfo.id,
- // resultId: _this.resultId,
- // uid: _this.uid,
- // source: _this.source,
- // flag: _this.flag,
- // },
- // }).then(() => {})
- uni.hideLoading();
- // 答题结束获取支付
- _this.getQueryPromotionBySubjectId();
- })
- .catch(() => {
- _this.isLoading = false;
- uni.showToast({
- icon: "none",
- title: "提交失败",
- });
- uni.hideLoading();
- });
- },
- // 获取支付金额
- async getQueryPromotionBySubjectId() {
- let _this = this;
- let urls = queryPromotionBySubjectId + "/20210714221054";
- await _this.$request
- .get({
- url: urls,
- loadingTip: "加载中...",
- data: {},
- })
- .then((res) => {
- console.log('量表支付信息', res.data);
- let data = res.data;
- if (data.price == 0) {
- uni.navigateTo({
- url: `/newScale/Career/testResult?resultId=${_this.resultId}&messageShare=1`
- });
- } else {
- let params = {
- productId: '20210714221054',
- userId: _this.userInfo?.id,
- resultId: _this.resultId,
- description: data.name,
- total: data.price,
- sceneType: uni.getSystemInfoSync().platform == "android" ?
- "Android" : "iOS",
- };
- uni.setStorageSync('orderInfo', params);
- uni.navigateTo({
- url: "/newScale/paymentPage/index?tName=Career",
- });
- }
- });
- },
- checkActive(item) {
- return this.userAnswerList[this.currentIndex] && this.userAnswerList[this.currentIndex]
- .checkItems ==
- item ? 'active' : ''
- },
- getAnswerItem(arr) {
- return arr.split(';')
- }
- }
- }
- </script>
- <style scoped>
- .bg {
- width: 100%;
- height: 1624rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/testPage_bg.png) no-repeat top;
- background-size: 100% 100%;
- overflow: hidden;
- }
- .tips {
- width: 50%;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: normal;
- font-size: 24rpx;
- color: #666666;
- line-height: 55rpx;
- }
- .question_box {
- box-sizing: border-box;
- width: 688rpx;
- height: 933rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/question_bg.png);
- background-size: 100% 100%;
- margin: 288rpx auto 20rpx;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: normal;
- font-size: 40rpx;
- color: #333333;
- padding: 96rpx 56rpx 0 56rpx;
- position: relative;
- }
- .question_box .qs_txt {
- width: 100%;
- height: 180rpx;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: bold;
- font-size: 40rpx;
- color: #222222;
- line-height: 1.4;
- margin: 30rpx auto 30rpx;
- }
- .question_box image {
- width: 43rpx;
- margin: 0 10rpx;
- }
- .answer {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- width: 100%;
- padding-left: 10%;
- margin: 0 auto;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_bg.png) no-repeat left center;
- background-size: 38rpx 38rpx;
- transition: background 200ms linear;
- margin: 0 auto 32rpx;
- }
- .answer.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_bg_active.png) no-repeat left center;
- background-size: 38rpx 38rpx;
- color: #4A74F0;
- }
- .answer text {
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: normal;
- font-size: 36rpx;
- color: #999999;
- line-height: 1.6;
- letter-spacing: 2rpx;
- }
- /* .answer1 {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_A.png);
- background-size: cover;
- }
- .answer1.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_A_active.png);
- background-size: cover;
- color: #FFFFFF;
- }
- .answer2 {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_B.png);
- background-size: cover;
- }
- .answer2.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_B_active.png);
- background-size: cover;
- color: #FFFFFF;
- }
- .answer3 {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_C.png);
- background-size: cover;
- }
- .answer3.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_C_active.png);
- background-size: cover;
- color: #FFFFFF;
- }
- .answer4 {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_D.png);
- background-size: cover;
- }
- .answer4.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_D_active.png);
- background-size: cover;
- color: #FFFFFF;
- }
- .answer5 {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_E.png);
- background-size: cover;
- }
- .answer5.active {
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/answer_E_active.png);
- background-size: cover;
- color: #FFFFFF;
- } */
- .prev_btn {
- text-align: center;
- }
- .process {
- box-sizing: border-box;
- width: 647rpx;
- height: 20rpx;
- background: #FFFFFF;
- border-radius: 10rpx;
- overflow: hidden;
- position: absolute;
- top: 20rpx;
- left: 50%;
- transform: translateX(-50%);
- }
- .process_bar {
- height: 20rpx;
- background: #2E9AFF;
- border-radius: 10rpx;
- transition: width 200ms linear;
- }
- .question_num {
- width: 238rpx;
- line-height: 70rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Career/question_num_bg.png) no-repeat;
- background-size: cover;
- }
- .num_front {
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: bold;
- font-size: 48rpx;
- color: #FF25A0;
- line-height: 55rpx;
- text-shadow: 2rpx 2rpx 5rpx rgba(146, 9, 0, 0.45);
- }
- .num_behond {
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: bold;
- font-size: 32rpx;
- color: #222222;
- line-height: 55rpx;
- text-shadow: 2rpx 2rpx 5rpx rgba(146, 9, 0, 0.45);
- }
- .contral_box {
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 54rpx 0 100rpx 0;
- }
- .prev_btn {
- margin: 0 20rpx;
- }
- .prev_btn image {
- width: 304rpx;
- }
- </style>
|