wyling007 il y a 3 ans
Parent
commit
24cfd1d0cc

+ 1 - 26
src/App.vue

@@ -24,7 +24,7 @@
 	}
 	/* 可以设置不同的进入和离开动画   */
 	/* 设置持续时间和动画函数        */
-	/* .slide-left-enter,
+	.slide-left-enter,
 	.slide-right-leave-active {
 		opacity: 0;
 		-webkit-transform: translate(30px, 0);
@@ -35,30 +35,5 @@
 		opacity: 0;
 		-webkit-transform: translate(-30px, 0);
 		transform: translate(-30px, 0);
-	} */
-
-	.slide-right-enter-active,
-	.slide-right-leave-active,
-	.slide-left-enter-active,
-	.slide-left-leave-active {
-		will-change: transform;
-		transition: all 250ms;
-		position: absolute;
-	}
-	.slide-right-enter {
-		opacity: 0;
-		transform: translate3d(-100%, 0, 0);
-	}
-	.slide-right-leave-active {
-		opacity: 0;
-		transform: translate3d(100%, 0, 0);
-	}
-	.slide-left-enter {
-		opacity: 0;
-		transform: translate3d(100%, 0, 0);
-	}
-	.slide-left-leave-active {
-		opacity: 0;
-		transform: translate3d(-100%, 0, 0);
 	}
 </style>

+ 36 - 56
src/api/modules/pay.ts

@@ -7,67 +7,47 @@ import router from "@/route";
 declare let WeixinJSBridge: any;
 
 interface PayConfig {
-  appId: string;
-  timeStamp: string;
-  nonceStr: string;
-  package: string;
-  signType: string;
-  paySign: string;
+	appId: string;
+	timeStamp: string;
+	nonceStr: string;
+	package: string;
+	signType: string;
+	paySign: string;
 }
 
 function onBridgeReady(payConfig: PayConfig) {
-  WeixinJSBridge.invoke(
-    "getBrandWCPayRequest",
-    payConfig,
-    async function (res: any) {
-      if (res.err_msg == "get_brand_wcpay_request:ok") {
-        // 使用以上方式判断前端返回,微信团队郑重提示:
-        //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
-        let userDataRes = await API.userInfo();
-        store.commit("setUserData", {
-          ...store.getters.getUserData,
-          expireTime: userDataRes.data.data.expireTime,
-        });
-        Toast.success("支付成功");
-        router.push("/home/test");
-      }
-    }
-  );
+	WeixinJSBridge.invoke("getBrandWCPayRequest", payConfig, async function (res: any) {
+		if (res.err_msg == "get_brand_wcpay_request:ok") {
+			// 使用以上方式判断前端返回,微信团队郑重提示:
+			//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+			let userDataRes = await API.userInfo();
+			store.commit("setUserData", {
+				...store.getters.getUserData,
+				expireTime: userDataRes.data.data.expireTime,
+			});
+			Toast.success("支付成功");
+			router.push("/home/test");
+		}
+	});
 }
 
 /**
  * 获取支付配置,并调起微信支付
  */
 export async function prepareOrder(dictCode: number) {
-  let res = await request({
-    url: "/student/wx/prepareOrder",
-    method: "post",
-    data: {
-      dictCode,
-    },
-  });
-
-  if (res.data.code === 200) {
-    if (typeof WeixinJSBridge !== "undefined") {
-      onBridgeReady(res.data.data);
-    }
-  }
-}
-
-/**
- * 循环支付,并调起微信支付
- */
-export async function loopPrepareOrder() {
-  let res = await request({
-    url: "/student/wx/prepareOrder-test",
-    method: "post",
-  });
-
-  if (res.data.code === 200) {
-    if (typeof WeixinJSBridge !== "undefined") {
-      onBridgeReady(res.data.data);
-    }
-  }
+	let res = await request({
+		url: "/student/wx/prepareOrder",
+		method: "post",
+		data: {
+			dictCode,
+		},
+	});
+
+	if (res.data.code === 200) {
+		if (typeof WeixinJSBridge !== "undefined") {
+			onBridgeReady(res.data.data);
+		}
+	}
 }
 
 /**
@@ -75,9 +55,9 @@ export async function loopPrepareOrder() {
  * @returns
  */
 export async function getVipPrice() {
-  const res = await request({
-    url: `/system/dict/data/type/vip_type_price`,
-  });
+	const res = await request({
+		url: `/system/dict/data/type/vip_type_price`,
+	});
 
-  return res.data;
+	return res.data;
 }

+ 3 - 11
src/hooks/index.ts

@@ -19,6 +19,9 @@ export const useLogin = async (query: LocationQuery) => {
 export const useUpdateUserInfo = async () => {
 	//获取用户信息
 	const userDataRes = await API.userInfo();
+	if (userDataRes.data.code !== 200) {
+		throw userDataRes.data.msg;
+	}
 	store.commit("setUserData", {
 		...store.getters.getUserData,
 		...userDataRes.data.data,
@@ -47,17 +50,6 @@ export const useProfitPrice = () => {
 	};
 };
 
-/** 判断是不是zhangbing的openapi */
-export const useOpenIdIsZhangbing = () => {
-	const store = useStore();
-	const openid = computed(() => store.getters.getUserData.openid);
-	const userOpenidArr = ["ovKTX50v7OAEPI_ERofpUvrNQCJU", "ovKTX5-FKLF6_sgTtCIXpG_lz3PY", "ovKTX5zYvp9OXE43ADwLa1RHna0g"];
-	const isZhangbing = userOpenidArr.includes(openid.value);
-	return {
-		isZhangbing,
-	};
-};
-
 export const useSound = (videoSrc: string) => {
 	const sound = new Howl({
 		autoplay: true,

+ 1 - 4
src/route/guard.ts

@@ -36,10 +36,7 @@ const guard = (router: Router) => {
 		}
 		//检测token状态,token失效直接跳转至登陆链接
 		try {
-			const authTest = await userInfo();
-			if (authTest.data.code !== 200) {
-				throw authTest.data.msg;
-			}
+			useUpdateUserInfo();
 		} catch (error) {
 			//监听到登陆事件
 			if (to.query.state === "LOGIN") {

+ 2 - 2
src/views/cashOut/components/cashout.ts

@@ -1,8 +1,8 @@
 import { mountComponent, useUnmountComponent } from "@/utils/mount-component";
 import cashout from "./cashout.vue";
 
-export const showCashout = () => {
-	const { unmount } = mountComponent(cashout);
+export const showCashout = (callback: () => any) => {
+	const { unmount } = mountComponent(cashout, { callback });
 	return {
 		unmount,
 	};

+ 4 - 2
src/views/cashOut/components/cashout.vue

@@ -4,7 +4,7 @@
 			<div class="block">
 				<Form @submit="handleCashout">
 					<CellGroup inset>
-						<Field v-model="amount" label="提现金额()" type="number" placeholder="请输入提现金额" />
+						<Field v-model="amount" label="提现金额()" type="number" placeholder="请输入提现金额" />
 					</CellGroup>
 					<div class="submit-box">
 						<Button :loading="loading" :disabled="!amount" type="primary" hairline native-type="submit" loading-text="结算中..."> 提现 </Button>
@@ -29,7 +29,7 @@
 				return false;
 			}
 			loading.value = true;
-			const data = await cashOutModel.cashout(amount.value);
+			const data = await cashOutModel.cashout(amount.value * 100);
 			loading.value = false;
 			if (data.code === 200) {
 				Toast.success("提现成功");
@@ -53,6 +53,7 @@
 	import { useUpdateUserInfo } from "@/hooks";
 	const props = defineProps<{
 		unmount: () => void;
+		callback: () => any;
 	}>();
 
 	const { amount, loading, cashout } = useCashout();
@@ -61,6 +62,7 @@
 		if (await cashout()) {
 			props.unmount();
 			useUpdateUserInfo();
+			props.callback();
 		}
 	};
 </script>

+ 7 - 4
src/views/cashOut/index.vue

@@ -12,7 +12,7 @@
 					>
 				</div>
 			</div>
-			<m-button @click="showCashout" class="continue" width="90px" height="30px" text="我要提现" />
+			<m-button @click="showCashout(updateExtractList)" class="continue" width="90px" height="30px" text="我要提现" />
 		</div>
 	</div>
 	<div class="summary content-box">
@@ -53,13 +53,16 @@
 
 		const extractList = ref<Array<ExtractType>>([]);
 
-		onBeforeMount(async () => {
+		const updateExtractList = async () => {
 			const extractListRes = await cashOutModel.extractList();
 			extractList.value = extractListRes.rows;
-		});
+		};
+
+		onBeforeMount(updateExtractList);
 
 		return {
 			extractList,
+			updateExtractList,
 		};
 	};
 </script>
@@ -70,7 +73,7 @@
 	const searchValue = ref("");
 
 	const { profitPrice } = useProfitPrice();
-	const { extractList } = useExtract();
+	const { extractList, updateExtractList } = useExtract();
 </script>
 
 <style scoped lang="scss">

+ 3 - 10
src/views/home/children/user/index.vue

@@ -1,6 +1,6 @@
 <template>
 	<div class="user">
-		<van-cell label="未绑定手机号" is-link center @click="showVConsole">
+		<van-cell label="" is-link center @click="showVConsole">
 			<template #icon>
 				<m-user-avatar class="user-avatar" />
 			</template>
@@ -31,11 +31,6 @@
 			</van-cell>
 		</van-cell-group>
 		<van-cell-group class="group">
-			<van-cell title="0.01捐款(内部专用)" is-link center @click="loopPrepareOrder" v-if="isZhangbing">
-				<template #icon>
-					<m-icon type="bbgx" class="cell-icon" />
-				</template>
-			</van-cell>
 			<van-cell title="反馈帮助" is-link center url="https://support.qq.com/product/359609">
 				<template #icon>
 					<m-icon type="fkbz" class="cell-icon" />
@@ -46,12 +41,11 @@
 </template>
 
 <script lang="ts">
-	import { useExpireTime, RouterBus, useOpenIdIsZhangbing } from "@/hooks";
+	import { useExpireTime, RouterBus } from "@/hooks";
 	import VConsole from "vconsole";
 </script>
 
 <script lang="ts" setup>
-	import { loopPrepareOrder } from "@/api";
 	const { expireTime } = useExpireTime();
 	const { goBuyVip, goCashOut, goMyBranch, goMyIntegral } = new RouterBus();
 	let doubleClickNumber = 0;
@@ -59,10 +53,9 @@
 		if (doubleClickNumber !== 9) {
 			doubleClickNumber = (doubleClickNumber + 1) % 10;
 		} else {
-			let vconsole = new VConsole();
+			new VConsole();
 		}
 	};
-	const { isZhangbing } = useOpenIdIsZhangbing();
 </script>
 
 <style scoped lang="scss">