tk-vue3-template 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +6 -0
- package/.prettierrc.json +7 -0
- package/README.md +35 -0
- package/eslint.config.js +19 -0
- package/index.html +44 -0
- package/jsconfig.json +8 -0
- package/package.json +47 -0
- package/src/App.vue +20 -0
- package/src/api/Interface.js +10 -0
- package/src/api/index.js +42 -0
- package/src/assets/font/Regular.ttf +0 -0
- package/src/assets/img/bg_empty_data.png +0 -0
- package/src/assets/img/icon_gotop.svg +19 -0
- package/src/components/BackTop.vue +61 -0
- package/src/components/NoData.vue +46 -0
- package/src/main.js +25 -0
- package/src/router/index.js +14 -0
- package/src/stores/counter.js +12 -0
- package/src/styles/base.less +103 -0
- package/src/styles/common.less +1059 -0
- package/src/utils/common.js +50 -0
- package/src/utils/request.js +81 -0
- package/src/views/index.vue +124 -0
- package/tk-vue3-template-0.0.1.tgz +0 -0
- package/vite.config.js +68 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import DSBridge from 'dsbridge'
|
|
2
|
+
class Common {
|
|
3
|
+
// 动态修改标题
|
|
4
|
+
getUrlName(name) {
|
|
5
|
+
var r = new RegExp('(\\?|#|&)' + name + '=([^&#]*)(&|#|$)')
|
|
6
|
+
var m = location.href.match(r)
|
|
7
|
+
return decodeURIComponent(!m ? '' : m[2])
|
|
8
|
+
}
|
|
9
|
+
getToken() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
DSBridge.call(`DS.getToken`, {}, (v) => {
|
|
12
|
+
resolve(v)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
setHeader(params) {
|
|
17
|
+
DSBridge.call('DS.setHeader', {
|
|
18
|
+
native_headershow: params.showHeader, // 1 显示原生titlebar,其他不显示
|
|
19
|
+
statusBarAppearance: params.statusBarAppearance, // 沉浸式
|
|
20
|
+
titleName: params.titleName, // 标题栏的名字
|
|
21
|
+
top_link_image: params.top_link_image, // 图片背景链接
|
|
22
|
+
topstyle: params.topstyle, // topimg 图片 topcolor 颜色背景
|
|
23
|
+
native_top_words_color: params.native_top_words_color, // 文字颜色
|
|
24
|
+
str_link_color: params.str_link_color, // 颜色背景渐变色开始色
|
|
25
|
+
end_link_color: params.end_link_color, // 颜色背景渐变色结束色
|
|
26
|
+
hideBottom: params.hideBottom, // 底部状态栏
|
|
27
|
+
isHideCloseBt: params.hideCloseBtn, // 是否隐藏关闭按钮 0,不隐藏,1隐藏
|
|
28
|
+
isBounceEnabled: params.bounceEnabled // ios 页面弹动 1 可弹动 0 禁止弹动
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
closePage() {
|
|
32
|
+
DSBridge.call('DS.closePage', {})
|
|
33
|
+
}
|
|
34
|
+
formatTimestamp(timestamp) {
|
|
35
|
+
// 10位时间戳需要乘以1000转换为毫秒
|
|
36
|
+
const date = new Date(timestamp * 1000);
|
|
37
|
+
|
|
38
|
+
const year = date.getFullYear();
|
|
39
|
+
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要+1
|
|
40
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
41
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
42
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
43
|
+
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
44
|
+
|
|
45
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default new Common()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import md5 from 'js-md5'
|
|
3
|
+
import CryptoJS from 'crypto-js'
|
|
4
|
+
import common from '@/utils/common'
|
|
5
|
+
import { showToast } from 'vant'
|
|
6
|
+
const service = axios.create({
|
|
7
|
+
timeout: 10000, // 设置请求超时
|
|
8
|
+
baseURL: api_url,
|
|
9
|
+
})
|
|
10
|
+
// post请求头
|
|
11
|
+
service.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
|
|
12
|
+
const version = '1.0.1'
|
|
13
|
+
const signKey = focus[47]
|
|
14
|
+
const encrypt = 2
|
|
15
|
+
const device = 'web'
|
|
16
|
+
// const device = 'api' //本地
|
|
17
|
+
// let token = 'aceb8388-11745d35-47518315-89a6-c69151d1d93d'
|
|
18
|
+
let token = ''
|
|
19
|
+
|
|
20
|
+
// 请求拦截器
|
|
21
|
+
service.interceptors.request.use(
|
|
22
|
+
async function (request) {
|
|
23
|
+
// token = '54fec0d8-cebfdea6-78222553-b6d9-ca40b7392a03'
|
|
24
|
+
token = await common.getToken()
|
|
25
|
+
const xid = common.getUrlName('xid')
|
|
26
|
+
const time = Date.parse(new Date()) / 1000
|
|
27
|
+
const custom = Math.random().toString(36).substr(2)
|
|
28
|
+
const c = request.url
|
|
29
|
+
let url = ''
|
|
30
|
+
if (c.search('&') !== -1) {
|
|
31
|
+
url = c.substring(0, c.indexOf('&'))
|
|
32
|
+
} else {
|
|
33
|
+
url = c
|
|
34
|
+
}
|
|
35
|
+
let str = xid + signKey + url.toLowerCase() + time + device + version + token + custom
|
|
36
|
+
let sign = md5(str)
|
|
37
|
+
request.headers.xid = xid
|
|
38
|
+
request.headers.version = version
|
|
39
|
+
request.headers.device = device
|
|
40
|
+
request.headers.token = token
|
|
41
|
+
request.headers.encrypt = encrypt
|
|
42
|
+
request.headers.custom = custom
|
|
43
|
+
request.headers.sign = sign
|
|
44
|
+
request.headers.time = time
|
|
45
|
+
return request
|
|
46
|
+
},
|
|
47
|
+
error => {
|
|
48
|
+
return Promise.error(error)
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
// 响应拦截器
|
|
52
|
+
service.interceptors.response.use(
|
|
53
|
+
response => {
|
|
54
|
+
const ret = response.data
|
|
55
|
+
const iv = CryptoJS.enc.Hex.parse(md5('key_' + ret.time))
|
|
56
|
+
const option = { iv: iv, padding: CryptoJS.pad.ZeroPadding }
|
|
57
|
+
if (ret.encrypt === 1 && ret.data) {
|
|
58
|
+
let newKey = md5(ret.sign)
|
|
59
|
+
let key = CryptoJS.enc.Hex.parse(newKey)
|
|
60
|
+
let decrypted = CryptoJS.AES.decrypt(ret.data, key, option)
|
|
61
|
+
let string = decrypted.toString(CryptoJS.enc.Utf8)
|
|
62
|
+
try {
|
|
63
|
+
ret.data = JSON.parse(string)
|
|
64
|
+
} catch (e) {
|
|
65
|
+
ret.data = string
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (ret.code === 1){
|
|
69
|
+
return ret
|
|
70
|
+
}else{
|
|
71
|
+
showToast(ret.msg)
|
|
72
|
+
return Promise.reject(ret.msg);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
},
|
|
76
|
+
error => {
|
|
77
|
+
console.log(error)
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
export default service
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-14 page">
|
|
3
|
+
<div class="text-16 text-center">
|
|
4
|
+
vue3模板
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, getCurrentInstance, reactive, onMounted } from 'vue'
|
|
10
|
+
import { Sticky as VanSticky, NavBar as VanNavBar, PullRefresh as VanPullRefresh, Icon as VanIcon, List as VanList, Skeleton as VanSkeleton } from 'vant'
|
|
11
|
+
import NoData from '@/components/NoData.vue'
|
|
12
|
+
import BackTop from '@/components/BackTop.vue'
|
|
13
|
+
import common from '@/utils/common';
|
|
14
|
+
const { proxy } = getCurrentInstance()
|
|
15
|
+
const showSkeleton = ref(true)
|
|
16
|
+
const isLoading = ref(false)
|
|
17
|
+
const isFinished = ref(false)
|
|
18
|
+
const currentPage = ref(1)
|
|
19
|
+
const dataList = ref([])
|
|
20
|
+
const currentType = ref(1)
|
|
21
|
+
const userInfo = ref({})
|
|
22
|
+
const background = ref('#ff4444')
|
|
23
|
+
const isRefreshing = ref(false)
|
|
24
|
+
const tabList = [{
|
|
25
|
+
name: '余额明细',
|
|
26
|
+
value: 1
|
|
27
|
+
}, {
|
|
28
|
+
name: '提现记录',
|
|
29
|
+
value: 2
|
|
30
|
+
}]
|
|
31
|
+
|
|
32
|
+
// 页面挂载时执行
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// 设置头部
|
|
38
|
+
const setHeader = (params) => {
|
|
39
|
+
common.setHeader({
|
|
40
|
+
showHeader: 0,
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const getUserInfo = async () => {
|
|
48
|
+
let res = await proxy.$api.userInfo()
|
|
49
|
+
userInfo.value = res.data || {}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</script>
|
|
54
|
+
<style lang="less" scoped>
|
|
55
|
+
.page {
|
|
56
|
+
padding-top: 46px;
|
|
57
|
+
}
|
|
58
|
+
.nav {
|
|
59
|
+
position: fixed;
|
|
60
|
+
top: 0;
|
|
61
|
+
left: 0;
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 46px;
|
|
64
|
+
padding: 0 12px;
|
|
65
|
+
background: #ffffff;
|
|
66
|
+
&-back {
|
|
67
|
+
height: 100%;
|
|
68
|
+
}
|
|
69
|
+
&-content {
|
|
70
|
+
position: absolute;
|
|
71
|
+
height: 100%;
|
|
72
|
+
left: 50%;
|
|
73
|
+
transform: translateX(-50%);
|
|
74
|
+
.nav-tab {
|
|
75
|
+
position: relative;
|
|
76
|
+
border-radius: 99px;
|
|
77
|
+
background: #f5f7f9;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
.tab-item {
|
|
80
|
+
position: relative;
|
|
81
|
+
padding: 6px 12px;
|
|
82
|
+
border-radius: 99px;
|
|
83
|
+
z-index: 5;
|
|
84
|
+
transition: all 0.1s ease-in-out;
|
|
85
|
+
}
|
|
86
|
+
.tab-bg {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 0;
|
|
89
|
+
left: 0;
|
|
90
|
+
height: 100%;
|
|
91
|
+
width: 50%;
|
|
92
|
+
background: #ff4444;
|
|
93
|
+
border-radius: 99px;
|
|
94
|
+
transition: all 0.05s ease-in-out;
|
|
95
|
+
z-index: 0;
|
|
96
|
+
&-right {
|
|
97
|
+
left: 50%;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
.main {
|
|
105
|
+
padding: 10px;
|
|
106
|
+
.item {
|
|
107
|
+
padding: 0 12px;
|
|
108
|
+
&-header {
|
|
109
|
+
border-bottom: 1px solid #f7f7f7;
|
|
110
|
+
padding: 10px 0;
|
|
111
|
+
&-label {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
&-content {
|
|
115
|
+
padding: 10px 0;
|
|
116
|
+
&-item {
|
|
117
|
+
.value {
|
|
118
|
+
color: #c0c0c0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
Binary file
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import autoprefixer from 'autoprefixer'
|
|
6
|
+
import pxtorem from 'postcss-pxtorem'
|
|
7
|
+
|
|
8
|
+
// https://vite.dev/config/
|
|
9
|
+
const outputDir = 'withdrawLog'
|
|
10
|
+
const staticVersion = 'BUILD_VERSION'
|
|
11
|
+
export default defineConfig(({ mode })=>{
|
|
12
|
+
const isProduction = mode === 'production'
|
|
13
|
+
return {
|
|
14
|
+
base: './',
|
|
15
|
+
plugins: [
|
|
16
|
+
vue()
|
|
17
|
+
],
|
|
18
|
+
resolve: {
|
|
19
|
+
alias: {
|
|
20
|
+
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
server: {
|
|
24
|
+
host: '0.0.0.0', // 允许外部访问
|
|
25
|
+
port: 3000, // 指定端口,可选
|
|
26
|
+
},
|
|
27
|
+
build: {
|
|
28
|
+
outDir: outputDir,
|
|
29
|
+
assetsDir: staticVersion,
|
|
30
|
+
sourcemap: false,
|
|
31
|
+
minify: 'esbuild', // 明确指定
|
|
32
|
+
// 配置代码分割
|
|
33
|
+
rollupOptions: {
|
|
34
|
+
plugins: [
|
|
35
|
+
{
|
|
36
|
+
name: 'file-manager-plugin',
|
|
37
|
+
generateBundle() {
|
|
38
|
+
if (isProduction) {
|
|
39
|
+
this.emitFile({
|
|
40
|
+
type: 'asset',
|
|
41
|
+
// fileName: `${outputDir}/version.txt`,
|
|
42
|
+
source: './version.txt'
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// 扩展依赖预构建
|
|
51
|
+
optimizeDeps: {
|
|
52
|
+
include: ['vue', 'vue-router', 'pinia', 'vant', 'axios', 'dsbridge']
|
|
53
|
+
},
|
|
54
|
+
css: {
|
|
55
|
+
postcss: {
|
|
56
|
+
plugins: [
|
|
57
|
+
autoprefixer(),
|
|
58
|
+
pxtorem({
|
|
59
|
+
rootValue: 37.5,
|
|
60
|
+
propList: ['*'],
|
|
61
|
+
selectorBlackList: ['van-circle__layer']
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
})
|