diff --git a/.env b/.env index 74c8a35..2c79874 100644 --- a/.env +++ b/.env @@ -16,7 +16,8 @@ VITE_PWD_ENC_KEY='pigxpigxpigxpigx' # OAUTH2 APP模式客户端信息 VITE_OAUTH2_APP_CLIENT='mini:mini' -VITE_OAUTH2_ZZDSHAPP_CLIENT='zzdsh:zzdsh' +# 图片访问基础地址 +VITE_IMAGE_BASE_PATH = http://localhost:9999 # ******************** start 开发环境 start ******************** # VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api diff --git a/src/global.d.ts b/src/global.d.ts index 9411dd1..61ab5f3 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -1,3 +1,2 @@ declare const __TABBAR__: Array; declare const __ROUTES__: Array; -declare const __APP_SERVICE__: string; diff --git a/src/pages/test/login.vue b/src/pages/test/login.vue index 181aa6f..f1fc46b 100644 --- a/src/pages/test/login.vue +++ b/src/pages/test/login.vue @@ -43,7 +43,6 @@ const doSubmit = async () => { return; } uni.setStorageSync(tokenKey, res.data); - uni.setStorageSync(refreshTokenKey, res.data); const { data: userData } = await userApi.userInfo(); uni.setStorageSync(userInfoKey, userData); uni.hideLoading(); diff --git a/src/pages/wallet/list.vue b/src/pages/wallet/list.vue index 587b0d8..1665b4d 100644 --- a/src/pages/wallet/list.vue +++ b/src/pages/wallet/list.vue @@ -7,6 +7,8 @@ import uqrcode from "@@/utils/uqrcode" import { hooks, router } from "@@/index" import { merchantApi, walletApi } from "@@/api" +import { filePath } from "@@/utils/file" + const state = reactive({ showBindDialog: false, showFreezeDialog: false, @@ -35,7 +37,7 @@ onShow(() => { }) const pageRef = ref(null) -const pageHook = hooks.usePage(pageRef, walletApi.all, null, 'data') +const pageHook = hooks.usePage(pageRef, walletApi.all, null, 'data.records') const query = (page: number, pagesize: number) => { pageHook.startPage(page, pagesize, false, state.pa); } @@ -147,13 +149,13 @@ const doFreeze = async () => { - + - {{ v.walletTypeStr }} + {{ v.walletTypeName }} - 冻结审核中 + 冻结审核中 正常 已冻结 diff --git a/src/pages/wallet/recharge.vue b/src/pages/wallet/recharge.vue index 0e12cb3..bad99bd 100644 --- a/src/pages/wallet/recharge.vue +++ b/src/pages/wallet/recharge.vue @@ -103,7 +103,7 @@ const doPay = async () => { - {{ state.detail.walletTypeStr }} + {{ state.detail.walletTypeName }} diff --git a/src/sheep/api/wallet.ts b/src/sheep/api/wallet.ts index cdb651a..12a292c 100644 --- a/src/sheep/api/wallet.ts +++ b/src/sheep/api/wallet.ts @@ -3,7 +3,7 @@ import request from "@/sheep/utils/request"; export default { all: () => request({ - url: "pay/wallet/get-all", + url: "/wallet/wallet-manage/app/get-all", method: "GET", custom: { showLoading: false, @@ -20,7 +20,7 @@ export default { }), detail: (params: any) => request({ - url: "pay/wallet/detail", + url: "wallet/wallet-manage/app/detail", method: "GET", params, custom: { @@ -56,7 +56,7 @@ export default { }), transaction: (params: any) => request({ - url: "pay/wallet-transaction/page-by-id", + url: "wallet/wallet-transaction/page", method: "GET", params, custom: { @@ -74,7 +74,7 @@ export default { }), rechargeList: (params: any) => request({ - url: "pay/wallet-recharge-package/list", + url: "wallet/wallet-recharge-package/app/list", method: "GET", params, custom: { diff --git a/src/sheep/utils/file.ts b/src/sheep/utils/file.ts new file mode 100644 index 0000000..99b0d42 --- /dev/null +++ b/src/sheep/utils/file.ts @@ -0,0 +1,5 @@ +export const filePath = (path?: string) => { + const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH; + if (!path) return ""; + return imageBaseUrl + path; +}; diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts index 01d5ba2..0d166f9 100644 --- a/src/sheep/utils/request.ts +++ b/src/sheep/utils/request.ts @@ -38,8 +38,6 @@ const http = new Request({ header: { Accept: "*/*", "Content-Type": "application/json;charset=UTF-8", - Authorization: "", - "TENANT-ID": "", }, withCredentials: true, custom: options, @@ -56,8 +54,13 @@ http.interceptors.request.use( config_header["CLIENT-TOC"] = "Y"; } config_header["TENANT-ID"] = "1"; - if (tokenStorage && tokenStorage.access_token && config_header) { - config_header.Authorization = tokenStorage.access_token; + if ( + config.url != "/sys/auth/refresh-token" && + tokenStorage && + tokenStorage.access_token && + config_header + ) { + config_header.Authorization = `Bearer ${tokenStorage.access_token}`; } if (config.custom && config.custom.showLoading) { LoadingInstance.count++; diff --git a/src/sheep/utils/util.ts b/src/sheep/utils/util.ts deleted file mode 100644 index 6a3d558..0000000 --- a/src/sheep/utils/util.ts +++ /dev/null @@ -1,200 +0,0 @@ -import { isObject } from "@vue/shared"; -import * as CryptoJS from "crypto-js"; - -/** - * @description 获取元素节点信息(在组件中的元素必须要传ctx) - * @param { String } selector 选择器 '.app' | '#app' - * @param { Boolean } all 是否多选 - * @param { ctx } context 当前组件实例 - */ -export const getRect = (selector: string, all = false, context?: any) => { - return new Promise((resolve, reject) => { - let query = uni.createSelectorQuery(); - if (context) { - query = uni.createSelectorQuery().in(context); - } - query[all ? "selectAll" : "select"](selector) - .boundingClientRect(function (rect) { - if (all && Array.isArray(rect) && rect.length) { - return resolve(rect); - } - if (!all && rect) { - return resolve(rect); - } - reject("找不到元素"); - }) - .exec(); - }); -}; - -/** - * @description 获取当前页面实例 - */ -export function currentPage() { - const pages = getCurrentPages(); - const currentPage = pages[pages.length - 1]; - return currentPage || {}; -} - -/** - * @description 后台选择链接专用跳转 - */ -interface Link { - path: string; - name?: string; - type: string; - isTab: boolean; - query?: Record; -} - -export enum LinkTypeEnum { - "SHOP_PAGES" = "shop", - "CUSTOM_LINK" = "custom", -} - -export function navigateTo( - link: Link, - navigateType: "navigateTo" | "reLaunch" | "switchTab" = "navigateTo" -) { - const url = link.query - ? `${link.path}?${objectToQuery(link.query)}` - : link.path; - navigateType == "navigateTo" && uni.navigateTo({ url }); - navigateType == "reLaunch" && uni.reLaunch({ url }); - navigateType == "switchTab" && uni.switchTab({ url }); -} - -/** - * @description 是否为空 - * @param {unknown} value - * @return {Boolean} - */ -export const isEmpty = (value: unknown) => { - return value == null && typeof value == "undefined"; -}; - -/** - * @description 对象格式化为Query语法 - * @param { Object } params - * @return {string} Query语法 - */ -export function objectToQuery(params: Record): string { - let query = ""; - for (const props of Object.keys(params)) { - const value = params[props]; - const part = encodeURIComponent(props) + "="; - if (!isEmpty(value)) { - console.log(encodeURIComponent(props), isObject(value)); - if (isObject(value)) { - for (const key of Object.keys(value)) { - if (!isEmpty(value[key])) { - const params = props + "[" + key + "]"; - const subPart = encodeURIComponent(params) + "="; - query += subPart + encodeURIComponent(value[key]) + "&"; - } - } - } else { - query += part + encodeURIComponent(value) + "&"; - } - } - } - return query.slice(0, -1); -} - -/** - * @description 格式化输出价格 - * @param { string } price 价格 - * @param { string } take 小数点操作 - * @param { string } prec 小数位补 - */ -export function formatPrice({ price, take = "all", prec = undefined }: any) { - let [integer, decimals = ""] = (price + "").split("."); - - // 小数位补 - if (prec !== undefined) { - const LEN = decimals.length; - for (let i = prec - LEN; i > 0; --i) decimals += "0"; - decimals = decimals.substr(0, prec); - } - - switch (take) { - case "int": - return integer; - case "dec": - return decimals; - case "all": - return integer + "." + decimals; - } -} - -/** - * @description 组合异步任务 - * @param { string } task 异步任务 - */ - -export function series(...task: Array<(_arg: any) => any>) { - return function (): Promise { - return new Promise((resolve, reject) => { - const iteratorTask = task.values(); - const next = (res?: any) => { - const nextTask = iteratorTask.next(); - if (nextTask.done) { - resolve(res); - } else { - Promise.resolve(nextTask.value(res)).then(next).catch(reject); - } - }; - next(); - }); - }; -} - -/** - * @description 添加单位 - * @param {String | Number} value 值 100 - * @param {String} unit 单位 px em rem - */ -export const addUnit = (value: string | number, unit = "rpx") => { - return !Object.is(Number(value), NaN) ? `${value}${unit}` : value; -}; - -/** - * 自动适配不同的后端架构 - * 1. 例如 /act/oa/task ,在微服务架构保持不变,在单体架构编程 /admin/oa/task - * 2. 特殊 /gen/xxx ,在微服务架构、单体架构编程 都需保持不变 - * - * @param originUrl 原始路径 - */ -export const adaptationUrl = (originUrl?: string) => { - // 微服务架构 不做路径转换,为空不做路径转换 - const isMicro = import.meta.env.VITE_IS_MICRO; - if (isEmpty(isMicro) || isMicro === "true") { - return originUrl; - } - - // 验证码服务 - if (originUrl?.startsWith("/code/")) { - return `/admin${originUrl}`; - } - - // 如果是代码生成服务,不做路径转换 - if (originUrl?.startsWith("/gen")) { - return originUrl; - } - // 转为 /admin 路由前缀的请求 - return `/admin/${originUrl?.split("/").splice(2).join("/")}`; -}; - -/** - *加密处理 - */ -export function encryption(src: string, keyWord: string) { - const key = CryptoJS.enc.Utf8.parse(keyWord); - // 加密 - const encrypted = CryptoJS.AES.encrypt(src, key, { - iv: key, - mode: CryptoJS.mode.CFB, - padding: CryptoJS.pad.NoPadding, - }); - return encrypted.toString(); -} diff --git a/vite.config.ts b/vite.config.ts index 2ecd339..ca43b84 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,13 +5,15 @@ import uni from "@dcloudio/vite-plugin-uni"; import Unocss from "unocss/vite"; import { useRouter } from "./src/sheep"; +import { filePath } from "./src/sheep/utils/file-path"; export default defineConfig(({ mode }) => { - const { NODE_ENV, VITE_APP_DEV_SERVICE, VITE_APP_PROD_SERVICE } = loadEnv( - mode, - process.cwd(), - "" - ); + const { + NODE_ENV, + VITE_APP_DEV_SERVICE, + VITE_APP_PROD_SERVICE, + VITE_IMAGE_BASE_PATH, + } = loadEnv(mode, process.cwd(), ""); const baseUrl = NODE_ENV == "development" ? VITE_APP_DEV_SERVICE : VITE_APP_PROD_SERVICE; return {