Authored by baoss

订单确认优惠券选择 review by bevishuang

... ... @@ -128,7 +128,7 @@
"id": 12,
"name": "商品详情线下店",
"pathName": "pages/productDetail/index",
"query": "q=https%3A%2F%2Fo.yohobuy.com%2Fufo%3Fp%3D6298%2C70%26skup%3D6298%26skn%3D10001242%20",
"query": "q=https://o.yohobuy.com/ufo?p=12714,94&skup=12714&skn=10000110",
"scene": 1011
},
{
... ...
... ... @@ -13,63 +13,73 @@ Component({
type: String,
value: '',
},
chosenIdx: {
type: String,
value: ''
},
},
data: {
// chosenIdx: ''
activityChosenIdx: '',
expressChosenIdx: ''
},
methods: {
confirm: function () {
let item = this.data.coupons[this.data.chosenIdx];
let codeType = item && item.coupon_type|| '';
let code = item && item.coupon_code || '';
let amount = item && item.coupon_value_str || '';
this.triggerEvent('confirmselect', { code, amount, codeType})
let chosenIdxName = ['activityChosenIdx','expressChosenIdx'];
let code = [];
let amount = 0;
chosenIdxName.forEach(val => {
let item = this.data.coupons[this.data[val]];
let itemCode = item && item.coupon_code || '';
let itemAmount = item && item.coupon_value_str || '';
code.push(itemCode);
amount = itemAmount && parseFloat(itemAmount) + amount;
})
code = code.join(',');
this.triggerEvent('confirmselect', { code, amount})
},
cancel: function () {
this.triggerEvent('cancel')
},
check: function (e) {
let idx = e.currentTarget.dataset.idx;
let that = this;
let type = e.currentTarget.dataset.type;
this.data.coupons.forEach((item, index) => {
let listItem = item;
if (index !== idx && item.isChosen) {
this.setData({
[`coupons[${index}].isChosen`]: false,
[`coupons[${idx}].selected`]: 'N'
});
}
if (index === idx) {
this.setData({
[`coupons[${idx}].isChosen`]: true,
[`coupons[${idx}].selected`]: 'Y'
});
if(item.coupon_type === type) {
if (index !== idx && item.isChosen) {
this.setData({
[`coupons[${index}].isChosen`]: false,
[`coupons[${idx}].selected`]: 'N'
});
}
if (index === idx) {
this.setData({
[`coupons[${idx}].isChosen`]: true,
[`coupons[${idx}].selected`]: 'Y'
});
}
}
});
this.data.chosenIdx = idx;
let idxName = type === 100 ? 'activityChosenIdx' : 'expressChosenIdx'
this.data[idxName] = idx;
},
uncheck: function (e) {
let idx = e.currentTarget.dataset.idx;
let type = e.currentTarget.dataset.type;
this.setData({
[`coupons[${idx}].isChosen`]: false,
[`coupons[${idx}].selected`]: 'N'
});
this.data.chosenIdx = '';
let idxName = type === 100 ? 'activityChosenIdx' : 'expressChosenIdx'
this.data[idxName] = '';
},
_show: function (show) {
if (show) {
if (this.data.selectedCode) {
this.data.coupons.forEach((item, index) => {
if (item.coupon_code === this.data.selectedCode) {
if (this.data.selectedCode.includes(item.coupon_code)) {
this.setData({
[`coupons[${index}].isChosen`]: true
});
this.data.chosenIdx = index;
let idxName = item.coupon_type === 100 ? 'activityChosenIdx' : 'expressChosenIdx'
this.data[idxName] = index;
} else {
this.setData({
[`coupons[${index}].isChosen`]: false
... ... @@ -82,7 +92,8 @@ Component({
[`coupons[${index}].isChosen`]: false
});
});
this.data.chosenIdx = '';
this.data.activityChosenIdx = '';
this.data.expressChosenIdx = '';
}
}
console.log(this.data.coupons)
... ...
... ... @@ -23,11 +23,12 @@
<text class="name"><text class="prefix">[UFO]</text>{{item.coupon_name}}</text>
<text class="period">{{item.coupon_validity}}</text>
<block wx:if="{{item.isChosen}}">
<image bindtap="uncheck" class="checked" data-idx="{{index}}"
<image bindtap="uncheck" class="checked" data-idx="{{index}}" data-type="{{item.coupon_type}}"
src="../../assets/images/checked.png"></image>
</block>
<block wx:else>
<view bindtap="check" class="check" data-idx="{{index}}"></view>
<view wx:if="{{isStore && item.coupon_type === 110}}" class="check disabled"></view>
<view bindtap="check" class="check" data-idx="{{index}}" data-type="{{item.coupon_type}}"></view>
</block>
</view>
</view>
... ...
... ... @@ -161,7 +161,9 @@
border-radius: 48rpx;
box-sizing: border-box;
}
.coupon-use-select .coupon-item .right .check.disabled {
background-color: #f3f3f3;
}
.coupon-use-select .coupon-item .right .checked {
position: absolute;
top: 50%;
... ...
... ... @@ -135,13 +135,13 @@ export default class SelectSize extends Component {
<Text className="price">¥{this.state.curPrice}</Text>
}
</Button>
<Button className='dowload-btn btn-col' hover-class='none' onClick={this.onClickBuy.bind(this, this.state.canBuy)} data-can-buy={this.state.canBu}>
{this.state.canBuy && <Button className='dowload-btn btn-col' hover-class='none'>
{/* 下载有货app体验更低价 */}
更低价
{
<Text className="price">¥{this.state.curLowestPrice}</Text>
}
</Button>
</Button>}
</View>)
:
<Button className={this.state.canBuy ? 'buy-btn' : 'buy-btn disabled'} hover-class='none' onClick={this.onClickBuy.bind(this, this.state.canBuy)} data-can-buy={this.state.canBu}>
... ...
... ... @@ -74,14 +74,12 @@ Page({
},
async confirmSelectCoupon({detail}) {
let code = detail.code;
let codeType = detail.codeType;
let amount = detail.amount || '';
let couponsList = this.data.couponList;
if (couponsList){
couponsList.forEach((item, index) => {
if (code === item.coupon_code) {
if (code.includes(item.coupon_code)) {
item.isChosen = true;
item.selected = 'Y'
}
... ... @@ -93,8 +91,7 @@ Page({
couponsList,
selectCouponAmount: amount,
selectCouponCode: code,
selectingCoupon: false,
selectingCouponType: codeType
selectingCoupon: false
});
// 区分线上线下
... ... @@ -104,10 +101,6 @@ Page({
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds) {
promotion_id = this.data.promotionTips.promotionIds;
}
//判断优惠劵的类型
if (code && codeType !== 110){
promotion_id = '';
}
try {
if (this.data.isStore) {
info = await api.orderOfflineCompute({
... ... @@ -193,16 +186,29 @@ Page({
let that = this;
if (data && data.couponList && data.couponList.length > 0){
let coupons = [];
let activityCoupons = [];
let expressCoupons = [];
let couponsAmount = 0;
data.couponList.forEach((item, index) => {
let selected = item.selected;
let couponsType = item.coupon_type;
if (selected === 'Y'){
item.isChosen = true;
data.selectCouponAmount = item.coupon_value_str;
data.selectCouponCode = item.coupon_code;
couponsAmount += parseFloat(item.coupon_value_str);
coupons.push(item.coupon_code);
}else {
item.isChosen = false;
}
if(couponsType === 100) {
activityCoupons.push(item)
} else if(couponsType === 110) {
expressCoupons.push(item)
}
});
data.activityCoupons = activityCoupons;
data.expressCoupons = expressCoupons;
data.selectCouponAmount = couponsAmount;
data.selectCouponCode = coupons.join(',');
}
if (data.good && data.good.goodImg) {
... ... @@ -254,10 +260,7 @@ Page({
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds){
promotionId = this.data.promotionTips.promotionIds;
}
if (this.data.selectingCouponType && this.data.selectingCouponType !== 110) {
promotionId = '';
}
if (this.data.isStore) {
this.check = this.selectComponent("#check");
let checkRes = await this.check.init();
... ...
... ... @@ -38,6 +38,6 @@
</view>
</view>
</view>
<couponSelect bindconfirmselect="confirmSelectCoupon" show="{{selectingCoupon}}" selected-code="{{selectCouponCode}}"
bindcancel="cancelSelectCoupon" coupons="{{couponList}}" chosenIdx="{{chosenIdx}}"></couponSelect>
<couponSelect bindconfirmselect="confirmSelectCoupon" show="{{selectingCoupon}}" selected-code="{{selectCouponCode}}" isStore="{{isStore === 1}}"
bindcancel="cancelSelectCoupon" coupons="{{couponList}}"></couponSelect>
<checkstore id="check" storeId="{{storeId}}" productId="{{product_id}}"></checkstore>
... ...
... ... @@ -44,10 +44,17 @@
<text class='order-detail-sum-grey-txt'>-¥{{data.priceInfo.activityCutPrice}}</text>
</block>
</view>
<view class='order-detail-count-view' wx:if="{{data.isOffline !== 'Y'}}">
<block wx:if="{{data.isOffline !== 'Y'}}">
<view class='order-detail-count-view'>
<text class='order-detail-sum-grey-txt'>运费:</text>
<text class='order-detail-sum-grey-txt'>¥{{data.priceInfo.feePrice}}</text>
</view>
<view class='order-detail-count-view' wx:if="{{data.priceInfo.shippingCouponCutPrice && data.priceInfo.shippingCouponCutPrice != '0.00' && data.priceInfo.shippingCouponCutPrice != '0'}}">
<text class='order-detail-sum-grey-txt'>运费券:</text>
<text class='order-detail-sum-grey-txt'>-¥{{data.priceInfo.shippingCouponCutPrice}}</text>
</view>
</block>
<view class='order-detail-count-view' wx:if="{{data.priceInfo.couponCutPrice}}">
<block wx:if="{{data.priceInfo.couponCutPrice != '0.00' && data.priceInfo.couponCutPrice != '0'}}">
<text class='order-detail-sum-grey-txt'>优惠券:</text>
... ...