·修改部分页面数据冗余

This commit is contained in:
lemon橪
2021-05-14 17:31:40 +08:00
parent 23804939eb
commit 7f4212755d
42 changed files with 1415 additions and 2987 deletions

View File

@@ -1,17 +1,17 @@
<template>
<view class="coupon-center">
<swiper :current="tabIndex" class="swiper-box" @change="ontabchange">
<swiper-item @touchmove.stop class="swiper-item" v-for="tab in categoryIndexData" :key="tab.category_id">
<swiper class="swiper-box">
<swiper-item class="swiper-item">
<scroll-view class="scroll-v" enableBackToTop="true" scroll-y @scrolltolower="loadMore">
<u-empty mode="coupon" text="没有优惠券了" v-if="nomsg"></u-empty>
<view v-else class="coupon-item" v-for="(item, index) in list" :key="index">
<u-empty mode="coupon" text="没有优惠券了" v-if="whetherEmpty"></u-empty>
<view v-else class="coupon-item" v-for="(item, index) in couponList" :key="index">
<view class="left">
<view class="wave-line">
<view class="wave" v-for="(item, index) in 12" :key="index"></view>
</view>
<view class="msg">
<view class="message">
<view>
<!--判断当前优惠券类型 couponType PRICE || DISCOUNT -->
<span v-if="item.couponType == 'DISCOUNT'">{{ item.couponDiscount }}</span>
<span v-else>{{ item.price }}</span>
</view>
@@ -22,11 +22,11 @@
</view>
<view class="right">
<view>
<!-- 根据scopeType 判断是否是 平台品类或店铺 -->
<view v-if="item.scopeType">
<span v-if="item.scopeType == 'ALL' && item.id == 'platform'">全平台</span>
<span v-if="item.scopeType == 'PORTION_CATEGORY'">仅限品类</span>
<view v-else>{{ item.storeName == 'platform' ? '全平台' :item.storeName+'店铺' }}使用</view>
</view>
<view>有效期至{{ item.endTime.split(" ")[0] }}</view>
</view>
@@ -47,53 +47,53 @@
<script>
import { receiveCoupons } from "@/api/members.js";
import { getAllCoupons } from "@/api/promotions.js";
import { getCategoryIndexData } from "@/api/home.js";
export default {
data() {
return {
loadStatus: "more",
nomsg: false,
list: [],
loadStatus: "more", //下拉状态
whetherEmpty: false, //是否为空
couponList: [], // 优惠券列表
params: {
pageNumber: 1,
pageSize: 10,
status: 1,
},
storeId: "",
categoryIndexData: [],
currentLeft: 0,
tabIndex: 0,
storeId: "", //店铺 id
};
},
onLoad(option) {
this.storeId = option.storeId;
this.getCoupon();
this.getTabbar();
},
onPullDownRefresh() {
//下拉刷新
console.log("refresh");
this.params.pageNumber = 1;
this.list = [];
this.couponList = [];
this.getCoupon();
},
methods: {
/**
* 获取当前优惠券
*/
getCoupon() {
//全部优惠券
uni.showLoading({
title: "加载中",
});
if (this.storeId) {
getAllCoupons({ storeId: this.storeId ,...this.params })
let submitData = { ...this.params };
// 判断当前是否有店铺
this.storeId ? (submitData = { ...this.params, storeId: this.storeId }): "",
getAllCoupons(submitData)
.then((res) => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.statusCode == 200) {
if (res.data.code == 200) {
// 如果请求成功,展示数据并进行展示
let data = res.data.result;
if (data.total == 0) {
this.nomsg = true;
// 当本次请求数据为空展示空信息
this.whetherEmpty = true;
} else {
this.list.push(...data.records);
this.couponList.push(...data.records);
this.loadStatus = "noMore";
}
}
@@ -101,33 +101,11 @@ export default {
.catch((err) => {
uni.hideLoading();
});
} else {
getAllCoupons(this.params)
.then((res) => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.statusCode == 200) {
console.log(res);
let data = res.data.result;
if (data.total == 0) {
this.nomsg = true;
console.log("这里");
} else if (data.total < 10) {
this.list.push(...data.records);
this.loadStatus = "noMore";
} else {
this.list.push(...data.records);
if (data.data.length < 10) this.loadStatus = "noMore";
}
}
})
.catch((err) => {
uni.hideLoading();
});
}
},
/**
* 领取优惠券
*/
receive(item) {
//领取优惠券
receiveCoupons(item.id).then((res) => {
if (res.data.code == 200) {
uni.showToast({
@@ -141,49 +119,16 @@ export default {
});
}
});
// this.$set(this.list,0,this.list[0])
// console.log(this.list)
},
getTabbar() {
//获取顶级分类
// uni.showLoading({
// title: "加载中"
// })
let tabbar = {
category_id: 0,
name: "全部",
parent_id: 0,
category_path: "|0|",
goods_count: 0,
category_order: 0,
list_show: 1,
image:
"https://wwwyinbeicn.oss-cn-beijing.aliyuncs.com/yinbeistore/normal/FF468285411041E1AE5C36DAD1161AE4.png",
};
getCategoryIndexData().then((res) => {
console.log(res);
this.categoryIndexData.push(tabbar, ...res.data.result);
});
},
/**
* 加载更多
*/
loadMore() {
if (this.loadStatus != "noMore") {
this.params.pageNumber++;
this.getAllCoupons();
}
},
setCat(type) {
this.tabIndex = type;
// this.searchStore();
},
ontabchange(e) {
this.tabIndex = e.detail.current;
if (e.detail.current > 3) {
this.currentLeft = (e.detail.current - 3) * 90;
} else {
this.currentLeft = 0;
}
// this.searchStore();
},
},
onNavigationBarButtonTap(e) {
uni.navigateTo({
@@ -201,7 +146,7 @@ page {
.coupon-center {
height: 100%;
.list-scroll-content {
.couponList-scroll-content {
position: relative;
width: 100%;
display: flex;
@@ -247,7 +192,7 @@ page {
width: 260rpx;
background-color: $light-color;
position: relative;
.msg {
.message {
color: $font-color-white;
display: flex;
justify-content: center;

View File

@@ -21,9 +21,9 @@
: coupon.storeName == 'platform' ? '全平台' :coupon.storeName+''
}}使用</view>
<view class="text"> 有效期至{{coupon.endTime}}</view>
</view>
<button class="btn" @click="gostorePage" v-if="coupon.used_status==0">立即使用</button>
</view>
</view>
</template>
@@ -32,34 +32,16 @@
export default {
data() {
return {
customStyle: {
backgroundColor: this.lightColor,
},
coupon: {},
coupon: {}, //优惠券数据
};
},
onLoad(option) {
this.coupon = JSON.parse(decodeURIComponent(option.item));
console.log(this.coupon);
},
methods: {
gostorePage() {
let id = this.coupon.storeId;
if (id) {
uni.navigateTo({
url: `/pages/product/shopPage?id=${id}`,
});
} else {
uni.switchTab({
url: "/pages/tabbar/home/index",
});
}
},
},
};
</script>
<style lang="scss">
<style lang="scss" scoped>
page,
.content {
// background: $main-color;
@@ -140,9 +122,5 @@ page,
line-height: 2em;
color: #999;
}
.btn {
margin: 140rpx 20rpx;
}
}
</style>

View File

@@ -1,59 +0,0 @@
<template>
<view class="coupin-intro">
<view class="title">
1.优惠券的获取
</view>
<view class="mb-60">
通过活动赠送客服补偿等获得(系统自动添加, 无需兑换);
</view>
<view class="title">
2.优惠券使用
</view>
<view>1每张抵用券仅能使用一次不找零不退换不兑换现金</view>
<view>2单笔订单只能使用1张优惠券, 不支持同时使用多张, 用券后差额不找零, 不退回</view>
<view>3优惠券 (包括新用户券) 不能抵扣运费, 只能抵扣商品金额特价商品不可使用优惠券, 与其他优惠不同享</view>
<view>4每张优惠券的使用条件请查看对应优惠券的使用说明</view>
<view>5请在有效期内使用优惠券, 未使用的优惠券过期后, 将自动作废</view>
<view>6每个用户仅限使用1张新用户专享优惠券, 同一帐号和手机号均视为同一用户</view>
<view>7用券前订单满88元即可包邮港澳台地区需满500元包邮</view>
<view class="mb-60">8使用抵用券抵扣部分的货款不开具发票</view>
<view class="title">3.优惠券失效</view>
<view>1新用户券使用一张后其他新用户券失效, 取消订单后不返还</view>
<view>2使用优惠券的订单, 若产生退货, 优惠券均不退回, 退款金额按优惠后的小计金额退款</view>
<view>3参加满赠券活动获得的赠券,发生退货时,若订单中剩余商品不满足赠券条件,实物赠品需勾选退货并寄回,否则将从退款中扣减对应金额,客服审核通过退货申请后,所获赠券将会自动失效</view>
<view>4优惠券严禁出售或转让, 如经发现并证实的, 该券将予以失效处理</view>
<view>5如需了解更多, 请联系在线客服或拨打客服电话400-0000-000</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss">
.coupin-intro{
background-color: #fff;
color: #999999;
font-size: $font-sm;
padding: 30rpx;
border-top: 1px solid $border-color-light;
line-height: 2.5em;
.title{
font-size: $font-base;
font-weight: bold;
}
.mb-60{
margin-bottom: 60rpx;
}
}
</style>

View File

@@ -1,18 +1,14 @@
<template>
<div class="wrapper">
<div class="nomore" v-if="current === 0 && couponsList.length <= 0">
暂无优惠券
<div class="empty" v-if="couponsList.length <= 0">
<u-empty text="暂无优惠券" mode="coupon"></u-empty>
</div>
<div class="nomore" v-if="current === 1 && disabledCouponsList.length <= 0">
暂无优惠券
</div>
<view class="coupon-item" v-for="(item, index) in couponsList" :key="index" v-if="item.memberCouponStatus == 'NEW'">
<view class="left">
<view class="wave-line">
<view class="wave" v-for="(item, index) in 12" :key="index"></view>
</view>
<view class="msg">
<view class="message">
<view>
<span v-if="item.couponType == 'DISCOUNT'">{{ item.discount }}</span>
<span v-else>{{ item.price }}</span>
@@ -41,51 +37,31 @@
</div>
</template>
<script>
import {
useCoupon,
getMemberCouponList,
getMemberCanUse,
} from "@/api/trade.js";
import { useCoupon, getMemberCanUse } from "@/api/trade.js";
export default {
data() {
return {
current: 0,
list: [
{
name: "可用优惠券",
},
{
name: "不可用优惠券",
},
],
curNow: "",
couponsList: [],
disabledCouponsList: [],
couponsList: [], //优惠券集合
params: {
memberCouponStatus: "NEW",
//传参
memberCouponStatus: "NEW", //优惠券状态
pageNumber: 1,
pageSize: 10,
scopeId: "",
storeId: "",
totalPrice: "",
// endTime: this.$u.timeFormat(new Date().getTime(),'yyyy-mm-dd hh:MM:ss')
scopeId: "", //商品skuid
storeId: "", //店铺id
totalPrice: "", //价格
},
way: [],
routerVal: "",
routerVal: "", //上级传参
};
},
onReachBottom() {
this.pageNumber++;
this.getAllCouponsFun();
},
/**
* 赋值
*/
onLoad(val) {
this.routerVal = val;
this.params.scopeId = val.skuId;
this.params.storeId = val.storeId;
if (val.type) {
this.params.endTime = new Date().getTime();
}
},
mounted() {
uni.getStorage({
@@ -98,20 +74,21 @@ export default {
},
methods: {
// 获取优惠券数量
/**
* 获取优惠券数量
*/
getCoupons() {
getMemberCanUse(this.params).then((res) => {
if (res.data.success) {
this.couponsList = res.data.result.records;
}
});
},
// 领取优惠券
async clickWay(coupon) {
/**
* 领取优惠券
*/
clickWay(coupon) {
useCoupon({
memberCouponId: coupon.id,
used: true,
@@ -128,139 +105,18 @@ export default {
}
});
},
submitback() {
uni.navigateBack();
},
// 获取商品优惠券
getAllCouponsFun() {},
sectionChange(index) {
this.curNow = index;
},
change(index) {
this.current = index;
},
},
};
</script>
<style scoped lang="scss">
.nomore {
.empty {
margin-top: 20px;
text-align: center;
}
.selectBtn {
position: fixed;
bottom: 0;
background: #fff;
text-align: center;
width: 100%;
padding: 20rpx 0;
}
.wrapper {
background: #f9f9f9;
overflow: hidden;
}
.coupon-jd {
margin: 40rpx auto 0 auto;
width: 700rpx;
height: auto;
background-color: #ffffff;
display: flex;
.left {
padding: 0 30rpx;
width: 200rpx;
background-color: $aider-light-color;
text-align: center;
font-size: 28rpx;
color: #ffffff;
.sum {
margin-top: 50rpx;
font-weight: bold;
font-size: 32rpx;
.num {
font-size: 60rpx;
}
}
.type {
margin-bottom: 50rpx;
font-size: 24rpx;
}
}
.right {
padding: 20rpx 20rpx 0;
font-size: 28rpx;
.top {
border-bottom: 2rpx dashed $u-border-color;
.title {
margin-right: 60rpx;
line-height: 40rpx;
.tag {
padding: 4rpx 20rpx;
background-color: $aider-light-color;
border-radius: 20rpx;
color: #ffffff;
font-weight: bold;
font-size: 24rpx;
margin-right: 10rpx;
}
}
.bottom {
display: flex;
margin-top: 20rpx;
align-items: center;
justify-content: space-between;
margin-bottom: 10rpx;
.date {
font-size: 20rpx;
flex: 1;
}
}
}
.tips {
width: 100%;
line-height: 50rpx;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 24rpx;
.transpond {
margin-right: 10rpx;
}
.explain {
display: flex;
align-items: center;
}
.particulars {
width: 30rpx;
height: 30rpx;
box-sizing: border-box;
padding-top: 8rpx;
border-radius: 50%;
background-color: $u-type-info-disabled;
text-align: center;
}
}
}
}
.immediate-use {
height: auto;
padding: 0 20rpx;
font-size: 24rpx;
text-align: center;
width: 160rpx;
margin: 20rpx 0;
border-radius: 40rpx;
line-height: 40rpx;
color: $aider-light-color;
border: 2rpx solid $aider-light-color;
}
.coupon-item {
display: flex;
align-items: center;
@@ -272,7 +128,7 @@ export default {
width: 260rpx;
background-color: $light-color;
position: relative;
.msg {
.message {
color: $font-color-white;
display: flex;
justify-content: center;

View File

@@ -1,26 +1,25 @@
<template>
<view class="b-content">
<view class="navbar">
<view v-for="(item, index) in navList" :key="index" class="nav-item" @click="tabClick(index)"><text :class="{ current: tabCurrentIndex === index }">{{
<!-- 循环出头部tab栏 -->
<view v-for="(item, index) in navList" :key="index" class="nav-item" @click="handleTabClick(index)"><text :class="{ current: tabCurrentIndex === index }">{{
item.text
}}</text></view>
</view>
<swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
<swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
<swiper-item class="tab-content" v-for="(navItem, navIndex) in navList" :key="navIndex">
<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
<!-- 空白页 -->
<empty v-if="tabItem.nomsg"></empty>
<u-empty mode="coupon" text="暂无优惠券了" v-if="navItem.wheterEmpty"></u-empty>
<!-- 数据 -->
<view v-if="tabItem.dataList && coupon" class="coupon-item" :class="{ 'coupon-used': tabIndex != 0 }" v-for="(coupon, index) in tabItem.dataList" :key="index">
<view v-if="navItem.dataList && coupon" class="coupon-item" :class="{ 'coupon-used': navIndex != 0 }" v-for="(coupon, index) in navItem.dataList" :key="index">
<view class="left">
<view class="wave-line">
<view class="wave" v-for="(item, index) in 12" :key="index"></view>
</view>
<view class="msg">
<view class="price" v-if="coupon.couponType == 'DISCOUNT'">{{ coupon.discount }}</view>
<view class="price" v-else>{{ coupon.price }}</view>
<!-- <view class="price" v-if="coupon.couponType == 'PRICE'">{{ coupon.price | unitPrice }}</view> -->
<!-- <view class="price" v-if="coupon.couponType == 'DISCOUNT'">{{ coupon.couponDiscount }}</view> -->
<view class="message">
<view class="price" v-if="coupon.couponType == 'DISCOUNT'">{{ coupon.discount }}</view>
<view class="price" v-else>{{ coupon.price }}</view>
<view class="sub-price">{{ coupon.consumeThreshold | unitPrice }}可用</view>
</view>
<view class="circle circle-top"></view>
@@ -43,20 +42,20 @@
<u-icon style="float: right; margin-top: 10rpx" name="arrow-right"></u-icon>
</view>
</view>
<view class="jiao-1" v-if="tabIndex == 0">
<view class="jiao-1" v-if="navIndex == 0">
<text class="text-1">新到</text>
<text class="text-2" v-if="coupon.used_status == 1">将过期</text>
</view>
<image class="no-icon" v-if="tabIndex == 1" src="@/static/img/used.png"></image>
<image class="no-icon" v-if="tabIndex == 2" src="@/pages/floor/imgs/overdue.png"></image>
<view class="receive" v-if="tabIndex == 0" @click="nowUse(coupon)">
<image class="no-icon" v-if="navIndex == 1" src="@/static/img/used.png"></image>
<image class="no-icon" v-if="navIndex == 2" src="@/pages/floor/imgs/overdue.png"></image>
<view class="receive" v-if="navIndex == 0" @click="useItNow(coupon)">
<text>立即</text><br />
<text>使用</text>
</view>
<view class="bg-quan"> </view>
</view>
</view>
<uni-load-more :status="tabItem.loadStatus"></uni-load-more>
<uni-load-more :status="navItem.loadStatus"></uni-load-more>
</scroll-view>
</swiper-item>
</swiper>
@@ -69,8 +68,9 @@ import { getMemberCoupons } from "@/api/members.js";
export default {
data() {
return {
tabCurrentIndex: 0,
tabCurrentIndex: 0, //tab栏下标默认为0 未使用
navList: [
//每个tab存储的信息
{
text: "未使用",
loadStatus: "more",
@@ -81,7 +81,7 @@ export default {
pageSize: 10,
status: 1,
},
nomsg: false,
wheterEmpty: false,
},
{
text: "已使用",
@@ -93,7 +93,7 @@ export default {
pageSize: 10,
status: 2,
},
nomsg: false,
wheterEmpty: false,
},
{
text: "已过期",
@@ -105,40 +105,37 @@ export default {
pageSize: 10,
status: 3,
},
nomsg: false,
wheterEmpty: false,
},
],
couponList: [],
couponList: [], //优惠券列表
};
},
onNavigationBarButtonTap() {
uni.navigateTo({
url: "/pages/cart/coupon/couponIntro",
});
},
onLoad() {
// this.tabCurrentIndex = 0;
this.getData();
},
onPullDownRefresh() {
let index = this.tabCurrentIndex;
this.navList[index].params.pageNumber = 1;
this.navList[index].dataList = [];
this.getData();
},
watch: {
/**
* 监听切换顶部tab栏实现刷新数据
*/
tabCurrentIndex(val) {
if (this.navList[val].dataList.length == 0) this.getData();
},
},
methods: {
//顶部tab点击
tabClick(index) {
/**
* 顶部tab点击
*/
handleTabClick(index) {
this.tabCurrentIndex = index;
// this.loadData();
},
/**
* 读取优惠券
*/
getData() {
//读取优惠券
uni.showLoading({
title: "加载中",
});
@@ -149,7 +146,7 @@ export default {
let data = res.data.result.records;
if (data.length == 0) {
if (res.data.pageNumber == 1) {
this.navList[index].nomsg = true;
this.navList[index].wheterEmpty = true;
} else {
this.navList[index].loadStatus = "noMore";
}
@@ -163,9 +160,17 @@ export default {
uni.hideLoading();
});
},
/**
* 切换tab
*/
changeTab(e) {
this.tabCurrentIndex = e.target.current;
},
/**
* 加载数据
*/
loadData() {
let index = this.tabCurrentIndex;
if (this.navList[index].loadStatus != "noMore") {
@@ -173,10 +178,11 @@ export default {
this.getData();
}
},
nowUse(item) {
console.log(item)
return
//立即使用
/**
* 立即使用优惠券
*/
useItNow(item) {
if (item.storeId) {
uni.navigateTo({
url: `/pages/product/shopPage?id=${item.storeId}`,
@@ -186,9 +192,11 @@ export default {
url: "/pages/tabbar/home/index",
});
}
},
/**
* 优惠券详情
*/
couponDetail(item) {
uni.navigateTo({
url:
@@ -199,12 +207,11 @@ export default {
},
};
</script>
<style>
<style lang="scss" scoped>
page {
height: 100%;
}
</style>
<style lang="scss">
$item-color: #fff;
.b-content {
@@ -232,7 +239,7 @@ $item-color: #fff;
background-color: $light-color;
position: relative;
.msg {
.message {
color: $font-color-white;
display: flex;
justify-content: center;
@@ -370,27 +377,6 @@ $item-color: #fff;
}
}
}
.coupon-used {
.left {
background-color: #dddddd;
.wave-line {
background-color: #dddddd;
}
}
.right {
color: #cccccc;
.content {
color: #cccccc;
> view:nth-child(1) {
color: #cccccc;
}
}
.bg-quan {
border: 6rpx solid #cccccc;
color: #cccccc;
}
}
}
}
.navbar {