feat:更新

This commit is contained in:
dengtongyu committed 2023-04-21 01:08:58 +08:00
1 parent 4d4dbe4cd9
commit fb09018f1e
7 files changed
+29 -15

No files matched your search

+2 -2
View File
@@ -9,10 +9,10 @@ switch (VITE_APP_ENV) {
proxyTarget = "http://apibeta.haloapp.vip";
break;
case "prod":
proxyTarget = "http://apibeta.haloapp.vip";
proxyTarget = "https://api.xingyuwenhua.com.cn";
break;
default:
proxyTarget = "http://apibeta.haloapp.vip";
proxyTarget = "http://api.xingyuwenhua.com.cn";
break;
}
+2
View File
@@ -17,12 +17,14 @@
"dependencies": {
"axios": "^0.27.2",
"pinia": "^2.0.19",
"qs": "^6.11.1",
"vant": "^4.2.0",
"vue": "^3.2.37",
"vue-router": "^4.1.3"
},
"devDependencies": {
"@types/node": "^18.11.18",
"@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@vitejs/plugin-legacy": "^2.0.1",
+3 -1
View File
@@ -1,6 +1,8 @@
<script setup lang="ts" name="App">
import Home from "@/pages/Home.vue";
</script>
<template>
<router-view />
<!-- <router-view /> -->
<Home />
</template>
+4 -4
View File
@@ -1,17 +1,17 @@
import ajax from "../lib/ajax";
// import { passid } from "../../config";
import { stringify } from "qs";
const chargeprodList = function (param?: any) {
const params = Object.assign({channelType: 2}, param || {});
return ajax.get("/chargeprod/list", { params });
};
const chargeUser = function (param: any) {
return ajax.get("/user/getChargeUser", { params: param });
const chargeUser = function (param: any, config?:any) {
return ajax.get("/user/getChargeUser", { params: param, ...config });
};
const submitPay = function (param: any) {
return ajax.post("/wx/submitPay", param);
return ajax.post("/wx/submitPay", stringify(param));
};
export {
+2 -2
View File
@@ -1,5 +1,5 @@
import { createApp } from "vue";
import routes from "./routes";
// import routes from "./routes";
import App from "./App.vue";
import pinia from "./store/pinia";
import { install } from "./installComponents";
@@ -7,7 +7,7 @@ import "./styles/index.less";
const app = createApp(App);
app.use(pinia);
app.use(routes);
// app.use(routes);
install(app);
app.mount("#app");
+4 -3
View File
@@ -7,6 +7,7 @@ import { getQueryString } from "@/lib/util";
const payStore = pay(pinia);
const locateObj = getQueryString();
// console.log("locateObj", locateObj);
const { openId, data, channel } = locateObj;
const searchKeyword = ref<string>("");
@@ -36,11 +37,12 @@ const selectHandler = (index: number) => {
};
const regUser = /^\d{7}$/;
const regUser = /^[0-9]*$/;
const regPhone = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
const searchHandler = () => {
const keyword = searchKeyword.value;
if(!keyword) return;
// console.log(keyword, regUser.test(keyword), regPhone.test(keyword));
if (regUser.test(keyword) || regPhone.test(keyword)) {
payStore.getChargeUser(keyword);
@@ -95,9 +97,8 @@ const payHandler = () => {
const confirmHandler = () => {
const data:any = {};
const isPhone = regPhone.test(searchKeyword.value);
const isUserId = regUser.test(searchKeyword.value);
if(isPhone) data.phone = searchKeyword.value;
if(isUserId) data.erban_no = searchKeyword.value;
else data.erban_no = userInfoErbanNo.value;
payStore.payRequest(data);
};
+12 -3
View File
@@ -3,6 +3,9 @@ import { defineStore } from "pinia";
import { showNotify, showToast } from "vant";
import { chargeprodList, chargeUser, submitPay } from "@/api/index";
import { onBridgeReady } from "@/wx/index";
import axios from "axios";
const CancelToken = axios.CancelToken;
let source = CancelToken.source();
const pay = defineStore("pay", () => {
@@ -12,7 +15,7 @@ const pay = defineStore("pay", () => {
const initParams = (data:any) => {
openId.value = data.openId || "";
dataId.value = data.dataId || "";
dataId.value = data.data || "";
channel.value = data.channel || "";
};
@@ -54,14 +57,16 @@ const pay = defineStore("pay", () => {
const getChargeUser = (erbanNo: string | number) => {
source.cancel("getChargeUser canceled");
source = CancelToken.source();
return new Promise((resolve, reject) => {
chargeUser({ erbanNo: erbanNo })
chargeUser({ erbanNo: erbanNo }, { cancelToken: source.token })
.then((res: any) => {
const { code, data, message } = res;
if (code === 200) {
receiveUser.value = data;
} else if (code === 1404) {
showNotify({ type: "warning", message: "您输入的账号不存在" });
// showNotify({ type: "warning", message: "您输入的账号不存在" });
}
else {
showNotify({ type: "warning", message: message });
@@ -69,7 +74,11 @@ const pay = defineStore("pay", () => {
resolve(res);
})
.catch((err: any) => {
if (axios.isCancel(err)) {
console.info("Request canceled", err.message);
}else{
reject(err);
}
});
});
};