This commit is contained in:
dzc committed 2024-11-11 14:42:47 +08:00
commit 7d450caf77
146 files changed
+39809

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import dayjs from "dayjs"
import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
const state = reactive<any>({
})
const applyForm = reactive<any>({
displayTimeRange: "",
displayTimeRangeStr: "",
count: 1,
remark: "",
})
const applyFormRules = reactive<any>({
displayTimeRangeStr: [
{ required: true, message: '请选择使用时间' }
],
count: [
{ required: true, message: '请输入申请数量' },
{ required: true, min: 1, message: '最少申请1张' },
{ required: true, max: 20, message: '最多申请20张' },
]
})
onLoad(() => {
});
onShow(() => {
})
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
try {
uni.showLoading({ title: '申请中...', mask: false });
const _pa = {
applyStartTime: dayjs(range[0]).valueOf(),
applyEndTime: dayjs(range[1]).valueOf(),
count: applyForm.count,
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.foreignApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: '申请成功', icon: "none" });
router.back()
} catch (error) {
console.error(error);
uni.hideLoading()
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="displayTimeRangeStr" label="使用时间" :showBottom="false">
<tm-between-time start="2020-1-1" end="2030-1-1" v-model="applyForm.displayTimeRange"
v-model:model-str="applyForm.displayTimeRangeStr" format="YYYY-MM-DD">
<view style="pointer-events: none;">
<tm-input v-model="applyForm.displayTimeRangeStr" disabled placeholder="请选择使用时间..">
<template v-slot:rightIcon>
<text class="p-0.5rem color-#b1b1b1 iconfont icon-xiangxiajiantouxiao"></text>
</template>
</tm-input>
</view>
</tm-between-time>
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input v-model="applyForm.count" type="number" showClear placeholder="请输入申请数量.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input v-model="applyForm.remark" type="textarea" showClear placeholder="请输入备注.."></tm-input>
</tm-form-item>
</tm-form>
<view class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
提交
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
+72
View File
@@ -0,0 +1,72 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from 'radash'
import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
const data = {
tabs: ['待审核', '已通过', '已拒绝'],
}
const state = reactive<any>({
pa: {
id: null,
pagesize: 99,
},
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, applyApi.foreignItems, null, 'data')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.pa.id = options.id
}
});
onShow(() => {
})
const doTab = (e: any) => {
if (state.pa.status != e + 1) {
state.pa.status = e + 1
pageRef.value.reload(true)
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<template #top>
<view class="h-30rpx" />
</template>
<view class="flex-col card p-x-20rpx p-y-30rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i">
<view class="flex-row items-center justify-between">
<view class="">
<tm-tag v-if="v.status == 1" size="m" color="info">未使用</tm-tag>
<tm-tag v-if="v.status == 2" size="m" color="success">已使用</tm-tag>
<view class="m-t-10rpx sub-text-26">
<text>{{ v.userNameStr }}</text>
<text class="m-l-10rpx">{{ v.userMobile }}</text>
</view>
</view>
<image class="w-100rpx h-100rpx" :src="v.code" mode="aspectFill" />
</view>
</view>
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+97
View File
@@ -0,0 +1,97 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
const data = {
tabs: ['待审核', '已通过', '已拒绝'],
}
const state = reactive<any>({
pa: {
status: 1,
},
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, applyApi.foreignList, null, 'data.list')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
onLoad(() => {
});
onShow(() => {
pageRef.value.reload(false)
})
const doTab = (e: any) => {
if (state.pa.status != e + 1) {
state.pa.status = e + 1
pageRef.value.reload(true)
}
}
const doApply = async () => {
router.jump("/pages/apply/foreign-apply")
}
const doCard = (v: any) => {
if (v.status == 2) {
router.jump("/pages/apply/foreign-items", { id: v.id })
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<template #top>
<view class="h-30rpx" />
<view class="bg-white rounded-16rpx px-20rpx">
<z-tabs :list="data.tabs" @change="doTab" />
</view>
</template>
<view class="h-20rpx" />
<view class="flex-col card p-x-20rpx p-y-30rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i"
@tap="doCard(v)">
<view class="flex-row items-center justify-between">
<view class="sub-text-28">电子餐券</view>
<view class="sub-text-24">{{ hooks.useTime(v.createTime, "") }}</view>
</view>
<view class="sub-text-24">
<view class="m-t-20rpx">
<text>有效期</text>
<text class="m-l-10rpx">
{{ hooks.useTime(v.applyStartTime, " {y}-{m}-{d}") }}
~
{{ hooks.useTime(v.applyEndTime, "{y}-{m}-{d}") }}
</text>
</view>
<view class="m-t-20rpx">
<text>数量</text>
<text class="m-l-10rpx">{{ v.count }}</text>
</view>
</view>
</view>
<template #bottom>
<view
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doApply">
申请
</view>
<view class="h-30rpx" />
</template>
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+69
View File
@@ -0,0 +1,69 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
const state = reactive<any>({
})
const applyForm = reactive<any>({
remark: "",
})
const applyFormRules = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
})
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
try {
uni.showLoading({ title: '申请中...', mask: false });
const _pa = {
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.strideApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: '申请成功', icon: "none" });
router.back()
} catch (error) {
console.error(error);
uni.hideLoading()
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input v-model="applyForm.remark" type="textarea" showClear placeholder="请输入备注.."></tm-input>
</tm-form-item>
</tm-form>
<view class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
提交
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
+71
View File
@@ -0,0 +1,71 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
const data = {
tabs: ['待审核', '已通过', '已拒绝'],
}
const state = reactive<any>({
pa: {
status: 1,
},
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, applyApi.strideList, null, 'data.list')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
onLoad(() => {
});
onShow(() => {
})
const doTab = (e: any) => {
if (state.pa.status != e + 1) {
state.pa.status = e + 1
pageRef.value.reload(true)
}
}
const doApply = async () => {
router.jump("/pages/apply/stride-apply")
}
</script>
<template>
<crud-layout title="跨单位就餐" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<template #top>
<view class="h-30rpx" />
<view class="bg-white rounded-16rpx px-20rpx">
<z-tabs :list="data.tabs" @change="doTab" />
</view>
</template>
<view class="flex-col card p-x-20rpx p-y-30rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i">
</view>
<template #bottom>
<view
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doApply">
申请
</view>
<view class="h-30rpx" />
</template>
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks } from "@@/index"
import { merchantApi } from "@@/api"
const state = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, merchantApi.merchantList, null, 'data')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
</script>
<template>
<crud-layout>
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks } from "@@/index"
import { merchantApi } from "@@/api"
const state = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, merchantApi.merchantList, null, 'data')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
</script>
<template>
<crud-layout>
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+122
View File
@@ -0,0 +1,122 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash";
import { hooks, router, constant } from "@@/index"
import { merchantApi, userApi, walletApi } from "@@/api"
const data = {
serviceList: [
{ text: '钱包管理', icon: '/static/icon/service_3.png', router: '/pages/wallet/list' },
{ text: '车牌管理', icon: '/static/icon/service_2.png', router: '/pages/user/diff-price' },
{ text: '外来人员就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/foreign-list' },
{ text: '跨单位就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/stride-list' },
]
};
const state = reactive<any>({
wallet: [],
userInfo: {}
})
onLoad(() => {
});
onShow(() => {
getUserInfo()
})
const getUserInfo = () => {
const userInfoKey = constant.storageConstant.USERINFO
const userStorage = uni.getStorageSync(userInfoKey)
if (!isEmpty(userStorage)) {
state.userInfo = userStorage
}
}
const doLogin = async () => {
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
const tokenStorage = uni.getStorageSync(tokenKey)
const userStorage = uni.getStorageSync(userInfoKey)
if (isEmpty(tokenStorage) || isEmpty(userStorage)) {
uni.showLoading({
title: '登录中...',
mask: true
});
const { data: authData } = await userApi.auth("test");
uni.setStorageSync(tokenKey, authData)
const { data: userData } = await userApi.userInfo();
uni.setStorageSync(userInfoKey, userData)
getUserInfo()
uni.hideLoading()
uni.showToast({ title: '登录成功', icon: "none" });
}
}
const doLogout = async () => {
uni.showLoading({
title: '退出登录中...',
mask: true
});
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
uni.removeStorageSync(tokenKey)
uni.removeStorageSync(userInfoKey)
state.userInfo = {}
uni.hideLoading()
uni.showToast({ title: '退出登录成功', icon: "none" });
}
</script>
<template>
<crud-layout title="我的" bg="/static/page/blue-bg.png">
<view class="flex-row items-center">
<image class="w-100rpx h-100rpx rounded-full" v-if="state.userInfo.avatar" :src="state.userInfo.avatar"
mode="aspectFill" />
<image class="w-100rpx h-100rpx rounded-full" v-else src="/static/icon/default-avatar.png"
mode="aspectFill" />
<view class="m-l-30rpx" v-if="state.userInfo.id">
<view class="flex-row items-center">
<text class="sub-text-30">{{ state.userInfo.nickname }}</text>
<text class="iconfont icon-youjiantou color-#666666 m-l-20rpx"></text>
</view>
<text class="sub-text-26">ID {{ state.userInfo.id }}</text>
</view>
<view v-else class="flex-row items-center m-l-30rpx" @tap="doLogin">
<text class="sub-text-32">请先登录</text>
<text class="iconfont icon-youjiantou"></text>
</view>
</view>
<view class="m-t-40rpx rounded-20rpx shadow-main p-30rpx p-b-40rpx bg-white!">
<view class="main-text-30 m-b-35rpx">我的服务</view>
<view class="service_item flex-row items-center justify-between" v-for="(v, i) in data.serviceList" :key="i"
@tap="router.jump(v.router)">
<view class="flex-row-center">
<image class="w-40rpx h-40rpx" :src="v.icon" mode="aspectFill" />
<text class="sub-text-28 m-l-20rpx">{{ v.text }}</text>
</view>
<view class="iconfont icon-youjiantou"></view>
</view>
</view>
<view class="flex-col-center m-t-40rpx m-x-30rpx">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff"
@tap="doLogout">
退出登录
</view>
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
.service_item:not(:last-child) {
padding-bottom: 40rpx;
border-bottom: 1px solid #fafafa;
margin-bottom: 40rpx;
}
</style>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks } from "@@/index"
import { merchantApi } from "@@/api"
const state = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, merchantApi.merchantList, null, 'data')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
</script>
<template>
<crud-layout>
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+80
View File
@@ -0,0 +1,80 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash"
import { hooks } from "@@/index"
import { walletApi } from "@@/api"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
const data = {
tabs: ['全部', '收入', '支出'],
}
const state = reactive<any>({
walletId: null,
pa: {
createTime: null,
type: 0,
walletId: null
},
})
onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.walletId = options.id
state.pa.walletId = options.id
}
});
onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, walletApi.transaction, null, 'data.list')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
const doTab = (e: any) => {
if (state.pa.type != e) {
state.pa.type = e
pageRef.value.reload(true)
}
}
</script>
<template>
<crud-layout title="饭卡" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<view class="h-30rpx" />
<view class="bg-white rounded-16rpx px-20rpx">
<z-tabs :list="data.tabs" @change="doTab" />
</view>
<view class="h-20rpx" />
<view class="flex-row items-center justify-between card p-x-20rpx p-y-30rpx m-b-20rpx"
v-for="(v, i) in pageHook.list" :key="i">
<view class="flex">
<view class="w-150rpx flex justify-left p-r-25rpx">
<tm-tag v-if="v.title == '更新余额'" size="m">{{ v.title }}</tm-tag>
<tm-tag v-if="v.title == '支付'" color="error" size="m">支付交易</tm-tag>
<tm-tag v-if="v.title == '支付退款'" color="info" size="m">{{ v.title }}</tm-tag>
</view>
<view class="flex-row-center">
<text class="sub-text-30">{{ v.price }}</text>
</view>
</view>
<view class="sub-text-24 text-right">
{{ hooks.useTime(v.createTime, "") }}
</view>
</view>
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped></style>
+164
View File
@@ -0,0 +1,164 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash"
import { hooks, router } from "@@/index"
import { merchantApi, walletApi } from "@@/api"
const state = reactive<any>({
showBindDialog: false,
showFreezeDialog: false,
currentCard: {}
})
const bindForm = reactive<any>({
cardNumber: ""
})
const bindFormRules = reactive<any>({
cardNumber: [
{ required: true, message: '请输入卡号' },
{ required: true, min: 8, message: '饭卡长度在8位' },
{ required: true, max: 8, message: '饭卡长度在8位' },
]
})
const freezeForm = reactive<any>({
remark: ""
})
onLoad(() => {
});
onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, walletApi.all, null, 'data')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
const openBindDialog = (v: any) => {
state.showBindDialog = true
state.currentCard = v
}
const closeBindDialog = () => {
state.showBindDialog = false
}
const bindFormRef = ref<any>(null)
const doBind = async () => {
bindFormRef.value.submit()
const { isPass } = bindFormRef.value.validate()
if (!isPass) return
try {
uni.showLoading({ title: '绑定中...', mask: false });
const _pa = {
walletId: state.currentCard.id,
cardNumber: bindForm.cardNumber,
}
const { data, code }: any = await walletApi.bind(_pa)
if (code != 0) throw new Error()
closeBindDialog()
pageRef.value.reload(true)
uni.hideLoading()
uni.showToast({ title: '绑定成功', icon: "none" });
} catch (error) {
console.error(error);
uni.hideLoading()
}
}
const openFreezeDialog = (v: any) => {
state.showFreezeDialog = true
state.currentCard = v
}
const closeFreezeDialog = () => {
state.showFreezeDialog = false
}
const doFreeze = async () => {
try {
uni.showLoading({ title: '申请中...', mask: false });
const _pa = {
walletId: state.currentCard.id,
remark: freezeForm.remark,
}
const { data, code }: any = await walletApi.freeze(_pa)
if (code != 0) throw new Error()
closeFreezeDialog()
pageRef.value.reload(true)
uni.hideLoading()
uni.showToast({ title: '申请成功', icon: "none" });
} catch (error) {
console.error(error);
uni.hideLoading()
}
}
</script>
<template>
<crud-layout title="钱包" bg="/static/page/blue-bg.png">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="5"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<view class="h-30rpx" />
<view v-for="(v, i) in pageHook.list" :key="i" @tap="router.jump('/pages/wallet/detail', { id: v.id })">
<view class="flex-col rounded-20rpx p-x-20rpx p-y-30rpx m-b-30rpx bg-#222222">
<view class="flex-row items-center justify-between">
<view class="flex-row items-center">
<image class="w-52rpx h-52rpx" src="/static/icon/vip.png" mode="aspectFill" />
<text class="m-l-25rpx main-text-32 color-#fbddb0!">
{{ v.walletTypeStr }}
</text>
<text v-if="v.cardNumber" class="m-l-25rpx main-text-32 color-#fbddb0!">
{{ v.cardNumber }}
</text>
</view>
<view class="underline sub-text-28 color-#fbddb0!"
@tap.stop="router.jump('/pages/wallet/recharge', { id: v.id })">
去充值
</view>
</view>
<view class="flex-row items-center justify-between m-t-30rpx">
<text class="main-text-32 color-#fbddb0!">
余额 ¥{{ hooks.useMoney(v.balance) }}
</text>
<text v-if="v.walletTypeCode == 1 && !v.cardNumber"
class="iconfont icon-bangding color-#fbddb0!" @tap.stop="openBindDialog(v)" />
<text v-if="v.walletTypeCode == 1 && v.cardNumber" class="iconfont icon-jiebang color-#fbddb0!"
@tap.stop="openFreezeDialog(v)" />
</view>
</view>
</view>
</z-paging>
</crud-layout>
<tm-drawer z-index="100" v-model:show="state.showBindDialog" :overlayClick="false" title="绑定饭卡" :show-close="true"
position="bottom" size="40%">
<view class="h-50rpx" />
<tm-form ref="bindFormRef" v-model="bindForm" :rules="bindFormRules">
<tm-form-item name="cardNumber" :showLabel="false" :showBottom="false">
<tm-input v-model="bindForm.cardNumber" showClear placeholder="请输入卡号.." />
</tm-form-item>
</tm-form>
<view class="h-50rpx" />
<view class="bg-#0094ff p-y-20rpx text-center rounded-40rpx sub-text-30 color-white!" @tap="doBind">
绑定
</view>
</tm-drawer>
<tm-drawer z-index="100" v-model:show="state.showFreezeDialog" :overlayClick="false" title="申请冻结" :show-close="true"
position="bottom" size="40%">
<view class="h-50rpx" />
<tm-form ref="bindFormRef" v-model="freezeForm">
<tm-form-item name="remark" :showLabel="false" :showBottom="false">
<tm-input v-model="freezeForm.remark" type="textarea" showClear placeholder="请输入备注.." />
</tm-form-item>
</tm-form>
<view class="h-50rpx" />
<view class="bg-#0094ff p-y-20rpx text-center rounded-40rpx sub-text-30 color-white!" @tap="doFreeze">
冻结
</view>
</tm-drawer>
</template>
<style lang="scss" scoped></style>
+172
View File
@@ -0,0 +1,172 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash"
import { hooks, constant } from "@@/index"
import { walletApi, payApi } from "@@/api"
const data = {
payType: [
{ text: "模拟支付", disabled: false, type: 0, value: "mock" },
{ text: "微信支付", disabled: true, type: 1, value: "wx_pub" },
{ text: "支付宝支付", disabled: true, type: 2, value: "alipay_wap" },
]
}
const state = reactive<any>({
walletId: null,
currentPayType: 0,
currentRecharge: -1,
userInfo: {},
detail: {},
rechargeList: []
})
onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.walletId = options.id
}
});
onShow(() => {
getUserInfo()
getDetail()
getRechargeList()
})
const getDetail = async () => {
const _pa = { walletTypeId: state.walletId }
const { data } = await walletApi.detail(_pa)
state.detail = data
}
const getUserInfo = () => {
const userInfoKey = constant.storageConstant.USERINFO
const userStorage = uni.getStorageSync(userInfoKey)
if (!isEmpty(userStorage)) {
state.userInfo = userStorage
}
}
const getRechargeList = async () => {
const _pa = {}
const { data } = await walletApi.rechargeList(_pa)
state.rechargeList = data
}
const doPay = async () => {
if (state.currentRecharge == -1) {
uni.showToast({ title: '请选择充值金额', icon: "none" });
return
}
try {
uni.showLoading({ title: '充值中...', mask: true });
const targetRecharge = state.rechargeList[state.currentRecharge]
const targetPayType = data.payType[state.currentPayType]
if (isEmpty(targetRecharge)) throw new Error()
const _pa = {
payPrice: targetRecharge.payPrice,
walletId: state.walletId,
packageId: targetRecharge.id,
}
const { data: createData, code: createCode }: any = await walletApi.recharge(_pa)
console.log(createCode, "createCode");
if (createCode != 0) throw new Error()
const _payPa = {
id: createData.payOrderId,
walletId: state.walletId,
channelCode: targetPayType.value,
channelExtras: {},
}
const { data: payData, code: payCode }: any = await payApi.submitOrder(_payPa)
if (payCode != 0) throw new Error()
state.currentPayType = 1
state.currentRecharge = -1
getDetail()
uni.hideLoading()
uni.showToast({ title: '充值成功', icon: "none" });
} catch (error) {
console.error(error);
uni.hideLoading()
uni.showToast({ title: '充值失败', icon: "none" });
}
}
</script>
<template>
<crud-layout title="充值" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="flex-row items-center justify-between h-120rpx p-x-30rpx bg-#222222 rounded-20rpx">
<view class="flex-row items-center">
<image class="w-52rpx h-52rpx" src="/static/icon/vip.png" mode="aspectFill" />
<text class="m-l-25rpx main-text-32 color-#fbddb0!">
{{ state.detail.walletTypeStr }}
</text>
</view>
<view class="main-text-28 color-#fbddb0!">
¥{{ hooks.useMoney(state.detail.balance) }}
</view>
</view>
<view class="prefix_title m-t-35rpx">充值</view>
<view class="recharge p-30rpx bg-white rounded-20rpx m-t-20rpx shadow-main">
<view :class="[state.currentRecharge == i ? 'recharge_item_active' : '']" class="recharge_item"
v-for="(v, i) in state.rechargeList" :key="i" @tap="state.currentRecharge = i">
<text class="sub-text-30 text-center">¥{{ hooks.useMoney(v.payPrice) }}</text>
</view>
</view>
<view class="prefix_title m-t-35rpx">支付</view>
<view class="p-30rpx p-b-40rpx bg-white rounded-20rpx m-t-20rpx shadow-main">
<tm-radio-group direction="column" gap="40" v-model="state.currentPayType">
<tm-radio :disabled="v.disabled" v-for="(v, i) in data.payType" :key="i" :value="v.type"
:label="v.text" />
</tm-radio-group>
</view>
<view class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doPay">
确认充值
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
.prefix_title {
font-size: 28rpx;
font-weight: 800;
color: #333;
&::before {
content: '';
display: inline-block;
width: 8rpx;
height: 24rpx;
background: #0094ff;
border-radius: 4rpx;
margin-right: 10rpx;
}
}
.recharge_item_active {
background: #e9f5fe;
border: 1px solid #e9f5fe !important;
&>text {
color: #0094ff !important;
}
}
.recharge {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20rpx;
border-bottom: 1px solid #f9f9f9;
&_item {
display: flex;
flex-direction: column;
border: 1px solid #cccccc;
border-radius: 16rpx;
padding: 20rpx 0;
}
}
</style>