Authored by huangyCode

Merge branch 'feature/support-coupon' of http://git.yoho.cn/mobile/yoho-miniapp-…

…ufo into feature/support-coupon
import OrderListService from '../../pages/orderList/orderListService.js';
import OrderActionService from './orderActionService.js';
import event from '../../utils/event';
Component({
properties: {
showConfirm: {
type: Boolean,
value: false
},
orderCode: {
type: String,
value: '',
observer: '_orderChange'
},
navBack: {
type: Number,
value: 0
}
},
data: {
slideLeft: 0,
startX: 0,
hideSlide: true,
hideTip: false,
containerWidth: 0,
slideIconWidth: 0,
status: '',
orderPrice: '',
orderPriceDesc: '',
penaltyAmount: '',
penaltyDesc: '',
penaltyRate: '',
refundAmount: '',
refundDesc: ''
},
methods: {
closeSlide: function() {
this.setData({
hideSlide: true
});
},
touchStart: function (e) {
this.data.startX = e.touches[0].clientX;
},
touchMove: function (e) {
let currentX = e.touches[0].clientX;
if (currentX - this.data.startX < 0 || this.data.complete) {
return;
}
if (currentX - this.data.startX > (this.data.containerWidth - this.data.slideIconWidth - 4)) {
this.data.complete = true;
this.setData({
slideLeft: this.data.containerWidth - this.data.slideIconWidth - 4
});
return this.slideComplete();
}
this.setData({
hideTip: true,
slideLeft: currentX - this.data.startX
});
},
touchEnd: function (e) {
if (!this.data.complete) {
this.setData({
slideLeft: 0,
hideTip: false
});
}
},
confirm: function() {
let ctx = this;
if (!this.data.needPenalty) {
let api = new OrderActionService();
let params = {
method: 'ufo.buyer.cancel',
orderCode: this.data.orderCode
};
this.setData({
showConfirm: false
});
api.actionOrder(params).then(() => {
if (+this.data.navBack === 1){
wx.navigateBack({
delta: 1
});
}
event.emit('refresh-order');
});
return;
}
this.setData({
showConfirm: false,
hideSlide: false
}, () => {
let query = this.createSelectorQuery();
query.select('.slide-container').boundingClientRect();
query.exec(function (res) {
if (res && res[0] && res[0].width) {
ctx.data.containerWidth = res[0].width;
}
});
query = this.createSelectorQuery();
query.select('.slide-icon').boundingClientRect();
query.exec(function (res) {
if (res && res[0] && res[0].width) {
ctx.data.slideIconWidth = res[0].width;
}
});
});
},
keep: function () {
this.setData({
showConfirm: false
});
},
slideComplete: function() {
this._reset();
let api = new OrderActionService();
let params = {
method: 'ufo.buyer.cancel',
orderCode: this.data.orderCode
};
api.actionOrder(params).then(() => {
if (+this.data.navBack === 1){
wx.navigateBack({
delta: 1
});
}
event.emit('refresh-order');
});
},
_reset: function() {
this.setData({
hideSlide: true,
slideLeft: 0,
hideTip: false,
complete: false
});
},
_orderChange: function (val) {
if (!val) {
return;
}
let api = new OrderListService();
this.data.complete = false;
this.setData({
hideSlide: true,
slideLeft: 0
});
api.getCancelOrderInfo({orderCode: val}).then(data => {
this.data.needPenalty = data && data.needPenalty || false;
if (data && !data.needPenalty) {
this.setData({
...data,
status: '0',
cancelText: data && data.confirmDesc || '确定取消订单?',
cancelBtnText: '取消订单'
});
}
if (data && data.needPenalty) {
if (data && data.showPrice) {
this.setData({
...data,
status: '1',
cancelText: data && data.confirmDesc || '确定取消订单?',
cancelBtnText: '赔付并取消订单'
});
} else {
this.setData({
status: '2',
cancelText: data && data.confirmDesc || '确定取消订单?',
cancelBtnText: '赔付并取消订单'
});
}
}
});
}
}
});
... ...
{
"component": true,
"usingComponents": {
}
}
... ...
<view class="cancel-order-dialog">
<view class="confirm-layer {{status == '0' || status == '2' ? 'no-penalty' : ''}}}" wx:if="{{showConfirm}}">
<view class="mask"></view>
<view class="info">
<block wx:if="{{status == '0'}}">
<view class="item solo">{{cancelText}}</view>
</block>
<block wx:if="{{status == '1'}}">
<view class="item"><text class="left">{{orderPriceDesc}}</text><text class="right">{{orderPrice}}</text></view>
<view class="item"><text class="left">{{penaltyDesc}}({{penaltyRate}})</text><text class="right danger">{{penaltyAmount}}</text></view>
<view class="item"><text class="left">{{refundDesc}}</text><text class="right">{{refundAmount}}</text></view>
</block>
<block wx:if="{{status == '2'}}">
<view class="item solo">{{cancelText}}</view>
</block>
<view class="bottom-btn">
<view class="cancel btn {{status == '0' ? 'invalid' : ''}}" bindtap="confirm">{{cancelBtnText}}</view>
<view class="keep btn" bindtap="keep">保留订单</view>
</view>
</view>
</view>
<view class="slide-layer" hidden="{{hideSlide}}">
<view class="slide-mask">
<image class="close-icon"
bindtap="closeSlide"
src="../../assets/images/close.png"></image>
</view>
<view class="slide">
<view class="slide-container">
<view class="tip" hidden="{{hideTip}}">滑动确认赔付并取消订单</view>
<image class="slide-icon"
catchtouchstart="touchStart"
catchtouchmove="touchMove"
catchtouchend="touchEnd"
style="margin-left:{{slideLeft}}px"
src="../../assets/images/slide.png"></image>
</view>
</view>
</view>
</view>
... ...
.cancel-order-dialog .confirm-layer .info {
position: fixed;
width: 560rpx;
height: 400rpx;
z-index: 1000;
top: 50%;
left: 50%;
margin-left: -280rpx;
margin-top: -240rpx;
background-color: #ffffff;
text-align: center;
padding: 80rpx 44rpx 0 44rpx;
box-sizing: border-box;
}
.cancel-order-dialog .confirm-layer .info .item {
font-size: 28px;
color: #000000;
letter-spacing: 0;
text-align: left;
margin-bottom: 14rpx;
}
.cancel-order-dialog .confirm-layer .info .item .right {
float: right;
}
.cancel-order-dialog .confirm-layer .info .item .right.danger {
color: #D0021B;
}
.cancel-order-dialog .confirm-layer .info .item.solo {
text-align: center;
font-size: 38rpx;
margin-top: 30rpx;
}
.cancel-order-dialog .confirm-layer .info .bottom-btn{
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 100rpx;
font-size: 0;
border-top: 1px solid #EEEEEE;
}
.cancel-order-dialog .confirm-layer .bottom-btn .btn {
display: inline-block;
width: 50%;
line-height: 100rpx;
text-align: center;
font-size: 24rpx;
box-sizing: border-box;
}
.cancel-order-dialog .confirm-layer .bottom-btn .btn.keep {
font-size: 30px;
color: #000000;
letter-spacing: 0;
text-align: center;
font-weight: 500;
}
.cancel-order-dialog .confirm-layer .bottom-btn .btn.cancel {
font-size: 30px;
color: #D0021B;
letter-spacing: 0;
text-align: center;
border-right: 1px solid #EEEEEE;
}
.cancel-order-dialog .confirm-layer .bottom-btn .btn.cancel.invalid {
color: #e0e0e0;
}
.cancel-order-dialog .confirm-layer .mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.4;
z-index: 999;
background: #000000;
}
.cancel-order-dialog .confirm-layer.no-penalty .info {
position: fixed;
width: 560rpx;
height: 260rpx;
z-index: 1000;
top: 50%;
left: 50%;
margin-left: -280rpx;
margin-top: -120rpx;
background-color: #ffffff;
text-align: center;
padding: 34rpx 44rpx 0 44rpx;
box-sizing: border-box;
}
.cancel-order-dialog .confirm-layer.no-penalty .item.solo {
text-align: center;
font-size: 28rpx;
}
.cancel-order-dialog .slide-mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.9;
z-index: 999;
background: #000000;
}
.cancel-order-dialog .slide-layer .close-icon {
position: fixed;
top: 60rpx;
right: 40rpx;
width: 48rpx;
height: 48rpx;
}
.cancel-order-dialog .slide-container {
position: absolute;
width: 640rpx;
height: 140rpx;
z-index: 9999;
background: #FFFFFF;
border-radius: 70rpx;
top: 50%;
left: 50%;
margin-top: -70rpx;
margin-left: -320rpx;
}
.cancel-order-dialog .slide-container .tip {
font-size: 28px;
color: #444444;
letter-spacing: 0;
text-align: center;
line-height: 140rpx;
margin-left: 122rpx;
}
.cancel-order-dialog .slide-container .slide-icon {
position: absolute;
width: 132rpx;
height: 132rpx;
top: 4rpx;
left: 4rpx;
}
... ...
... ... @@ -10,7 +10,7 @@ Component({
},
coupons: {
type: Array,
value: []
value: [{value: 100}, {value: 200}, {value: 200}, {value: 200}, {value: 200}, {value: 200}]
}
},
data: {
... ...
... ... @@ -8,12 +8,19 @@
</view>
<block wx:else>
<scroll-view class="coupon-scroll" scroll-y>
<view class="coupon-item"></view>
<view class="coupon-item"></view>
<view class="coupon-item"></view>
<view class="coupon-item"></view>
<view class="coupon-item"></view>
<view class="coupon-item"></view>
<block wx:for="{{coupons}}">
<view class="coupon-item">
<view class="left">
<text class="value">5</text>
<text class="condition">满200可用</text>
</view>
<view class="right">
<text class="name">[UFO]Adidas Origins店铺使用</text>
<text class="period">2018.1.12-2018.5.20</text>
<view class="check"></view>
</view>
</view>
</block>
</scroll-view>
</block>
<view class="confirm" bindtap="confirm">确定</view>
... ...
... ... @@ -23,6 +23,8 @@
overflow-y: scroll;
height: 720rpx;
padding-bottom: 120rpx;
text-align: center;
font-size: 0;
}
.coupon-use-select .empty {
... ... @@ -57,14 +59,95 @@
.coupon-use-select .coupon-item {
display: inline-block;
position: relative;
height: 200rpx;
margin: 20rpx 20rpx 0 20rpx;
background-color: #ffffff;
width: 720rpx;
background: url("https://img10.static.yhbimg.com/yhb-img01/2019/03/05/20/01b68a5d4f22945fe5afcf0f768538cfd3.png") no-repeat;
background-size: 720rpx 200rpx;
}
.coupon-use-select .coupon-item:first-child {
margin-top: 10rpx;
}
.coupon-use-select .coupon-item:last-child {
margin-bottom: 20rpx;
margin-bottom: 10rpx;
}
.coupon-use-select .coupon-item .left {
position: absolute;
top: 0;
left: 10rpx;
height: 200rpx;
width: 220rpx;
padding-top: 38rpx;
text-align: center;
box-sizing: border-box;
}
.coupon-use-select .coupon-item .left .value {
display: block;
font-weight: bold;
font-size: 72px;
color: #002B47;
letter-spacing: 0;
text-align: center;
line-height: 1;
}
.coupon-use-select .coupon-item .left .condition {
display: block;
font-size: 24px;
color: #002B47;
letter-spacing: 0;
text-align: center;
line-height: 1;
margin-top: 16rpx;
}
.coupon-use-select .coupon-item .right {
padding-top: 30rpx;
padding-left: 240rpx;
padding-right: 80rpx;
box-sizing: border-box;
}
.coupon-use-select .coupon-item .right .name {
display: block;
font-size: 24px;
color: #222222;
letter-spacing: 0;
line-height: 30rpx;
word-break: break-all;
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
text-align: left;
}
.coupon-use-select .coupon-item .right .period {
display: block;
font-size: 22px;
color: #999999;
letter-spacing: 0;
margin-top: 26rpx;
text-align: left;
}
.coupon-use-select .coupon-item .right .check {
position: absolute;
top: 50%;
right: 50rpx;
width: 48rpx;
height: 48rpx;
margin-top: -24rpx;
border: 2rpx solid #cccccc;
border-radius: 48rpx;
box-sizing: border-box;
}
.coupon-use-select .confirm {
... ...