feat:商家活动兑换券核销
This commit is contained in:
1 parent
f9dcaf2be3
commit
14f2702ba8
8 files changed
+136
-57
No files matched your search
@@ -95,6 +95,8 @@ function downloadFile(file: any) {
|
||||
onLoad(async (options: any) => {
|
||||
const id = options.id
|
||||
if (!id) return
|
||||
// 临时商户活动的通知公告跳转链接
|
||||
if (id == "1969326082705055746") return uni.navigateTo({ url: "/pages/merchant/merchant-activity" })
|
||||
|
||||
try {
|
||||
// 增加浏览量
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
<template>
|
||||
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<template #main-top>
|
||||
<view class="bg-white rounded-16rpx px-20rpx my-20rpx">
|
||||
<view class="bg-white rounded-16rpx px-20rpx my-20rpx mx-4">
|
||||
<z-tabs :list="tabs" @change="doTab" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view class="card w-full h-400rpx relative activity-card overflow-hidden">
|
||||
<view class="ribbon">兑换券</view>
|
||||
<view class="px-10 py-4 flex justify-between font-bold">
|
||||
<text class="text-32 c-#FFD941">限时领取</text>
|
||||
<text class="text-32 c-#FFD941 px-1 rounded-full bg-#FFD94133">2025-09-21</text>
|
||||
<view
|
||||
class="card w-full h-400rpx relative activity-card overflow-hidden mb-2 px-10 py-2"
|
||||
:style="{ backgroundColor: getActStatus(item.actStatus)?.color }"
|
||||
v-for="(item, index) in couponList"
|
||||
:key="index"
|
||||
>
|
||||
<view class="ribbon" :style="{ backgroundColor: getActStatus(item.actStatus)?.color }">
|
||||
{{ getActStatus(item.actStatus)?.name }}
|
||||
</view>
|
||||
<view class="w-2/3 px-10 text-32 c-#fff font-bold">店内消费额外支付1元可领取衣服一件</view>
|
||||
<view class="absolute bottom-60 left-80 text-28 bg-#eeeeee44 c-#fff px-2 rounded-full">限量领取 先到先得</view>
|
||||
<view class="text-28 c-#fff text-right">ID {{ item.id }}</view>
|
||||
<view class="flex justify-between font-bold mt-1">
|
||||
<text class="text-32 c-#FFD941">限时领取</text>
|
||||
<text class="text-32 c-#FFD941 px-1 rounded-full bg-#eeeeee44">2025-09-21</text>
|
||||
</view>
|
||||
<view class="w-4/5 py-2 text-30 c-#fff">店内消费额外支付1元可领取价值89元的速干T恤1件</view>
|
||||
<view class="absolute bottom-60 left-80 text-28 bg-#eeeeee44 c-#fff px-2 rounded-full">限量领取 先领先得</view>
|
||||
<view class="absolute bottom-40 right-80 text-20 c-#fff">领取时间 {{ item.createTime }}</view>
|
||||
<view class="absolute bottom-10 right-80 text-20 c-#fff">核销时间 {{ item.receiverTime }}</view>
|
||||
</view>
|
||||
|
||||
<view class="h-100rpx"></view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
@@ -22,16 +34,18 @@
|
||||
import { actCancel } from "@/sheep/api"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import { reactive, ref } from "vue"
|
||||
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
|
||||
|
||||
const tabs = [
|
||||
{ id: null, name: "全部", disabled: false },
|
||||
{ id: 1, name: "未核销", disabled: false },
|
||||
{ id: 1, name: "已核销", disabled: false },
|
||||
{ id: 1, name: "未核销", disabled: false, color: "#1879ff77" },
|
||||
{ id: 2, name: "已核销", disabled: false, color: "#03DC6C77" },
|
||||
{ id: 3, name: "已过期", disabled: false, color: "#FF672B77" },
|
||||
]
|
||||
const params = reactive({
|
||||
actStatus: tabs[0].id,
|
||||
})
|
||||
const couponList = ref([])
|
||||
const couponList = ref<any>([])
|
||||
|
||||
onLoad(() => {
|
||||
getCouponList()
|
||||
@@ -42,6 +56,10 @@ const doTab = (e: any) => {
|
||||
getCouponList()
|
||||
}
|
||||
|
||||
const getActStatus = (actStatus: string | number) => {
|
||||
return tabs.find((item: any) => item.id == actStatus)
|
||||
}
|
||||
|
||||
// 商家查看优惠券列表
|
||||
const getCouponList = async () => {
|
||||
const { code, data, msg }: any = await actCancel.appMchPage(params)
|
||||
@@ -56,12 +74,10 @@ const getCouponList = async () => {
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
background-position: 150%;
|
||||
background-color: #1879ff77;
|
||||
}
|
||||
.ribbon {
|
||||
width: 160rpx;
|
||||
height: 40rpx;
|
||||
background: #dd0d1f;
|
||||
position: absolute;
|
||||
left: -40rpx;
|
||||
top: 20rpx;
|
||||
|
||||
@@ -4,39 +4,69 @@
|
||||
<view class="card w-full h-400rpx relative activity-card overflow-hidden">
|
||||
<view class="ribbon">兑换券</view>
|
||||
<view class="px-10 py-4 flex justify-between font-bold">
|
||||
<text class="text-32 c-#FFD941">限时领取</text>
|
||||
<text class="text-32 c-#FFD941 px-1 rounded-full bg-#FFD94133">2025-09-21</text>
|
||||
<text class="text-32 c-#FF4F3F">限时领取</text>
|
||||
<text class="text-32 c-#FF4F3F px-1 rounded-full bg-#eeeeee44">2025-09-21</text>
|
||||
</view>
|
||||
<view class="w-2/3 px-10 text-32 c-#fff font-bold">店内消费额外支付1元可领取衣服一件</view>
|
||||
<view class="absolute bottom-60 left-80 text-28 bg-#eeeeee44 c-#fff px-2 rounded-full">限量领取 先到先得</view>
|
||||
<view class="w-4/5 px-10 py-2 text-30 c-#fff">店内消费额外支付1元可领取价值89元的速干T恤1件</view>
|
||||
<view class="absolute bottom-60 left-80 text-28 bg-#eeeeee44 c-#fff px-2 rounded-full">限量领取 先领先得</view>
|
||||
</view>
|
||||
<view v-if="isGet" class="text-center card p-3 sub-text-30">已 领 取</view>
|
||||
<view v-else class="text-center card p-3 sub-text-30" @click="doGetCoupon">立 即 领 取</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed bottom-80rpx left-40rpx">
|
||||
<tm-button class="px-2" size="m" :linear="['to right', '#0779FD', '#62abff']" @click="getActivityQrcode">去支付</tm-button>
|
||||
<view v-if="isGet" class="text-center">
|
||||
<tm-button class="px-2 my-4" @click="CouponVerification">我的核销码</tm-button>
|
||||
</view>
|
||||
</view>
|
||||
</crud-layout>
|
||||
|
||||
<tm-drawer z-index="100" v-model:show="showQrCodeDialog" title="兑换券核销二维码" :show-close="true" position="bottom" size="60%">
|
||||
<view class="flex-col-center">
|
||||
<view class="h-80rpx" />
|
||||
<canvas canvas-id="qrcodeId" class="size-200px" />
|
||||
</view>
|
||||
</tm-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { actCancel } from "@/sheep/api"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import { ref } from "vue"
|
||||
import uqrcode from "@@/utils/uqrcode"
|
||||
import * as CryptoJS from "crypto-js"
|
||||
|
||||
const isGet = ref(false)
|
||||
const isGet = ref(false) // 是否已领取
|
||||
const couponInfo = ref<any>(null)
|
||||
const showQrCodeDialog = ref(false)
|
||||
|
||||
// 立即领取
|
||||
onLoad(() => {
|
||||
getCouponInfo()
|
||||
})
|
||||
|
||||
// 获取优惠券信息
|
||||
const getCouponInfo = async () => {
|
||||
try {
|
||||
uni.showLoading({ title: "加载中...", mask: true })
|
||||
const { code, data }: any = await actCancel.appFindUnique()
|
||||
if (code != 0) {
|
||||
isGet.value = false
|
||||
return
|
||||
}
|
||||
couponInfo.value = data
|
||||
isGet.value = true
|
||||
} catch (error) {
|
||||
uni.showToast({ title: "加载失败", icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
// 领取兑换券
|
||||
const doGetCoupon = async () => {
|
||||
try {
|
||||
uni.showLoading({ title: "正在领取..." })
|
||||
const { code, msg }: any = await actCancel.appGet({})
|
||||
if (code != 0) {
|
||||
isGet.value = true
|
||||
return uni.showToast({ title: msg || "领取失败", icon: "none" })
|
||||
}
|
||||
if (code != 0) return uni.showToast({ title: msg || "领取失败", icon: "none" })
|
||||
uni.showToast({ title: "领取成功", icon: "success" })
|
||||
isGet.value = true
|
||||
await getCouponInfo()
|
||||
} catch (error: any) {
|
||||
uni.showToast({ title: "领取失败", icon: "none" })
|
||||
} finally {
|
||||
@@ -44,18 +74,19 @@ const doGetCoupon = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 去支付
|
||||
const getActivityQrcode = async () => {
|
||||
try {
|
||||
uni.showLoading({ title: "加载中...", mask: true })
|
||||
const { code, data, msg }: any = await actCancel.appFindUnique()
|
||||
if (code != 0) return uni.showToast({ title: msg || "你还未领取兑换券", icon: "none" })
|
||||
uni.navigateTo({ url: `/pages/pay/scanPay?actId=${data.actId}` })
|
||||
} catch (error) {
|
||||
uni.showToast({ title: "加载失败", icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
// 券核销
|
||||
const CouponVerification = async () => {
|
||||
showQrCodeDialog.value = true
|
||||
// const words = CryptoJS.enc.Utf8.parse(JSON.stringify({ actId: couponInfo.value.id, totalPrice: 1 }))
|
||||
const words = CryptoJS.enc.Utf8.parse(JSON.stringify({ actId: "1969324063059877890", totalPrice: 1 }))
|
||||
uqrcode.make({
|
||||
canvasId: "qrcodeId",
|
||||
text: CryptoJS.enc.Base64.stringify(words),
|
||||
size: 200,
|
||||
margin: 0,
|
||||
success: (res) => {},
|
||||
complete: () => {},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -77,14 +77,6 @@ onLoad(async (options: any) => {
|
||||
return
|
||||
}
|
||||
|
||||
const { actId } = options
|
||||
if (!isEmpty(actId)) {
|
||||
amount.value = "1.00"
|
||||
scanPayState.mchName = "活动支付"
|
||||
numberKeyboardShow.value = false
|
||||
return
|
||||
}
|
||||
|
||||
const { id } = options
|
||||
if (!isEmpty(id)) {
|
||||
scanPayState.mchId = id
|
||||
|
||||
+34
-3
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<template #main-top>
|
||||
<view class="flex items-center bg-#ECF4F9 py-3 px-5">
|
||||
<view class="flex items-center py-3 px-5">
|
||||
<image
|
||||
v-if="state.userInfo?.sysUser?.avatar"
|
||||
class="size-100rpx rounded-full"
|
||||
@@ -49,6 +49,16 @@
|
||||
<text @click="doPhone('15657370065')">15657370065</text>
|
||||
</view>
|
||||
</crud-layout>
|
||||
|
||||
<tm-modal :show="state.actModalShow" :showCancel="false" title="兑换券核销" zIndex="999" @confirm="" @cancel="" @close="">
|
||||
<view class="text-center"></view>
|
||||
<template #footer>
|
||||
<view class="w-full flex justify-center gap-6">
|
||||
<tm-button skin="thin" @tap="actModalCancel">取消</tm-button>
|
||||
<tm-button color="primary" @tap="actModalConfirm">确定</tm-button>
|
||||
</view>
|
||||
</template>
|
||||
</tm-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -58,7 +68,7 @@ import { isEmpty } from "radash"
|
||||
import { filePath } from "@@/utils/file"
|
||||
import { getAppInfo } from "@@/utils/app"
|
||||
import { hooks, router, constant } from "@@/index"
|
||||
import { userApi } from "@@/api"
|
||||
import { actCancel, userApi } from "@@/api"
|
||||
import { isDevEnv } from "@/sheep/utils/app"
|
||||
import { APPENV } from "@/sheep/constant"
|
||||
|
||||
@@ -73,6 +83,8 @@ const state = reactive<any>({
|
||||
{ text: "清除缓存", icon: "/static/icon/clear-storage.png", path: "" },
|
||||
],
|
||||
appInfo: "",
|
||||
actModalShow: false,
|
||||
actVal: {},
|
||||
})
|
||||
|
||||
// 常量
|
||||
@@ -252,7 +264,26 @@ const login = {
|
||||
},
|
||||
}
|
||||
|
||||
const { scanCodeAction, processUrlScanResult, processBase64ScanResult } = hooks.useScanCode()
|
||||
// 打开活动核销对话框
|
||||
const actModalShow = (v) => {
|
||||
state.actModalShow = true
|
||||
state.actVal = v
|
||||
}
|
||||
// 确认核销
|
||||
const actModalConfirm = async () => {
|
||||
const { code, msg }: any = await actCancel.appCreateActOrder(state.actVal)
|
||||
if (code != 0) return uni.showToast({ title: msg || "核销失败", icon: "none" })
|
||||
uni.showToast({ title: "核销成功", icon: "success" })
|
||||
state.actModalShow = false
|
||||
state.actVal = {}
|
||||
}
|
||||
// 取消核销
|
||||
const actModalCancel = () => {
|
||||
state.actModalShow = false
|
||||
state.actVal = {}
|
||||
}
|
||||
|
||||
const { scanCodeAction, processUrlScanResult, processBase64ScanResult } = hooks.useScanCode(actModalShow)
|
||||
|
||||
// 扫一扫
|
||||
const appScanCode = async () => {
|
||||
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
params,
|
||||
}),
|
||||
/**
|
||||
* app创建活动订单
|
||||
* app创建活动订单
|
||||
* @param data.actId 活动id
|
||||
* @param data.totalPrice 总金额
|
||||
*/
|
||||
|
||||
@@ -153,7 +153,6 @@ page {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
padding: 0 30rpx;
|
||||
background: #ecf4f9;
|
||||
}
|
||||
|
||||
&_bottom {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { router } from ".."
|
||||
import { APPENV } from "../constant"
|
||||
import { getAppInfo, isDevEnv } from "../utils/app"
|
||||
|
||||
export function useScanCode() {
|
||||
export function useScanCode(actModalShow) {
|
||||
async function scanCodeAction(): Promise<string | undefined> {
|
||||
const appInfo = await getAppInfo()
|
||||
|
||||
@@ -12,8 +12,10 @@ export function useScanCode() {
|
||||
// const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxNDIxNTYwODQzNzQxMTg0MSIsImNhYmluZXRObyI6IjEifQ==" // 测试线上-智能柜-收款二维码
|
||||
// const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 邓本地-测试环境-新县府超市收款二维码
|
||||
// const testQrCode = "eyJoYXJkRG9vcklkIjoiMTkxMzE1NzA4MDQxODI5NTgwOSIsImNhYmluZXRObyI6IjEifQ==" // 邓本地-测试单门智能柜柜门二维码
|
||||
const testQrCode = "http://192.168.101.45:8889/h5/#/pages/pay/scanPay?id=1905816751043452930&name=测试新县府超市" // 邓本地-测试环境-新县府超市收款二维码
|
||||
// const testQrCode = "http://192.168.101.45:8889/h5/#/pages/pay/scanPay?id=1905816751043452930&name=测试新县府超市" // 邓本地-测试环境-新县府超市收款二维码
|
||||
// const testQrCode = "http://192.168.101.45:8889/h5/#/pages/pay/scanPay?hardDoorId=1913157080418295809&cabinetNo=1" // 测试智能柜柜门二维码
|
||||
// const testQrCode = "eyJhY3RJZCI6IjE5NjkyNTAwOTg1MTM4MDUzMTQiLCJ0b3RhbFByaWNlIjoxfQ==" // 测试商户活动核销
|
||||
const testQrCode = "eyJhY3RJZCI6IjE5NjkzMjQwNjMwNTk4Nzc4OTAiLCJ0b3RhbFByaWNlIjoxfQ==" // 测试商户活动核销
|
||||
uni.showModal({ content: "开发环境不是浙政钉和诗画环境,扫码仅供测试" })
|
||||
return Promise.resolve(testQrCode)
|
||||
}
|
||||
@@ -64,14 +66,20 @@ export function useScanCode() {
|
||||
function processBase64ScanResult(scanResult: string) {
|
||||
const decodedString = decodeBase64(scanResult)
|
||||
if (!decodedString) return
|
||||
|
||||
try {
|
||||
const decodedJson = JSON.parse(decodedString)
|
||||
// 商户活动优惠券扫码核销
|
||||
if (decodedJson.actId) {
|
||||
actModalShow({ actId: decodedJson.actId, totalPrice: decodedJson.totalPrice })
|
||||
return
|
||||
}
|
||||
// 商户扫码支付
|
||||
if (decodedJson.id) {
|
||||
router.jump("/pages/pay/scanPay", { id: decodedJson.id })
|
||||
return
|
||||
}
|
||||
if (decodedJson?.hardDoorId && decodedJson?.cabinetNo) {
|
||||
// 智能柜扫码开门
|
||||
if (decodedJson.hardDoorId && decodedJson.cabinetNo) {
|
||||
router.jump("/pages/cabinet/buy", { hardDoorId: decodedJson.hardDoorId, cabinetNo: decodedJson.cabinetNo })
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user