小程序同步优惠劵
parent
fec3daea9a
commit
81a5bca78d
|
|
@ -36,6 +36,7 @@ class PluginsService
|
|||
public static function PluginsData($plugins, $attachment_field = [], $is_cache = true)
|
||||
{
|
||||
// 从缓存获取数据
|
||||
$data = [];
|
||||
$key = config('shopxo.cache_plugins_data_key').$plugins;
|
||||
if($is_cache === true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -337,4 +337,74 @@ textarea {
|
|||
width: 210rpx;
|
||||
height: 210rpx;
|
||||
border: 1px dashed #e9e9e9;
|
||||
}
|
||||
|
||||
/*
|
||||
* 优惠劵 - 插件
|
||||
*/
|
||||
.coupon-container {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.coupon-container .item {
|
||||
overflow: hidden;
|
||||
height: 180rpx;
|
||||
border: 1px solid #D2364C;
|
||||
}
|
||||
.coupon-container .v-left {
|
||||
width: calc(100% - 140rpx);
|
||||
padding: 30rpx 0 30rpx 20rpx;
|
||||
box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
-webkit-box-sizing:border-box;
|
||||
}
|
||||
.coupon-container .v-left .base {
|
||||
color: #D2364C;
|
||||
}
|
||||
.coupon-container .v-left .base .symbol {
|
||||
font-family: Verdana, Tahoma;
|
||||
font-size: 48rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
.coupon-container .v-left .base .price {
|
||||
font-weight: 700;
|
||||
font-family: arial;
|
||||
font-size: 76rpx;
|
||||
}
|
||||
.coupon-container .v-left .base .desc {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.coupon-container .v-left base-tips, .coupon-container .v-left .base-time {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.coupon-container .v-right {
|
||||
background: #d2364c;
|
||||
width: 140rpx;
|
||||
height: 180rpx;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
.coupon-container .v-right:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.coupon-container .v-right .circle {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: -1px;
|
||||
top: -3px;
|
||||
width: 3px;
|
||||
height: 180rpx;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAACpCAYAAADur4c3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo3MjUzYzIwOS04ZWNlLTRlNTctODQ4OC01ZDExOTkwOGNkYmMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MTM1QzgxREZGRDI5MTFFNTg3QjhGRUQ1MDY5OURERUQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MTM1QzgxREVGRDI5MTFFNTg3QjhGRUQ1MDY5OURERUQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTJiNzVkOGUtZDc2Yi00MzEzLWFmNmYtYTJkNTRlYTI4YTY1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjcyNTNjMjA5LThlY2UtNGU1Ny04NDg4LTVkMTE5OTA4Y2RiYyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pvy+vnQAAAEqSURBVHjaYvz//z8DDDAxIAFyOVeBOAHEYfyPMDsLmXMfmfMT2YADDP8h4CEQq4A4aUDMA1LNSKZDXwJxGcg1yJaWIXOeInO+IxuwA+acK0AsA+IEADEbic7hhPOAer4DcQcQMyNb2oLMeYVsADcyZwPMObuBWBTEsQFpI9E54sjO+QvEc0F+YoHKJgHxJ2TnvEM2gBmZswrmnA1AzAXiaJPhHC1k58BNQ3bBTGTOR2QD/iJzFsH8Mw/kHxBHggzn2KA7BxzWyC5Yisz5imwACmc2LLY7QbEN4nCS4ZwAIGZFds5lUEpEdsF6nKn3PTJnAsiAV0BcBsSM5GamFCDmQXYOOJ8iu2Anzrz9HKU8ABlwDYgTKcnbo0XNaFEzWtQgipqOYVLUAAQYAKPWa4c8cIHnAAAAAElFTkSuQmCC) no-repeat;
|
||||
}
|
||||
.coupon-container .item-disabled .v-right {
|
||||
background: #dfdfdf !important;
|
||||
color: #c0c0c0 !important;
|
||||
cursor: no-drop !important;
|
||||
}
|
||||
.coupon-container .item-disabled {
|
||||
border: 1px solid #dfdfdf !important;
|
||||
}
|
||||
|
|
@ -60,6 +60,8 @@ App({
|
|||
"user_orderaftersale": "退款/售后",
|
||||
"user_orderaftersale_detail": "订单售后",
|
||||
"user_order_comments": "订单评论",
|
||||
"coupon": "领劵中心",
|
||||
"user_coupon": "优惠劵",
|
||||
},
|
||||
|
||||
// 请求地址
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
"pages/user-integral/user-integral",
|
||||
"pages/user-goods-browse/user-goods-browse",
|
||||
"pages/user-orderaftersale/user-orderaftersale",
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail"
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
|
||||
"pages/coupon/coupon",
|
||||
"pages/user-coupon/user-coupon"
|
||||
],
|
||||
"window": {
|
||||
"defaultTitle": "shopxo",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<image a:if="{{(data_base || null) != null && (data_base.banner_images || null) != null}}" class="banner wh-auto dis-block" src="{{data_base.banner_images}}" mode="widthFix" />
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view a:if="{{data_list.length > 0}}" class="coupon-container">
|
||||
<block a:for="{{data_list}}">
|
||||
<view class="item spacing-mt bg-white {{item.is_operable == 0 ? 'item-disabled' : ''}}" style="border:1px solid {{item.bg_color_value}};">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text" style="color:{{item.bg_color_value}};">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text a:if="{{(item.desc || null) != null}}" class="desc cr-888">{{item.desc}}</text>
|
||||
</view>
|
||||
<view a:if="{{(item.use_limit_type_name || null) != null}}" class="base-tips cr-666 single-text">{{item.use_limit_type_name}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" onTap="coupon_receive_event" data-index="{{index}}" data-value="{{item.id}}" style="background:{{item.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>{{item.is_operable_name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<view a:if="{{data_list_loding_status != 3}}">
|
||||
<import src="/pages/common/nodata.axml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.axml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: [],
|
||||
data_base: null,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.coupon });
|
||||
},
|
||||
|
||||
init() {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
my.showLoading({ title: "加载中..." });
|
||||
if (self.data.data_list.length <= 0)
|
||||
{
|
||||
self.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
my.request({
|
||||
url: app.get_request_url("index", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var status = ((data.data || []).length > 0);
|
||||
this.setData({
|
||||
data_base: data.base || null,
|
||||
data_list: data.data || [],
|
||||
data_list_loding_msg: '',
|
||||
data_list_loding_status: status ? 3 : 0,
|
||||
data_bottom_line_status: status,
|
||||
});
|
||||
|
||||
// 导航名称
|
||||
if ((data.base || null) != null && (data.base.application_name || null) != null)
|
||||
{
|
||||
my.setNavigationBar({title: data.base.application_name });
|
||||
}
|
||||
} else {
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg,
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错',
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
my.redirectTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var self = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
var temp_list = this.data.data_list;
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
my.showLoading({ title: "处理中..." });
|
||||
my.request({
|
||||
url: app.get_request_url("receive", "coupon"),
|
||||
method: "POST",
|
||||
data: { "coupon_id": value },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
if (self.data.data_base != null && self.data.data_base.is_repeat_receive != 1)
|
||||
{
|
||||
temp_list[index]['is_operable'] = 0;
|
||||
temp_list[index]['is_operable_name'] = '已领取';
|
||||
self.setData({ data_list: temp_list });
|
||||
}
|
||||
} else {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"pullRefresh": true
|
||||
}
|
||||
|
|
@ -266,4 +266,34 @@
|
|||
}
|
||||
.limitedtimediscount .countdown .ds {
|
||||
padding: 0 4rpx;
|
||||
}
|
||||
|
||||
/*
|
||||
* 优惠劵 - 插件
|
||||
*/
|
||||
.coupon-container {
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.coupon-container scroll-view {
|
||||
height: 174rpx;
|
||||
}
|
||||
.coupon-container .item {
|
||||
display: inline-block;
|
||||
width: 60vw;
|
||||
}
|
||||
.coupon-container .v-left {
|
||||
padding: 20rpx 0 20rpx 20rpx;
|
||||
}
|
||||
.coupon-container .item:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 170rpx;
|
||||
}
|
||||
.coupon-container .v-left .base .price {
|
||||
font-size: 46rpx;
|
||||
}
|
||||
|
|
@ -55,6 +55,29 @@
|
|||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 优惠劵 -->
|
||||
<view a:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.data.length > 0}}" class="coupon-container wh-auto spacing-mt bg-white">
|
||||
<scroll-view scroll-x="true">
|
||||
<block a:for="{{plugins_coupon_data.data}}">
|
||||
<view class="item bg-white {{item.is_operable == 0 ? 'item-disabled' : ''}}" style="border:1px solid {{item.bg_color_value}};">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text" style="color:{{item.bg_color_value}};">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
</view>
|
||||
<view a:if="{{(item.use_limit_type_name || null) != null}}" class="base-tips cr-666 single-text">{{item.use_limit_type_name}}</view>
|
||||
<view a:if="{{(item.desc || null) != null}}" class="desc cr-888 single-text">{{item.desc}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" onTap="coupon_receive_event" data-index="{{index}}" data-value="{{item.id}}" style="background:{{item.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>{{item.is_operable_name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 属性导航 -->
|
||||
<!-- <view a:if="{{false}}" class="spacing">
|
||||
<view class="goods-attr-show-title bg-white arrow-right cr-666" onTap="good_attribute_nav_event">
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ Page({
|
|||
plugins_limitedtimediscount_time_millisecond: 0,
|
||||
plugins_limitedtimediscount_timer: null,
|
||||
plugins_limitedtimediscount_timers: null,
|
||||
|
||||
// 优惠劵
|
||||
plugins_coupon_data: null,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
|
|
@ -113,6 +116,7 @@ Page({
|
|||
|
||||
common_app_is_limitedtimediscount: data.common_app_is_limitedtimediscount || 0,
|
||||
plugins_limitedtimediscount_data: data.plugins_limitedtimediscount_data || null,
|
||||
plugins_coupon_data: data.plugins_coupon_data || null,
|
||||
});
|
||||
|
||||
// 限时秒杀倒计时
|
||||
|
|
@ -713,6 +717,51 @@ Page({
|
|||
clearInterval(this.data.plugins_limitedtimediscount_timers);
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
my.redirectTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var self = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
var temp_list = this.data.plugins_coupon_data.data;
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
my.showLoading({ title: "处理中..." });
|
||||
my.request({
|
||||
url: app.get_request_url("receive", "coupon"),
|
||||
method: "POST",
|
||||
data: { "coupon_id": value },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
if (self.data.plugins_coupon_data.base != null && self.data.plugins_coupon_data.base.is_repeat_receive != 1) {
|
||||
temp_list[index]['is_operable'] = 0;
|
||||
temp_list[index]['is_operable_name'] = '已领取';
|
||||
self.setData({ 'plugins_coupon_data.data': temp_list });
|
||||
}
|
||||
} else {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 自定义分享
|
||||
onShareAppMessage() {
|
||||
var user = app.get_user_info(this, 'onShareAppMessage') || null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 导航
|
||||
*/
|
||||
.nav-tabs {
|
||||
overflow: hidden;
|
||||
background: #eee;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.nav-tabs .nav-item {
|
||||
text-align: center;
|
||||
width: 33.33%;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-bottom: 6rpx solid transparent;
|
||||
}
|
||||
.nav-tabs .nav-item-active {
|
||||
color: #d2364c;
|
||||
border-bottom: 6rpx solid #d2364c;
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据列表
|
||||
*/
|
||||
.coupon-container {
|
||||
margin-top: 100rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 230rpx;
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<view a:if="{{data_list != null}}">
|
||||
<!-- 导航 -->
|
||||
<view class="nav-tabs">
|
||||
<block a:for="{{nav_tabs_list}}">
|
||||
<view class="nav-item cr-666 fl {{item.value == nav_tabs_value ? 'nav-item-active' : ''}}" data-index="{{index}}" data-value="{{item.value}}" onTap="nav_tabs_event">{{item.name}}</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view class="coupon-container">
|
||||
<!-- 未使用 -->
|
||||
<view a:if="{{(data_list.not_use || null) != null && data_list.not_use.length > 0 && nav_tabs_value == 'not_use'}}">
|
||||
<block a:for="{{data_list.not_use}}">
|
||||
<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 a:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view a: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>
|
||||
<navigator url="/pages/index/index" open-type="switchTab" hover-class="none">
|
||||
<view class="v-right fr" style="background:{{item.coupon.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>去使用</text>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 已使用 -->
|
||||
<view a:if="{{(data_list.already_use || null) != null && data_list.already_use.length > 0 && nav_tabs_value == 'already_use'}}">
|
||||
<block a:for="{{data_list.already_use}}">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text a:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view a: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.use_time_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已使用</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 已过期 -->
|
||||
<view a:if="{{(data_list.already_expire || null) != null && data_list.already_expire.length > 0 && nav_tabs_value == 'already_expire'}}">
|
||||
<block a:for="{{data_list.already_expire}}">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text a:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view a: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_end_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已过期</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view a:if="{{data_list_loding_status != 3}}">
|
||||
<import src="/pages/common/nodata.axml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.axml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: null,
|
||||
|
||||
nav_tabs_list: [
|
||||
{ name: "未使用", value: "not_use" },
|
||||
{ name: "已使用", value: "already_use" },
|
||||
{ name: "已过期", value: "already_expire" },
|
||||
],
|
||||
nav_tabs_value: 'not_use',
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.user_coupon });
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
my.redirectTo({
|
||||
url: "/pages/login/login?event_callback=init"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
my.showLoading({ title: "加载中..." });
|
||||
if (this.data.data_list == null || (this.data.data_list[this.data.nav_tabs_value] || null) == null || this.data.data_list[this.data.nav_tabs_value].length <= 0) {
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
my.request({
|
||||
url: app.get_request_url("user", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
self.setData({
|
||||
data_list: res.data.data || null,
|
||||
data_list_loding_msg: '',
|
||||
});
|
||||
self.data_view_handle();
|
||||
} else {
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg,
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错',
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 数据处理
|
||||
data_view_handle() {
|
||||
var status = 0;
|
||||
if (this.data.data_list != null && (this.data.data_list[this.data.nav_tabs_value] || null) != null && this.data.data_list[this.data.nav_tabs_value].length > 0) {
|
||||
status = 3;
|
||||
}
|
||||
this.setData({
|
||||
data_list_loding_status: status,
|
||||
data_bottom_line_status: (status == 3),
|
||||
});
|
||||
},
|
||||
|
||||
// 导航事件
|
||||
nav_tabs_event(e) {
|
||||
this.setData({ nav_tabs_value: e.currentTarget.dataset.value});
|
||||
this.data_view_handle();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"pullRefresh": true
|
||||
}
|
||||
|
|
@ -405,4 +405,74 @@ button[disabled].bg-primary {
|
|||
width: 210rpx;
|
||||
height: 210rpx;
|
||||
border: 1px dashed #e9e9e9;
|
||||
}
|
||||
|
||||
/*
|
||||
* 优惠劵 - 插件
|
||||
*/
|
||||
.coupon-container {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.coupon-container .item {
|
||||
overflow: hidden;
|
||||
height: 180rpx;
|
||||
border: 1px solid #D2364C;
|
||||
}
|
||||
.coupon-container .v-left {
|
||||
width: calc(100% - 140rpx);
|
||||
padding: 30rpx 0 30rpx 20rpx;
|
||||
box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
-webkit-box-sizing:border-box;
|
||||
}
|
||||
.coupon-container .v-left .base {
|
||||
color: #D2364C;
|
||||
}
|
||||
.coupon-container .v-left .base .symbol {
|
||||
font-family: Verdana, Tahoma;
|
||||
font-size: 48rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
.coupon-container .v-left .base .price {
|
||||
font-weight: 700;
|
||||
font-family: arial;
|
||||
font-size: 76rpx;
|
||||
}
|
||||
.coupon-container .v-left .base .desc {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.coupon-container .v-left base-tips, .coupon-container .v-left .base-time {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.coupon-container .v-right {
|
||||
background: #d2364c;
|
||||
width: 140rpx;
|
||||
height: 180rpx;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
.coupon-container .v-right:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.coupon-container .v-right .circle {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: -1px;
|
||||
top: -3px;
|
||||
width: 3px;
|
||||
height: 180rpx;
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAACpCAYAAADur4c3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo3MjUzYzIwOS04ZWNlLTRlNTctODQ4OC01ZDExOTkwOGNkYmMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MTM1QzgxREZGRDI5MTFFNTg3QjhGRUQ1MDY5OURERUQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MTM1QzgxREVGRDI5MTFFNTg3QjhGRUQ1MDY5OURERUQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTJiNzVkOGUtZDc2Yi00MzEzLWFmNmYtYTJkNTRlYTI4YTY1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjcyNTNjMjA5LThlY2UtNGU1Ny04NDg4LTVkMTE5OTA4Y2RiYyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pvy+vnQAAAEqSURBVHjaYvz//z8DDDAxIAFyOVeBOAHEYfyPMDsLmXMfmfMT2YADDP8h4CEQq4A4aUDMA1LNSKZDXwJxGcg1yJaWIXOeInO+IxuwA+acK0AsA+IEADEbic7hhPOAer4DcQcQMyNb2oLMeYVsADcyZwPMObuBWBTEsQFpI9E54sjO+QvEc0F+YoHKJgHxJ2TnvEM2gBmZswrmnA1AzAXiaJPhHC1k58BNQ3bBTGTOR2QD/iJzFsH8Mw/kHxBHggzn2KA7BxzWyC5Yisz5imwACmc2LLY7QbEN4nCS4ZwAIGZFds5lUEpEdsF6nKn3PTJnAsiAV0BcBsSM5GamFCDmQXYOOJ8iu2Anzrz9HKU8ABlwDYgTKcnbo0XNaFEzWtQgipqOYVLUAAQYAKPWa4c8cIHnAAAAAElFTkSuQmCC) no-repeat;
|
||||
}
|
||||
.coupon-container .item-disabled .v-right {
|
||||
background: #dfdfdf !important;
|
||||
color: #c0c0c0 !important;
|
||||
cursor: no-drop !important;
|
||||
}
|
||||
.coupon-container .item-disabled {
|
||||
border: 1px solid #dfdfdf !important;
|
||||
}
|
||||
|
|
@ -55,6 +55,8 @@ App({
|
|||
"user_orderaftersale": "退款/售后",
|
||||
"user_orderaftersale_detail": "订单售后",
|
||||
"user_order_comments": "订单评论",
|
||||
"coupon": "领劵中心",
|
||||
"user_coupon": "优惠劵",
|
||||
},
|
||||
|
||||
// 请求地址
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
"pages/user-integral/user-integral",
|
||||
"pages/user-goods-browse/user-goods-browse",
|
||||
"pages/user-orderaftersale/user-orderaftersale",
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail"
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
|
||||
"pages/coupon/coupon",
|
||||
"pages/user-coupon/user-coupon"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTitleText": "{{application_title}}",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: [],
|
||||
data_base: null
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({ title: app.data.common_pages_title.coupon });
|
||||
},
|
||||
|
||||
init() {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
swan.showLoading({ title: "加载中..." });
|
||||
if (self.data.data_list.length <= 0)
|
||||
{
|
||||
self.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
swan.request({
|
||||
url: app.get_request_url("index", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var status = (data.data || []).length > 0;
|
||||
this.setData({
|
||||
data_base: data.base || null,
|
||||
data_list: data.data || [],
|
||||
data_list_loding_msg: '',
|
||||
data_list_loding_status: status ? 3 : 0,
|
||||
data_bottom_line_status: status
|
||||
});
|
||||
|
||||
// 导航名称
|
||||
if ((data.base || null) != null && (data.base.application_name || null) != null) {
|
||||
swan.setNavigationBarTitle({ title: data.base.application_name });
|
||||
}
|
||||
} else {
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_cache_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
swan.redirectTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var self = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
var temp_list = this.data.data_list;
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
swan.showLoading({ title: "处理中..." });
|
||||
swan.request({
|
||||
url: app.get_request_url("receive", "coupon"),
|
||||
method: "POST",
|
||||
data: { "coupon_id": value },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
if (self.data.data_base != null && self.data.data_base.is_repeat_receive != 1) {
|
||||
temp_list[index]['is_operable'] = 0;
|
||||
temp_list[index]['is_operable_name'] = '已领取';
|
||||
self.setData({ data_list: temp_list });
|
||||
}
|
||||
} else {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<image s-if="(data_base || null) != null && (data_base.banner_images || null) != null" class="banner wh-auto dis-block" src="{{data_base.banner_images}}" mode="widthFix" />
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view s-if="data_list.length > 0" class="coupon-container">
|
||||
<block s-for="item, index in data_list" s-key="item">
|
||||
<view class="item spacing-mt bg-white {{item.is_operable == 0 ? 'item-disabled' : ''}}" style="border:1px solid {{item.bg_color_value}};">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text" style="color:{{item.bg_color_value}};">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text s-if="(item.desc || null) != null" class="desc cr-888">{{item.desc}}</text>
|
||||
</view>
|
||||
<view s-if="(item.use_limit_type_name || null) != null" class="base-tips cr-666 single-text">{{item.use_limit_type_name}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" bindtap="coupon_receive_event" data-index="{{index}}" data-value="{{item.id}}" style="background:{{item.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>{{item.is_operable_name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<view s-if="data_list_loding_status != 3">
|
||||
<import src="/pages/common/nodata.swan" />
|
||||
<template is="nodata" data="{{{status: data_list_loding_status, msg: data_list_loding_msg}}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.swan" />
|
||||
<template is="bottom_line" data="{{{status: data_bottom_line_status}}}"></template>
|
||||
|
|
@ -295,4 +295,34 @@
|
|||
}
|
||||
.limitedtimediscount .countdown .ds {
|
||||
padding: 0 4rpx;
|
||||
}
|
||||
|
||||
/*
|
||||
* 优惠劵 - 插件
|
||||
*/
|
||||
.coupon-container {
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.coupon-container scroll-view {
|
||||
height: 174rpx;
|
||||
}
|
||||
.coupon-container .item {
|
||||
display: inline-block;
|
||||
width: 60vw;
|
||||
}
|
||||
.coupon-container .v-left {
|
||||
padding: 20rpx 0 20rpx 20rpx;
|
||||
}
|
||||
.coupon-container .item:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 170rpx;
|
||||
}
|
||||
.coupon-container .v-left .base .price {
|
||||
font-size: 46rpx;
|
||||
}
|
||||
|
|
@ -41,6 +41,9 @@ Page({
|
|||
plugins_limitedtimediscount_time_millisecond: 0,
|
||||
plugins_limitedtimediscount_timer: null,
|
||||
plugins_limitedtimediscount_timers: null,
|
||||
|
||||
// 优惠劵
|
||||
plugins_coupon_data: null,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
|
|
@ -112,7 +115,8 @@ Page({
|
|||
common_app_is_use_mobile_detail: data.common_app_is_use_mobile_detail || 0,
|
||||
|
||||
common_app_is_limitedtimediscount: data.common_app_is_limitedtimediscount || 0,
|
||||
plugins_limitedtimediscount_data: data.plugins_limitedtimediscount_data || null
|
||||
plugins_limitedtimediscount_data: data.plugins_limitedtimediscount_data || null,
|
||||
plugins_coupon_data: data.plugins_coupon_data || null,
|
||||
});
|
||||
|
||||
// 限时秒杀倒计时
|
||||
|
|
@ -662,6 +666,50 @@ Page({
|
|||
clearInterval(this.data.plugins_limitedtimediscount_timers);
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_cache_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
swan.redirectTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var self = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
var temp_list = this.data.plugins_coupon_data.data;
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
swan.showLoading({ title: "处理中..." });
|
||||
swan.request({
|
||||
url: app.get_request_url("receive", "coupon"),
|
||||
method: "POST",
|
||||
data: { "coupon_id": value },
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
if (self.data.plugins_coupon_data.base != null && self.data.plugins_coupon_data.base.is_repeat_receive != 1) {
|
||||
temp_list[index]['is_operable'] = 0;
|
||||
temp_list[index]['is_operable_name'] = '已领取';
|
||||
self.setData({ 'plugins_coupon_data.data': temp_list });
|
||||
}
|
||||
} else {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 自定义分享
|
||||
onShareAppMessage() {
|
||||
var user = app.get_user_cache_info(this, 'onShareAppMessage') || null;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,29 @@
|
|||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 优惠劵 -->
|
||||
<view s-if="(plugins_coupon_data || null) != null && plugins_coupon_data.data.length > 0" class="coupon-container wh-auto spacing-mt bg-white">
|
||||
<scroll-view scroll-x="true">
|
||||
<block s-for="item, index in plugins_coupon_data.data" s-key="item">
|
||||
<view class="item bg-white {{item.is_operable == 0 ? 'item-disabled' : ''}}" style="border:1px solid {{item.bg_color_value}};">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text" style="color:{{item.bg_color_value}};">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
</view>
|
||||
<view s-if="(item.use_limit_type_name || null) != null" class="base-tips cr-666 single-text">{{item.use_limit_type_name}}</view>
|
||||
<view s-if="(item.desc || null) != null" class="desc cr-888 single-text">{{item.desc}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" bindtap="coupon_receive_event" data-index="{{index}}" data-value="{{item.id}}" style="background:{{item.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>{{item.is_operable_name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 属性导航 -->
|
||||
<!-- <view wx:if="{{false}}" class="spacing">
|
||||
<view class="goods-attr-show-title bg-white arrow-right cr-666" bindtap="good_attribute_nav_event">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 导航
|
||||
*/
|
||||
.nav-tabs {
|
||||
overflow: hidden;
|
||||
background: #eee;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.nav-tabs .nav-item {
|
||||
text-align: center;
|
||||
width: 33.33%;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-bottom: 6rpx solid transparent;
|
||||
}
|
||||
.nav-tabs .nav-item-active {
|
||||
color: #d2364c;
|
||||
border-bottom: 6rpx solid #d2364c;
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据列表
|
||||
*/
|
||||
.coupon-container {
|
||||
margin-top: 100rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 230rpx;
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: null,
|
||||
|
||||
nav_tabs_list: [{ name: "未使用", value: "not_use" }, { name: "已使用", value: "already_use" }, { name: "已过期", value: "already_expire" }],
|
||||
nav_tabs_value: 'not_use'
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({ title: app.data.common_pages_title.user_coupon });
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_cache_info(this, "init");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
swan.redirectTo({
|
||||
url: "/pages/login/login?event_callback=init"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
swan.showLoading({ title: "加载中..." });
|
||||
if (this.data.data_list == null || (this.data.data_list[this.data.nav_tabs_value] || null) == null || this.data.data_list[this.data.nav_tabs_value].length <= 0) {
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
swan.request({
|
||||
url: app.get_request_url("user", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
self.setData({
|
||||
data_list: res.data.data || null,
|
||||
data_list_loding_msg: ''
|
||||
});
|
||||
self.data_view_handle();
|
||||
} else {
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 数据处理
|
||||
data_view_handle() {
|
||||
var status = 0;
|
||||
if (this.data.data_list != null && (this.data.data_list[this.data.nav_tabs_value] || null) != null && this.data.data_list[this.data.nav_tabs_value].length > 0) {
|
||||
status = 3;
|
||||
}
|
||||
this.setData({
|
||||
data_list_loding_status: status,
|
||||
data_bottom_line_status: status == 3
|
||||
});
|
||||
},
|
||||
|
||||
// 导航事件
|
||||
nav_tabs_event(e) {
|
||||
this.setData({ nav_tabs_value: e.currentTarget.dataset.value });
|
||||
this.data_view_handle();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<view s-if="data_list != null">
|
||||
<!-- 导航 -->
|
||||
<view class="nav-tabs">
|
||||
<block s-for="item, index in nav_tabs_list" s-key="item">
|
||||
<view class="nav-item cr-666 fl {{item.value == nav_tabs_value ? 'nav-item-active' : ''}}" data-index="{{index}}" data-value="{{item.value}}" bindtap="nav_tabs_event">{{item.name}}</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view class="coupon-container">
|
||||
<!-- 未使用 -->
|
||||
<view s-if="(data_list.not_use || null) != null && data_list.not_use.length > 0 && nav_tabs_value == 'not_use'">
|
||||
<block s-for="item, index in data_list.not_use" s-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 s-if="(item.coupon.desc || null) != null" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view s-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>
|
||||
<navigator url="/pages/index/index" open-type="switchTab" hover-class="none">
|
||||
<view class="v-right fr" style="background:{{item.coupon.bg_color_value}};">
|
||||
<text class="circle"></text>
|
||||
<text>去使用</text>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 已使用 -->
|
||||
<view s-if="(data_list.already_use || null) != null && data_list.already_use.length > 0 && nav_tabs_value == 'already_use'">
|
||||
<block s-for="item, index in data_list.already_use" s-key="item">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text s-if="(item.coupon.desc || null) != null" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view s-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.use_time_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已使用</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 已过期 -->
|
||||
<view s-if="(data_list.already_expire || null) != null && data_list.already_expire.length > 0 && nav_tabs_value == 'already_expire'">
|
||||
<block s-for="item, index in data_list.already_expire" s-key="item">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text s-if="(item.coupon.desc || null) != null" class="desc cr-888">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view s-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_end_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已过期</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view s-if="data_list_loding_status != 3">
|
||||
<import src="/pages/common/nodata.swan" />
|
||||
<template is="nodata" data="{{{status: data_list_loding_status, msg: data_list_loding_msg}}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.swan" />
|
||||
<template is="bottom_line" data="{{{status: data_bottom_line_status}}}"></template>
|
||||
|
|
@ -445,7 +445,6 @@ button[disabled].bg-primary {
|
|||
.coupon-container .v-left base-tips, .coupon-container .v-left .base-time {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.coupon-container .v-right {
|
||||
background: #d2364c;
|
||||
width: 140rpx;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,12 @@ Page({
|
|||
get_data_list() {
|
||||
var self = this;
|
||||
wx.showLoading({ title: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
if (self.data.data_list.length <= 0)
|
||||
{
|
||||
self.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
wx.request({
|
||||
url: app.get_request_url("index", "coupon"),
|
||||
|
|
@ -76,12 +79,12 @@ Page({
|
|||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
receive_event(e) {
|
||||
var user = app.get_user_cache_info(this, "receive_event");
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_cache_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
wx.redirectTo({
|
||||
url: "/pages/login/login?event_callback=receive_event"
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -789,11 +789,11 @@ Page({
|
|||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
var user = app.get_user_cache_info(this, "receive_event");
|
||||
var user = app.get_user_cache_info(this, "coupon_receive_event");
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
wx.redirectTo({
|
||||
url: "/pages/login/login?event_callback=receive_event"
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -292,11 +292,9 @@
|
|||
padding: 0 4rpx;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 优惠劵 - 插件
|
||||
*/
|
||||
|
||||
.coupon-container {
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type == 0 ? '元' : '折'}}</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>
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
<view class="base single-text">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type == 0 ? '元' : '折'}}</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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue