Commit 8790ce86 authored by hewenhao's avatar hewenhao

Merge branch 'feature/2023-07-25-captcha' into 'master'

Feature/2023 07 25 captcha See merge request wykolor/mall-webview!6
parents 2739ebbb 7d53f87b
> 1%
last 2 versions
not dead
not ie 11
VUE_APP_DEPLOY_MODE=test
VUE_APP_DEPLOY_MODE=production
\ No newline at end of file
NODE_ENV=production
VUE_APP_DEPLOY_MODE=test
\ No newline at end of file
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/vue3-essential',
'@vue/standard',
'@vue/typescript/recommended'
],
parserOptions: {
ecmaVersion: 2020
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-explicit-any': 0,
'vue/multi-word-component-names': 'off'
}
}
@geek:registry=http://git.jksxb.cn:8081/repository/geek/
disturl=https://npm.taobao.org/dist
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
module.exports = { module.exports = {
presets: ["@vue/cli-plugin-babel/preset"] presets: [
}; ['@vue/cli-plugin-babel/preset', {
include: [
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-logical-assignment-operators',
'@babel/plugin-proposal-optional-chaining'
]
}]
]
}
module.exports = {
'*.{js,jsx,vue,ts,tsx}': 'vue-cli-service lint'
}
{ {
"name": "bonus", "name": "mall-webview",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "node scripts/build.js", "build": "vue-cli-service build",
"serve": "node scripts/build.js --watch", "serve": "vue-cli-service serve",
"lint": "node scripts/build.js --lint" "dev": "vue-cli-service serve",
"lint": "vue-cli-service lint --fix"
}, },
"dependencies": { "dependencies": {
"amfe-flexible": "^2.2.1", "amfe-flexible": "^2.2.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.8.3",
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",
"vant": "^3.0.9", "vant": "^3.0.9",
"vconsole": "^3.4.0", "vconsole": "^3.4.0",
"vue": "^3.0.0", "vue": "^3.2.13",
"vue-class-component": "^8.0.0-0", "vue-router": "^4.2.4",
"vue-router": "^4.0.0-0", "vuex": "^4.0.2"
"vuex": "^4.0.0-0",
"webpack-merge": "^5.7.3"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.33.0", "@geek/webpack-upload-assets-plugin": "^1.0.1",
"@typescript-eslint/parser": "^2.33.0", "@types/js-cookie": "^3.0.3",
"@vue/cli-plugin-babel": "~4.5.0", "@typescript-eslint/eslint-plugin": "^5.4.0",
"@vue/cli-plugin-eslint": "~4.5.0", "@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-typescript": "~4.5.0", "@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-service": "~4.5.0", "@vue/cli-plugin-typescript": "~5.0.0",
"@vue/compiler-sfc": "^3.0.0", "@vue/cli-plugin-vuex": "~5.0.0",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/cli-service": "~5.0.0",
"@vue/eslint-config-typescript": "^5.0.2", "@vue/eslint-config-standard": "^6.1.0",
"eslint": "^6.7.2", "@vue/eslint-config-typescript": "^9.1.0",
"eslint-plugin-prettier": "^3.1.3", "@vue/preload-webpack-plugin": "^2.0.0",
"eslint-plugin-vue": "^7.0.0-0", "eslint": "^7.32.0",
"execa": "^5.0.0", "eslint-plugin-import": "^2.25.3",
"less": "^4.1.1", "eslint-plugin-node": "^11.1.0",
"less-loader": "^8.0.0", "eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"lint-staged": "^11.1.2",
"postcss-plugin-px2rem": "^0.8.1", "postcss-plugin-px2rem": "^0.8.1",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sass": "^1.26.5", "sass": "^1.32.7",
"sass-loader": "^8.0.2", "sass-loader": "^12.0.0",
"ts-import-plugin": "^1.6.7", "ts-import-plugin": "^1.6.7",
"typescript": "~3.9.3" "typescript": "~4.5.5",
}, "webpack-merge": "^5.7.3"
"eslintConfig": { }
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": 0
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="//at.alicdn.com/t/font_2425189_lvk0clvlo2.css"> <link rel="stylesheet" href="//at.alicdn.com/t/font_2425189_lvk0clvlo2.css">
<title>我的奖励金</title> <title>我的奖励金</title>
<script src="https://turing.captcha.qcloud.com/TCaptcha.js"></script> <script src="//turing.captcha.qcloud.com/TCaptcha.js"></script>
<script src="//cdn.jkwljy.com/libs/skynet/index-1.1.4.js" ></script> <script src="//cdn.jkwljy.com/libs/skynet/index-1.1.4.js" ></script>
<script> <script>
var SkynetReport = window.SkynetReport || {}; var SkynetReport = window.SkynetReport || {};
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
}); });
} }
</script> </script>
<!-- <% if (String(VUE_APP_DEPLOY_MODE) === 'test') { %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vConsole/3.4.1/vconsole.min.js"></script>
<script>new window.VConsole({});</script>
<% } %> -->
<script> <script>
(function flexible (window, document) { (function flexible (window, document) {
var docEl = document.documentElement var docEl = document.documentElement
......
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const rawArgv = process.argv.slice(2);
const args = require("minimist")(rawArgv);
const execa = require("execa");
const resolve = d => path.resolve(__dirname, d);
const bin = cmd => resolve("../node_modules/.bin/" + cmd);
const { watch, lint } = args;
let cmd = "build";
if (lint) {
cmd = "lint";
} else if (watch) {
cmd = "serve";
}
let deployMode = args._[0] || "production";
if (cmd === "serve") {
deployMode = "test";
}
process.env.VUE_APP_DEPLOY_MODE = deployMode;
execa(bin("vue-cli-service"), [cmd], {
cwd: resolve(".."),
stdio: "inherit",
env: process.env
});
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
import { createApp } from "vue"; import { createApp } from 'vue'
import App from "./App.vue"; import App from './App.vue'
import router from "./router"; import router from './router'
import store from "./store"; import store from './store'
import "./assets/style/normalize.css"; import './assets/style/normalize.css'
if (process.env.VUE_APP_DEPLOY_MODE === "test") {
const VConsole = require("vconsole");
new VConsole();
}
createApp(App) createApp(App)
.use(store) .use(store)
.use(router) .use(router)
.mount("#app"); .mount('#app')
...@@ -7,42 +7,42 @@ ...@@ -7,42 +7,42 @@
// 流水类型 // 流水类型
export enum FlowType { export enum FlowType {
ADD = "ADD", // 收入 ADD = 'ADD', // 收入
REDUCE = "REDUCE" // 支出 REDUCE = 'REDUCE' // 支出
} }
// 业务类型 // 业务类型
export enum BizType { export enum BizType {
WITHDRAW = "WITHDRAW", // 提现 WITHDRAW = 'WITHDRAW', // 提现
ORDER = "ORDER", // 订单支付 ORDER = 'ORDER', // 订单支付
ORDER_RETURN = "ORDER_RETURN", // 订单返还 ORDER_RETURN = 'ORDER_RETURN', // 订单返还
INTRODUCE = "INTRODUCE", // 转介绍 INTRODUCE = 'INTRODUCE', // 转介绍
WITHDRAW_RETURN = "WITHDRAW_RETURN", // 提现返还 WITHDRAW_RETURN = 'WITHDRAW_RETURN', // 提现返还
BATCH_RECHARGE = "BATCH_RECHARGE" // 奖励金充值 BATCH_RECHARGE = 'BATCH_RECHARGE' // 奖励金充值
} }
// 奖励金账户状态 // 奖励金账户状态
export enum BonusAccountStatus { export enum BonusAccountStatus {
ACTIVE = "ACTIVE", // 正常 ACTIVE = 'ACTIVE', // 正常
FREEZE = "FREEZE" // 冻结 FREEZE = 'FREEZE' // 冻结
} }
// 奖励金预提现错误状态 // 奖励金预提现错误状态
export enum ErrCode { export enum ErrCode {
NOT_BIND = "NOT_BIND", // 未绑定微信 NOT_BIND = 'NOT_BIND', // 未绑定微信
USER_FREEZE = "USER_FREEZE", // 用户冻结 USER_FREEZE = 'USER_FREEZE', // 用户冻结
ACCOUNT_FREEZE = "ACCOUNT_FREEZE", // 学生账户冻结 ACCOUNT_FREEZE = 'ACCOUNT_FREEZE', // 学生账户冻结
USER_UP_LIMIT = "USER_UP_LIMIT", // 用户上限 USER_UP_LIMIT = 'USER_UP_LIMIT', // 用户上限
SYSTEM_UP_LIMIT = "SYSTEM_UP_LIMIT", // 系统上限 SYSTEM_UP_LIMIT = 'SYSTEM_UP_LIMIT', // 系统上限
STUDENT_WITHDRAWING = "STUDENT_WITHDRAWING", // 学生提现中 STUDENT_WITHDRAWING = 'STUDENT_WITHDRAWING', // 学生提现中
BALANCE_NOT_ENOUGH = "BALANCE_NOT_ENOUGH", // 余额不足 BALANCE_NOT_ENOUGH = 'BALANCE_NOT_ENOUGH', // 余额不足
STUDENT_NO_SIGN_UP = "STUDENT_NO_SIGN_UP" // 未入过常规/精品班级班 STUDENT_NO_SIGN_UP = 'STUDENT_NO_SIGN_UP' // 未入过常规/精品班级班
} }
// 提现记录状态 // 提现记录状态
export enum WithdrawStatus { export enum WithdrawStatus {
WITHDRAWING = "WITHDRAWING", WITHDRAWING = 'WITHDRAWING',
RECEIVED = "RECEIVED", RECEIVED = 'RECEIVED',
FAILED = "FAILED" FAILED = 'FAILED'
} }
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Bonus from "../views/bonus/index.vue"; import Bonus from '../views/bonus/index.vue'
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
path: "/", path: '/',
name: "Bonus", name: 'Bonus',
component: Bonus component: Bonus
}, },
{ {
path: "/bonusDetail", path: '/bonusDetail',
name: "bonusDetail", name: 'bonusDetail',
component: () => import("../views/bonus/bonus-detail/index.vue") component: () => import('../views/bonus/bonus-detail/index.vue')
}, },
{ {
path: "/withdraw", path: '/withdraw',
name: "withdraw", name: 'withdraw',
component: () => import("../views/bonus/withdraw/index.vue") component: () => import('../views/bonus/withdraw/index.vue')
}, },
{ {
path: "/test", path: '/test',
name: "test", name: 'test',
component: () => import("../views/test/index.vue") component: () => import('../views/test/index.vue')
}, },
{ {
path: "/test/paging", path: '/test/paging',
name: "test-paging", name: 'test-paging',
component: () => import("../views/test/paging.vue") component: () => import('../views/test/paging.vue')
} }
]; ]
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHashHistory(),
routes routes
}); })
export default router; export default router
...@@ -9,44 +9,44 @@ import { ...@@ -9,44 +9,44 @@ import {
WithdrawParams, WithdrawParams,
WithdrawResponse, WithdrawResponse,
WithdrawRiskResponse WithdrawRiskResponse
} from "@/model/bonus"; } from '@/model/bonus'
import { get, post } from "../request"; import { get, post } from '../request'
// 奖励金收支列表 // 奖励金收支列表
export const getBonusList = async (params: Partial<BonusListParams>) => { export const getBonusList = async (params: Partial<BonusListParams>) => {
return await get<Paging<BonusListResponse>>( return await get<Paging<BonusListResponse>>(
`/api-jksxb-app/v1/marketingAccount/bonus/flow/list`, '/api-jksxb-app/v1/marketingAccount/bonus/flow/list',
params params
); )
}; }
// 奖励金账户信息 // 奖励金账户信息
export const getBonusAccount = (studentId: string) => { export const getBonusAccount = (studentId: string) => {
return get<BonusAccountResponse>(`/api-jksxb-app/v1/marketingAccount/bonus/count`, { studentId }); return get<BonusAccountResponse>('/api-jksxb-app/v1/marketingAccount/bonus/count', { studentId })
}; }
// 提现记录列表 // 提现记录列表
export const getWithdrawList = async (params: Partial<WithdrawListParams>) => { export const getWithdrawList = async (params: Partial<WithdrawListParams>) => {
return await get<Paging<WithdrawListResponse>>(`/api-jksxb-app/v1/withdraw/query`, params); return await get<Paging<WithdrawListResponse>>('/api-jksxb-app/v1/withdraw/query', params)
}; }
// 检验图形验证码 // 检验图形验证码
export const checkCaptcha = (params: CheckCaptchaParams) => { export const checkCaptcha = (params: CheckCaptchaParams) => {
return post<string>(`/api-jksxb-app/v1/withdraw/checkCaptcha`, params); return post<string>('/api-jksxb-app/v1/withdraw/checkCaptcha', params)
}; }
// 提现 // 提现
export const withdraw = (params: object) => { export const withdraw = (params: object) => {
return post<WithdrawResponse>("/api-jksxb-app/v1/withdraw", params); return post<WithdrawResponse>('/api-jksxb-app/v1/withdraw', params)
}; }
// 绑定微信 // 绑定微信
export const bindWeiChat = (params: { code: string }) => { export const bindWeiChat = (params: { code: string }) => {
return post("/api-jksxb-app/v1/withdraw/bind/wx/parent", params); return post('/api-jksxb-app/v1/withdraw/bind/wx/parent', params)
}; }
// 获取用户风控值 // 获取用户风控值
export const getWithdrawRisk = (studentId: string) => { export const getWithdrawRisk = (studentId: string) => {
return get<WithdrawRiskResponse>("/api-jksxb-app/v1/risk/getWithdrawRisk", { studentId }); return get<WithdrawRiskResponse>('/api-jksxb-app/v1/risk/getWithdrawRisk', { studentId })
}; }
import axios, { AxiosRequestConfig } from "axios"; import axios, { AxiosRequestConfig } from 'axios'
import Cookies from "js-cookie"; import Cookies from 'js-cookie'
import { unref } from "vue"; import { unref } from 'vue'
import router from "../router"; import router from '../router'
const instance = axios.create({ const instance = axios.create({
headers: { headers: {
"content-type": "application/json;charset=UTF-8", 'content-type': 'application/json;charset=UTF-8',
Authorization: `Bearer ${Cookies.get("token")}` Authorization: `Bearer ${Cookies.get('token')}`
}, },
baseURL: "", baseURL: '',
timeout: 10000, timeout: 10000,
withCredentials: true withCredentials: true
}); })
let globalToken: string | null = null; let globalToken: string | null = null
// 拦截器 在请求之前拦截 // 拦截器 在请求之前拦截
instance.interceptors.request.use( instance.interceptors.request.use(
(config: AxiosRequestConfig) => { (config: AxiosRequestConfig) => {
const route = unref(router.currentRoute); const route = unref(router.currentRoute)
let token = route.query.token; let token = route.query.token
token = Array.isArray(token) ? token[0] : token; token = Array.isArray(token) ? token[0] : token
// refresh token // refresh token
if (token && token !== globalToken) { if (token && token !== globalToken) {
globalToken = token; globalToken = token
} }
if (globalToken) { if (globalToken) {
const pre = config.headers || {}; const pre = config.headers || {}
return { return {
...config, ...config,
headers: { headers: {
...pre, ...pre,
Authorization: `Bearer ${globalToken}` Authorization: `Bearer ${globalToken}`
} }
}; }
} }
return config; return config
}, },
error => { error => {
// 请求错误 // 请求错误
return Promise.reject(error); return Promise.reject(error)
} }
); )
// 响应拦截器 // 响应拦截器
instance.interceptors.response.use( instance.interceptors.response.use(
response => { response => {
const { code, msg } = response.data; const { code, msg } = response.data
if (code !== 0) { if (code !== 0) {
return Promise.reject(msg); return Promise.reject(msg)
} }
return response.data; return response.data
}, },
error => { error => {
return Promise.reject(error.message); return Promise.reject(error.message)
} }
); )
export default instance; export default instance
import axios from "./http"; import axios from './http'
/** /**
* 封装的get请求 * 封装的get请求
* @param {*} url 请求路径 * @param {*} url 请求路径
* @param {*} params 请求参数 * @param {*} params 请求参数
* @returns * @returns
*/ */
export function get<T>(url: string, params?: object) { export function get<T> (url: string, params?: object) {
return axios return axios
.get<T>(url, { params }) .get<T>(url, { params })
.then(res => res.data); .then(res => res.data)
} }
/** /**
...@@ -17,6 +17,6 @@ export function get<T>(url: string, params?: object) { ...@@ -17,6 +17,6 @@ export function get<T>(url: string, params?: object) {
* @param {*} params 请求参数 * @param {*} params 请求参数
* @returns * @returns
*/ */
export function post<T>(url: string, data?: object) { export function post<T> (url: string, data?: object) {
return axios.post<T>(url, data).then(res => res.data); return axios.post<T>(url, data).then(res => res.data)
} }
import { createStore } from "vuex"; import { createStore } from 'vuex'
import bonus from "./module/bonus"; import bonus from './module/bonus'
export default createStore({ export default createStore({
state: { state: {
studentName: "wangyan" studentName: 'wangyan'
}, },
getters: { getters: {
studentFullName: state => state.studentName + "WANG" studentFullName: state => state.studentName + 'WANG'
}, },
mutations: {}, mutations: {},
actions: {}, actions: {},
modules: { modules: {
bonus: bonus bonus: bonus
} }
}); })
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
type State = {
studentId: number;
token: string;
userId: number;
}
const bonus = { const bonus = {
namespaced: true, namespaced: true,
state: () => ({ state: () => ({
studentId: 0, studentId: 0,
token: "", token: '',
userId: 0 userId: 0
}), }),
getters: {}, getters: {},
mutations: { mutations: {
saveStudentId(state, payload) { saveStudentId (state: State, payload: number) {
state.studentId = payload; state.studentId = payload
}, },
saveToken(state, payload) { saveToken (state: State, payload: string) {
Cookies.set('token', payload) Cookies.set('token', payload)
state.token = payload; state.token = payload
}, },
saveUserId(state, payload) { saveUserId (state: State, payload: number) {
state.userId = payload; state.userId = payload
} }
}, },
actions: {} actions: {}
}; }
export default bonus; export default bonus
import { ErrCode } from "@/model/bonus/constant"; import { ErrCode } from '@/model/bonus/constant'
export function formatBonusTipTxt(errCode: string): string { export function formatBonusTipTxt (errCode: string): string {
let tip = ""; let tip = ''
switch (errCode) { switch (errCode) {
case ErrCode.NOT_BIND: case ErrCode.NOT_BIND:
tip = "绑定微信后,才可进行提现!"; tip = '绑定微信后,才可进行提现!'
break; break
case ErrCode.USER_FREEZE: case ErrCode.USER_FREEZE:
case ErrCode.ACCOUNT_FREEZE: case ErrCode.ACCOUNT_FREEZE:
tip = "当前账号存在风险,无法进行提现操作!如需帮助请联系:400-8777389"; tip = '当前账号存在风险,无法进行提现操作!如需帮助请联系:400-8777389'
break; break
case ErrCode.USER_UP_LIMIT: case ErrCode.USER_UP_LIMIT:
case ErrCode.SYSTEM_UP_LIMIT: case ErrCode.SYSTEM_UP_LIMIT:
tip = tip =
"今日已达到提现次数/提现金额上限,无法进行提现操作,请明日进行提现操作!如需帮助请联系:400-8777389"; '今日已达到提现次数/提现金额上限,无法进行提现操作,请明日进行提现操作!如需帮助请联系:400-8777389'
break; break
case ErrCode.STUDENT_WITHDRAWING: case ErrCode.STUDENT_WITHDRAWING:
tip = tip =
"您当前有一笔资金处于提现中,待该笔资金完成提现后,再进行提现操作!如需帮助请联系:400-8777389"; '您当前有一笔资金处于提现中,待该笔资金完成提现后,再进行提现操作!如需帮助请联系:400-8777389'
break; break
case ErrCode.BALANCE_NOT_ENOUGH: case ErrCode.BALANCE_NOT_ENOUGH:
tip = "提现金额至少为:1.00元。当前可提现金额不足!如需帮助请联系:400-8777389!"; tip = '提现金额至少为:1.00元。当前可提现金额不足!如需帮助请联系:400-8777389!'
break; break
case ErrCode.STUDENT_NO_SIGN_UP: case ErrCode.STUDENT_NO_SIGN_UP:
tip = "您当前未报常规/专题/精品班,报班后才可进行提现操作!"; tip = '您当前未报常规/专题/精品班,报班后才可进行提现操作!'
break; break
default: default:
tip = ""; tip = ''
} }
return tip; return tip
} }
let appId = "2095826303"; // 腾讯验证码appid let appId = '2095826303' // 腾讯验证码appid
if (process.env.VUE_APP_DEPLOY_MODE === "test") { if (process.env.VUE_APP_DEPLOY_MODE === 'test') {
appId = "2087826974"; appId = '2087826974'
} }
export default appId export default appId
\ No newline at end of file
...@@ -16,13 +16,13 @@ export interface Emitter { ...@@ -16,13 +16,13 @@ export interface Emitter {
all: EventHandlerMap; all: EventHandlerMap;
on<T = any>(type: EventType, handler: Handler<T>): void; on<T = any>(type: EventType, handler: Handler<T>): void;
on(type: "*", handler: WildcardHandler): void; on(type: '*', handler: WildcardHandler): void;
off<T = any>(type: EventType, handler: Handler<T>): void; off<T = any>(type: EventType, handler: Handler<T>): void;
off(type: "*", handler: WildcardHandler): void; off(type: '*', handler: WildcardHandler): void;
emit<T = any>(type: EventType, event?: T): void; emit<T = any>(type: EventType, event?: T): void;
emit(type: "*", event?: any): void; emit(type: '*', event?: any): void;
} }
/** /**
...@@ -30,8 +30,8 @@ export interface Emitter { ...@@ -30,8 +30,8 @@ export interface Emitter {
* @name mitt * @name mitt
* @returns {Mitt} * @returns {Mitt}
*/ */
export default function mitt(_all?: EventHandlerMap): Emitter { export default function mitt (_all?: EventHandlerMap): Emitter {
const all = _all || new Map(); const all = _all || new Map()
return { return {
/** /**
...@@ -45,11 +45,11 @@ export default function mitt(_all?: EventHandlerMap): Emitter { ...@@ -45,11 +45,11 @@ export default function mitt(_all?: EventHandlerMap): Emitter {
* @param {Function} handler Function to call in response to given event * @param {Function} handler Function to call in response to given event
* @memberOf mitt * @memberOf mitt
*/ */
on<T = any>(type: EventType, handler: Handler<T>) { on<T = any> (type: EventType, handler: Handler<T>) {
const handlers = all.get(type); const handlers = all.get(type)
const added = handlers && handlers.push(handler); const added = handlers && handlers.push(handler)
if (!added) { if (!added) {
all.set(type, [handler]); all.set(type, [handler])
} }
}, },
...@@ -59,10 +59,10 @@ export default function mitt(_all?: EventHandlerMap): Emitter { ...@@ -59,10 +59,10 @@ export default function mitt(_all?: EventHandlerMap): Emitter {
* @param {Function} handler Handler function to remove * @param {Function} handler Handler function to remove
* @memberOf mitt * @memberOf mitt
*/ */
off<T = any>(type: EventType, handler: Handler<T>) { off<T = any> (type: EventType, handler: Handler<T>) {
const handlers = all.get(type); const handlers = all.get(type)
if (handlers) { if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1); handlers.splice(handlers.indexOf(handler) >>> 0, 1)
} }
}, },
...@@ -76,13 +76,13 @@ export default function mitt(_all?: EventHandlerMap): Emitter { ...@@ -76,13 +76,13 @@ export default function mitt(_all?: EventHandlerMap): Emitter {
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @memberOf mitt * @memberOf mitt
*/ */
emit<T = any>(type: EventType, evt: T) { emit<T = any> (type: EventType, evt: T) {
((all.get(type) || []) as EventHandlerList).slice().map(handler => { ((all.get(type) || []) as EventHandlerList).slice().map(handler => {
handler(evt); return handler(evt)
});
((all.get("*") || []) as WildCardEventHandlerList).slice().map(handler => {
handler(type, evt);
}); });
((all.get('*') || []) as WildCardEventHandlerList).slice().map(handler => {
return handler(type, evt)
})
} }
}; }
} }
/* eslint-disable @typescript-eslint/camelcase */ import { App } from 'vue'
import { App } from "vue"; import mitt from './mitt'
import mitt from "./mitt";
const isiOS = () => { const isiOS = () => {
const u = navigator.userAgent; const u = navigator.userAgent
const iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); const iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
return iOs; return iOs
}; }
const isAndroid = () => { const isAndroid = () => {
const u = navigator.userAgent; const u = navigator.userAgent
const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; const android = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
return android; return android
}; }
const postMessage = data => { const postMessage = (data: any) => {
if (isAndroid()) { if (isAndroid()) {
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage && window.ReactNativeWebView.onMessage &&
window.ReactNativeWebView.onMessage(JSON.stringify(data)); window.ReactNativeWebView.onMessage(JSON.stringify(data))
} }
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.postMessage && window.ReactNativeWebView.postMessage &&
window.ReactNativeWebView.postMessage(JSON.stringify(data)); window.ReactNativeWebView.postMessage(JSON.stringify(data))
}; }
if (isiOS() || isAndroid()) { if (isiOS() || isAndroid()) {
// const debugLog = console.log // const debugLog = console.log
...@@ -37,99 +36,99 @@ if (isiOS() || isAndroid()) { ...@@ -37,99 +36,99 @@ if (isiOS() || isAndroid()) {
// } // }
} }
function install(Vue: App) { function install (Vue: App) {
const GEEK_NATVIE_NAME = "GEEK_NATVIE_NAME"; const GEEK_NATVIE_NAME = 'GEEK_NATVIE_NAME'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const event_bus = mitt(); const event_bus = mitt()
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
window.$geek_excuteJS = function(args) { window.$geek_excuteJS = function (args: any) {
try { try {
const params = JSON.parse(args); const params = JSON.parse(args)
event_bus.emit(GEEK_NATVIE_NAME, params); event_bus.emit(GEEK_NATVIE_NAME, params)
} catch (error) { } catch (error) {
event_bus.emit(GEEK_NATVIE_NAME, args); event_bus.emit(GEEK_NATVIE_NAME, args)
} }
}; }
Vue.mixin({ Vue.mixin({
methods: { methods: {
listenNativeMessage(arg) { listenNativeMessage (arg: any) {
const { method, data } = arg; const { method, data } = arg
if (method) { if (method) {
this[method] && this[method](data); this[method] && this[method](data)
} }
}, },
$nativeTitle(title) { $nativeTitle (title: string) {
const message = { const message = {
type: "title", type: 'title',
data: title data: title
}; }
postMessage(message); postMessage(message)
}, },
$shareImg(base64Img, timeline = false) { $shareImg (base64Img: string, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? 'shareTimeline' : 'share',
data: { data: {
type: "img", type: 'img',
img: base64Img img: base64Img
} }
}; }
postMessage(message); postMessage(message)
}, },
$shareText(txt, timeline = false) { $shareText (txt: string, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? 'shareTimeline' : 'share',
data: { data: {
type: "text", type: 'text',
description: txt description: txt
} }
}; }
postMessage(message); postMessage(message)
}, },
$shareNews({ title, url, description }, timeline = false) { $shareNews ({ title, url, description }: any, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? 'shareTimeline' : 'share',
data: { data: {
type: "news", type: 'news',
description, description,
webpageUrl: url, webpageUrl: url,
title title
} }
}; }
postMessage(message); postMessage(message)
}, },
$playVieo(url) { $playVieo (url: string) {
const message = { const message = {
type: "video", type: 'video',
data: { data: {
url url
} }
}; }
postMessage(message); postMessage(message)
}, },
$postMessage(message) { $postMessage (message: string) {
postMessage(message); postMessage(message)
}, },
$exitWebView(data) { $exitWebView (data: any) {
this.$postMessage({ this.$postMessage({
type: "exitWebview", type: 'exitWebview',
data data
}); })
}, },
$shareReport(params) { $shareReport (params: any) {
this.$postMessage({ this.$postMessage({
type: "reportShare", type: 'reportShare',
params params
}); })
} }
}, },
created() { created () {
event_bus.on(GEEK_NATVIE_NAME, this.listenNativeMessage); event_bus.on(GEEK_NATVIE_NAME, this.listenNativeMessage)
}, },
beforeUnmount() { beforeUnmount () {
event_bus.off(GEEK_NATVIE_NAME, this.listenNativeMessage); event_bus.off(GEEK_NATVIE_NAME, this.listenNativeMessage)
} }
}); })
} }
export default install; export default install
export function countDown(times: number, interval = 1000, callback?: Function) { /* eslint-disable node/no-callback-literal */
let count = 0; export function countDown (times: number, interval = 1000, cb?: (arg: number) => void) {
const timeoutParams: {timeCounter: number | undefined} = { timeCounter: undefined } let count = 0
function _countDownStart() { const timeoutParams: {timeCounter: number | undefined} = { timeCounter: undefined }
function _countDownStart () {
if (!timeoutParams.timeCounter) { if (!timeoutParams.timeCounter) {
return; return
} }
count++; count++
callback && callback(times - count + 1); if (cb) {
cb(times - count + 1)
}
if (count > times) { if (count > times) {
clearTimeout(timeoutParams.timeCounter); clearTimeout(timeoutParams.timeCounter)
} else { } else {
timeoutParams.timeCounter = setTimeout(_countDownStart, interval); timeoutParams.timeCounter = setTimeout(_countDownStart, interval)
} }
} }
timeoutParams.timeCounter = setTimeout(_countDownStart, interval); timeoutParams.timeCounter = setTimeout(_countDownStart, interval)
return timeoutParams; return timeoutParams
} }
/* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from "vue"; import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from 'vue'
import mitt from "./mitt"; import mitt from './mitt'
const eventBus = mitt(); const eventBus = mitt()
const GEEK_NATIVE_NAME = "GEEK_NATIVE_NAME"; const GEEK_NATIVE_NAME = 'GEEK_NATIVE_NAME'
interface NativeInvokeFuncParams { interface NativeInvokeFuncParams {
method: string; method: string;
...@@ -14,30 +13,30 @@ interface NativeInvokeFuncParams { ...@@ -14,30 +13,30 @@ interface NativeInvokeFuncParams {
} }
const isAndroid = () => { const isAndroid = () => {
const u = navigator.userAgent; const u = navigator.userAgent
const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; const android = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
return android; return android
}; }
window.$geek_excuteJS = function (args) { window.$geek_excuteJS = function (args: any) {
try { try {
const params = JSON.parse(args); const params = JSON.parse(args)
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params)
} catch (error) { } catch (error) {
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args)
} }
}; }
export const sendNativeMessage = (data: { type: string; data?: any; __callback__?: string }) => { export const sendNativeMessage = (data: { type: string; data?: any; __callback__?: string }) => {
if (isAndroid()) { if (isAndroid()) {
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage && window.ReactNativeWebView.onMessage &&
window.ReactNativeWebView.onMessage(JSON.stringify(data)); window.ReactNativeWebView.onMessage(JSON.stringify(data))
} }
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.postMessage && window.ReactNativeWebView.postMessage &&
window.ReactNativeWebView.postMessage(JSON.stringify(data)); window.ReactNativeWebView.postMessage(JSON.stringify(data))
}; }
type ListenerType = (this: ComponentInternalInstance | null, ...arg: any[]) => any; type ListenerType = (this: ComponentInternalInstance | null, ...arg: any[]) => any;
...@@ -50,89 +49,89 @@ function useNativeBridge(eventMap: { ...@@ -50,89 +49,89 @@ function useNativeBridge(eventMap: {
[key: string]: ListenerType; [key: string]: ListenerType;
}): [typeof sendNativeMessage, typeof eventBus]; }): [typeof sendNativeMessage, typeof eventBus];
function useNativeBridge( function useNativeBridge (
eventTypeOrEventMap: string | { [key: string]: ListenerType }, eventTypeOrEventMap: string | { [key: string]: ListenerType },
listener?: ListenerType listener?: ListenerType
): [typeof sendNativeMessage, typeof eventBus] { ): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) { const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
if (!arg) return; if (!arg) return
const { method, data } = arg; const { method, data } = arg
if (typeof eventTypeOrEventMap === "string") { if (typeof eventTypeOrEventMap === 'string') {
if (eventTypeOrEventMap === method && listener) { if (eventTypeOrEventMap === method && listener) {
listener.apply(this, [data]); listener.apply(this, [data])
} }
} else if (typeof eventTypeOrEventMap[method] === "function") { } else if (typeof eventTypeOrEventMap[method] === 'function') {
eventTypeOrEventMap[method].apply(this, [data]); eventTypeOrEventMap[method].apply(this, [data])
} }
}; }
let fn: let fn:
| ((this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) => void) | ((this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) => void)
| null = null; | null = null
onMounted(() => { onMounted(() => {
fn = _listener.bind(getCurrentInstance()); fn = _listener.bind(getCurrentInstance())
eventBus.on<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn); eventBus.on<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn)
}); })
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (fn) { if (fn) {
eventBus.off<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn); eventBus.off<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn)
} }
}); })
return [sendNativeMessage, eventBus]; return [sendNativeMessage, eventBus]
} }
export { useNativeBridge }; export { useNativeBridge }
const INVOKE_NATIVE_METHOD_TIMEOUT = 10000; const INVOKE_NATIVE_METHOD_TIMEOUT = 10000
function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }): Promise<T> { function invokeNativeMethod<T = any, P = any> (arg: { type: string; data?: P }): Promise<T> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, ""); const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, '')
const timer = setTimeout(() => { const timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`)); reject(new Error(`invoke ${arg.type} timeout`))
eventBus.off(GEEK_NATIVE_NAME, onCallback); eventBus.off(GEEK_NATIVE_NAME, onCallback)
}, INVOKE_NATIVE_METHOD_TIMEOUT); }, INVOKE_NATIVE_METHOD_TIMEOUT)
eventBus.on(GEEK_NATIVE_NAME, onCallback); eventBus.on(GEEK_NATIVE_NAME, onCallback)
function onCallback(params?: NativeInvokeFuncParams) { function onCallback (params?: NativeInvokeFuncParams) {
if (params?.method === callbackName) { if (params?.method === callbackName) {
clearTimeout(timer); clearTimeout(timer)
if (params.error) { if (params.error) {
reject(new Error(params.error)); reject(new Error(params.error))
} else { } else {
resolve(params.data); resolve(params.data)
} }
eventBus.off(GEEK_NATIVE_NAME, onCallback); eventBus.off(GEEK_NATIVE_NAME, onCallback)
} }
} }
sendNativeMessage({ ...arg, __callback__: callbackName }); sendNativeMessage({ ...arg, __callback__: callbackName })
}); })
} }
/** /**
* 微信登录 * 微信登录
*/ */
export function bindWeChat() { export function bindWeChat () {
return invokeNativeMethod<{ code: string; userId: string }>({ type: "bindWechat" }); return invokeNativeMethod<{ code: string; userId: string }>({ type: 'bindWechat' })
} }
/** /**
* 打电话 * 打电话
*/ */
export function makeCall(phone: string) { export function makeCall (phone: string) {
return invokeNativeMethod<null, string>({ type: "makecall", data: phone }); return invokeNativeMethod<null, string>({ type: 'makecall', data: phone })
} }
/** /**
* *
* 返回APP首页 * 返回APP首页
*/ */
export function goHome() { export function goHome () {
return invokeNativeMethod<null, null>({ type: 'goHome'}); return invokeNativeMethod<null, null>({ type: 'goHome' })
} }
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { reactive, UnwrapRef, computed, ComputedRef } from "vue"; import { reactive, UnwrapRef, computed, ComputedRef } from 'vue'
type PagingFuncRet<T = object> = { type PagingFuncRet<T = object> = {
list: T[] | null; list: T[] | null;
...@@ -36,7 +36,7 @@ export type UsePagingRet<T, P> = [ ...@@ -36,7 +36,7 @@ export type UsePagingRet<T, P> = [
} }
] ]
function usePaging<T = object, P = any>( function usePaging<T = object, P = any> (
fn: PagingFunc<T, P>, fn: PagingFunc<T, P>,
paramsFn?: () => Partial<P> paramsFn?: () => Partial<P>
): UsePagingRet<T, P> { ): UsePagingRet<T, P> {
...@@ -50,69 +50,69 @@ function usePaging<T = object, P = any>( ...@@ -50,69 +50,69 @@ function usePaging<T = object, P = any>(
hasNextPage: false, hasNextPage: false,
error: null, error: null,
total: 0 total: 0
}); })
const request = (isRefresh: boolean) => { const request = (isRefresh: boolean) => {
return async (arg: Partial<P> = {}) => { return async (arg: Partial<P> = {}) => {
if (paging.loading || paging.refreshing) return; if (paging.loading || paging.refreshing) return
if (!isRefresh && !paging.hasNextPage) return; if (!isRefresh && !paging.hasNextPage) return
if (isRefresh) { if (isRefresh) {
paging.refreshing = true; paging.refreshing = true
} else { } else {
paging.loading = true; paging.loading = true
} }
const currentPage = isRefresh ? 1 : paging.pageNum + 1; const currentPage = isRefresh ? 1 : paging.pageNum + 1
try { try {
const params = paramsFn ? paramsFn() : {}; const params = paramsFn ? paramsFn() : {}
const ret = await fn({ const ret = await fn({
...arg, ...arg,
...params, ...params,
pageNum: currentPage, pageNum: currentPage,
pageSize: paging.pageSize pageSize: paging.pageSize
}); })
if (Array.isArray(ret.list)) { if (Array.isArray(ret.list)) {
if (isRefresh) { if (isRefresh) {
paging.list = ret.list as UnwrapRef<T[]>; paging.list = ret.list as UnwrapRef<T[]>
} else { } else {
paging.list = paging.list.concat(ret.list as UnwrapRef<T[]>); paging.list = paging.list.concat(ret.list as UnwrapRef<T[]>)
} }
} }
paging.total = ret.total; paging.total = ret.total
paging.hasNextPage = ret.hasNextPage; paging.hasNextPage = ret.hasNextPage
paging.pageNum = currentPage; paging.pageNum = currentPage
} catch (error) { } catch (error: any) {
paging.error = error.message; paging.error = error.message
} finally { } finally {
if (isRefresh) { if (isRefresh) {
paging.refreshing = false; paging.refreshing = false
} else { } else {
paging.loading = false; paging.loading = false
} }
paging.isLoad = true; paging.isLoad = true
} }
}; }
}; }
const loadMore = request(false); const loadMore = request(false)
const refresh = request(true); const refresh = request(true)
const finishText = computed(() => { const finishText = computed(() => {
const { total, isLoad, error } = paging; const { total, isLoad, error } = paging
if (!isLoad || error) return ""; if (!isLoad || error) return ''
if (total < 1) return "暂无相关数据"; if (total < 1) return '暂无相关数据'
if (total > 1) { if (total > 1) {
return "没有更多了"; return '没有更多了'
} }
return ""; return ''
}); })
const isFinished = computed(() => { const isFinished = computed(() => {
const { hasNextPage, error } = paging; const { hasNextPage, error } = paging
return !!error || !hasNextPage; return !!error || !hasNextPage
}); })
return [paging, loadMore, refresh, { finishText, isFinished }]; return [paging, loadMore, refresh, { finishText, isFinished }]
} }
export { usePaging }; export { usePaging }
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
</van-dialog> </van-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watchEffect } from "vue"; import { defineComponent, ref, watchEffect } from 'vue'
import { Dialog, Button, Toast } from "vant"; import { Dialog, Button, Toast } from 'vant'
import { bindWeChat } from "@/util/use-native-bridge"; import { bindWeChat } from '@/util/use-native-bridge'
import { bindWeiChat } from "@/server/api/bonus"; import { bindWeiChat } from '@/server/api/bonus'
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -41,31 +41,31 @@ export default defineComponent({ ...@@ -41,31 +41,31 @@ export default defineComponent({
show: Boolean, show: Boolean,
withdrawAccount: String withdrawAccount: String
}, },
emits: ["updateBonusAccount", "update:show"], emits: ['updateBonusAccount', 'update:show'],
setup(props, context) { setup (props, context) {
const binding = ref(false); const binding = ref(false)
const showDialog = ref(false); const showDialog = ref(false)
watchEffect(() => { watchEffect(() => {
showDialog.value = props.show; showDialog.value = props.show
}); })
const bindWeiChatModal = async () => { const bindWeiChatModal = async () => {
binding.value = true; binding.value = true
try { try {
const params = await bindWeChat(); const params = await bindWeChat()
await bindWeiChat(params); await bindWeiChat(params)
Toast("绑定成功"); Toast('绑定成功')
context.emit("update:show", false); context.emit('update:show', false)
context.emit("updateBonusAccount"); context.emit('updateBonusAccount')
} catch (err) { } catch (err) {
Toast("绑定失败"); Toast('绑定失败')
} finally { } finally {
binding.value = false; binding.value = false
} }
}; }
return { showDialog, bindWeiChatModal, binding }; return { showDialog, bindWeiChatModal, binding }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -15,29 +15,29 @@ ...@@ -15,29 +15,29 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from "vue"; import { defineComponent, computed } from 'vue'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
import { getBonusList } from "@/server/api/bonus"; import { getBonusList } from '@/server/api/bonus'
import PullRefreshList from "../components/pull-pefresh-list.vue"; import PullRefreshList from '../components/pull-pefresh-list.vue'
export default defineComponent({ export default defineComponent({
components: { components: {
PullRefreshList PullRefreshList
}, },
setup() { setup () {
const route = useRoute(); const route = useRoute()
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const paramsFn = () => ({ const paramsFn = () => ({
studentId: route.query.studentId || bonusStoreState.value.studentId, studentId: route.query.studentId || bonusStoreState.value.studentId,
flowType: "ADD" flowType: 'ADD'
}); })
return { getBonusList, paramsFn }; return { getBonusList, paramsFn }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from "vue"; import { defineComponent, ref } from 'vue'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
import { Tab, Tabs, List, PullRefresh } from "vant"; import { Tab, Tabs, List, PullRefresh } from 'vant'
import BonusReduceList from "./reduce.vue"; import BonusReduceList from './reduce.vue'
import BonusAddList from "./add.vue"; import BonusAddList from './add.vue'
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -34,10 +34,10 @@ export default defineComponent({ ...@@ -34,10 +34,10 @@ export default defineComponent({
BonusAddList, BonusAddList,
BonusReduceList BonusReduceList
}, },
setup() { setup () {
const route = useRoute(); const route = useRoute()
const currentTab = ref(route.query.active || "REDUCE"); const currentTab = ref(route.query.active || 'REDUCE')
return { currentTab }; return { currentTab }
} }
}); })
</script> </script>
...@@ -42,31 +42,31 @@ ...@@ -42,31 +42,31 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from "vue"; import { defineComponent, computed } from 'vue'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
import { getBonusList } from "@/server/api/bonus"; import { getBonusList } from '@/server/api/bonus'
import { FlowType, BizType } from "@/model/bonus/constant"; import { FlowType, BizType } from '@/model/bonus/constant'
import PullRefreshList from "../components/pull-pefresh-list.vue"; import PullRefreshList from '../components/pull-pefresh-list.vue'
export default defineComponent({ export default defineComponent({
components: { components: {
PullRefreshList PullRefreshList
}, },
setup() { setup () {
const route = useRoute(); const route = useRoute()
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const paramsFn = () => ({ const paramsFn = () => ({
studentId: route.query.studentId || bonusStoreState.value.studentId, studentId: route.query.studentId || bonusStoreState.value.studentId,
flowType: "REDUCE" flowType: 'REDUCE'
}); })
return { FlowType, BizType, getBonusList, paramsFn }; return { FlowType, BizType, getBonusList, paramsFn }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -12,11 +12,9 @@ ...@@ -12,11 +12,9 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, onMounted, PropType } from "vue"; import { defineComponent, onMounted, PropType } from 'vue'
import { PullRefresh, List, Empty, Loading } from 'vant'
import { PullRefresh, List, Empty, Loading } from "vant"; import { PagingFunc, usePaging } from '@/util/use-paging'
import { PagingFunc, usePaging } from "@/util/use-paging";
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -34,14 +32,14 @@ export default defineComponent({ ...@@ -34,14 +32,14 @@ export default defineComponent({
type: Function as PropType<() => Partial<any>> type: Function as PropType<() => Partial<any>>
} }
}, },
setup(props) { setup (props) {
const [paging, loadMore, refresh, helpers] = usePaging(props.request, props.paramsFn); const [paging, loadMore, refresh, helpers] = usePaging(props.request, props.paramsFn)
onMounted(refresh); onMounted(refresh)
return { ...helpers, paging, loadMore, refresh }; return { ...helpers, paging, loadMore, refresh }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -94,20 +94,20 @@ ...@@ -94,20 +94,20 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onMounted, reactive, toRefs } from "vue"; import { computed, defineComponent, onMounted, reactive, toRefs } from 'vue'
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from 'vue-router'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { Button, Col, Row, Cell, Loading, Toast } from "vant"; import { Button, Col, Row, Cell, Loading, Toast } from 'vant'
import { BonusAccountResponse } from "@/model/bonus"; import { BonusAccountResponse } from '@/model/bonus'
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant"; import { BonusAccountStatus, ErrCode } from '@/model/bonus/constant'
import { bindWeChat, useNativeBridge } from "@/util/use-native-bridge"; import { bindWeChat, useNativeBridge } from '@/util/use-native-bridge'
import { bindWeiChat, getBonusAccount } from "@/server/api/bonus"; import { bindWeiChat, getBonusAccount } from '@/server/api/bonus'
import WithdrawList from "./withdraw-list.vue"; import WithdrawList from './withdraw-list.vue'
import WithdrawRulesDialog from "./withdraw-rules-dialog.vue"; import WithdrawRulesDialog from './withdraw-rules-dialog.vue'
import WithdrawableDialog from "./withdrawable-dialog.vue"; import WithdrawableDialog from './withdrawable-dialog.vue'
import BindWXDialog from "./bind-w-x-dialog.vue"; import BindWXDialog from './bind-w-x-dialog.vue'
interface BonusState { interface BonusState {
bonusAccount: BonusAccountResponse | null; bonusAccount: BonusAccountResponse | null;
...@@ -126,82 +126,82 @@ const Bonus = defineComponent({ ...@@ -126,82 +126,82 @@ const Bonus = defineComponent({
WithdrawableDialog, WithdrawableDialog,
BindWXDialog BindWXDialog
}, },
setup() { setup () {
const route = useRoute(); const route = useRoute()
const router = useRouter(); const router = useRouter()
const store = useStore(); const store = useStore()
const { studentId, token, userId } = route.query; const { studentId, token, userId } = route.query
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
store.commit("bonus/saveStudentId", studentId); store.commit('bonus/saveStudentId', studentId)
store.commit("bonus/saveToken", token); store.commit('bonus/saveToken', token)
store.commit("bonus/saveUserId", userId); store.commit('bonus/saveUserId', userId)
const [sendNativeMessage] = useNativeBridge("test", () => { const [sendNativeMessage] = useNativeBridge('test', () => {
// //
}); })
const state = reactive<BonusState>({ const state = reactive<BonusState>({
showWithdrawRules: false, showWithdrawRules: false,
showBindWx: false, showBindWx: false,
showDangerous: false, showDangerous: false,
bonusAccount: null, bonusAccount: null,
BonusAccountStatus BonusAccountStatus
}); })
// 获取奖励金信息 // 获取奖励金信息
const getBonusAccountReq = async () => { const getBonusAccountReq = async () => {
Toast.loading({ Toast.loading({
duration: 0, duration: 0,
message: "加载中..." message: '加载中...'
}); })
try { try {
state.bonusAccount = await getBonusAccount(bonusStoreState.value.studentId); state.bonusAccount = await getBonusAccount(bonusStoreState.value.studentId)
} finally { } finally {
Toast.clear(); Toast.clear()
} }
}; }
onMounted(() => { onMounted(() => {
const message = { const message = {
type: "title", type: 'title',
data: "我的奖励金" data: '我的奖励金'
}; }
sendNativeMessage(message); sendNativeMessage(message)
getBonusAccountReq(); getBonusAccountReq()
}); })
const withdraw = () => { const withdraw = () => {
if (!state.bonusAccount?.errCode) { if (!state.bonusAccount?.errCode) {
// 都正常的状态 // 都正常的状态
router.push({ router.push({
name: "withdraw", name: 'withdraw',
params: { params: {
withdrawableTotal: state.bonusAccount?.withdrawableTotal || 0, withdrawableTotal: state.bonusAccount?.withdrawableTotal || 0,
withdrawAccount: state.bonusAccount?.withdrawAccount || "", withdrawAccount: state.bonusAccount?.withdrawAccount || '',
withdrawAccountId: state.bonusAccount?.withdrawAccountId || "" withdrawAccountId: state.bonusAccount?.withdrawAccountId || ''
} }
}); })
} else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) { } else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
state.showBindWx = true; state.showBindWx = true
} else { } else {
state.showDangerous = true; state.showDangerous = true
} }
}; }
// 绑定或者换邦 // 绑定或者换邦
const bindWeiChatOrUnbind = async () => { const bindWeiChatOrUnbind = async () => {
// 已经绑定微信 // 已经绑定微信
if (state.bonusAccount?.withdrawAccount) { if (state.bonusAccount?.withdrawAccount) {
state.showBindWx = true; state.showBindWx = true
return false; return false
} }
try { try {
const params = await bindWeChat(); const params = await bindWeChat()
await bindWeiChat(params); await bindWeiChat(params)
getBonusAccountReq(); getBonusAccountReq()
Toast("绑定成功"); Toast('绑定成功')
} catch { } catch {
Toast("绑定失败"); Toast('绑定失败')
} }
}; }
return { return {
...toRefs(state), ...toRefs(state),
...@@ -209,10 +209,10 @@ const Bonus = defineComponent({ ...@@ -209,10 +209,10 @@ const Bonus = defineComponent({
bindWeiChatOrUnbind, bindWeiChatOrUnbind,
bonusStoreState, bonusStoreState,
getBonusAccountReq getBonusAccountReq
}; }
} }
}); })
export default Bonus; export default Bonus
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -51,28 +51,28 @@ ...@@ -51,28 +51,28 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from "vue"; import { defineComponent, computed } from 'vue'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { getWithdrawList } from "@/server/api/bonus"; import { getWithdrawList } from '@/server/api/bonus'
import { WithdrawStatus } from "@/model/bonus/constant"; import { WithdrawStatus } from '@/model/bonus/constant'
import PullRefreshList from "./components/pull-pefresh-list.vue"; import PullRefreshList from './components/pull-pefresh-list.vue'
export default defineComponent({ export default defineComponent({
components: { components: {
PullRefreshList PullRefreshList
}, },
setup() { setup () {
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const paramsFn = () => ({ const paramsFn = () => ({
studentId: bonusStoreState.value.studentId studentId: bonusStoreState.value.studentId
}); })
return { WithdrawStatus, getWithdrawList, paramsFn }; return { WithdrawStatus, getWithdrawList, paramsFn }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
</van-dialog> </van-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watchEffect, reactive, toRefs, computed, onMounted } from "vue"; import { defineComponent, ref, watchEffect, reactive, toRefs, computed, onMounted } from 'vue'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { Dialog, Button } from "vant"; import { Dialog, Button } from 'vant'
import { makeCall } from "@/util/use-native-bridge"; import { makeCall } from '@/util/use-native-bridge'
import { getWithdrawRisk } from "@/server/api/bonus"; import { getWithdrawRisk } from '@/server/api/bonus'
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -38,38 +38,38 @@ export default defineComponent({ ...@@ -38,38 +38,38 @@ export default defineComponent({
props: { props: {
show: Boolean show: Boolean
}, },
emits: ["update:show"], emits: ['update:show'],
setup(props) { setup (props) {
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const state = reactive({ const state = reactive({
studentDailyWithdrawLimit: 0, studentDailyWithdrawLimit: 0,
userDailyWithdrawLimit: 0 userDailyWithdrawLimit: 0
}); })
const showDialog = ref(false); const showDialog = ref(false)
watchEffect(() => { watchEffect(() => {
showDialog.value = props.show; showDialog.value = props.show
}); })
const phoneCall = () => { const phoneCall = () => {
makeCall("400—8777389"); makeCall('400—8777389')
}; }
const getWithdrawRiskReq = async () => { const getWithdrawRiskReq = async () => {
const { studentDailyWithdrawLimit, userDailyWithdrawLimit } = await getWithdrawRisk( const { studentDailyWithdrawLimit, userDailyWithdrawLimit } = await getWithdrawRisk(
bonusStoreState.value.studentId bonusStoreState.value.studentId
); )
state.studentDailyWithdrawLimit = studentDailyWithdrawLimit; state.studentDailyWithdrawLimit = studentDailyWithdrawLimit
state.userDailyWithdrawLimit = userDailyWithdrawLimit; state.userDailyWithdrawLimit = userDailyWithdrawLimit
}; }
onMounted(getWithdrawRiskReq); onMounted(getWithdrawRiskReq)
return { showDialog, phoneCall, ...toRefs(state) }; return { showDialog, phoneCall, ...toRefs(state) }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bonus-rule-dialog { .bonus-rule-dialog {
......
...@@ -58,17 +58,17 @@ ...@@ -58,17 +58,17 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onMounted, reactive, toRefs } from "vue"; import { computed, defineComponent, onMounted, reactive, toRefs } from 'vue'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
import { useStore } from "vuex"; import { useStore } from 'vuex'
import { Button, Cell, Dialog, Field, Toast } from "vant"; import { Button, Cell, Dialog, Field, Toast } from 'vant'
import { sendNativeMessage } from "@/util/use-native-bridge"; import { sendNativeMessage } from '@/util/use-native-bridge'
import { getWithdrawRisk } from "@/server/api/bonus"; import { getWithdrawRisk } from '@/server/api/bonus'
import { WithdrawResponse } from "@/model/bonus"; import { WithdrawResponse } from '@/model/bonus'
import WithdrawSuccessDialog from "./withdraw-success-dialog.vue"; import WithdrawSuccessDialog from './withdraw-success-dialog.vue'
import WithdrawDialog from "./withdraw-dialog.vue"; import WithdrawDialog from './withdraw-dialog.vue'
interface State { interface State {
WithdrawResponse?: WithdrawResponse | object; WithdrawResponse?: WithdrawResponse | object;
...@@ -85,77 +85,79 @@ const Withdraw = defineComponent({ ...@@ -85,77 +85,79 @@ const Withdraw = defineComponent({
WithdrawSuccessDialog, WithdrawSuccessDialog,
WithdrawDialog WithdrawDialog
}, },
setup() { setup () {
const route = useRoute(); const route = useRoute()
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const state = reactive<State>({ const state = reactive<State>({
withdrawAmount: 0, withdrawAmount: 0,
withdrawableTotal: 0, withdrawableTotal: 0,
showWithdraw: false, showWithdraw: false,
showWithdrawSuccess: false, showWithdrawSuccess: false,
withdrawAccount: "", withdrawAccount: '',
withdrawAccountId: "", withdrawAccountId: '',
withdrawResponse: {}, withdrawResponse: {},
studentDailyWithdrawLimit: 0 // 学生单日提现上限 studentDailyWithdrawLimit: 0 // 学生单日提现上限
}); })
const { withdrawableTotal, withdrawAccount, withdrawAccountId } = route.params; const { withdrawableTotal, withdrawAccount, withdrawAccountId } = route.params
state.withdrawableTotal = Number(withdrawableTotal); state.withdrawableTotal = Number(withdrawableTotal)
state.withdrawAccount = withdrawAccount as string; state.withdrawAccount = withdrawAccount as string
state.withdrawAccountId = withdrawAccountId as string; state.withdrawAccountId = withdrawAccountId as string
const formatter = value => { const formatter = (value: number) => {
if (value <= 0) return ""; if (value <= 0) return ''
if (value > state.withdrawableTotal) { if (value > state.withdrawableTotal) {
Toast(`今日可提现金额为:${state.withdrawableTotal}元`); Toast(`今日可提现金额为:${state.withdrawableTotal}元`)
return state.withdrawableTotal.toFixed(2); return state.withdrawableTotal.toFixed(2)
} }
return value && Number(value).toFixed(2); return value && Number(value).toFixed(2)
}; }
// 确认提现 // 确认提现
const withdrawSubmit = () => { const withdrawSubmit = () => {
if (!state.withdrawAmount) { if (!state.withdrawAmount) {
Toast("请输入提现金额"); Toast('请输入提现金额')
return false; return false
} }
if (Number(state.withdrawAmount) < 1) { if (Number(state.withdrawAmount) < 1) {
Toast("金额必须大于等于1元"); Toast('金额必须大于等于1元')
return false; return false
} }
state.showWithdraw = true; state.showWithdraw = true
}; }
// 提现成功 // 提现成功
const withdrawSuccess = data => { const withdrawSuccess = (data: any) => {
state.withdrawResponse = data; state.withdrawResponse = data
state.showWithdrawSuccess = true; state.showWithdrawSuccess = true
}; }
// 获取风控值 // 获取风控值
const getWithdrawRiskReq = async () => { const getWithdrawRiskReq = async () => {
const { studentDailyWithdrawLimit } = await getWithdrawRisk(bonusStoreState.value.studentId); const { studentDailyWithdrawLimit } = await getWithdrawRisk(bonusStoreState.value.studentId)
state.studentDailyWithdrawLimit = studentDailyWithdrawLimit; state.studentDailyWithdrawLimit = studentDailyWithdrawLimit
}; }
onMounted(() => { onMounted(() => {
const message = { const message = {
type: "title", type: 'title',
data: "提现" data: '提现'
}; }
sendNativeMessage(message); sendNativeMessage(message)
getWithdrawRiskReq(); getWithdrawRiskReq()
}); })
const refs = toRefs(state)
return { return {
...toRefs(state), ...refs,
formatter, formatter,
withdrawSubmit, withdrawSubmit,
withdrawSuccess withdrawSuccess
}; }
} }
}); })
export default Withdraw; export default Withdraw
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -60,17 +60,17 @@ ...@@ -60,17 +60,17 @@
</template> </template>
<script lang="ts"> <script lang="ts">
declare const TencentCaptcha: any; import { defineComponent, ref, watchEffect, reactive, computed, toRefs } from 'vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'
import { defineComponent, ref, watchEffect, reactive, computed, toRefs } from "vue"; import { Dialog, Button, Field, Toast, Cell } from 'vant'
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import { Dialog, Button, Field, Toast, Cell } from "vant"; import { checkCaptcha, withdraw } from '@/server/api/bonus'
import { countDown } from '@/util/timer'
import appId from '@/util/index'
import { checkCaptcha, withdraw } from "@/server/api/bonus"; declare const TencentCaptcha: any
import { countDown } from "@/util/timer";
import appId from "@/util/index";
interface TencentCaptchaResponse { interface TencentCaptchaResponse {
ret: number; ret: number;
...@@ -100,103 +100,103 @@ export default defineComponent({ ...@@ -100,103 +100,103 @@ export default defineComponent({
}, // 提现金额 }, // 提现金额
withdrawAccount: String // 微信账户 withdrawAccount: String // 微信账户
}, },
setup(props, context) { setup (props, context) {
const route = useRoute(); const route = useRoute()
const store = useStore(); const store = useStore()
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus)
const state = reactive<State>({ const state = reactive<State>({
withdrawing: false, withdrawing: false,
tencentCaptchPass: false, // 图形验证码是否通过 tencentCaptchPass: false, // 图形验证码是否通过
smsVerifyPass: false, smsVerifyPass: false,
mobileTip: "", mobileTip: '',
showTime: "获取验证码", showTime: '获取验证码',
smsVerifyCode: "" // 验证码 smsVerifyCode: '' // 验证码
}); })
const showDialog = ref(false); const showDialog = ref(false)
watchEffect(() => { watchEffect(() => {
showDialog.value = props.show; showDialog.value = props.show
}); })
// 获取验证码 // 获取验证码
const getSmsVerifyCode = () => { const getSmsVerifyCode = () => {
const captcha = new TencentCaptcha( const captcha = new TencentCaptcha(
appId, appId,
async (res: TencentCaptchaResponse) => { async (res: TencentCaptchaResponse) => {
const { ret, randstr, ticket } = res; const { ret, randstr, ticket } = res
if (ret === 0) { if (ret === 0) {
state.tencentCaptchPass = true; state.tencentCaptchPass = true
state.smsVerifyPass = true; state.smsVerifyPass = true
try { try {
const data = await checkCaptcha({ randStr: randstr, ticket }); const data = await checkCaptcha({ randStr: randstr, ticket })
Toast("发送验证码成功"); Toast('发送验证码成功')
state.mobileTip = data; state.mobileTip = data
state.timeoutParams = countDown(60, 1000, (time: number) => { state.timeoutParams = countDown(60, 1000, (time: number) => {
time === 0 time === 0
? (state.showTime = `获取验证码`) ? (state.showTime = '获取验证码')
: (state.showTime = `${time} 后再获取`); : (state.showTime = `${time} 后再获取`)
if (time === 0) { if (time === 0) {
state.smsVerifyPass = false; state.smsVerifyPass = false
} }
}); })
} catch { } catch {
Toast("发送验证码失败,请重试"); Toast('发送验证码失败,请重试')
state.smsVerifyPass = false; state.smsVerifyPass = false
} }
} }
}, },
{ {
needFeedBack: false needFeedBack: false
} }
); )
captcha.show(); captcha.show()
}; }
// 提现 // 提现
const withdrawReal = async () => { const withdrawReal = async () => {
if (!state.smsVerifyCode) { if (!state.smsVerifyCode) {
Toast("请输入验证码"); Toast('请输入验证码')
return; return
} }
state.withdrawing = true; state.withdrawing = true
try { try {
const params = { const params = {
studentId: bonusStoreState.value.studentId, studentId: bonusStoreState.value.studentId,
smsVerifyCode: state.smsVerifyCode, smsVerifyCode: state.smsVerifyCode,
withdrawAmount: props.withdrawAmount, withdrawAmount: props.withdrawAmount,
withdrawAccountId: route.params.withdrawAccountId as string withdrawAccountId: route.params.withdrawAccountId as string
}; }
const data = await withdraw(params); const data = await withdraw(params)
context.emit("update:show", false); context.emit('update:show', false)
context.emit("withdrawSuccess", data); context.emit('withdrawSuccess', data)
} catch (err) { } catch (err: any) {
Toast(err); Toast(err)
} finally { } finally {
state.withdrawing = false; state.withdrawing = false
} }
}; }
// 重置参数 // 重置参数
const resetParams = () => { const resetParams = () => {
if (state.timeoutParams && state.timeoutParams.timeCounter) { if (state.timeoutParams && state.timeoutParams.timeCounter) {
clearTimeout(state.timeoutParams.timeCounter); clearTimeout(state.timeoutParams.timeCounter)
} }
state.tencentCaptchPass = false; state.tencentCaptchPass = false
state.smsVerifyPass = false; state.smsVerifyPass = false
state.smsVerifyCode = ""; state.smsVerifyCode = ''
state.mobileTip = ""; state.mobileTip = ''
state.showTime = "获取验证码"; state.showTime = '获取验证码'
}; }
const closeWithdraw = () => { const closeWithdraw = () => {
context.emit("update:show", false); context.emit('update:show', false)
resetParams(); resetParams()
}; }
return { showDialog, ...toRefs(state), getSmsVerifyCode, withdrawReal, closeWithdraw }; return { showDialog, ...toRefs(state), getSmsVerifyCode, withdrawReal, closeWithdraw }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.withdraw-validate { .withdraw-validate {
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watchEffect } from "vue"; import { defineComponent, ref, watchEffect } from 'vue'
import { useRouter } from "vue-router"; import { useRouter } from 'vue-router'
import { Dialog, Button } from "vant"; import { Dialog, Button } from 'vant'
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -38,21 +38,21 @@ export default defineComponent({ ...@@ -38,21 +38,21 @@ export default defineComponent({
show: Boolean, show: Boolean,
withdrawResponse: Object withdrawResponse: Object
}, },
setup(props) { setup (props) {
const router = useRouter(); const router = useRouter()
const showDialog = ref(false); const showDialog = ref(false)
watchEffect(() => { watchEffect(() => {
showDialog.value = props.show; showDialog.value = props.show
}); })
const goBack = () => { const goBack = () => {
router.back(); router.back()
}; }
return { showDialog, goBack }; return { showDialog, goBack }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
</van-dialog> </van-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watchEffect } from "vue"; import { defineComponent, ref, watchEffect } from 'vue'
import { Dialog, Button } from "vant"; import { Dialog, Button } from 'vant'
import { makeCall, goHome } from "@/util/use-native-bridge"; import { makeCall, goHome } from '@/util/use-native-bridge'
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt"; import { formatBonusTipTxt } from '@/util/formatBonusTipTxt'
import { ErrCode } from "@/model/bonus/constant"; import { ErrCode } from '@/model/bonus/constant'
export default defineComponent({ export default defineComponent({
components: { components: {
...@@ -37,18 +37,18 @@ export default defineComponent({ ...@@ -37,18 +37,18 @@ export default defineComponent({
show: Boolean, show: Boolean,
errCode: String errCode: String
}, },
emits: ["update:show"], emits: ['update:show'],
setup(props) { setup (props) {
const showDialog = ref(false); const showDialog = ref(false)
watchEffect(() => { watchEffect(() => {
showDialog.value = props.show; showDialog.value = props.show
}); })
const phoneCall = () => { const phoneCall = () => {
makeCall("400—8777389"); makeCall('400—8777389')
}; }
return { showDialog, phoneCall, goHome, formatBonusTipTxt, ErrCode }; return { showDialog, phoneCall, goHome, formatBonusTipTxt, ErrCode }
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -5,36 +5,35 @@ ...@@ -5,36 +5,35 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref } from 'vue'
import { useNativeBridge } from "@/util/use-native-bridge"; import { useNativeBridge } from '@/util/use-native-bridge'
import { Toast } from "vant"; import { Toast } from 'vant'
const [sendNativeMessage, eventBus] = useNativeBridge({ const [sendNativeMessage, eventBus] = useNativeBridge({
onBindWechatChange(arg) { onBindWechatChange (arg) {
console.log(this, arg); console.log(this, arg)
} }
}); })
useNativeBridge("onBindWechatChange", function(arg) { useNativeBridge('onBindWechatChange', function (arg) {
console.log(this, arg, "bb"); console.log(this, arg, 'bb')
}); })
const count = ref(1000); const count = ref(1000)
const emitTest = () => { const emitTest = () => {
eventBus.emit("GEEK_NATVIE_NAME", { eventBus.emit('GEEK_NATVIE_NAME', {
method: "onBindWechatChange", method: 'onBindWechatChange',
data: { data: {
hhh: 13213 hhh: 13213
} }
}); })
count.value = count.value + 1; count.value = count.value + 1
}; }
const emitTest2 = () => { const emitTest2 = () => {
eventBus.emit("GEEK_NATVIE_NAME", { eventBus.emit('GEEK_NATVIE_NAME', {
method: "title", method: 'title',
data: "我的体现计划" data: '我的体现计划'
}); })
}
};
</script> </script>
<style></style> <style></style>
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PagingFunc } from '@/util/use-paging'; import type { PagingFunc } from '@/util/use-paging'
import { usePaging } from "@/util/use-paging"; import { usePaging } from '@/util/use-paging'
import { onMounted } from "vue"; import { onMounted } from 'vue'
import { PullRefresh, List } from 'vant'; import { PullRefresh, List } from 'vant'
type ListType = { type ListType = {
a: number; a: number;
...@@ -25,7 +25,7 @@ type ListType = { ...@@ -25,7 +25,7 @@ type ListType = {
}; };
const fn: PagingFunc<ListType, { test: number }> = async (arg) => { const fn: PagingFunc<ListType, { test: number }> = async (arg) => {
await new Promise(resolve => setTimeout(resolve, 1000)); await new Promise(resolve => setTimeout(resolve, 1000))
console.log(arg) console.log(arg)
return { return {
hasNextPage: arg.pageNum < 4, hasNextPage: arg.pageNum < 4,
...@@ -34,14 +34,14 @@ const fn: PagingFunc<ListType, { test: number }> = async (arg) => { ...@@ -34,14 +34,14 @@ const fn: PagingFunc<ListType, { test: number }> = async (arg) => {
a: Math.random(), a: Math.random(),
index index
})) }))
}; }
}; }
const [paging, loadMore, onRefresh] = usePaging(fn, () => ({ test: 1 })); const [paging, loadMore, onRefresh] = usePaging(fn, () => ({ test: 1 }))
onMounted(() => { onMounted(() => {
onRefresh(); onRefresh()
}); })
</script> </script>
<style lang="scss"> <style lang="scss">
.item { .item {
......
...@@ -4,16 +4,14 @@ ...@@ -4,16 +4,14 @@
"module": "esnext", "module": "esnext",
"strict": true, "strict": true,
"jsx": "preserve", "jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node", "moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"useDefineForClassFields": true,
"noImplicitAny": false,
"types": [ "types": [
"webpack-env" "webpack-env"
], ],
......
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const tsImportPluginFactory = require("ts-import-plugin"); const tsImportPluginFactory = require('ts-import-plugin')
const { merge } = require("webpack-merge"); const { merge } = require('webpack-merge')
const PreloadPlugin = require('@vue/preload-webpack-plugin')
const createUploadAssetsPlugin = require('@geek/webpack-upload-assets-plugin')
const { defineConfig } = require('@vue/cli-service')
module.exports = { const shouldUploadAssetsToCdn =
publicPath: "./", process.env.NODE_ENV === 'production' && process.env.VUE_APP_DEPLOY_MODE !== 'test'
parallel: process.env.NODE_ENV !== "production", const { getPublicPath, Plugin: WebpackUploadAssetsPlugin } = createUploadAssetsPlugin({
outputDir: "mall-webview", exclude: /(workers(\/|\\))|(meta(\/|\\))|static|favicon.ico|index.html|share.html/
})
console.log('upload assets to cdn', shouldUploadAssetsToCdn)
const proxyUrl = 'https://geek.jkwljy.com'
const proxyOptions = {
target: proxyUrl,
secure: /^https/.test(proxyUrl), // 如果是https接口,需要配置这个参数
changeOrigin: true // 如果接口跨域,需要进行这个参数配置
}
module.exports = defineConfig({
publicPath: shouldUploadAssetsToCdn ? getPublicPath() : './',
parallel: process.env.NODE_ENV !== 'production',
outputDir: 'mall-webview',
productionSourceMap: false, productionSourceMap: false,
devServer: { devServer: {
hot: true, hot: true,
open: true, open: true,
https: false, https: false,
proxy: { proxy: {
//配置跨域 // 配置跨域
"/mock": { '/mock': {
target: "http://192.168.44.114:4100", target: 'http://192.168.44.114:4100',
ws: true,
changOrigin: true //允许跨域
},
"/service": {
target: "http://192.168.32.31",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true // 允许跨域
}, },
"/api": { '/hlw-*': proxyOptions,
target: "http://172.10.61.170", '/service': proxyOptions,
ws: true, '/api': proxyOptions
changOrigin: true //允许跨域
}
} }
}, },
chainWebpack: config => { chainWebpack: config => {
config.plugin(`html`).tap(args => { config.plugin('html').tap(args => {
const minify = args[0].minify; const minify = args[0].minify
args[0].minify = minify ? { ...minify, minifyJS: true } : minify; args[0].minify = minify ? { ...minify, minifyJS: true } : minify
return args; return args
}); })
config
.plugin('prefetch')
.use(PreloadPlugin, [{
rel: 'prefetch',
fileWhitelist: [/\.css$/, /\.js$/],
include: 'asyncChunks'
}]).after('html')
if (shouldUploadAssetsToCdn) {
config
.plugin('cos-upload')
.after('build-info')
.use(WebpackUploadAssetsPlugin)
}
config.module config.module
.rule("ts") .rule('ts')
.use("ts-loader") .use('ts-loader')
.tap(options => { .tap(options => {
options = merge(options, { options = merge(options, {
transpileOnly: true, transpileOnly: true,
getCustomTransformers: () => ({ getCustomTransformers: () => ({
before: [ before: [
tsImportPluginFactory({ tsImportPluginFactory({
libraryName: "vant", libraryName: 'vant',
libraryDirectory: "es", libraryDirectory: 'es',
style: true style: true
}) })
] ]
}), }),
compilerOptions: { compilerOptions: {
module: "es2015" module: 'es2015'
} }
}); })
return options; return options
}); })
}, },
css: { css: {
loaderOptions: { loaderOptions: {
postcss: { postcss: {
plugins: [ postcssOptions: {
require("postcss-plugin-px2rem")({ plugins: [
rootValue: 75, require('postcss-plugin-px2rem')({
propList: ["*"], rootValue: 75,
replace: true, propList: ['*'],
mediaQuery: false, replace: true,
minPixelValue: 2, mediaQuery: false,
exclude: /(node_module)/i minPixelValue: 2,
}) exclude: /(node_module)/i
] })
]
}
} }
} }
} }
}; })
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment