testPage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <view class="bg">
  3. <view class="question_box">
  4. <view style="overflow: hidden;"></view>
  5. <image class="paperclip" src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/paperclip.png"
  6. mode="widthFix"></image>
  7. <view class="question_num">
  8. <text class="num_front">出题{{currentIndex + 1}}</text><text class="num_behond">/{{maxLength}}</text>
  9. </view>
  10. <view class="process">
  11. <view class="process_bar" :style="{'width': percentage}"></view>
  12. </view>
  13. <view class="question_box_wrap">
  14. <view class="question_title">
  15. <text>{{currentQuestion.answer}}</text>
  16. </view>
  17. <view class="answer_list">
  18. <view :class="['answer', checkActive(item)]" v-for="(item, index) in currentAnswerList"
  19. @click="nextHandle(item)">
  20. <text>
  21. {{item}}
  22. </text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="tips">请选择你的答案进入下一题</view>
  27. </view>
  28. <view class="contral_box">
  29. <view class="prev_btn" v-if="currentIndex > 0" @click="prevHandle">
  30. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/prev_btn.png" mode="widthFix">
  31. </image>
  32. </view>
  33. <view class="prev_btn" v-if="userAnswerList.length >= 20" @click="submitResult">
  34. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/submit_btn.png"
  35. mode="widthFix"></image>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. getResult,
  43. queryPromotionBySubjectId,
  44. } from "@/api/index.js";
  45. export default {
  46. data() {
  47. return {
  48. isChecked: true,
  49. isShake: false,
  50. scaleDetail: {},
  51. questionList: [],
  52. currentQuestion: {},
  53. currentAnswerList: [],
  54. currentIndex: 0,
  55. userAnswerList: [],
  56. resultId: '',
  57. isLoading: false,
  58. isDisbale: false,
  59. maxLength: 0,
  60. userInfo: {},
  61. questionImgList: [{
  62. 'qImg': 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question1.png',
  63. 'answerImglist': [
  64. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer1-A.png',
  65. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer1-B.png',
  66. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer1-C.png'
  67. ]
  68. },
  69. {
  70. 'qImg': 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question2.png',
  71. 'answerImglist': [
  72. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer2-A.png',
  73. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer2-B.png',
  74. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer2-C.png'
  75. ]
  76. },
  77. {
  78. 'qImg': 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question3.png',
  79. 'answerImglist': [
  80. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer3-A.png',
  81. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer3-B.png',
  82. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer3-C.png'
  83. ]
  84. },
  85. {
  86. 'qImg': 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question4.png',
  87. 'answerImglist': [
  88. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer4-A.png',
  89. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer4-B.png',
  90. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer4-C.png'
  91. ]
  92. },
  93. {
  94. 'qImg': 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question5.png',
  95. 'answerImglist': [
  96. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer5-A.png',
  97. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer5-B.png',
  98. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer5-C.png'
  99. ]
  100. },
  101. ],
  102. userSelectArr: [],
  103. canPrev: false
  104. }
  105. },
  106. computed: {
  107. percentage() {
  108. return (this.userAnswerList.length / this.questionList.length) * 613 + 'rpx'
  109. }
  110. },
  111. created() {
  112. this.loadData();
  113. this.userInfo = uni.getStorageSync('user');
  114. },
  115. methods: {
  116. loadData() {
  117. this.$request
  118. .get({
  119. url: `scaleInfo/20210804164957`,
  120. loadingTip: "加载中...",
  121. data: {},
  122. }).then((res) => {
  123. this.questionList = JSON.parse(JSON.stringify(res.data));
  124. this.maxLength = this.questionList.length;
  125. this.currentQuestion = this.questionList[this.currentIndex];
  126. this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
  127. })
  128. },
  129. nextHandle(str) {
  130. if (this.isDisbale) {
  131. return;
  132. }
  133. this.isDisbale = true;
  134. this.userAnswerList[this.currentIndex] = JSON.parse(JSON.stringify(this.currentQuestion));
  135. this.userAnswerList[this.currentIndex].checkItems = str;
  136. if (this.currentIndex >= this.questionList.length - 1) {
  137. this.isDisbale = false;
  138. // this.submitResult();
  139. } else {
  140. setTimeout(() => {
  141. this.currentIndex++;
  142. this.currentQuestion = this.questionList[this.currentIndex];
  143. this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
  144. this.isDisbale = false;
  145. }, 150)
  146. }
  147. },
  148. prevHandle() {
  149. if (this.canPrev || this.currentIndex == 0) {
  150. return;
  151. }
  152. this.canPrev = true;
  153. setTimeout(() => {
  154. this.canPrev = false;
  155. this.currentIndex--;
  156. this.currentQuestion = this.questionList[this.currentIndex];
  157. this.currentAnswerList = this.getAnswerItem(this.currentQuestion.checkItems);
  158. }, 300)
  159. },
  160. submitResult() {
  161. let _this = this;
  162. if (_this.isLoading) {
  163. return
  164. }
  165. _this.isLoading = true;
  166. let params = {
  167. testPlanId: "",
  168. scale_result: _this.userAnswerList,
  169. userId: this.userInfo.id,
  170. };
  171. uni.showLoading({
  172. title: "测试结果生成中",
  173. });
  174. _this.$request
  175. .post({
  176. url: `${getResult}/20210804164957`,
  177. loadingTip: "加载中...",
  178. data: params,
  179. })
  180. .then((res) => {
  181. _this.isLoading = false;
  182. _this.resultId = res.data;
  183. // _this.$request.post({
  184. // url: `scaleExternalSource/save`,
  185. // loadingTip: "加载中...",
  186. // data: {
  187. // currentUserId: _this.userInfo.id,
  188. // resultId: _this.resultId,
  189. // uid: _this.uid,
  190. // source: _this.source,
  191. // flag: _this.flag,
  192. // },
  193. // }).then(() => {})
  194. uni.hideLoading();
  195. // 跳转支付页面
  196. uni.navigateTo({
  197. url: `/newScale/paymentPage/index?tName=Charm&resultId=${_this.resultId}`
  198. });
  199. })
  200. .catch(() => {
  201. _this.isLoading = false;
  202. uni.showToast({
  203. icon: "none",
  204. title: "提交失败",
  205. });
  206. uni.hideLoading();
  207. });
  208. },
  209. // 获取支付金额
  210. async getQueryPromotionBySubjectId() {
  211. let _this = this;
  212. let urls = queryPromotionBySubjectId + "/20210804164957";
  213. await _this.$request
  214. .get({
  215. url: urls,
  216. loadingTip: "加载中...",
  217. data: {},
  218. })
  219. .then((res) => {
  220. console.log('量表支付信息', res.data);
  221. let data = res.data;
  222. if (data.price == 0) {
  223. uni.navigateTo({
  224. url: `/newScale/Charm/testResult?resultId=${_this.resultId}&messageShare=1`
  225. });
  226. } else {
  227. let params = {
  228. productId: '20210804164957',
  229. userId: _this.userInfo?.id,
  230. resultId: _this.resultId,
  231. description: data.name,
  232. total: data.price,
  233. sceneType: uni.getSystemInfoSync().platform == "android" ?
  234. "Android" : "iOS",
  235. };
  236. uni.setStorageSync('orderInfo', params);
  237. uni.navigateTo({
  238. url: "/newScale/paymentPage/index?tName=Charm"
  239. });
  240. }
  241. });
  242. },
  243. checkActive(item) {
  244. return this.userAnswerList[this.currentIndex] && this.userAnswerList[this.currentIndex]
  245. .checkItems ==
  246. item ? 'active' : ''
  247. },
  248. getAnswerItem(arr) {
  249. return arr.split(';')
  250. }
  251. }
  252. }
  253. </script>
  254. <style scoped>
  255. .bg {
  256. width: 100%;
  257. min-height: 100vh;
  258. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/testPage_bg.png) no-repeat top;
  259. background-size: 100% auto;
  260. overflow: hidden;
  261. }
  262. .tips {
  263. font-family: 'Alibaba PuHuiTi 2.0';
  264. font-weight: normal;
  265. font-size: 28rpx;
  266. color: #FFFFFF;
  267. line-height: 60rpx;
  268. text-align: center;
  269. }
  270. .question_box {
  271. box-sizing: border-box;
  272. width: 702rpx;
  273. height: 1021rpx;
  274. background: linear-gradient(0deg, #EA1750 0%, #FF8189 100%);
  275. border-radius: 26rpx;
  276. padding: 0 15rpx;
  277. margin: 43rpx auto;
  278. position: relative;
  279. }
  280. .question_box_wrap {
  281. width: 668rpx;
  282. height: 830rpx;
  283. background: linear-gradient(0deg, #FFFFFF 76%, #FFEAEF 100%);
  284. box-shadow: 0rpx 0rpx 3rpx 0rpx rgba(133, 14, 45, 0.5);
  285. border-radius: 20rpx;
  286. border: 2px solid #FFFFFF;
  287. }
  288. .question_title {
  289. box-sizing: border-box;
  290. width: 100%;
  291. height: 160rpx;
  292. font-family: 'YanShiXieHeiTi';
  293. font-size: 40rpx;
  294. text-align: justify;
  295. color: #EA1750;
  296. padding: 16px 30rpx 0 30rpx;
  297. }
  298. .question_box text.qs_txt {
  299. padding-bottom: 4rpx;
  300. border-bottom: 4rpx solid #2E9AFF;
  301. line-height: 1.6;
  302. }
  303. .item00 {
  304. width: 262rpx;
  305. position: absolute;
  306. top: 115rpx;
  307. left: 16rpx;
  308. }
  309. .item01 {
  310. width: 341rpx;
  311. position: absolute;
  312. top: -16rpx;
  313. right: 6rpx;
  314. }
  315. .item02 {
  316. width: 362rpx;
  317. position: absolute;
  318. bottom: 36rpx;
  319. left: 203rpx;
  320. }
  321. .item10 {
  322. width: 294rpx;
  323. position: absolute;
  324. top: 44rpx;
  325. left: 26rpx;
  326. }
  327. .item11 {
  328. width: 266rpx;
  329. position: absolute;
  330. top: 83rpx;
  331. right: 49rpx;
  332. }
  333. .item12 {
  334. width: 303rpx;
  335. position: absolute;
  336. bottom: 50rpx;
  337. left: 177rpx;
  338. }
  339. .item20 {
  340. width: 275rpx;
  341. position: absolute;
  342. top: 32rpx;
  343. left: 210rpx;
  344. }
  345. .item21 {
  346. width: 272rpx;
  347. position: absolute;
  348. left: 59rpx;
  349. bottom: 132rpx;
  350. }
  351. .item22 {
  352. width: 248rpx;
  353. position: absolute;
  354. bottom: 71rpx;
  355. right: 32rpx;
  356. }
  357. .item30 {
  358. width: 362rpx;
  359. position: absolute;
  360. top: 21rpx;
  361. left: 0rpx;
  362. }
  363. .item31 {
  364. width: 358rpx;
  365. position: absolute;
  366. right: 7rpx;
  367. top: 116rpx;
  368. }
  369. .item32 {
  370. width: 386rpx;
  371. position: absolute;
  372. bottom: 0;
  373. left: 64rpx;
  374. }
  375. .item40 {
  376. width: 269rpx;
  377. position: absolute;
  378. top: 149rpx;
  379. left: 36rpx;
  380. }
  381. .item41 {
  382. width: 263rpx;
  383. position: absolute;
  384. right: 9rpx;
  385. top: 129rpx;
  386. }
  387. .item42 {
  388. width: 269rpx;
  389. position: absolute;
  390. right: 122rpx;
  391. bottom: 42rpx;
  392. }
  393. .answer_list {
  394. box-sizing: border-box;
  395. width: 100%;
  396. height: 725rpx;
  397. padding-top: 56rpx;
  398. position: relative;
  399. }
  400. .answer {
  401. box-sizing: border-box;
  402. display: flex;
  403. align-items: center;
  404. width: 602rpx;
  405. height: 137rpx;
  406. padding: 0 6% 4rpx 14%;
  407. margin: 33rpx 0;
  408. font-family: 'Alibaba PuHuiTi 2.0';
  409. font-weight: normal;
  410. font-size: 32rpx;
  411. color: #333333;
  412. cursor: pointer;
  413. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer_bg.png);
  414. background-size: 100% 100%;
  415. transition: background 200ms linear;
  416. margin: 0 auto 45rpx;
  417. }
  418. .answer.active {
  419. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/answer_bg_active.png);
  420. background-size: 100% 100%;
  421. color: #FFFFFF;
  422. }
  423. .prev_btn {
  424. text-align: center;
  425. }
  426. .process {
  427. box-sizing: border-box;
  428. width: 613rpx;
  429. height: 16rpx;
  430. padding: 0;
  431. background: linear-gradient(0deg, #FFFFFF 0%, #FFEAEF 100%);
  432. box-shadow: 0rpx 0rpx 3rpx 0rpx rgba(133, 14, 45, 0.5);
  433. border-radius: 8rpx;
  434. border: 1px solid #FFFFFF;
  435. overflow: hidden;
  436. margin: 6rpx auto 14rpx;
  437. }
  438. .process_bar {
  439. height: 12rpx;
  440. background: #F54E6D;
  441. border-radius: 10rpx;
  442. transition: width 200ms linear;
  443. }
  444. .question_num {
  445. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/question_num_bg.png) no-repeat;
  446. background-size: cover;
  447. text-align: right;
  448. margin: 14rpx 53rpx 0 0;
  449. }
  450. .num_front {
  451. font-family: Alibaba PuHuiTi 2.0;
  452. font-weight: bold;
  453. font-size: 48rpx;
  454. color: #FEFEFE;
  455. line-height: 55rpx;
  456. text-shadow: 2rpx 2rpx 5rpx rgba(146, 9, 0, 0.45);
  457. }
  458. .num_behond {
  459. font-family: Alibaba PuHuiTi 2.0;
  460. font-weight: bold;
  461. font-size: 32rpx;
  462. color: #FEFEFE;
  463. line-height: 55rpx;
  464. text-shadow: 2rpx 2rpx 5rpx rgba(146, 9, 0, 0.45);
  465. }
  466. .contral_box {
  467. display: flex;
  468. justify-content: center;
  469. align-items: center;
  470. margin: 54rpx 0 100rpx 0;
  471. }
  472. .prev_btn {
  473. margin: 0 20rpx;
  474. }
  475. .prev_btn image {
  476. width: 304rpx;
  477. }
  478. .paperclip {
  479. width: 55rpx;
  480. position: absolute;
  481. top: -40rpx;
  482. left: 38rpx;
  483. }
  484. </style>