优惠券开发
parent
b45ac18c93
commit
72c1207a7d
|
|
@ -1,9 +1,6 @@
|
|||
/*
|
||||
* 优惠劵
|
||||
*/
|
||||
.coupon-container {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.coupon-container .item {
|
||||
overflow: hidden;
|
||||
height: 180rpx;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@
|
|||
max-height: 80vh;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 50rpx;
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
|
|
|
|||
|
|
@ -143,12 +143,12 @@
|
|||
<icon type="clear" size="20"></icon>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="plugins_coupon_list.length > 0" class="coupon-container oh br-b">
|
||||
<view v-if="plugins_coupon_list.length > 0" class="coupon-container padding-horizontal-main padding-bottom-main oh">
|
||||
<view class="not-use-tips tc">
|
||||
<text @tap="plugins_coupon_not_use_event">不使用优惠劵</text>
|
||||
</view>
|
||||
<block v-for="(item, index) in plugins_coupon_list" :key="index">
|
||||
<view :class="'item spacing-mt bg-white radius ' + ((item.is_active || 0) == 1 ? 'item-disabled' : '')" :style="'border:1px solid ' + item.coupon.bg_color_value + ';'">
|
||||
<view :class="'item spacing-mt bg-white border-radius-main ' + ((item.is_active || 0) == 1 ? 'item-disabled' : '')" :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 v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@
|
|||
|
||||
<!-- 优惠券弹层 -->
|
||||
<component-popup :prop-show="popup_coupon_status" prop-position="bottom" @onclose="popup_coupon_close_event">
|
||||
<view class="coupon-popup padding-horizontal-main padding-top-main">
|
||||
<view class="padding-horizontal-main padding-top-main">
|
||||
<view class="close oh">
|
||||
<view class="fr" @tap.stop="popup_coupon_close_event">
|
||||
<icon type="clear" size="20"></icon>
|
||||
|
|
@ -376,7 +376,7 @@
|
|||
<view class="coupon-container padding-bottom-main">
|
||||
<block v-if="(plugins_coupon_data || null) != null && plugins_coupon_data.data.length > 0">
|
||||
<block v-for="(item, index) in plugins_coupon_data.data" :key="index">
|
||||
<view :class="'item bg-white radius ' + (item.is_operable == 0 ? 'item-disabled' : '')" :style="'border:1px solid ' + item.bg_color_value + ';'">
|
||||
<view :class="'item bg-white border-radius-main ' + (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 v-if="item.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
|
|
|
|||
|
|
@ -1,270 +1,243 @@
|
|||
<template>
|
||||
<view>
|
||||
<image v-if="(data_base || null) != null && (data_base.banner_images || null) != null" class="banner wh-auto dis-block" :src="data_base.banner_images" mode="widthFix"></image>
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view v-if="data_list.length > 0" class="coupon-container">
|
||||
<block v-for="(item, index) in data_list" :key="index">
|
||||
<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 v-if="item.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text v-if="(item.desc || null) != null" class="desc cr-gray">{{item.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.use_limit_type_name}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" @tap="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 v-if="data_list_loding_status != 3">
|
||||
<!--<import src="/pages/common/nodata.wxml"></import>-->
|
||||
<block data-type="template" data-is="nodata" data-attr="status: data_list_loding_status, msg: data_list_loding_msg">
|
||||
<!-- 1 加载中 -->
|
||||
<view v-if="0 == 1" class="no-data-loding tc">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 2 处理错误 -->
|
||||
<view v-else-if="0 == 2" class="no-data-box tc">
|
||||
<image src="/static/images/error.png" mode="widthFix"></image>
|
||||
<view class="no-data-tips">{{msg || '处理错误'}}</view>
|
||||
</view>
|
||||
|
||||
<!-- 0 默认没有数据 -->
|
||||
<view v-else-if="0 == 0" class="no-data-box tc">
|
||||
<image src="/static/images/empty.png" mode="widthFix"></image>
|
||||
<view class="no-data-tips">{{msg || '没有相关数据'}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!--<import src="/pages/common/bottom_line.wxml"></import>-->
|
||||
<block data-type="template" data-is="bottom_line" data-attr="status: data_bottom_line_status">
|
||||
<view v-if="(status || false)" class="data-bottom-line">
|
||||
<view class="left fl"></view>
|
||||
<view class="msg fl">我是有底线的</view>
|
||||
<view class="right fr"></view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const app = getApp();
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: [],
|
||||
data_base: null,
|
||||
// 优惠劵领取
|
||||
temp_coupon_receive_index: null,
|
||||
temp_coupon_receive_value: null,
|
||||
// 基础配置
|
||||
currency_symbol: app.globalData.data.currency_symbol
|
||||
};
|
||||
},
|
||||
|
||||
components: {},
|
||||
props: {},
|
||||
|
||||
onLoad(params) {
|
||||
// 显示分享菜单
|
||||
app.globalData.show_share_menu();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 数据加载
|
||||
this.init(); // 初始化配置
|
||||
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 自定义分享
|
||||
onShareAppMessage() {
|
||||
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
|
||||
var name = (this.data_base || null) != null && (this.data_base.application_name || null) != null ? this.data_base.application_name : app.globalData.data.application_title;
|
||||
return {
|
||||
title: name,
|
||||
desc: app.globalData.data.application_describe,
|
||||
path: '/pages/index/index?referrer=' + user_id
|
||||
};
|
||||
},
|
||||
|
||||
// 分享朋友圈
|
||||
onShareTimeline() {
|
||||
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
|
||||
var name = (this.data_base || null) != null && (this.data_base.application_name || null) != null ? this.data_base.application_name : app.globalData.data.application_title;
|
||||
return {
|
||||
title: name,
|
||||
query: 'referrer=' + user_id
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
currency_symbol: app.globalData.get_config('currency_symbol')
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
init() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
uni.showLoading({
|
||||
title: "加载中..."
|
||||
});
|
||||
|
||||
if (self.data_list.length <= 0) {
|
||||
self.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "index", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
uni.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) {
|
||||
uni.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.globalData.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
// 参数处理
|
||||
if ((e || null) == null) {
|
||||
var index = this.temp_coupon_receive_index;
|
||||
var value = this.temp_coupon_receive_value;
|
||||
} else {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
this.setData({
|
||||
temp_coupon_receive_index: index,
|
||||
temp_coupon_receive_value: value
|
||||
});
|
||||
} // 登录校验
|
||||
|
||||
|
||||
var user = app.globalData.get_user_info(this, 'coupon_receive_event');
|
||||
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var self = this;
|
||||
var temp_list = this.data_list;
|
||||
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
uni.showLoading({
|
||||
title: "处理中..."
|
||||
});
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("receive", "coupon", "coupon"),
|
||||
method: "POST",
|
||||
data: {
|
||||
"coupon_id": value
|
||||
},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
app.globalData.showToast(res.data.msg, "success");
|
||||
|
||||
if (self.data_base != null && self.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 {
|
||||
if (app.globalData.is_login_check(res.data, self, 'coupon_receive_event')) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
<template>
|
||||
<view>
|
||||
<image v-if="(data_base || null) != null && (data_base.banner_images || null) != null" class="wh-auto dis-block" :src="data_base.banner_images" mode="widthFix"></image>
|
||||
|
||||
<!-- 优惠劵列表 -->
|
||||
<view v-if="data_list.length > 0" class="coupon-container padding-main">
|
||||
<block v-for="(item, index) in data_list" :key="index">
|
||||
<view :class="'item border-radius-main bg-white spacing-mb ' + (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 v-if="item.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.discount_value}}</text>
|
||||
<text class="unit">{{item.type_unit}}</text>
|
||||
<text v-if="(item.desc || null) != null" class="desc cr-gray">{{item.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.use_limit_type_name}}</view>
|
||||
</view>
|
||||
<view class="v-right fr" @tap="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 v-else>
|
||||
<!-- 提示信息 -->
|
||||
<component-no-data :prop-status="data_list_loding_status" :prop-msg="data_list_loding_msg"></component-no-data>
|
||||
</view>
|
||||
|
||||
<!-- 结尾 -->
|
||||
<component-bottom-line :prop-status="data_bottom_line_status"></component-bottom-line>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentNoData from "../../../../components/no-data/no-data";
|
||||
import componentBottomLine from "../../../../components/bottom-line/bottom-line";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
data_list: [],
|
||||
data_base: null,
|
||||
// 优惠劵领取
|
||||
temp_coupon_receive_index: null,
|
||||
temp_coupon_receive_value: null,
|
||||
// 基础配置
|
||||
currency_symbol: app.globalData.data.currency_symbol
|
||||
};
|
||||
},
|
||||
|
||||
components: {
|
||||
componentNoData,
|
||||
componentBottomLine
|
||||
},
|
||||
props: {},
|
||||
|
||||
onLoad(params) {
|
||||
// 显示分享菜单
|
||||
app.globalData.show_share_menu();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 数据加载
|
||||
this.init();
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 自定义分享
|
||||
onShareAppMessage() {
|
||||
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
|
||||
var name = (this.data_base || null) != null && (this.data_base.application_name || null) != null ? this.data_base.application_name : app.globalData.data.application_title;
|
||||
return {
|
||||
title: name,
|
||||
desc: app.globalData.data.application_describe,
|
||||
path: '/pages/plugins/coupon/index/index?referrer=' + user_id
|
||||
};
|
||||
},
|
||||
|
||||
// 分享朋友圈
|
||||
onShareTimeline() {
|
||||
var user_id = app.globalData.get_user_cache_info('id', 0) || 0;
|
||||
var name = (this.data_base || null) != null && (this.data_base.application_name || null) != null ? this.data_base.application_name : app.globalData.data.application_title;
|
||||
return {
|
||||
title: name,
|
||||
query: 'referrer=' + user_id
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
currency_symbol: app.globalData.get_config('currency_symbol')
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
init() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
uni.showLoading({
|
||||
title: "加载中..."
|
||||
});
|
||||
if (self.data_list.length <= 0) {
|
||||
self.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "index", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
uni.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) {
|
||||
uni.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.globalData.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 优惠劵领取事件
|
||||
coupon_receive_event(e) {
|
||||
// 参数处理
|
||||
if ((e || null) == null) {
|
||||
var index = this.temp_coupon_receive_index;
|
||||
var value = this.temp_coupon_receive_value;
|
||||
} else {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
this.setData({
|
||||
temp_coupon_receive_index: index,
|
||||
temp_coupon_receive_value: value
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// 登录校验
|
||||
var user = app.globalData.get_user_info(this, 'coupon_receive_event');
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login?event_callback=coupon_receive_event"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
var temp_list = this.data_list;
|
||||
if (temp_list[index]['is_operable'] != 0) {
|
||||
uni.showLoading({
|
||||
title: "处理中..."
|
||||
});
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("receive", "coupon", "coupon"),
|
||||
method: "POST",
|
||||
data: {
|
||||
"coupon_id": value
|
||||
},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.globalData.showToast(res.data.msg, "success");
|
||||
if (this.data_base != null && this.data_base.is_repeat_receive !=
|
||||
1) {
|
||||
temp_list[index]['is_operable'] = 0;
|
||||
temp_list[index]['is_operable_name'] = '已领取';
|
||||
this.setData({
|
||||
data_list: temp_list
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (app.globalData.is_login_check(res.data, this, 'coupon_receive_event')) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 导航
|
||||
*/
|
||||
.nav {
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
.nav .item {
|
||||
width: 33.33%;
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据列表
|
||||
*/
|
||||
.scroll-box {
|
||||
height: calc(100vh - 80rpx);
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 230rpx;
|
||||
}
|
||||
|
|
@ -1,302 +1,238 @@
|
|||
<template>
|
||||
<view>
|
||||
<!-- 导航 -->
|
||||
<view class="nav-tabs">
|
||||
<block v-for="(item, index) in nav_tabs_list" :key="index">
|
||||
<view :class="'nav-item cr-base fl ' + (item.value == nav_tabs_value ? 'nav-item-active' : '')" :data-index="index" :data-value="item.value" @tap="nav_tabs_event">{{item.name}}</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<scroll-view :scroll-y="true" class="scroll-box" lower-threshold="30">
|
||||
<!-- 优惠劵列表 -->
|
||||
<view v-if="data_list != null" class="coupon-container">
|
||||
<!-- 未使用 -->
|
||||
<view v-if="(data_list.not_use || null) != null && data_list.not_use.length > 0 && nav_tabs_value == 'not_use'">
|
||||
<block v-for="(item, index) in data_list.not_use" :key="index">
|
||||
<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 v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray 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 v-if="(data_list.already_use || null) != null && data_list.already_use.length > 0 && nav_tabs_value == 'already_use'">
|
||||
<block v-for="(item, index) in data_list.already_use" :key="index">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray single-text">使用 {{item.use_time_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已使用</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 已过期 -->
|
||||
<view v-if="(data_list.already_expire || null) != null && data_list.already_expire.length > 0 && nav_tabs_value == 'already_expire'">
|
||||
<block v-for="(item, index) in data_list.already_expire" :key="index">
|
||||
<view class="item spacing-mt bg-white item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray 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 v-if="data_list_loding_status != 3">
|
||||
<!--<import src="/pages/common/nodata.wxml"></import>-->
|
||||
<block data-type="template" data-is="nodata" data-attr="status: data_list_loding_status, msg: data_list_loding_msg">
|
||||
<!-- 1 加载中 -->
|
||||
<view v-if="0 == 1" class="no-data-loding tc">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 2 处理错误 -->
|
||||
<view v-else-if="0 == 2" class="no-data-box tc">
|
||||
<image src="/static/images/error.png" mode="widthFix"></image>
|
||||
<view class="no-data-tips">{{msg || '处理错误'}}</view>
|
||||
</view>
|
||||
|
||||
<!-- 0 默认没有数据 -->
|
||||
<view v-else-if="0 == 0" class="no-data-box tc">
|
||||
<image src="/static/images/empty.png" mode="widthFix"></image>
|
||||
<view class="no-data-tips">{{msg || '没有相关数据'}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!--<import src="/pages/common/bottom_line.wxml"></import>-->
|
||||
<block data-type="template" data-is="bottom_line" data-attr="status: data_bottom_line_status">
|
||||
<view v-if="(status || false)" class="data-bottom-line">
|
||||
<view class="left fl"></view>
|
||||
<view class="msg fl">我是有底线的</view>
|
||||
<view class="right fr"></view>
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const app = getApp();
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
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',
|
||||
// 基础配置
|
||||
currency_symbol: app.globalData.data.currency_symbol
|
||||
};
|
||||
},
|
||||
|
||||
components: {},
|
||||
props: {},
|
||||
|
||||
onShow() {
|
||||
// 数据加载
|
||||
this.init(); // 初始化配置
|
||||
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
currency_symbol: app.globalData.get_config('currency_symbol')
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
init() {
|
||||
var user = app.globalData.get_user_info(this, "init");
|
||||
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/login?event_callback=init"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
data_bottom_line_status: false
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
uni.showLoading({
|
||||
title: "加载中..."
|
||||
});
|
||||
|
||||
if (this.data_list == null || (this.data_list[this.nav_tabs_value] || null) == null || this.data_list[this.nav_tabs_value].length <= 0) {
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "coupon", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
uni.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
|
||||
});
|
||||
|
||||
if (app.globalData.is_login_check(res.data, self, 'get_data_list')) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 数据处理
|
||||
data_view_handle() {
|
||||
var status = 0;
|
||||
|
||||
if (this.data_list != null && (this.data_list[this.nav_tabs_value] || null) != null && this.data_list[this.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();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
/*
|
||||
* 导航
|
||||
*/
|
||||
.nav-tabs {
|
||||
overflow: hidden;
|
||||
background: #eee;
|
||||
width: 100%;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据列表
|
||||
*/
|
||||
.scroll-box{
|
||||
height: calc(100vh - 80rpx);
|
||||
}
|
||||
.coupon-container .item,
|
||||
.coupon-container .v-right,
|
||||
.coupon-container .v-right .circle {
|
||||
height: 230rpx;
|
||||
}
|
||||
<template>
|
||||
<view>
|
||||
<!-- 导航 -->
|
||||
<view class="nav bg-white">
|
||||
<block v-for="(item, index) in nav_tabs_list" :key="index">
|
||||
<view :class="'item fl tc cr-gray ' + (item.value == nav_tabs_value ? 'cr-main' : '')" :data-index="index" :data-value="item.value" @tap="nav_tabs_event">{{item.name}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<scroll-view :scroll-y="true" class="scroll-box" lower-threshold="30">
|
||||
<!-- 优惠劵列表 -->
|
||||
<view v-if="data_list != null" class="coupon-container padding-horizontal-main padding-top-main">
|
||||
<!-- 未使用 -->
|
||||
<block v-if="(data_list.not_use || null) != null && data_list.not_use.length > 0 && nav_tabs_value == 'not_use'">
|
||||
<block v-for="(item, index) in data_list.not_use" :key="index">
|
||||
<view class="item spacing-mb bg-white border-radius-main" :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 v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray 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>
|
||||
</block>
|
||||
|
||||
<!-- 已使用 -->
|
||||
<block v-if="(data_list.already_use || null) != null && data_list.already_use.length > 0 && nav_tabs_value == 'already_use'">
|
||||
<block v-for="(item, index) in data_list.already_use" :key="index">
|
||||
<view class="item spacing-mb bg-white border-radius-main item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray single-text">使用 {{item.use_time_time}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已使用</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
<!-- 已过期 -->
|
||||
<block v-if="(data_list.already_expire || null) != null && data_list.already_expire.length > 0 && nav_tabs_value == 'already_expire'">
|
||||
<block v-for="(item, index) in data_list.already_expire" :key="index">
|
||||
<view class="item spacing-mt bg-white border-radius-main item-disabled">
|
||||
<view class="v-left fl">
|
||||
<view class="base single-text">
|
||||
<text v-if="item.coupon.type == 0" class="symbol">{{currency_symbol}}</text>
|
||||
<text class="price">{{item.coupon.discount_value}}</text>
|
||||
<text class="unit">{{item.coupon.type_unit}}</text>
|
||||
<text v-if="(item.coupon.desc || null) != null" class="desc cr-gray">{{item.coupon.desc}}</text>
|
||||
</view>
|
||||
<view v-if="(item.coupon.use_limit_type_name || null) != null" class="base-tips cr-base single-text">{{item.coupon.use_limit_type_name}}</view>
|
||||
<view class="base-time cr-gray single-text">过期 {{item.time_end_text}}</view>
|
||||
</view>
|
||||
<view class="v-right fr">
|
||||
<text class="circle"></text>
|
||||
<text>已过期</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<component-no-data :prop-status="data_list_loding_status" :prop-msg="data_list_loding_msg"></component-no-data>
|
||||
|
||||
<!-- 结尾 -->
|
||||
<component-bottom-line :prop-status="data_bottom_line_status"></component-bottom-line>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentNoData from "../../../../components/no-data/no-data";
|
||||
import componentBottomLine from "../../../../components/bottom-line/bottom-line";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
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',
|
||||
// 基础配置
|
||||
currency_symbol: app.globalData.data.currency_symbol
|
||||
};
|
||||
},
|
||||
|
||||
components: {
|
||||
componentNoData,
|
||||
componentBottomLine
|
||||
},
|
||||
props: {},
|
||||
|
||||
onShow() {
|
||||
// 数据加载
|
||||
this.init();
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
currency_symbol: app.globalData.get_config('currency_symbol')
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
init() {
|
||||
var user = app.globalData.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/login?event_callback=init"
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
data_bottom_line_status: false
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
get_data_list() {
|
||||
var self = this;
|
||||
uni.showLoading({
|
||||
title: "加载中..."
|
||||
});
|
||||
if (this.data_list == null || (this.data_list[this.nav_tabs_value] || null) == null || this.data_list[this.nav_tabs_value].length <= 0) {
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
}
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "coupon", "coupon"),
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
uni.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
|
||||
});
|
||||
if (app.globalData.is_login_check(res.data, self, 'get_data_list')) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 数据处理
|
||||
data_view_handle() {
|
||||
var status = 0;
|
||||
if (this.data_list != null && (this.data_list[this.nav_tabs_value] || null) != null && this.data_list[this.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();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@import './user.css';
|
||||
</style>
|
||||
Loading…
Reference in New Issue