移动端自动发券前端展示

yeliang-king 2023-01-13 07:35:51 +08:00
parent f84f9ab696
commit 0843e457b0
6 changed files with 141 additions and 1 deletions

View File

@ -14,6 +14,16 @@ export function resetByMobile(params) {
});
}
//获取自动发券
export function getAutoCoup(){
return http.request({
url:`/promotion/coupon/activity`,
method:"GET",
needToken: true,
});
}
/**
* 账号密码登陆
* @params password

View File

@ -564,6 +564,7 @@
*/
storage.setUserInfo(user.data.result);
storage.setHasLogin(true);
storage.setAutoCp(0)
//
uni.showToast({
title: "登录成功!",

View File

@ -14,6 +14,14 @@ export default {
backgroundColor: "#fff",
},
};
},
onShow(){
setTimeout(()=>{
this.$refs.tpl.firstGetAuto();
},1000)
},
methods: {
},
onReachBottom(){
//

View File

@ -1,5 +1,37 @@
<template>
<div class="wrapper">
<u-popup v-model="showCp" mode="center" width="550rpx" height="400px">
<view style="height:130rpx;">
<view style="width:200rpx;height:120rpx;float:left;line-height:120rpx;font-size:35rpx;color:#28A4F2;font-weight:600;margin-left:20rpx;">优惠券活动</view>
<view style="width:120rpx;height:120rpx;float:right;">
<image @click="showCp = false" src="/static/cpauto1.png" style="width:100%;height:100%;"></image>
</view>
</view>
<scroll-view scroll-y="true" style="height: 620rpx;">
<!-- {{coupList}} -->
<view v-for="(item,index) in coupList" :key="index" >
<view class="grad1">
<view style="float:right;">
<view v-if="item.couponType == 'DISCOUNT'">{{ item.couponDiscount }}</view>
<view v-else><span style="color:red;font-size:32rpx;">{{ item.price | unitPrice}}</span></view>
<view><span style="color:red;font-size:32rpx;">{{ item.consumeThreshold | unitPrice }}</span>可用</view>
<view v-if="item.scopeType == 'ALL' && item.storeId == '0'"></view>
<view v-if="item.scopeType == 'PORTION_GOODS_CATEGORY'"></view>
<view v-else>{{ item.storeName == 'platform' ? '' :item.storeName+'' }}使
</view>
<view v-if="item.endTime">{{ item.endTime.split(" ")[0] }}</view>
</view>
<view style="color:white;font-size:28rpx;font-weight:500;float:left;writing-mode:vertical-rl;flex: auto;height:100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;" @click="showCp = false">
立即使用
</view>
</view>
</view>
</scroll-view>
</u-popup>
<!-- uni 中不能使用 vue component 所以用if判断每个组件 -->
<div v-for="(item, index) in pageData.list" :key="index">
<!-- 搜索栏如果在楼层装修顶部则会自动浮动否则不浮动 -->
@ -76,13 +108,19 @@ import tpl_goods from "@/pages/tabbar/home/template/tpl_goods"; //商品分类
import { getFloorData } from "@/api/home"; //
import permision from "@/js_sdk/wa-permission/permission.js"; //
import config from "@/config/config";
import {getAutoCoup} from "@/api/login"
import tpl_notice from "@/pages/tabbar/home/template/tpl_notice"; //
import tpl_promotions from "@/pages/tabbar/home/template/tpl_promotions_detail"; //
import storage from "@/utils/storage.js";
// import {receiveCoupons} from "@/api/members"
export default {
data() {
return {
config,
storage,
coupList:[],
showCp:false,
pageData: "", //
isIos: "",
enableLoad:false, //
@ -115,9 +153,58 @@ export default {
//
uni.showShareMenu({ withShareTicket: true });
// #endif
this.firstGetAuto()
},
methods: {
firstGetAuto(){
// console.log(123123213)
let data = new Date()
let datas = data.getDate()
let huors = data.getHours()
let flagCoup = storage.getAutoCp()
console.log(flagCoup)
console.log(datas)
if(storage.getAutoCp() && storage.getAutoCp() != '' && storage.getAutoCp() != undefined && storage.getAutoCp() != null){
if(Number(datas) > Number(flagCoup)){
if(Number(huors) >= 6){
storage.setAutoCp(datas)
this.getAutoCp()
}
}
}else{
this.getAutoCp()
}
},
getAutoCp(){
let data = new Date()
let datas = data.getDate()
getAutoCoup().then(res=>{
console.log(res)
if(res.data.success){
this.coupList.push(...res.data.result)
if(this.coupList != ''){
this.showCp = true
}else{
this.showCp = false
}
storage.setAutoCp(datas)
let objs = {};
this.coupList = this.coupList.reduce((cur, next) => {
//
if (next.id != undefined) {
objs[next.id]
? ""
: (objs[next.id] = true && cur.push(next));
}
return cur;
}, []);
}
})
},
// receiveCoupons(v){
// },
/**
* 实例化首页数据楼层
*/
@ -251,4 +338,30 @@ export default {
.navbar-right {
padding: 0 16rpx 0 0;
}
.grad1 {
width: 500rpx;
height: 200rpx;
background: radial-gradient(circle at right top, transparent 20rpx, #ff6b35 0) top left / 120rpx 51% no-repeat,
radial-gradient(circle at right bottom, transparent 20rpx, #ff6b35 0) bottom left /120rpx 51% no-repeat,
radial-gradient(circle at left top, transparent 20rpx, #ffffff 0) top right /380rpx 51% no-repeat,
radial-gradient(circle at left bottom, transparent 20rpx, #ffffff 0) bottom right /380rpx 51% no-repeat;
filter: drop-shadow(6rpx 6rpx 6rpx rgba(0,0,0,.3));
margin: 30rpx auto;
padding-top: 2rpx;
padding-bottom: 10rpx;
padding-left: 38rpx;
padding-right: 30rpx;
}
// .grad2 {
// width: 100px;
// height: 120px;
// background:
// radial-gradient(circle at left bottom, transparent 10px, #28A4F2 0) top left /60px 30px no-repeat,
// radial-gradient(circle at right bottom, transparent 10px, #28A4F2 0) top right /60px 30px no-repeat,
// radial-gradient(circle at left top, transparent 10px, #EFEFF4 0) bottom left /60px 90px no-repeat,
// radial-gradient(circle at right top, transparent 10px, #EFEFF4 0) bottom right /60px 90px no-repeat;
// filter: drop-shadow(3rpx 3rpx 3rpx rgba(0,0,0,.3));
// }
</style>

BIN
static/cpauto1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

View File

@ -10,6 +10,14 @@ const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login";
const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn";
const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data";
export default {
//写入自动发券
setAutoCp(val){
uni.setStorageSync('autoCp', val)
},
//获取自动发券时间
getAutoCp(){
return uni.getStorageSync('autoCp');
},
// 写入热门搜索时间戳
setHotWords(val) {
uni.setStorageSync("hotWords", val);