diff --git a/api/lottery.js b/api/lottery.js index dd81330..bb3815f 100644 --- a/api/lottery.js +++ b/api/lottery.js @@ -3,15 +3,57 @@ import request from '@/utils/request' /** * 抽奖活动信息 * */ -export function getDetail() { - return request.get('/lottery/dice/detail') +export function getDetail(params = {}) { + return request.get('/lottery/dice/detail', params) } /** * 抽奖 * */ -export function getPrize() { - return request.post('/lottery/dice/draw') +export function getPrize(data = {}) { + return request.post('/lottery/dice/draw', data) +} + +/** + * 县域抽奖活动详情 + * @param activityId 抽奖活动ID + */ +export function getDrawActivityInfo(activityId) { + return request.get('/draw/activityInfo', { activityId }) +} + +/** + * 县域抽奖活动规则 + */ +export function getDrawRuleConfig() { + return request.get('/draw/ruleConfig') +} + +/** + * 我的抽奖码列表 + * @param status 抽奖码状态(0:等待开奖, 1:已中奖, 2:未中奖, -1:已失效) + */ +export function getDrawMyTickets(status) { + const params = {} + if (status !== undefined && status !== null && status !== '') { + params.status = status + } + return request.get('/draw/myTickets', params) +} + +/** + * 抽奖活动中奖记录 + * @param activityId 抽奖活动ID + */ +export function getActivityWinRecord(activityId) { + return request.get('/draw/activityWinRecord', { activityId }) +} + +/** + * 获取抽奖相关显示配置 + */ +export function getDrawConfig() { + return request.get('/draw/config') } /** @@ -35,4 +77,12 @@ export function getLogs(page = 1, limit = 10) { * */ export function getLotteryShareInfo() { return request.get('/lottery/shareImage') -} \ No newline at end of file +} + +/** + * 订单支付完成后检查抽奖码 + * @param orderId 订单号 + */ +export function getDrawTicketByOrder(orderId) { + return request.get('/draw/ticketByOrder', { orderId }) +} diff --git a/pages.json b/pages.json index 379ee0f..8cbd610 100644 --- a/pages.json +++ b/pages.json @@ -401,11 +401,35 @@ "navigationBarTitleText": "抽奖" } }, + { + "path": "views/county-lottery", + "style": { + "navigationBarTitleText": "抽奖" + } + }, { "path": "views/lottery-log", "style": { "navigationBarTitleText": "抽奖记录" } + }, + { + "path": "views/county-lottery-rules", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "views/county-my-tickets", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "views/county-winners", + "style": { + "navigationStyle": "custom" + } } ] }, diff --git a/pages/home/index.vue b/pages/home/index.vue index 5b9db8b..ba8b31e 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -346,10 +346,34 @@ + + + + + + + + + + + × + + + + + + 支付成功 + + + + 恭喜获得抽奖码! + + + + + 您的专属抽奖码 + + + {{ drawTicketPopup.ticketCode }} + + 开奖时间:{{ drawTicketPopup.drawTime }} + + + + + 返回首页 + 查看我的抽奖码 + + + @@ -328,6 +360,7 @@ import {isNullOrEmpty, isWeixin} from "@/utils" import blPaymentPasswordInput from '@/components/blPaymentPasswordInput.vue' import uniPopup from '@/components/uni-popup/uni-popup.vue' import CouponsPopup from "@/components/CouponsPopup.vue" +import { getDrawTicketByOrder } from '@/api/lottery' import { pageListenMixins } from '@/mixins/pageListenMixins' const NAME = "OrderSubmission" @@ -395,7 +428,13 @@ export default { pageKeyId: Object.freeze('orderConfirm'), total: 0, couponTitle: '', - hasCoupon: false + hasCoupon: false, + drawTicketPopup: { + show: false, + orderId: '', + ticketCode: '', + drawTime: '' + } } }, computed: mapGetters(["userInfo", "storeItems"]), @@ -707,6 +746,7 @@ export default { createOrder(this.orderGroupInfo.orderKey, params).then(res => { uni.hideLoading() const data = res.data + const orderId = data && data.result ? data.result.orderId : '' switch (data.status) { case "ORDER_EXIST": case "EXTEND_ORDER": @@ -718,7 +758,7 @@ export default { this.$yrouter.replace({ path: "/pages/order/OrderDetails/index", query: { - id: data.result.orderId + id: orderId } }) break; @@ -743,21 +783,23 @@ export default { icon: "none", duration: 2000 }) - if (this.orderGroupInfo.cartInfo && this.orderGroupInfo.cartInfo.length === 1) { - this.$yrouter.replace({ - path: "/pages/order/OrderDetails/index", - query: { - id: data.result.orderId - } - }) - } else { - this.$yrouter.replace({ - path: "/pages/order/MyOrder/index", - query: { - type: 2 - } - }) - } + this.afterPaySuccess(orderId, () => { + if (this.orderGroupInfo.cartInfo && this.orderGroupInfo.cartInfo.length === 1) { + this.$yrouter.replace({ + path: "/pages/order/OrderDetails/index", + query: { + id: orderId + } + }) + } else { + this.$yrouter.replace({ + path: "/pages/order/MyOrder/index", + query: { + type: 2 + } + }) + } + }) break; case "WECHAT_H5_PAY": // H5支付 @@ -770,7 +812,16 @@ export default { break; case "WECHAT_PAY": // 小程序支付 - weappPay(data.result.jsConfig).finally(() => { + weappPay(data.result.jsConfig).then(() => { + this.afterPaySuccess(orderId, () => { + this.$yrouter.replace({ + path: "/pages/order/MyOrder/index", + query: { + type: 1 + } + }) + }) + }).catch(() => { this.$yrouter.replace({ path: "/pages/order/MyOrder/index", query: { @@ -781,13 +832,22 @@ export default { break; case "WECHAT_APP_PAY": // APP支付 - weappPay(data.result.jsConfig).finally(() => { + weappPay(data.result.jsConfig).then(() => { + this.afterPaySuccess(orderId, () => { + this.$yrouter.replace({ + path: "/pages/order/MyOrder/index", + query: { + type: 1 + } + }) + }) + }).catch(() => { this.$yrouter.replace({ path: "/pages/order/MyOrder/index", query: { type: 1 } - }); + }) }) break; } @@ -830,6 +890,50 @@ export default { this.computedPrice(1) // this.couponId = uni.getStorageSync('couponId') || 0 // this.couponTitle = item.couponTitle + }, + async afterPaySuccess(orderId, fallback) { + if (!orderId) { + fallback && fallback() + return + } + try { + const res = await getDrawTicketByOrder(orderId) + const result = (res && res.data) || {} + const hasTicket = Number(result.hasTicket || 0) === 1 + const howPopup = Number(result.howPopup || 0) === 1 + if (hasTicket && howPopup) { + this.drawTicketPopup = { + show: true, + orderId: orderId, + ticketCode: result.ticketCode || '', + drawTime: result.drawTime || '' + } + return + } + } catch (e) { + } + fallback && fallback() + }, + closeDrawTicketPopup() { + this.drawTicketPopup.show = false + this.$yrouter.replace({ + path: "/pages/order/MyOrder/index", + query: { + type: 1 + } + }) + }, + goHomeFromPopup() { + this.drawTicketPopup.show = false + uni.switchTab({ + url: '/pages/home/index' + }) + }, + goTicketsFromPopup() { + this.drawTicketPopup.show = false + uni.navigateTo({ + url: '/pkg-video/views/county-my-tickets' + }) } } }; @@ -1007,4 +1111,213 @@ export default { padding: 20rpx 0 0 0; color: #999; } + +.draw-ticket-mask { + position: fixed; + inset: 0; + z-index: 1000; + background: rgba(0, 0, 0, 0.45); + display: flex; + align-items: center; + justify-content: center; + padding: 24rpx; + box-sizing: border-box; +} + +.draw-ticket-popup { + width: 100%; + max-width: 640rpx; + background: #fff; + border-radius: 40rpx; + padding: 50rpx 40rpx 60rpx; + position: relative; + box-sizing: border-box; +} + +.draw-ticket-close { + position: absolute; + top: 30rpx; + right: 30rpx; + width: 60rpx; + height: 60rpx; + border: 4rpx solid #111; + border-radius: 50%; + font-size: 50rpx; + color: #111; + line-height: 52rpx; + text-align: center; + font-weight: 500; + z-index: 10; +} + +.draw-ticket-icon { + display: flex; + justify-content: center; + margin-top: 20rpx; +} + +.ticket-icon-box { + width: 90rpx; + height: 70rpx; + border: 6rpx solid #111; + border-radius: 10rpx; + position: relative; + box-sizing: border-box; +} + +.ticket-icon-box::before { + content: ''; + position: absolute; + top: -16rpx; + left: 14rpx; + width: 50rpx; + height: 12rpx; + border-top: 6rpx solid #111; + border-left: 6rpx solid #111; + border-right: 6rpx solid #111; + border-radius: 6rpx 6rpx 0 0; + background: #fff; +} + +.ticket-icon-check { + width: 36rpx; + height: 18rpx; + border-left: 6rpx solid #c23326; + border-bottom: 6rpx solid #c23326; + transform: rotate(-45deg); + position: absolute; + left: 20rpx; + top: 14rpx; +} + +.draw-ticket-title { + font-size: 56rpx; + color: #222; + font-weight: 800; + text-align: center; + margin-top: 24rpx; + letter-spacing: 2rpx; +} + +.ticket-card-container { + margin-top: 50rpx; + position: relative; + display: flex; + flex-direction: column; + align-items: center; +} + +.ticket-badge { + background-color: #fff9eb; + border: 6rpx solid #111; + border-radius: 40rpx; + padding: 12rpx 40rpx; + font-size: 46rpx; + font-weight: 800; + color: #222; + position: relative; + z-index: 2; + margin-bottom: -36rpx; + letter-spacing: 2rpx; +} + +.ticket-badge-arrow { + position: absolute; + bottom: -22rpx; + left: 50%; + transform: translateX(-50%); + width: 0; + height: 0; + border-left: 22rpx solid transparent; + border-right: 22rpx solid transparent; + border-top: 22rpx solid #111; +} + +.ticket-badge-arrow::after { + content: ''; + position: absolute; + top: -26rpx; + left: -16rpx; + border-left: 16rpx solid transparent; + border-right: 16rpx solid transparent; + border-top: 16rpx solid #fff9eb; +} + +.ticket-card { + width: 100%; + background: #c23326; + border-radius: 36rpx; + padding: 70rpx 36rpx 40rpx; + box-sizing: border-box; + text-align: center; + position: relative; +} + +.ticket-card-subtitle { + display: flex; + justify-content: center; +} + +.ticket-card-subtitle-text { + color: #fff; + font-size: 34rpx; + font-weight: 700; + border: 2rpx solid #fff; + border-radius: 40rpx; + padding: 8rpx 50rpx; + letter-spacing: 4rpx; +} + +.ticket-card-code-box { + background: #fff; + border-radius: 20rpx; + margin-top: 36rpx; + padding: 36rpx 0; +} + +.ticket-card-code { + color: #c23326; + font-size: 72rpx; + font-weight: 800; + letter-spacing: 8rpx; +} + +.ticket-card-time { + color: #fff; + font-size: 30rpx; + margin-top: 36rpx; + letter-spacing: 1rpx; +} + +.draw-ticket-actions { + margin-top: 60rpx; + display: flex; + justify-content: space-between; + align-items: center; + gap: 20rpx; +} + +.action-btn { + flex: 1; + height: 86rpx; + border-radius: 44rpx; + font-size: 32rpx; + font-weight: 600; + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + white-space: nowrap; +} + +.action-btn.home-btn { + color: #c23326; + border: 2rpx solid #c23326; + background: #fff; +} + +.action-btn.primary { + color: #fff; + background: #c23326; +} diff --git a/pages/user/User/index.vue b/pages/user/User/index.vue index 3d2fa91..cf2f6f7 100644 --- a/pages/user/User/index.vue +++ b/pages/user/User/index.vue @@ -215,6 +215,13 @@ + + + @@ -301,6 +308,7 @@ import { noticeList, getUserCenterBanner } from "@/api/user" +import { getDrawConfig } from '@/api/lottery' import {isWeixin} from "@/utils" import cookie from "@/utils/store/cookie" import { pageListenMixins } from '@/mixins/pageListenMixins' @@ -389,6 +397,10 @@ export default { ], bannerBgUrl: '', userCenterBannerUrl: '', + drawConfig: { + myTicketImage: '', + myTicketImageEnable: 0 + }, pageKeyId: Object.freeze('userIndex'), nowrap: true, // 是否已登录 @@ -403,6 +415,7 @@ export default { }, onShow() { uni.$emit('updateUnreadMessageCount') + this.getDrawConfigReq() if (this.$store.getters.token) { this.isNoLogin = false uni.showLoading({ @@ -429,6 +442,19 @@ export default { }, methods: { ...mapMutations(['updateAuthorizationPage']), + getDrawConfigReq() { + getDrawConfig().then(res => { + if (res && res.data) { + this.drawConfig = { + myTicketImage: res.data.myTicketImage || '', + myTicketImageEnable: Number(res.data.myTicketImageEnable) || 0 + } + } + }).catch(() => {}) + }, + goMyTicketList() { + this.linkTo('/pkg-video/views/county-my-tickets') + }, // 新增方法:计算文本像素长度 getTextWidth() { this.$nextTick(() => { @@ -681,6 +707,14 @@ export default { } .my-wrapper { padding: 30upx; + .my-ticket-entry { + margin-top: 30rpx; + .img { + width: 100%; + border-radius: 24rpx; + display: block; + } + } &.wrapper { padding: 0 0 30rpx 0 !important; } diff --git a/pkg-video/views/county-lottery-rules.vue b/pkg-video/views/county-lottery-rules.vue new file mode 100644 index 0000000..5e6f2b7 --- /dev/null +++ b/pkg-video/views/county-lottery-rules.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/pkg-video/views/county-lottery.vue b/pkg-video/views/county-lottery.vue new file mode 100644 index 0000000..8125e28 --- /dev/null +++ b/pkg-video/views/county-lottery.vue @@ -0,0 +1,786 @@ + + + + + diff --git a/pkg-video/views/county-my-tickets.vue b/pkg-video/views/county-my-tickets.vue new file mode 100644 index 0000000..0bf965e --- /dev/null +++ b/pkg-video/views/county-my-tickets.vue @@ -0,0 +1,550 @@ + + + + + diff --git a/pkg-video/views/county-winners.vue b/pkg-video/views/county-winners.vue new file mode 100644 index 0000000..624a914 --- /dev/null +++ b/pkg-video/views/county-winners.vue @@ -0,0 +1,692 @@ + + + + + diff --git a/pkg-video/views/lottery-log.vue b/pkg-video/views/lottery-log.vue index af4fb27..0298e34 100644 --- a/pkg-video/views/lottery-log.vue +++ b/pkg-video/views/lottery-log.vue @@ -157,4 +157,4 @@ export default { } } } - \ No newline at end of file + diff --git a/pkg-video/views/lottery.vue b/pkg-video/views/lottery.vue index 752180a..aed366f 100644 --- a/pkg-video/views/lottery.vue +++ b/pkg-video/views/lottery.vue @@ -403,4 +403,4 @@ image { background-size: 175rpx 185rpx; } } - \ No newline at end of file +