微信小程序优惠劵使用
parent
fa1bc1cf63
commit
e8acc7a42c
|
|
@ -60,6 +60,9 @@ class Buy extends Common
|
|||
// 支付方式
|
||||
$payment_list = PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]);
|
||||
|
||||
// 当前选中的优惠劵
|
||||
$coupon_id = isset($params['coupon_id']) ? intval($params['coupon_id']) : 0;
|
||||
|
||||
// 数据返回组装
|
||||
$result = [
|
||||
'goods_list' => $ret['data']['goods'],
|
||||
|
|
@ -67,6 +70,9 @@ class Buy extends Common
|
|||
'base' => $ret['data']['base'],
|
||||
'extension_data' => $ret['data']['extension_data'],
|
||||
'common_order_is_booking' => (int) MyC('common_order_is_booking', 0),
|
||||
|
||||
// 优惠劵
|
||||
'plugins_coupon_data' => CallPluginsServiceMethod('coupon', 'BaseService', 'BuyUserCouponData', ['order_goods'=>$ret['data']['goods'], 'coupon_id'=>$coupon_id]),
|
||||
];
|
||||
return DataReturn('操作成功', 0, $result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ class Goods extends Common
|
|||
'common_app_is_limitedtimediscount' => (int) MyC('common_app_is_limitedtimediscount'),
|
||||
'common_app_is_good_thing' => (int) MyC('common_app_is_good_thing'),
|
||||
'common_app_is_poster_share' => (int) MyC('common_app_is_poster_share'),
|
||||
|
||||
// 优惠劵
|
||||
'plugins_coupon_data' => $this->PluginsCouponGoods($goods_id),
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ App({
|
|||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
request_url: 'http://tp5-dev.com/',
|
||||
request_url: 'https://test.shopxo.net/',
|
||||
//request_url: 'https://test.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"pages": [
|
||||
"pages": ["pages/goods-detail/goods-detail",
|
||||
"pages/index/index",
|
||||
"pages/goods-category/goods-category",
|
||||
"pages/cart/cart",
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
"pages/login/login",
|
||||
"pages/paytips/paytips",
|
||||
"pages/goods-search/goods-search",
|
||||
"pages/goods-detail/goods-detail",
|
||||
|
||||
"pages/goods-comment/goods-comment",
|
||||
"pages/goods-attribute/goods-attribute",
|
||||
"pages/buy/buy",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ Page({
|
|||
extension_data: [],
|
||||
payment_id: 0,
|
||||
common_order_is_booking: 0,
|
||||
|
||||
// 优惠劵
|
||||
plugins_coupon_data: null,
|
||||
plugins_use_coupon_id: 0,
|
||||
plugins_choice_coupon_value: '选择优惠劵',
|
||||
popup_plugins_coupon_status: false,
|
||||
},
|
||||
onLoad(params) {
|
||||
if((params.data || null) == null || app.get_length(JSON.parse(params.data)) == 0)
|
||||
|
|
@ -70,6 +76,7 @@ Page({
|
|||
var data = this.data.params;
|
||||
data['address_id'] = this.data.address_id;
|
||||
data['payment_id'] = this.data.payment_id;
|
||||
data['coupon_id'] = this.data.plugins_use_coupon_id;
|
||||
wx.request({
|
||||
url: app.get_request_url("index", "buy"),
|
||||
method: "POST",
|
||||
|
|
@ -89,8 +96,21 @@ Page({
|
|||
extension_data: data.extension_data || [],
|
||||
data_list_loding_status: 3,
|
||||
common_order_is_booking: data.common_order_is_booking || 0,
|
||||
plugins_coupon_data: data.plugins_coupon_data || null,
|
||||
});
|
||||
|
||||
// 优惠劵选择处理
|
||||
if ((data.plugins_coupon_data || null) != null)
|
||||
{
|
||||
if ((data.plugins_coupon_data.coupon_choice || null) != null)
|
||||
{
|
||||
this.setData({ plugins_choice_coupon_value: data.plugins_coupon_data.coupon_choice.coupon.desc });
|
||||
} else {
|
||||
var coupon_count = ((data.plugins_coupon_data.coupon_list || null) != null) ? data.plugins_coupon_data.coupon_list.length : 0;
|
||||
this.setData({ plugins_choice_coupon_value: (coupon_count > 0) ? '可选优惠劵' + coupon_count + '张' : '暂无可用优惠劵' });
|
||||
}
|
||||
}
|
||||
|
||||
// 地址
|
||||
if (this.data.address == null || this.data.address_id == 0) {
|
||||
if((data.base.address || null) != null) {
|
||||
|
|
@ -141,6 +161,7 @@ Page({
|
|||
data['address_id'] = this.data.address_id;
|
||||
data['payment_id'] = this.data.payment_id;
|
||||
data['user_note'] = this.data.user_note_value;
|
||||
data['coupon_id'] = this.data.plugins_use_coupon_id;
|
||||
|
||||
// 数据验证
|
||||
var validation = [
|
||||
|
|
@ -203,6 +224,36 @@ Page({
|
|||
}
|
||||
}
|
||||
this.setData({payment_list: data || []});
|
||||
}
|
||||
},
|
||||
|
||||
// 优惠劵弹层开启
|
||||
plugins_coupon_open_event(e) {
|
||||
this.setData({ popup_plugins_coupon_status: true});
|
||||
},
|
||||
|
||||
// 优惠劵弹层关闭
|
||||
plugins_coupon_close_event(e) {
|
||||
this.setData({ popup_plugins_coupon_status: false });
|
||||
},
|
||||
|
||||
// 优惠劵选择
|
||||
plugins_coupon_use_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
this.setData({
|
||||
plugins_use_coupon_id: value,
|
||||
popup_plugins_coupon_status: false,
|
||||
});
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 不使用优惠劵
|
||||
plugins_coupon_not_use_event(e) {
|
||||
this.setData({
|
||||
plugins_use_coupon_id: 0,
|
||||
popup_plugins_coupon_status: false,
|
||||
});
|
||||
this.init();
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
{
|
||||
"enablePullDownRefresh": false
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {
|
||||
"component-popup": "/components/popup/popup"
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,12 @@
|
|||
<!-- 留言 -->
|
||||
<textarea bindinput="bind_user_note_event" maxlength="60" auto-height placeholder="留言" class="content-textarea bg-white spacing-mb" />
|
||||
|
||||
<!-- 优惠劵 -->
|
||||
<view class="plugins-coupon bg-white spacing-mb arrow-right" bindtap="plugins_coupon_open_event">
|
||||
<text class="cr-666">优惠劵</text>
|
||||
<text class="cr-ccc fr">{{plugins_choice_coupon_value}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 扩展数据展示 -->
|
||||
<view wx:if="{{extension_data.length > 0}}" class="extension-list spacing-mb">
|
||||
<view wx:for="{{extension_data}}" wx:key="key" class="item oh">
|
||||
|
|
@ -79,4 +85,38 @@
|
|||
<view wx:if="{{goods.length == 0}}">
|
||||
<import src="/pages/common/nodata.wxml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 优惠劵选择 -->
|
||||
<component-popup prop-show="{{popup_plugins_coupon_status}}" prop-position="bottom" bindonclose="plugins_coupon_close_event">
|
||||
<view class="plugins-coupon-popup bg-white">
|
||||
<view class="close oh">
|
||||
<view class="fr" catchtap="plugins_coupon_close_event">
|
||||
<icon type="clear" size="20" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.coupon_list.length > 0}}" class="coupon-container oh br-b">
|
||||
<view class="not-use-tips tc">
|
||||
<text bindtap="plugins_coupon_not_use_event">不使用优惠劵</text>
|
||||
</view>
|
||||
<block wx:for="{{plugins_coupon_data.coupon_list}}" wx:key="item">
|
||||
<view class="item spacing-mt bg-white" style="border:1px solid {{item.coupon.bg_color_value}};">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text" style="color:{{item.coupon.bg_color_value}};">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text wx:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view wx:if="{{(item.coupon.use_limit_type_name || null) != null}}" class="base-tips cr-666 single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-888 single-text">{{item.time_start_text}} 至 {{item.time_end_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" style="background:{{item.coupon.bg_color_value}};" data-index="{{index}}" data-value="{{item.id}}" bindtap="plugins_coupon_use_event">
|
||||
<text class="circle"></text>
|
||||
<text>{{plugins_use_coupon_id == item.id ? '已选' : '选择'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</component-popup>
|
||||
|
|
@ -130,4 +130,32 @@
|
|||
padding: 10rpx;
|
||||
min-height: 10vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件
|
||||
*/
|
||||
.plugins-coupon {
|
||||
padding: 25rpx 40rpx 25rpx 10rpx;
|
||||
}
|
||||
.plugins-coupon-popup {
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.plugins-coupon-popup .close {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.coupon-container {
|
||||
max-height: 80vh;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 230rpx;
|
||||
}
|
||||
.coupon-container .not-use-tips {
|
||||
color: #f7b240;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ Page({
|
|||
params = app.launch_params_handle(params);
|
||||
|
||||
// 参数赋值,初始化
|
||||
//params['goods_id']=2;
|
||||
params['goods_id']=2;
|
||||
this.setData({params: params});
|
||||
this.init();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue