Selaa lähdekoodia

[问卷调查][修改]:问卷调查修改

tags/2.3.0
meo 6 vuotta sitten
vanhempi
commit
1c8f6a3b56
7 muutettua tiedostoa jossa 300 lisäystä ja 149 poistoa
  1. +10
    -3
      components/questionnaire/questionnaire.js
  2. +11
    -10
      components/questionnaire/questionnaire.wxml
  3. +159
    -122
      pages/coupon/detail/index.js
  4. +2
    -5
      pages/coupon/detail/index.json
  5. +32
    -3
      pages/coupon/detail/index.wxml
  6. +85
    -0
      pages/coupon/detail/index.wxss
  7. +1
    -6
      pages/order/detail/index.js

+ 10
- 3
components/questionnaire/questionnaire.js Näytä tiedosto

@@ -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()});
}
},

+ 11
- 10
components/questionnaire/questionnaire.wxml Näytä tiedosto

@@ -1,24 +1,25 @@
<view class="b1" animation="{{alphaData}}">
<view id='con' class='con' animation="{{queueData}}">
<image class='close' mode='widthFix' src="./../../assets/img/closed.png" bindtap="close"></image>
<image class='ques_gou' mode='widthFix' src="./../../assets/img/ques_gou.png"></image>
<image class='image' src="./../../assets/img/headbg.png" mode='widthFix'></image>
<image class='img image' src="./../../assets/img/ques_bg.png" mode='widthFix'></image>
<view class='question'>
<view hidden="{{flag}}">
<view class="b1" animation="{{alphaData}}">
<view id='con' class='con' animation="{{queueData}}">
<image class='close' mode='widthFix' src="./../../assets/img/closed.png" bindtap="close"></image>
<image class='ques_gou' mode='widthFix' src="./../../assets/img/ques_gou.png"></image>
<image class='image' src="./../../assets/img/headbg.png" mode='widthFix'></image>
<image class='img image' src="./../../assets/img/ques_bg.png" mode='widthFix'></image>
<view class='question'>
<text class='title'>{{questionnaire.title}}</text>
<!-- 单选 -->
<radio-group class="radio-group" wx:if="{{questionnaire.flag=='single'}}" data-flags="sigle" bindtap="formSubmit" data-questionId="{{questionId}}">
<radio class="radio ques" wx:for="{{questionnaire.answers}}" wx:key="{{index}}" value="{{item.id}}" data-answer="{{item.name}}" data-answerId="{{item.id}}">
<view>{{item.name}}</view>
<view>{{item.name}}</view>
</radio>
</radio-group>
<!-- 多选 -->
<checkbox-group bindchange="checkboxChange" wx:if="{{questionnaire.flag=='multi'}}" bindchange="checkboxChange">
<label class="radio ques" wx:for="{{questionnaire.answers}}" wx:key="">
<checkbox value="{{item.id}}"/>{{item.name}}
<checkbox value="{{item.id}}" />{{item.name}}
</label>
</checkbox-group>
<view class='ques btns' wx:if="{{questionnaire.flag=='multi'}}" data-flags='multi' bindtap='formSubmit' data-questionId="{{questionId}}">确定</view>
</view>
</view> </view>
</view>
</view>

+ 159
- 122
pages/coupon/detail/index.js Näytä tiedosto

@@ -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') {}
}
};
// 来自页面内的按钮的转发


+ 2
- 5
pages/coupon/detail/index.json Näytä tiedosto

@@ -1,6 +1,3 @@
{
"usingComponents": {
"questionnaire": "../../../components/questionnaire/questionnaire"
},
"navigationBarTitleText": "券详情"
}
"navigationBarTitleText": "券详情"
}

+ 32
- 3
pages/coupon/detail/index.wxml Näytä tiedosto

@@ -7,7 +7,8 @@
<view class='coupons_info'>
<view class='fenxiang'>
<image class="fenxiang" src='./../../../assets/img/fenxiang.png' mode="widthFix"></image>
<button class='share user-motto' data-id='{{data.id}}' data-couponId='{{data.couponId}}' data-title='{{data.title}}' id="shareBtn" open-type="share" hover-class="other-button-hover"></button>
<button class='share user-motto' data-id='{{data.id}}' data-couponId='{{data.couponId}}' data-title='{{data.title}}'
id="shareBtn" open-type="share" hover-class="other-button-hover"></button>
</view>
<view>
<view class='distance' wx:if="{{data.targetAd==2&&data.endTime!=undefined&&data.type!=5}}">
@@ -35,7 +36,7 @@
<text class="pri01">{{data.salePriceStr}}</text>
<text class="yuan">元</text>
<text class='throgh' wx:if="{{data.unit==0}}">{{data.priceStr}}元</text>
<text wx:if="{{data.unit==1}}">{{data.priceStr}}小时</text>
<text wx:if="{{data.unit==1}}">{{data.priceStr}}小时</text>
</view>
<text class="restNum fr">剩余<text>{{data.remainInventory}}件</text></text>
</view>
@@ -90,4 +91,32 @@
</view>
</view>
<!-- 问卷调查 -->
<questionnaire wx:if="{{display=='block'}}" questionnaire="{{questionnaire}}" questionId="{{questionId}}" bind:myevent="close" bind:myevent="formSubmit" />
<view wx:if="{{flag}}">
<view class="b1" >
<view id='con' class='con' animation="{{alphaData}}">
<image class='close' mode='widthFix' src="./../../../assets/img/closed.png" bindtap="closeQuestion"></image>
<image class='ques_gou' mode='widthFix' src="./../../../assets/img/ques_gou.png"></image>
<image class='image' src="./../../../assets/img/headbg.png" mode='widthFix'></image>
<image class='img image' src="./../../../assets/img/ques_bg.png" mode='widthFix'></image>
<view class='question'>
<text class='titles'>{{questionnaire.title}}</text>
<!-- 单选 -->
<radio-group class="radio-group" wx:if="{{questionnaire.flag=='single'}}" data-flags="sigle" bindtap="formSubmit"
data-questionId="{{questionId}}">
<radio class="radio ques" wx:for="{{questionnaire.answers}}" wx:key="{{index}}" value="{{item.id}}"
data-answer="{{item.name}}" data-answerId="{{item.id}}">
<view>{{item.name}}</view>
</radio>
</radio-group>
<!-- 多选 -->
<checkbox-group bindchange="checkboxChange" wx:if="{{questionnaire.flag=='multi'}}" bindchange="checkboxChange">
<label class="radio ques" wx:for="{{questionnaire.answers}}" wx:key="index">
<checkbox value="{{item.id}}" />{{item.name}}
</label>
</checkbox-group>
<view class='ques btns' wx:if="{{questionnaire.flag=='multi'}}" data-flags='multi' bindtap='formSubmit'
data-questionId="{{questionId}}">确定</view>
</view>
</view>
</view>
</view>

+ 85
- 0
pages/coupon/detail/index.wxss Näytä tiedosto

@@ -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;
}

+ 1
- 6
pages/order/detail/index.js Näytä tiedosto

@@ -73,12 +73,7 @@ Page({
})
})
.catch(err => {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000,
mask: false
});
console.log(err);
})
},
/**


Ladataan…
Peruuta
Tallenna