diff --git a/common/config.js b/common/config.js index 8c397e1..45989a3 100644 --- a/common/config.js +++ b/common/config.js @@ -1,8 +1,8 @@ -const mode = 'devOnline'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 +const mode = 'devLocal'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 let ROOTPATH = ''; //域名 switch (mode) { case 'devLocal': - ROOTPATH = "//vr.langye.net" + ROOTPATH = "http://h5.ali251.langye.net" break; case 'devOnline': ROOTPATH = "//vr.langye.net" diff --git a/common/http.api.js b/common/http.api.js index 38bd948..095e350 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -3,10 +3,13 @@ let apiApp = { login: '/api/mobile/user/wechat-login', getAppId: '/api/mobile/user/wechat-login-url', getQuestions: '/api/mobile/quiz/get-questions', + getPoints: '/api/mobile/map-point/point-list', baseFormIndex: '/api/mobile/base-form/index', baseFormShow: '/api/mobile/base-form/show', baseFormSave: '/api/mobile/base-form/save', - baseFormDestroy: '/api/mobile/base-form/destroy' + baseFormDestroy: '/api/mobile/base-form/destroy', + saveQuiz: '/api/mobile/map-point/save-quiz', + pointDetail: '/api/mobile/map-point/point-detail', } // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作 @@ -16,12 +19,15 @@ const install = (Vue, vm) => { let login = (params = {}) => vm.$u.get(apiApp.login, params); let getAppId = (params = {}) => vm.$u.get(apiApp.getAppId, params); let getQuestions = (params = {}) => vm.$u.get(apiApp.getQuestions, params); + let getPoints = (params = {}) => vm.$u.get(apiApp.getPoints, params) let baseFormIndex = (params = {}) => vm.$u.get(apiApp.baseFormIndex, params); let baseFormShow = (params = {}) => vm.$u.get(apiApp.baseFormShow, params); let baseFormSave = (data = {}) => vm.$u.post(apiApp.baseFormSave, data); let baseFormDestroy = (params = {}) => vm.$u.post(apiApp.baseFormDestroy, params); + let saveQuiz = (params = {}) => vm.$u.post(apiApp.saveQuiz, params); + let pointDetail = (params = {}) => vm.$u.get(apiApp.pointDetail, params) // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 - vm.$u.api = { login, getAppId, getQuestions, baseFormIndex, baseFormShow, baseFormSave, baseFormDestroy }; + vm.$u.api = { login, getAppId, getQuestions, baseFormIndex, baseFormShow, baseFormSave, baseFormDestroy, getPoints, saveQuiz, pointDetail }; } export default { diff --git a/pages/answer/answer.vue b/pages/answer/answer.vue index 76bd0fa..eabe06b 100644 --- a/pages/answer/answer.vue +++ b/pages/answer/answer.vue @@ -17,12 +17,12 @@ leave-to-class="fade-out">
- 1921年,中国共产党召开了第一次全国代表大会,宣告中国共产党成立。你知道这次大会是在哪里召开的吗? + {{ questionTitle }}
-
-
{{num(index)}}
-
上海
+
+
{{num(item.myindex)}}
+
{{item.title}}
@@ -32,13 +32,24 @@ enter-active-class="fade-in" leave-to-class="fade-out">
-
- -
+ +
@@ -50,17 +61,47 @@ enter-active-class="fade-in" leave-to-class="fade-out">
-
- -
- -
- 打卡成功,已完成{{'3'}}个红色场馆的打卡, 完成8家红色场馆打卡即可获得荣誉证书 -
- -
- -
+ + +
@@ -71,21 +112,51 @@ export default { data() { return { + isTotalEnd: false, //是否完成所有打卡 + detail: {}, now: 0, nowAnswer: {}, - answers: [{},{},{}], + answers: [], + myAnswers: [],//回答答案数组 + isCorrect: false, progress: 1,//1答题中2答案3结束 flag: -1,//显示active index }; }, methods: { + async getDetail () { + const res = await this.$u.api.getPoints() + this.isTotalEnd = res.points.length == res.point_answer_total + this.detail = res + }, + async getQuestions () { + const res = await this.$u.api.getQuestions({ + point_id: this.vuex_point_id + }) + + this.answers = res.questions + }, + answer (item, index) { this.flag = index + this.myAnswers.push({ + question_id: this.answers[this.now].id, + answer_ids: item.id + }) + this.isCorrect = !!item.is_correct setTimeout(() => { this.progress = this.now === (this.answers.length - 1) ? 3 : 2 + + if (this.progress === 3) { + this.isTotalEnd = this.detail.points.length == ( Number(this.detail.point_answer_total) + 1) + this.$u.api.saveQuiz({ + point_id: this.vuex_point_id, + answers: this.myAnswers + }) + } },500) }, @@ -93,21 +164,42 @@ export default { this.now ++ this.flag = -1 this.progress = 1 + }, + + toMap () { + uni.navigateTo({ url:'/pages/map/map' }) + }, + + toCertificate () { + uni.navigateTo({ url:'/pages/certificate/certificate'}) } }, computed: { + correctAnswer () { + let correct = this.answers[this.now]?.options?.find(i => i.is_correct) + return `${this.num(correct?.myindex)}、${correct?.title}` + }, + questionTitle () { + return this.answers[this.now]?.title + }, + questionAnswers () { + return this.answers[this.now]?.options?.sort((a, b) => { + return a.myindex - b.myindex + }) + }, + num () { return function (index) { let map = new Map([ - [0,'A'], - [1,'B'], - [2,'C'], - [3,'D'], - [4,'E'], - [5,'F'], - [6,'G'], - [7,'H'], - [8,'I'], + [1,'A'], + [2,'B'], + [3,'C'], + [4,'D'], + [5,'E'], + [6,'F'], + [7,'G'], + [8,'H'], + [9,'I'], ]) return map.get(index) } @@ -153,6 +245,10 @@ export default { return `第${chineseNumber}题`; } } + }, + onShow() { + this.getQuestions(); + this.getDetail(); } } @@ -272,7 +368,8 @@ export default { font-size: 32rpx; font-weight: 500; color: #666666; - line-height: 135rpx; + padding-top: 52rpx; + //line-height: 135rpx; & > span { font-size: 34rpx; @@ -286,6 +383,7 @@ export default { line-height: 36rpx; padding: 0 calc(127rpx - 51rpx); + padding-top: 38rpx; } } } diff --git a/pages/certificate/certificate.vue b/pages/certificate/certificate.vue index e0cb0dd..7c5a9fe 100644 --- a/pages/certificate/certificate.vue +++ b/pages/certificate/certificate.vue @@ -1,9 +1,34 @@ @@ -18,9 +43,85 @@ export default { diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue index 1614240..4743975 100644 --- a/pages/detail/detail.vue +++ b/pages/detail/detail.vue @@ -7,7 +7,9 @@ diff --git a/pages/map/map.vue b/pages/map/map.vue index a923ee7..e3c5479 100644 --- a/pages/map/map.vue +++ b/pages/map/map.vue @@ -13,13 +13,14 @@ v-for="(item, index) in pointers" :key="index" :style="{ 'transform': `translate(calc(${area.w * item.x / 100}px - 50%),calc(${area.h * item.y / 100}px - 50%))` }" - @click="$u.throttle(() => toDetail(index))"> -
- + @click="$u.throttle(() => toDetail(item))"> +
+
@@ -38,7 +39,7 @@
- +