1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import { ref, reactive } from "vue";
- import { payment } from "@/services/ams";
- let isBtn = ref(true);
- const appid = uni.getStorageSync("appid");
- export function useDraw(props?: any, emit?: any) {
- const handleClose = () => {
- emit("update:show", false);
- };
- const isWithDraw = (status: string) => {
- return status === "3" || status === "5" || status === "6";
- };
- const onPayment = (data: any, type: string) => {
- if (!isWithDraw(data.processStatus)) return;
- if (!isBtn.value) return;
- isBtn.value = false;
- const status =
- data.processStatus === "3" ||
- data.processStatus === "5" ||
- data.processStatus === "6";
- if (!status) return;
- payment(data.id)
- .then((res: any) => {
- if (res.code === 500) {
- uni.showToast({ icon: "none", title: "提现中" });
- return;
- }
- if (
- wx.canIUse("requestMerchantTransfer") &&
- res.data &&
- res.data.packageInfo
- ) {
- wx.requestMerchantTransfer({
- mchId: res.data.merchantId,
- appId: appid,
- package: res.data.packageInfo,
- success: (response: any) => {
- uni.showToast({ icon: "success", title: "请求成功" });
- if (type === "1") {
- setTimeout(() => {
- uni.switchTab({
- url: "/pages/my/index",
- });
- }, 500);
- } else {
- handleClose();
- }
- },
- fail: (response: any) => {
- // uni.showToast({ icon: "none", title: "提现中" });
- },
- });
- } else {
- if (!res.data || !res.data.packageInfo) {
- uni.showToast({ icon: "none", title: "提现中" });
- } else {
- wx.showModal({
- content: "你的微信版本过低,请更新至最新版本。",
- showCancel: false,
- });
- }
- }
- })
- .catch((err) => {
- console.log("-----------------------");
- uni.showToast({ icon: "none", title: err.msg });
- });
- setTimeout(() => {
- isBtn.value = true;
- }, 1500);
- };
- return { handleClose, onPayment, isWithDraw };
- }
|