diff --git a/components/questionnaire/questionnaire.js b/components/questionnaire/questionnaire.js index 83f9159..1808454 100644 --- a/components/questionnaire/questionnaire.js +++ b/components/questionnaire/questionnaire.js @@ -19,6 +19,7 @@ Component({ scaleData: null, skewData: null, matrixData: null, + flag: false, }, methods:{ close:function(){ @@ -83,13 +84,19 @@ Component({ queueClick: function () { let that = this; var animation = wx.createAnimation({}); - animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1500 }) + setTimeout(function () { + that.setData({ flag: true }) + }, 600) + animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1000 }) that.setData({ queueData: animation.export()}) }, alphaClick: function (even) { let that = this; - var animation = wx.createAnimation({}) - animation.opacity(0).step({ duration: 1500 }) + var animation = wx.createAnimation({}); + setTimeout(function () { + that.setData({ flag: true }) + }, 600) + animation.opacity(0).step({ duration: 1000 }) that.setData({ alphaData: animation.export()}); } }, diff --git a/components/questionnaire/questionnaire.wxml b/components/questionnaire/questionnaire.wxml index 0b7af21..49dd9c6 100644 --- a/components/questionnaire/questionnaire.wxml +++ b/components/questionnaire/questionnaire.wxml @@ -1,24 +1,25 @@ - - - - - - - + \ No newline at end of file diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 7ac216f..47e21db 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -26,12 +26,15 @@ Page({ end_time: null, clock: "已经截止", questionnaire: {}, - questionId: null - }, - onShow: function () { - this.setData({ - display: "none", - }) + questionId: null, + widthScreen: null, + moveData: null, + rotateData: null, + alphaData: null, + scaleData: null, + skewData: null, + matrixData: null, + flag: false }, phone: function () { let that = this; @@ -41,68 +44,106 @@ Page({ }); } }, - /** - * @Meo - * 问卷调查组件传递的值 + * 点击提交问题单选 */ - close: function (e) { + formSubmit: function (e) { let that = this; - that.setData({ - questions1: e.detail, - display: "none" + /** + * 多选 + */ + console.log(e); + 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 => { + that.closeQuestion(); + }) + .catch(err => { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + }) + }, + /** + * 多选 + */ + checkboxChange: function (e) { + this.setData({ + anwserId: e.detail.value }) }, - formSubmit: function (e) { + + closeQuestion: function () { let that = this; - that.setData({ - questions2: e.detail, - display: "none" + var animation = wx.createAnimation({}) + setTimeout(function () { + that.setData({ + flag: false + }) + }, 1000) + animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ + duration: 1000 }) + that.setData({ + alphaData: animation.export() + }); + setTimeout(function () { + that.orderFunc(); + }, 1100) }, + /** * gotopay */ gotopay: function () { let that = this; - if (that.data.questions1 || that.data.questions2) { - that.setData({ - display: "none", - }) - that.orderFunc(); - } else { - Http.get({ + that.setData({ + alphaData: null + }) + 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 - }); - } - }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false + .then(res => { + console.log(res); + if (res.data == undefined) { + that.orderFunc(); + } else if (res.data) { + that.setData({ + flag: true, + questionnaire: JSON.parse(res.data.content), + questionId: res.data.id }); - }) - } + } + }) + .catch(err => { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + }) }, - countdown(end_time) { let that = this; var EndTime = end_time; @@ -110,7 +151,6 @@ Page({ var total_micro_second = EndTime - NowTime || []; // 渲染倒计时时钟 let obj = that.dateformat(total_micro_second); - if (total_micro_second > 0) { that.setData({ clock: obj, @@ -148,21 +188,22 @@ Page({ var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60); // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒"; - return { a1: day, b1: hr, c1: min, d1: sec } + return { + a1: day, + b1: hr, + c1: min, + d1: sec + } }, onLoad(options) { let that = this; wx.showLoading({ title: "加载中..." }); - /** - * 暂时注销 - * this.orderFunc() - */ that.setData({ couponChannelId: options.couponChannelId, couponId: options.couponId, - title: that.data.data.title, + title: that.data.data.title ? that.data.data.title : '', }); var parmer = { url: config.api.couponDetail, @@ -202,7 +243,7 @@ Page({ } }).catch(err => { wx.showToast({ - title: err.errMsg, + title: err.message, icon: 'none', duration: 2000, mask: false @@ -216,14 +257,14 @@ Page({ let that = this; // 支付成功 Http.post({ - url: config.api.payOrderUpdate, - data: { - payOrderId: payOrderId, - orderId: orderId, - status: status, - reason: reason - } - }) + url: config.api.payOrderUpdate, + data: { + payOrderId: payOrderId, + orderId: orderId, + status: status, + reason: reason + } + }) .then(res => { console.log(res); if (!type) { @@ -253,11 +294,11 @@ Page({ wx.showLoading({ title: "加载中..." }); - if (that.data.data.type == 6) { } else { + if (that.data.data.type == 6) {} else { Http.post({ - url: config.api.checkPhoneStatus, - data: {} - }) + url: config.api.checkPhoneStatus, + data: {} + }) .then(res => { var data = { couponChannelId: "" + that.data.couponChannelId, @@ -354,7 +395,7 @@ Page({ }); } else { wx.showToast({ - title: err.errMsg, + title: err.message, icon: 'none', duration: 2000, mask: false @@ -373,57 +414,56 @@ Page({ * 支付订单创建 */ Http.post({ - url: config.api.payOrderCreate, - data: { - orderId: orderId - } - }).then(res => { - /// Begin payment ---- - var payOrderId = "" + res.data.payOrderId; - wx.hideLoading(); - wx.requestPayment({ - timeStamp: res.data.timeStamp, - nonceStr: res.data.nonceStr, - package: res.data.package, - signType: (res.data.signType) ? res.data.signType : "MD5", - paySign: res.data.paySign, - success: res => { - that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); - if (res.errMsg == "requestPayment:ok") { - setTimeout(function () { - wx.hideLoading(); - }, 2000); + url: config.api.payOrderCreate, + data: { + orderId: orderId + } + }).then(res => { + /// Begin payment ---- + var payOrderId = "" + res.data.payOrderId; + wx.hideLoading(); + wx.requestPayment({ + timeStamp: res.data.timeStamp, + nonceStr: res.data.nonceStr, + package: res.data.package, + signType: (res.data.signType) ? res.data.signType : "MD5", + paySign: res.data.paySign, + success: res => { + that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); + if (res.errMsg == "requestPayment:ok") { + setTimeout(function () { + wx.hideLoading(); + }, 2000); + /** + * 用户支付成功以后跳转到券包列表 + */ + wx.setStorage({ + key: 'couponNum', + data: "couponNum", + }) + if (that.data.data.type == 5) { + setTimeout(() => { + wx.switchTab({ + url: '/pages/passCar/passCar' + }); + }, 1600); + } + } + }, + fail: res => { /** - * 用户支付成功以后跳转到券包列表 + * 支付失败,需要更新订单的状态 */ - wx.setStorage({ - key: 'couponNum', - data: "couponNum", - }) - if (that.data.data.type == 5) { - setTimeout(() => { - wx.switchTab({ - url: '/pages/passCar/passCar' - }); - }, 1600); - } - } - }, - fail: res => { - /** - * 支付失败,需要更新订单的状态 - */ - that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail',that); - return; - }, - complete: res => { - } - }); - /// End payment -------- - }) + that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that); + return; + }, + complete: res => {} + }); + /// End payment -------- + }) .catch(err => { wx.showToast({ - title: err.errMsg, + title: err.message, icon: 'none', duration: 2000, mask: false @@ -455,7 +495,7 @@ Page({ }) .catch(err => { wx.showToast({ - title: err.errMsg, + title: err.message, icon: 'none', duration: 2000, mask: false @@ -469,13 +509,10 @@ Page({ title: that.data.data.title, path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}`, success: function (res) { - if (res.errMsg == 'shareAppMessage:ok') { - } + if (res.errMsg == 'shareAppMessage:ok') {} }, fail: function (error) { - if (res.errMsg == 'shareAppMessage:fail cancel') { - } else if (res.errMsg == 'shareAppMessage:fail') { - } + if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {} } }; // 来自页面内的按钮的转发 diff --git a/pages/coupon/detail/index.json b/pages/coupon/detail/index.json index 1569a86..96c4fcf 100644 --- a/pages/coupon/detail/index.json +++ b/pages/coupon/detail/index.json @@ -1,6 +1,3 @@ { - "usingComponents": { - "questionnaire": "../../../components/questionnaire/questionnaire" - }, - "navigationBarTitleText": "券详情" - } \ No newline at end of file + "navigationBarTitleText": "券详情" +} \ No newline at end of file diff --git a/pages/coupon/detail/index.wxml b/pages/coupon/detail/index.wxml index a297c86..257c821 100644 --- a/pages/coupon/detail/index.wxml +++ b/pages/coupon/detail/index.wxml @@ -7,7 +7,8 @@ - + @@ -35,7 +36,7 @@ {{data.salePriceStr}} {{data.priceStr}}元 - {{data.priceStr}}小时 + {{data.priceStr}}小时 剩余{{data.remainInventory}}件 @@ -90,4 +91,32 @@ - \ No newline at end of file + + + + + + + + + {{questionnaire.title}} + + + + {{item.name}} + + + + + + + 确定 + + + + \ No newline at end of file diff --git a/pages/coupon/detail/index.wxss b/pages/coupon/detail/index.wxss index 4aed1f1..75bbbf4 100644 --- a/pages/coupon/detail/index.wxss +++ b/pages/coupon/detail/index.wxss @@ -350,4 +350,89 @@ page { } .ques{ display: none; +} + +.b1 { + position: fixed; + top: 0px; + bottom: 0px; + left: 0px; + right: 0px; + background: rgba(0, 0, 0, 0.8); + overflow: hidden; + z-index: 100; +} + +.con { + position: absolute; + top: 35rpx; + right: 0; + bottom: 0; + left: 0; + margin: auto; + width: 587rpx; +} + +.con .image{ + display: block; + width: 100%; +} + +.img { + margin-top: -50rpx; +} +.question { + display: block; + width: 587rpx; + background: #fff; + border-bottom-left-radius: 22rpx; + border-bottom-right-radius: 22rpx; + overflow: hidden; +} + +.ques { + display: block; + width: 511rpx; + margin: 0 auto; + height: 95rpx; + line-height: 95rpx; + font-size: 30rpx; + color: #333; + border-bottom: 1rpx solid #eee; +} + + +.titles { + width: 511rpx; + display: block; + text-align: center; + height: 50rpx; + margin: 0 auto; + padding-top:10rpx; + padding-bottom:20rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 41rpx; + border-bottom: 1rpx solid #eee; +} +.quessss >view:last-child{ + border-bottom:0; +} +.close{ + position: relative; + z-index: 10000; + display: block; + width: 70rpx; +} +.ques_gou{ + position: absolute; + 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/pages/order/detail/index.js b/pages/order/detail/index.js index 2bb93f6..98bce2b 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -73,12 +73,7 @@ Page({ }) }) .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); + console.log(err); }) }, /**