diff --git a/components/questionnaire/questionnaire.js b/components/questionnaire/questionnaire.js index cc1449a..f79b50b 100644 --- a/components/questionnaire/questionnaire.js +++ b/components/questionnaire/questionnaire.js @@ -5,6 +5,10 @@ Component({ questionnaire: { type: Object, value: {} + }, + questionId: { + type: String, + value: {} } }, data: { @@ -22,23 +26,55 @@ Component({ this.queueClick(); // 子组件向父组件传值 // 传值到 coupon=>detail页面 - var myEvent = "questions"; + var myEvent = "questions1"; this.triggerEvent('myevent', myEvent); }, /** - * 点击提交问题 + * 点击提交问题单选 */ formSubmit:function(e){ + let that = this; console.log(e); - console.log(e.target.dataset.questitle) - console.log(e.target.dataset.question) - this.alphaClick(); - this.queueClick(); + /** + * 多选 + */ + if (e.currentTarget.dataset.flags =='multi'){ + if (that.data.anwserId.length==0){ + var answserIs = "" + }else{ + var answserIs = that.data.anwserId.join(","); + } + } + else{ + var answserIs = e.target.dataset.answerid; + } + Http.post({ + url: config.api.answerQuestion, + data: { + answer: answserIs, + questionId: e.currentTarget.dataset.questionid + } + }) + .then(res => { + console.log(res); + this.alphaClick(); + this.queueClick(); + }) // 子组件向父组件传值 // 传值到 coupon=>detail页面 - var myEvent1 = "questions"; - this.triggerEvent('myevent1', myEvent1); + var myEvent1 = "questions2"; + this.triggerEvent('myevent', myEvent1); + }, + /** + * 多选 + */ + checkboxChange:function(e){ + console.log(e); + this.setData({ + anwserId:e.detail.value + }) }, + queueClick: function () { let that = this; var animation = wx.createAnimation({}); diff --git a/components/questionnaire/questionnaire.wxml b/components/questionnaire/questionnaire.wxml index 514fbfe..0b7af21 100644 --- a/components/questionnaire/questionnaire.wxml +++ b/components/questionnaire/questionnaire.wxml @@ -1,14 +1,24 @@ - + {{questionnaire.title}} - - {{item.ques}} - + + + + {{item.name}} + + + + + + + 确定 \ No newline at end of file diff --git a/components/questionnaire/questionnaire.wxss b/components/questionnaire/questionnaire.wxss index 48c483c..9a9684a 100644 --- a/components/questionnaire/questionnaire.wxss +++ b/components/questionnaire/questionnaire.wxss @@ -6,21 +6,20 @@ right: 0px; background: rgba(0, 0, 0, 0.8); overflow: hidden; - z-index: 1000000000000; + z-index: 100; } .con { position: absolute; - top: 120rpx; + top: 35rpx; right: 0; bottom: 0; left: 0; margin: auto; width: 587rpx; - } -.con .image { +.con .image{ display: block; width: 100%; } @@ -28,7 +27,6 @@ .img { margin-top: -50rpx; } - .question { display: block; width: 587rpx; @@ -39,16 +37,17 @@ } .ques { + display: block; width: 511rpx; margin: 0 auto; - height: 105rpx; - line-height: 105rpx; - text-align: center; + height: 95rpx; + line-height: 95rpx; font-size: 30rpx; color: #333; border-bottom: 1rpx solid #eee; } + .title { width: 511rpx; display: block; @@ -76,4 +75,10 @@ width: 20rpx; top: 160rpx; left: 23rpx; +} +.btns{ + color: #f8755b; + font-weight: bold; + font-size: 30rpx!important; + text-align: center!important; } \ No newline at end of file diff --git a/config/config.js b/config/config.js index f5b1290..cee900d 100755 --- a/config/config.js +++ b/config/config.js @@ -1,5 +1,5 @@ var config = { - // url: "http://10.11.205.51:7000/C/api", + // url: "http://10.11.207.233:7000/C/api", url: "https://ciformall.youlane.cn/C/api", // url:"https://c.malls.iformall.com/C/api", // url: "http://31adc9ce.ngrok.io/C/api", @@ -155,7 +155,15 @@ var config = { /** * 用户更新信息 */ - updateInfo: "/user/updateUserInfo" + updateInfo: "/user/updateUserInfo", + /** + * 查询问卷 + */ + getQuestion:"/wxQuestion/getQuestion", + /** + * 提交问卷 + */ + answerQuestion:"/wxQuestion/answerQuestion" }, weapp: { diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index fab3517..1502832 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -6,7 +6,8 @@ const util = require("../../../utils/util"); Page({ data: { data: {}, - questions:null, + questions1:null, + questions2:null, display:"none", carList: [], couponChannelId: null, @@ -22,12 +23,8 @@ Page({ result: [], end_time: null, clock: "已经截止", - questionnaire: { - title: "小主,您有娃吗 ?" , - questions: [ - { ques: "要你管" }, - { ques: "有萌娃" }] - }, + questionnaire: {}, + questionId:null }, onShow:function(){ this.setData({ @@ -51,17 +48,62 @@ Page({ close: function (e) { console.log(e.detail); let that = this; - if (e.detail == 'questions') { - this.orderFunc("questions"); - } + that.setData({ + questions1: e.detail, + display:"none" + }) }, formSubmit:function(e){ console.log(e.detail); let that = this; - if (e.detail == 'questions') { - this.orderFunc("questions"); + that.setData({ + questions2: e.detail, + display:"none" + }) + }, + + /** + * gotopay + */ + gotopay:function(){ + let that = this; + console.log(that.data.questions1) + if (that.data.questions1 == 'questions1' || that.data.questions2 == 'questions2'){ + that.setData({ + display: "none", + }) + that.orderFunc(); + }else{ + Http.get({ + url: config.api.getQuestion, + data: { + couponType: JSON.stringify(that.data.data.type) + } + }) + .then(res => { + if (res.data == undefined) { + that.setData({ + display: "none", + }) + that.orderFunc(); + } + else if (res.data) { + that.setData({ + display: "block", + questionnaire: JSON.parse(res.data.content), + questionId:res.data.id + }); + console.log(that.data.questionnaire); + } + }) + .catch(error=>{ + console.log(error) + }) } }, + + + countdown(end_time) { let that = this; var EndTime = end_time; @@ -375,38 +417,23 @@ Page({ ///// end virtual pay }); } else { - // 免费券 /** * @Meo * 功能:用户问卷调查功能 */ console.log(that.data.data.type); - that.setData({ - display:"block", - }) that.payOrderUpdate(orderId, "0", 1); wx.setStorage({ key: 'couponNum', data: "couponNum" }) - if (flag =='questions'){ - setTimeout(function () { - wx.navigateTo({ - url: `/pages/order/detail/index?orderId=${ - that.data.orderId - }` - }); - }, 1500) - }else{ - // setTimeout(function () { - // wx.navigateTo({ - // url: `/pages/order/detail/index?orderId=${ - // that.data.orderId - // }` - // }); - // }, 1000) - } - + setTimeout(function () { + wx.navigateTo({ + url: `/pages/order/detail/index?orderId=${ + that.data.orderId + }` + }); + }, 1000) /** * @Meo * type diff --git a/pages/coupon/detail/index.wxml b/pages/coupon/detail/index.wxml index 73756b9..3bfb986 100644 --- a/pages/coupon/detail/index.wxml +++ b/pages/coupon/detail/index.wxml @@ -81,13 +81,13 @@ - - + - \ No newline at end of file + \ No newline at end of file diff --git a/pages/coupon/detail/index.wxss b/pages/coupon/detail/index.wxss index 491a14e..4aed1f1 100644 --- a/pages/coupon/detail/index.wxss +++ b/pages/coupon/detail/index.wxss @@ -30,7 +30,7 @@ page { border-top-left-radius: 20rpx; border-top-right-radius: 20rpx; margin-top: -25rpx; - z-index: 100000000; + z-index: 10; } .fenxiang { @@ -272,7 +272,7 @@ page { right: 0; padding-bottom: 22rpx; padding-top: 22rpx; - z-index: 1000; + z-index: 100; } .buy { diff --git a/pages/index/index.js b/pages/index/index.js index 8861287..ed0b6a8 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -81,10 +81,16 @@ Page({ }) } var that = this; - var scene = decodeURIComponent(options.scene); - that.setData({ - scene:scene - }); + if (decodeURIComponent(options.scene)=="undefined"){ + that.setData({ + scene: 0 + }); + }else{ + that.setData({ + scene: decodeURIComponent(options.scene) + }); + } + console.log(that.data.scene); app.getLocation(); if (options.couponChannelId && options.couponId){ that.userLogin(options.couponChannelId, options.couponId);