领取优惠卷,我的优惠卷

This commit is contained in:
itgaojian163 2025-04-07 18:00:30 +08:00
parent 2dc51c6b1e
commit 2f7b338d00
19 changed files with 589 additions and 157 deletions

View File

@ -14,7 +14,8 @@
"pages/readTxt/readTxt",
"pages/mine/mineAccount/mineInfo/mineInfo",
"pages/mine/mineAccount/mineOrder/mineOrder",
"pages/mine/mineAccount/mineContact/mineContact"
"pages/mine/mineAccount/mineContact/mineContact",
"pages/treaty/rule/rule"
],
"window": {
"navigationBarTextStyle": "black",

View File

@ -10,16 +10,33 @@ Component({
visible: {
type: Boolean,
value: false
},
coupons: {
type: Object,
value: null
}
},
data: {
checked: false
},
methods: {
toggleCheck() {
this.setData({
checked: !this.data.checked
})
},
// 关闭弹窗
onClose() {
this.setData({
visible: false
});
this.triggerEvent('close'); // 触发关闭事件
this.triggerEvent('close', this.data.checked); // 触发关闭事件
},
onFurl() {
this.setData({
visible: false
})
this.triggerEvent('furl', this.data.checked); //触发收下试卷
}
}
})

View File

@ -1,6 +1,25 @@
<view class="ad-popup" wx:if="{{visible}}">
<view class="ad-content">
<image class="img" src="{{imageUrl}}" mode="aspectFill" />
<view class="close-btn" bindtap="onClose">×</view>
<view class="ic-close close-icon" bind:tap="onClose"></view>
<view class="image-box">
<view class="ad-bg img"></view>
<view class="content">
<view class="price-box">
<view class="p-icon">¥</view>
<view class="p-content">{{coupons.amount/100}}</view>
</view>
<view class="ad-desc-box">
<text class="ad-desc">{{coupons.title}}</text>
<view class="ad-period">有效期:{{coupons.useGmtStart}}至{{coupons.useGmtEnd}}</view>
</view>
</view>
</view>
<view class="custom-checkbox-group" bindtap="toggleCheck">
<view class="custom-checkbox {{checked ? 'checked' : ''}}">
<text wx:if="{{checked}}">✓</text>
</view>
<view style="margin-left: 5px;margin-top: 1px;">今日不再显示</view>
</view>
<view class="btn" bind:tap="onFurl">收下优惠卷</view>
</view>
</view>

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,7 @@ const apiPath = {
createProject: '/api/proj/create-quick', //快速创建项目
reCreate: '/api/proj/generate/proj-id/${projId}', //重新生成
proLangList: '/api/env/custom/list-active-lang', //项目语言
ruleData: '/app/agreementportal/getrelease/89c4ca41-a44e-4ae2-bad3-6fa6536dd453', //使用规则 project="operator"
}
class ProjectService {
//项目列表
@ -60,6 +61,10 @@ class ProjectService {
static doGetProLangList() {
return request(apiPath.proLangList, "GET")
}
//获取使用规则数据
static doGetRuleDate() {
return request(apiPath.ruleData, "GET", null, null, "operator")
}
}
export default ProjectService;

View File

@ -16,6 +16,8 @@ const apiPath = {
mineContact: '/api/proj-contact/listpage/self', //联系人列表
updateContact: '/api/proj-contact/update/{projContactId}', //更新联系人
delContact: '/api/proj-contact/remove/{ids}', //删除联系人
canClaimsCoupons: '/api/coupon/list-can-claim', //获取可以申领的优惠卷
saveCoupons: '/api/coupon/user/save', //领取优惠卷
}
class UserService {
static doLogin(data) {
@ -67,6 +69,14 @@ class UserService {
const path = apiPath.delContact.replace('{ids}', id)
return request(path, "DELETE")
}
//获取可以申领的优惠卷
static doGetClaimsCouponsList() {
return request(apiPath.canClaimsCoupons, "GET")
}
//领取优惠卷
static doSaveCoupons(data) {
return request(apiPath.saveCoupons, "POST", data)
}
}
export default UserService;

View File

@ -1,5 +1,6 @@
// index.js
import ProjectService from '../../net/api/projectApi'
import UserApi from '../../net/api/userApi'
import {
previewUrl,
copyrightUrl
@ -71,6 +72,9 @@ Page({
downloading: false, //下载文件中
isLoadMore: false, //是否正在加载更多中
hasMore: true, //是否有更多数据
showAd: false, //显示优惠卷广告
tempCoupons: null, //优惠卷
isNoShowToday: false, //今日不再显示
},
onLoad(e) {
const _self = this
@ -86,13 +90,39 @@ Page({
_self.setData({
contentHeight: h
})
const noShowToday = Cache.get('noShowToday')
const currentDate = new Date().toLocaleDateString();
if (noShowToday && noShowToday === currentDate) {
this.setData({
isNoShowToday: true
});
} else {
_self.doGetClaimsCoupons()
}
},
//获取可以申领的优惠卷
doGetClaimsCoupons() {
const _self = this
UserApi.doGetClaimsCouponsList()
.then(res => {
if (res && res.length > 0) {
_self.setData({
tempCoupons: res[0],
showAd: true
})
}
}, err => {
console.log(err)
})
},
//创建项目
createCopy() {
wx.navigateTo({
url: '/pages/copyright/createBuy/createBuy',
this.setData({
showAd: true
})
// wx.navigateTo({
// url: '/pages/copyright/createBuy/createBuy',
// })
},
//充值
goPayment() {
@ -395,5 +425,53 @@ Page({
})
const params = _self.buildParams(_self.data.pageData.page, false)
_self.doGetSelfList(params, false)
},
//关闭广告
doCloseAd(e) {
const isShow = e.detail
// isShow=true 今日不再显示
if (isShow) {
const currentDate = new Date().toLocaleDateString();
Cache.set('noShowToday', currentDate)
this.setData({
isNoShowToday: true
});
}
},
//收下优惠卷
doFurlCoupons(e) {
console.log('收下优惠卷')
const _self = this
const isShow = e.detail
// isShow=true 今日不再显示
if (isShow) {
const currentDate = new Date().toLocaleDateString();
Cache.set('noShowToday', currentDate)
this.setData({
isNoShowToday: true
});
}
wx.showLoading({
title: '领取中...',
})
const coupons = {
couponId: _self.data.tempCoupons.couponId
}
UserApi.doSaveCoupons(coupons)
.then(res => {
wx.hideLoading()
_self.setData({
successHint: '本次领取操作已成功,您可以在 “我的” 页面查看相关信息。',
showSuccess: true,
showAd: false
})
}, err => {
wx.hideLoading()
_self.setData({
errorHint: err.msg ? err.msg : '本次领取操作未成功,请重新进入小程序后再次尝试。',
showError: true,
showAd: false
})
})
}
})

View File

@ -4,7 +4,8 @@
"mp-half-screen-dialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog",
"mp-toptips": "weui-miniprogram/toptips/toptips",
"down-progress": "/components/down-progress/down-progress",
"mp-loading": "weui-miniprogram/loading/loading"
"mp-loading": "weui-miniprogram/loading/loading",
"ad-popup": "/components/ad-popup/ad-popup"
},
"navigationStyle": "custom"
}

View File

@ -96,7 +96,7 @@
<view class="hint">温馨提示:若您想把下载的文件留存到本地,打开预览页面后,在界面右上角操作栏内,选择使用其他软件打开或者保存文件功能就能实现。</view>
<view class="download-desc">
<view class="link-title">项目预览链接</view>
<text class="link">{{sysPreviewUrl}}</text>
<text class="link" selectable="true">{{sysPreviewUrl}}</text>
</view>
<view class="download-item">
<view class="download-title">
@ -152,23 +152,5 @@
<down-progress isShow="{{downloading}}" progress="{{downloadProgress}}"></down-progress>
<mp-toptips ext-class="custom-tips" msg="{{errorHint}}" type="error" show="{{showError}}"></mp-toptips>
<mp-toptips ext-class="custom-tips" msg="{{successHint}}" delay="2000" type="success" show="{{showSuccess}}"></mp-toptips>
<wxs src="../../utils/comm.wxs" module="tools"></wxs>
<!-- <view class="download-item">
<view class="download-title icon-tool">操作手册</view>
<view class="download-btn-box">
<view class="download-btn" bind:tap="download" data-path="/route/proj/download/manual/">DOC</view>
<view class="download-btn" bind:tap="download" data-path="/route/proj/download/manual/pdf/">PDF</view>
</view>
</view> -->
<!-- <view class="download-item">
<view class="download-title icon-source">源代码</view>
<view class="download-btn-box">
<view class="download-btn" bind:tap="download" data-path="/route/proj/download/code/">DOC</view>
<view class="download-btn" bind:tap="download" data-path="/route/proj/download/code/pdf/">PDF</view>
</view>
</view> -->
<ad-popup coupons="{{tempCoupons}}" bindclose="doCloseAd" bindfurl="doFurlCoupons" visible="{{showAd}}"></ad-popup>
<wxs src="../../utils/comm.wxs" module="tools"></wxs>

View File

@ -374,6 +374,9 @@
.download-item:nth-of-type(n+2) {
margin-top: 10px;
}
.download-item:last-child{
margin-bottom: 80px;
}
.download-title {
display: flex;
@ -497,4 +500,8 @@
text-align: center;
color: rgb(248, 185, 50);
font-weight: bold;
}
.weui-half-screen-dialog__ft{
height: 0;
padding: 0;
}

View File

@ -11,21 +11,40 @@ Page({
* 页面的初始数据
*/
data: {
couponsList: [],
loadingStatus: 'loading',
currentPage: 1,
listRefreshTrig: false,
currentStatus: 1,
rows: 10,
isLoadMore: false, //是否正在加载更多
height: windowHeight
height: windowHeight,
couponsList: [], //订单列表
pageData: {
page: 1,
rows: 10,
isEffective: '',
isUsed: '',
}, //检索参数
loadingState: 'loading', //加载状态
listRefreshTrig: false, //list刷新状态
isLoadMore: false, //加载更多的状态
hasMore: true, //是否有更多数据
keywords: '', //搜索关键字
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.setNavigationBarTitle({
title: '我的优惠卷',
})
wx.setNavigationBarColor({
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色
animation: { // 可选项
duration: 500,
timingFunc: 'easeIn'
}
})
//加载数据
this.doRefreshList()
},
//tab切换
doChangeStatus(e) {
@ -36,74 +55,95 @@ Page({
this.doRefreshList()
},
//获取我的优惠卷
doGetMyCoupons(data) {
doGetMyCoupons(isRefresh) {
const _self = this
ProApi.doGetCouponseList(data)
_self.setData({
couponsList: isRefresh ? [] : _self.data.couponsList,
loadingState: isRefresh ? 'loading' : ''
})
ProApi.doGetCouponseList(_self.data.pageData)
.then(res => {
wx.stopPullDownRefresh()
console.log('优惠卷')
console.log(res)
var status = 'success'
status = res.rows && res.rows.length > 0 ? 'success' : 'empty'
_self.setData({
loadingStatus: res.rows && res.rows.length > 0 ? 'success' : 'empty',
loadingState: isRefresh ? status : '',
couponsList: _self.data.couponsList.concat(res.rows),
listRefreshTrig: false,
isLoadMore: false
})
}, err => {
console.log(err)
wx.stopPullDownRefresh()
_self.setData({
couponsList: [],
loadingStatus: 'error',
hasMore: _self.data.couponsList.length < res.total
})
}, err => {
_self.setData({
loadingState: 'error',
listRefreshTrig: false,
isLoadMore: false
isLoadMore: false,
hasMore: true
})
})
},
//构建请求参数
buildParams(value) {
const _self = this
console.log(value)
var data = {}
if (value == 1) {
data.isEffective = 1
data.isUsed = 0
} else if (value == 2) {
data.isEffective = ''
data.isUsed = 1
} else {
data.isEffective = 0
data.isUsed = 0
}
data.rows = _self.data.rows
return data
},
//下拉刷新
doRefreshList() {
const _self = this
var isEffective = ''
var isUsed = ''
if (_self.data.currentStatus == 1) {
isEffective = 1
isUsed = 0
} else if (_self.data.currentStatus == 2) {
isEffective = ''
isUsed = 1
} else {
isEffective = 0
isUsed = 0
}
_self.setData({
currentPage: 1,
listRefreshTrig: true,
loadingStatus: 'loading'
loadingState: 'loading',
hasMore: true,
'pageData.page': 1,
'pageData.isEffective': isEffective,
'pageData.isUsed': isUsed,
isLoadMore: false
})
var data = _self.buildParams(_self.data.currentStatus)
data.page = _self.data.currentPage
_self.doGetMyCoupons(data)
_self.doGetMyCoupons(true)
},
//加载更多
doLoadMore() {
if (this.data.isLoadMore) {
//判断是否正在加载中 与是否存在更多数据
const _self = this
if (_self.data.isLoadMore || !_self.data.hasMore) {
return
}
console.log('加载更多')
const _self = this
var isEffective = ''
var isUsed = ''
if (_self.data.currentStatus == 1) {
isEffective = 1
isUsed = 0
} else if (_self.data.currentStatus == 2) {
isEffective = ''
isUsed = 1
} else {
isEffective = 0
isUsed = 0
}
_self.setData({
currentPage: ++_self.data.currentPage,
isLoadMore: true
isLoadMore: true,
'pageData.page': ++_self.data.pageData.page,
'pageData.isEffective': isEffective,
'pageData.isUsed': isUsed,
})
var data = _self.buildParams(_self.data.currentStatus)
data.page = _self.data.currentPage
_self.doGetMyCoupons(data)
_self.doGetMyCoupons(false)
},
//显示使用规则
showRule() {
ProApi.doGetRuleDate()
.then(res => {
console.log(res)
}, err => {
console.log(err)
})
}
})

View File

@ -1,5 +1,6 @@
{
"usingComponents": {
"mp-loading": "weui-miniprogram/loading/loading",
"container-loading": "/components/container-loading/container-loading"
}
}

View File

@ -1,32 +1,47 @@
<view class="list-title-btns">
<view bind:tap="doChangeStatus" data-value="1" class="{{currentStatus==1? 'btn-select':'btn-normal'}} border-left">可用</view>
<view bind:tap="doChangeStatus" data-value="2" class="{{currentStatus==2? 'btn-select':'btn-normal'}} border-right">已使用</view>
<view bind:tap="doChangeStatus" data-value="3" class="{{currentStatus==3? 'btn-select':'btn-normal'}} border-right">不可用</view>
<view bind:tap="doChangeStatus" data-value="1" class="{{currentStatus==1? 'btn-select':'btn-normal'}} border-left">
<view class="tab">
<text>可用</text>
<view class="{{currentStatus==1?'border-select':'border-normal'}}"></view>
</view>
</view>
<view bind:tap="doChangeStatus" data-value="2" class="{{currentStatus==2? 'btn-select':'btn-normal'}} border-right">
<view class="tab">
<text>已使用</text>
<view class="{{currentStatus==2?'border-select':'border-normal'}}"></view>
</view>
</view>
<view bind:tap="doChangeStatus" data-value="3" class="{{currentStatus==3? 'btn-select':'btn-normal'}} border-right">
<view class="tab">
<text>不可用</text>
<view class="{{currentStatus==3?'border-select':'border-normal'}}"></view>
</view>
</view>
</view>
<view style="margin-top: 50px;">
<container-loading loadingState="{{loadingStatus}}">
<view style="margin-top: 60px;">
<container-loading loadingState="{{loadingState}}">
<scroll-view scroll-y style="height: {{height}}px;" bindrefresherrefresh="doRefreshList" refresher-enabled refresher-triggered="{{listRefreshTrig}}" bindscrolltolower="doLoadMore" lower-threshold='30'>
<view class="coupons-list-box">
<block wx:for="{{couponsList}}" wx:key="index">
<view class="tickets">
<view class="l-tickets">
<view class="ticket-title">
<view style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
<view class="coupons-icon" style="width: 24px;height: 24px;">
</view>
<text>优惠卷</text>
</view>
<view></view>
<view class="tickets {{tools.boderStyle(currentStatus)}}">
<view class="l-tickets-box">
<view class="l-tickets {{tools.fontColor(currentStatus)}}">
<view class="l-icon">¥</view>
<view class="l-price">{{item.coupon.amount/100}}</view>
</view>
<view class="ticket-content">{{item.coupon.title}}</view>
<view class="ticket-desc">有效期:{{item.coupon.useGmtStart}}至{{item.coupon.useGmtEnd}}</view>
<view class="use-link" bind:tap="showRule">使用规则</view>
</view>
<!-- 虚线 -->
<view class="v-divide"></view>
<view class="r-tickets">
减{{amount/100}}元
<view class="r-title">{{item.coupon.title}}</view>
<view class="r-time">{{item.coupon.useGmtStart}}-{{item.coupon.useGmtEnd}}</view>
</view>
</view>
</block>
<mp-loading show="{{isLoadMore}}" type="circle"></mp-loading>
</view>
</scroll-view>
</container-loading>
</view>
</view>
<wxs src="../../../../utils/comm.wxs" module="tools"></wxs>

View File

@ -1,6 +1,6 @@
/* pages/mine/mineAccount/mineCoupons/mineCoupons.wxss */
page {
background-color: white;
background: linear-gradient(to bottom, #F0F0F0, #FFFFFF);
}
.list-title-btns {
@ -17,24 +17,46 @@ page {
.btn-select {
line-height: 20px;
background-color: rgba(244, 206, 152, 0.18);
color: rgba(233, 157, 66, 1);
font-size: 16px;
text-align: center;
flex: 1;
padding: 10px;
border: 1px solid rgba(244, 206, 152, 0.18);
color: #2A9E75;
font-weight: bold;
}
.btn-normal {
line-height: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
flex: 1;
font-size: 16px;
text-align: center;
border: 1px solid rgba(248, 248, 248, 1);
padding: 10px;
font-weight: bold;
}
.border-select {
width: 20px;
height: 4px;
background-color: #2A9E75;
margin-top: 10px;
border-radius: 2px;
}
.tab {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.border-normal {
width: 20px;
height: 4px;
margin-top: 10px;
border-radius: 2px;
background-color: #F0F0F0;
}
.coupons-list-box {
@ -49,64 +71,105 @@ page {
padding: 5px;
width: 90vw;
box-sizing: border-box;
border-radius: 5px;
background-color: white;
flex-direction: row;
padding: 20px 0px;
box-shadow: 0px 0px 1px 1px #F0F0F0;
}
.tickets:nth-of-type(n+2) {
margin-top: 10px;
}
.tickets-yellow {
border-left: 5px solid #FFA900;
}
.tickets-gray {
border-left: 5px solid #A9A9A9;
}
.tickets-green {
border-left: 5px solid #2A9E75;
}
.font-yellow {
color: #FFA900
}
.font-gray {
color: #A9A9A9;
}
.font-green {
color: #2A9E75;
}
.v-divide {
height: auto;
border-right: 1.5px dashed rgba(221, 221, 221, 1);
}
.l-tickets-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 0.3;
}
.l-tickets {
width: 60vw;
position: relative;
padding: 10px;
background: radial-gradient(circle at right top, transparent 16rpx, #ffaa0017 0) right top / 100% 50% no-repeat,
radial-gradient(circle at right bottom, transparent 16rpx, #ffaa0017 0) right bottom / 100% 50% no-repeat;
filter: drop-shadow(3px 0 3px rgba(0, 0, 0, .3));
}
.l-tickets::after {
content: '';
position: absolute;
height: 100%;
width: 8rpx;
top: 0;
left: -8rpx;
background: radial-gradient(circle at left center, transparent 8rpx, #ffaa0017 0) left center / 8rpx 20rpx;
}
.r-tickets {
flex: 1;
position: relative;
background: radial-gradient(circle at left top, transparent 16rpx, #ffaa0017 0, #ffaa0017 100%) right top / 100% 50% no-repeat,
radial-gradient(circle at left bottom, transparent 16rpx, #ffaa0017 0, #ffaa0017 100%) right bottom / 100% 50% no-repeat;
filter: drop-shadow(3px 0 3px rgba(0, 0, 0, .3));
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
align-items: flex-end;
padding: 10px;
}
.use-link {
color: #0a86fa;
text-align: center;
font-size: 12px;
}
.l-icon {
font-size: 14px;
font-weight: 500;
color: #5D3900;
margin-bottom: 6px;
}
.r-tickets::after {
content: '';
position: absolute;
height: 100%;
width: 8rpx;
top: 0;
right: -8rpx;
background: radial-gradient(circle at right center, transparent 8rpx, #ffaa0017 0) right center / 8rpx 20rpx;
.l-price {
font-size: 30px;
font-weight: bold;
margin-left: 5px;
}
.r-tickets::before {
content: '';
width: 1rpx;
background: linear-gradient(to top, #fff 0%, #fff 50%, transparent 50%) top left / 1rpx 20rpx repeat-y;
position: absolute;
left: 0;
top: 16rpx;
bottom: 16rpx;
.r-tickets {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
font-size: 14px;
flex: 0.7;
padding-left: 20px;
}
.r-title {
line-height: 25px;
color: #313131;
font-size: 18px;
font-weight: bold;
text-align: left;
font-family: PingFangSC-medium;
}
.r-time {
line-height: 17px;
color: rgba(118, 118, 118, 1);
font-size: 12px;
text-align: left;
font-family: PingFangSC-regular;
margin-top: 10px;
}
.ticket-container:nth-last-of-type(n+1) {

25
pages/treaty/rule/rule.js Normal file
View File

@ -0,0 +1,25 @@
// pages/treaty/rule/rule.js
Page({
/**
* 页面的初始数据
*/
data: {
id: '',
title: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const _self = this
this.setData({
id: options.id,
title: options.title
})
wx.setNavigationBarTitle({
title: _self.data.title,
})
},
})

View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@ -0,0 +1,2 @@
<!--pages/treaty/rule/rule.wxml-->
<text>pages/treaty/rule/rule.wxml</text>

View File

@ -0,0 +1 @@
/* pages/treaty/rule/rule.wxss */

View File

@ -65,10 +65,44 @@ var proType = function (value) {
return str
}
var boderStyle = function (value) {
var str = 'tickets-yellow' // tickets-gray tickets-green
console.log(value)
switch (value) {
case '1': //可用
str = 'tickets-yellow'
break
case '2': //已经使用
str = 'tickets-gray'
break
case '3': //不可用
str = 'tickets-green'
break
}
console.log(str)
return str
}
var fontColor = function (value) {
var str = 'font-yellow' // tickets-gray tickets-green
switch (value) {
case '1': //可用
str = 'font-yellow'
break
case '2': //已经使用
str = 'font-gray'
break
case '3': //不可用
str = 'font-green'
break
}
return str
}
module.exports = {
isEmpty: isEmpty,
status: status,
orderStatus: orderStatus,
proType: proType
proType: proType,
boderStyle: boderStyle,
fontColor: fontColor
};