af-mobile-client-vue3 1.2.17 → 1.2.18

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.2.17",
4
+ "version": "1.2.18",
5
5
  "packageManager": "pnpm@10.12.3",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -301,6 +301,18 @@ watch(localValue, (newVal) => {
301
301
  dataChangeFunc()
302
302
  })
303
303
 
304
+ // 监听 props.form 的变化
305
+ watch(
306
+ () => props.form,
307
+ (newVal, oldVal) => {
308
+ // 如果是从函数获取 options
309
+ if (props.attr.keyName && (props.attr.keyName.toString().includes('async ') || props.attr.keyName.toString().includes('function'))) {
310
+ debouncedUpdateOptions()
311
+ }
312
+ },
313
+ { deep: true },
314
+ )
315
+
304
316
  function updateFile(files, _index) {
305
317
  // 处理文件数据
306
318
  // 更新本地值
@@ -11,6 +11,9 @@ export interface WebConfig {
11
11
  homePage: string
12
12
  defaultAvatarUrl: string
13
13
  wechatLogin: boolean
14
+ wxLoginAge: boolean
15
+ wxAutoLogin: string
16
+ tenantName: string
14
17
  }
15
18
 
16
19
  // 存放 webConfig 中的 setting 配置
@@ -33,13 +36,14 @@ export const useSettingStore = defineStore('setting', () => {
33
36
 
34
37
  const useStore = createStorage()
35
38
  const catchWebConfig = useStore.get(APP_WEB_CONFIG_KEY)
36
- if (catchWebConfig) {
37
- setSetting(catchWebConfig)
39
+ if (catchWebConfig?.setting) {
40
+ setSetting(catchWebConfig?.setting)
38
41
  }
39
42
  else {
40
43
  const res = await getConfigByNameAsync('webMobileConfig')
41
44
  if (res.setting) {
42
45
  useStore.set(APP_WEB_CONFIG_KEY, res)
46
+ console.log('res.setting', res.setting)
43
47
  setSetting(res.setting)
44
48
  }
45
49
  }
@@ -205,6 +205,9 @@ export const useUserStore = defineStore('app-user', () => {
205
205
  console.error(e)
206
206
  }
207
207
  }
208
+ const getCode = (tenantName: string) => {
209
+ window.location.replace(`api/af-system/user/getcode?state=${tenantName}`)
210
+ }
208
211
 
209
212
  return {
210
213
  Login,
@@ -225,6 +228,7 @@ export const useUserStore = defineStore('app-user', () => {
225
228
  setRoutesConfig,
226
229
  setTenantName,
227
230
  getTenantName,
231
+ getCode,
228
232
  }
229
233
  })
230
234
 
@@ -93,3 +93,17 @@ html:not(.dark) {
93
93
  .forget_password_form {
94
94
  margin-top: 15px;
95
95
  }
96
+ /* 使图标垂直居中 */
97
+ .wechat-login-btn .van-icon {
98
+ vertical-align: middle;
99
+ }
100
+ /* 悬停效果 */
101
+ .wechat-login-btn:hover {
102
+ background-color: #06ad56 !important;
103
+ border-color: #06ad56 !important;
104
+ }
105
+ /* 点击效果 */
106
+ .wechat-login-btn:active {
107
+ background-color: #05994c !important;
108
+ border-color: #05994c !important;
109
+ }
@@ -1,57 +1,57 @@
1
- /**
2
- * 根据类型获取日期区间字符串
3
- * @param type '当年' | 'curMonth' | '当日'
4
- * @param show 区分实际值还是显示值, true为实际值, false为显示值
5
- * @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
6
- */
7
- export function getRangeByType(type: string, show: boolean): [string, string] {
8
- const now = new Date()
9
- const year = now.getFullYear()
10
- const month = (now.getMonth() + 1).toString().padStart(2, '0')
11
- const day = now.getDate().toString().padStart(2, '0')
12
-
13
- if (!show) {
14
- if (type === 'curYear') {
15
- return [
16
- `${year}-01-01 00:00:00`,
17
- `${year}-12-31 23:59:59`,
18
- ]
19
- }
20
- if (type === 'curMonth') {
21
- const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
22
- return [
23
- `${year}-${month}-01 00:00:00`,
24
- `${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
25
- ]
26
- }
27
- if (type === 'curDay') {
28
- return [
29
- `${year}-${month}-${day} 00:00:00`,
30
- `${year}-${month}-${day} 23:59:59`,
31
- ]
32
- }
33
- }
34
- if (show) {
35
- if (type === 'curYear') {
36
- return [
37
- `${year}-01-01`,
38
- `${year}-12-31`,
39
- ]
40
- }
41
- if (type === 'curMonth') {
42
- const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
43
- return [
44
- `${year}-${month}-01`,
45
- `${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
46
- ]
47
- }
48
- if (type === 'curDay') {
49
- return [
50
- `${year}-${month}-${day}`,
51
- `${year}-${month}-${day}`,
52
- ]
53
- }
54
- }
55
- // 兜底返回空字符串数组
56
- return ['', '']
57
- }
1
+ /**
2
+ * 根据类型获取日期区间字符串
3
+ * @param type '当年' | 'curMonth' | '当日'
4
+ * @param show 区分实际值还是显示值, true为实际值, false为显示值
5
+ * @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
6
+ */
7
+ export function getRangeByType(type: string, show: boolean): [string, string] {
8
+ const now = new Date()
9
+ const year = now.getFullYear()
10
+ const month = (now.getMonth() + 1).toString().padStart(2, '0')
11
+ const day = now.getDate().toString().padStart(2, '0')
12
+
13
+ if (!show) {
14
+ if (type === 'curYear') {
15
+ return [
16
+ `${year}-01-01 00:00:00`,
17
+ `${year}-12-31 23:59:59`,
18
+ ]
19
+ }
20
+ if (type === 'curMonth') {
21
+ const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
22
+ return [
23
+ `${year}-${month}-01 00:00:00`,
24
+ `${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
25
+ ]
26
+ }
27
+ if (type === 'curDay') {
28
+ return [
29
+ `${year}-${month}-${day} 00:00:00`,
30
+ `${year}-${month}-${day} 23:59:59`,
31
+ ]
32
+ }
33
+ }
34
+ if (show) {
35
+ if (type === 'curYear') {
36
+ return [
37
+ `${year}-01-01`,
38
+ `${year}-12-31`,
39
+ ]
40
+ }
41
+ if (type === 'curMonth') {
42
+ const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
43
+ return [
44
+ `${year}-${month}-01`,
45
+ `${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
46
+ ]
47
+ }
48
+ if (type === 'curDay') {
49
+ return [
50
+ `${year}-${month}-${day}`,
51
+ `${year}-${month}-${day}`,
52
+ ]
53
+ }
54
+ }
55
+ // 兜底返回空字符串数组
56
+ return ['', '']
57
+ }
@@ -1,19 +1,26 @@
1
1
  <script setup lang="ts">
2
2
  import XCellList from '@af-mobile-client-vue3/components/data/XCellList/index.vue'
3
3
  import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
4
+ import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
4
5
  import { defineEmits, ref } from 'vue'
5
6
  import { useRouter } from 'vue-router'
6
7
 
7
8
  // 定义事件
8
9
  const emit = defineEmits(['deleteRow'])
10
+ const userInfo = useUserStore().getUserInfo()
9
11
  // 访问路由
10
12
  const router = useRouter()
11
13
  // 获取默认值
12
14
  const idKey = ref('o_id')
13
15
 
14
16
  // 简易crud表单测试
15
- const configName = ref('lngChargeAuditMobileCRUD')
17
+ // const configName = ref('orderCarInMobileCRUD')
18
+ // const serviceName = ref('af-gaslink')
19
+ // const configName = ref('lngPriceManageMobileCRUD')
20
+ const configName = ref('测试2')
16
21
  const serviceName = ref('af-gaslink')
22
+ // const configName = ref('mobile_liushuiQueryCRUD')
23
+ // const serviceName = ref('af-revenue')
17
24
 
18
25
  // 资源权限测试
19
26
  // const configName = ref('crud_sources_test')
@@ -49,11 +56,11 @@ const serviceName = ref('af-gaslink')
49
56
  function toDetail(item) {
50
57
  router.push({
51
58
  name: 'XFormGroupView',
52
- query: {
53
- id: item[idKey.value],
54
- // id: item.rr_id,
55
- // o_id: item.o_id,
56
- },
59
+ // query: {
60
+ // id: item[idKey.value],
61
+ // id: item.rr_id,
62
+ // o_id: item.o_id,
63
+ // },
57
64
  })
58
65
  }
59
66
 
@@ -69,19 +76,35 @@ function toDetail(item) {
69
76
  // },
70
77
  // })
71
78
  // }
79
+ function addOption() {
80
+ router.push({
81
+ name: 'XFormGroupView',
82
+ // params: { id: totalCount.value },
83
+ // query: {
84
+ // configName: configName.value,
85
+ // serviceName: serviceName.value,
86
+ // mode: '新增',
87
+ // },
88
+ })
89
+ // 如果存在回调函数,调用它并传递true表示已处理
90
+ // if (typeof callback === 'function') {
91
+ // callback(true)
92
+ // }
93
+ }
72
94
 
73
95
  // 修改功能
74
- // function updateRow(result) {
75
- // router.push({
76
- // name: 'XFormView',
77
- // params: { id: result.o_id, openid: result.o_id },
78
- // query: {
79
- // configName: configName.value,
80
- // serviceName: serviceName.value,
81
- // mode: '修改',
82
- // },
83
- // })
84
- // }
96
+ function updateRow(result) {
97
+ console.log('用户----', userInfo)
98
+ router.push({
99
+ name: 'XFormGroupView',
100
+ // params: { id: result.o_id, openid: result.o_id },
101
+ // query: {
102
+ // configName: configName.value,
103
+ // serviceName: serviceName.value,
104
+ // mode: '修改',
105
+ // },
106
+ })
107
+ }
85
108
 
86
109
  // 删除功能
87
110
  function deleteRow(result) {
@@ -92,11 +115,23 @@ function deleteRow(result) {
92
115
  <template>
93
116
  <NormalDataLayout id="XCellListView" title="工作计划">
94
117
  <template #layout_content>
118
+ <!-- <XCellList -->
119
+ <!-- :config-name="configName" -->
120
+ <!-- :service-name="serviceName" -->
121
+ <!-- :custom-add="true" -->
122
+ <!-- :custom-edit="true" -->
123
+ <!-- :id-key="idKey" -->
124
+ <!-- @to-detail="toDetail" -->
125
+ <!-- @delete-row="deleteRow" -->
126
+ <!-- @update="updateRow" -->
127
+ <!-- @add="addOption" -->
128
+ <!-- /> -->
129
+
130
+ <!-- :fix-query-form="{ u_f_price_state: ['生效', '待生效'] }" -->
131
+
95
132
  <XCellList
96
- :config-name="configName"
97
- :service-name="serviceName"
98
- :fix-query-form="{ o_f_oper_name: 'edu_test' }"
99
- :id-key="idKey"
133
+ config-name="小小测试CRUD"
134
+ service-name="af-apply"
100
135
  @to-detail="toDetail"
101
136
  @delete-row="deleteRow"
102
137
  />
@@ -5,16 +5,19 @@ import { showDialog } from 'vant'
5
5
  import { ref } from 'vue'
6
6
  import { useRoute } from 'vue-router'
7
7
 
8
+ // const configName = ref('reviewFormGroup')
9
+ // const serviceName = ref('af-revenue')
10
+
8
11
  // 纯表单
9
- const configName = ref('form_check_test')
10
- const serviceName = ref('af-system')
12
+ // const configName = ref('form_check_test')
13
+ // const serviceName = ref('af-system')
11
14
 
12
15
  // const configName = ref("计划下发Form")
13
16
  // const serviceName = ref("af-linepatrol")
14
17
 
15
18
  // 表单组
16
- // const configName = ref('lngChargeAuditMobileFormGroup')
17
- // const serviceName = ref('af-gaslink')
19
+ const configName = ref('lngChargeAuditMobileFormGroup')
20
+ const serviceName = ref('af-gaslink')
18
21
 
19
22
  const formData = ref({})
20
23
  const formGroup = ref(null)
@@ -48,7 +48,7 @@ const getShow = computed(() => (unref(getLoginState) === LoginStateEnum.LOGIN))
48
48
 
49
49
  const login: any = inject('$login')
50
50
  onBeforeMount(async () => {
51
- if (isWechat()) {
51
+ if (isWechat() && setting.getSetting()?.wxAutoLogin) {
52
52
  // 检测是否要开放微信登录
53
53
  if (setting.getSetting()?.wechatLogin) {
54
54
  try {
@@ -187,8 +187,53 @@ async function afterGeneral(result) {
187
187
  // 每次重新登录时,清除indexedDB缓存
188
188
  indexedDB.clear()
189
189
  }
190
-
191
- onMounted(() => {})
190
+ async function wxLoginFun() {
191
+ await localStorage.setItem('wechatLoginPending', 'true')
192
+ userState.getCode(setting.getSetting()?.tenantName)
193
+ }
194
+ async function wxLoginFunContinue(code, state) {
195
+ try {
196
+ wxloading.value = true
197
+ const data = await userState.loginUnified({
198
+ unifiedCode: `${code}`,
199
+ tenantName: `${state}`,
200
+ loginMode: 'wechat',
201
+ resourceName: setting.getSetting()?.routerName || '智慧手机',
202
+ })
203
+ login.f = data
204
+ await Promise.all([GetAppDataService.load()])
205
+ const loginInfo = {
206
+ f: login.f,
207
+ jwt: login.f.id,
208
+ r: login.r,
209
+ }
210
+ userState.setLogin(loginInfo)
211
+ userState.setTenantName(route.query.state)
212
+ await afterGeneral(data.resources)
213
+ const toPath = decodeURIComponent((route.query?.redirect || '/') as string)
214
+ closeToast()
215
+ if (route.name === '/login')
216
+ await router.replace('/')
217
+ else await router.replace(toPath)
218
+ }
219
+ finally {
220
+ wxloading.value = false
221
+ }
222
+ }
223
+ function getQueryParam(param: string): string | null {
224
+ const search = window.location.search || window.location.hash.split('?')[1] || ''
225
+ const params = new URLSearchParams(search)
226
+ return params.get(param)
227
+ }
228
+ onMounted(() => {
229
+ const pending = localStorage.getItem('wechatLoginPending')
230
+ const code = getQueryParam('code')
231
+ const state = getQueryParam('state')
232
+ if (pending && code && state) {
233
+ localStorage.removeItem('wechatLoginPending')
234
+ wxLoginFunContinue(code, state)
235
+ }
236
+ })
192
237
  </script>
193
238
 
194
239
  <template>
@@ -241,6 +286,19 @@ onMounted(() => {})
241
286
  <VanButton class="login_btn btn" type="primary" block native-type="submit" :loading="loading">
242
287
  登 录
243
288
  </VanButton>
289
+ <VanButton
290
+ v-show="setting.getSetting()?.wxLoginAge && isWechat()"
291
+ class="wechat-login-btn btn"
292
+ type="primary"
293
+ block
294
+ native-type="button"
295
+ :loading="wxloading"
296
+ style="background-color: #07C160; border-color: #07C160; margin-top: 15px"
297
+ @click="wxLoginFun"
298
+ >
299
+ <VanIcon name="wechat" size="20px" />
300
+ 微信登录
301
+ </VanButton>
244
302
  </VanForm>
245
303
  </div>
246
304
  </template>
package/vite.config.ts CHANGED
@@ -24,12 +24,22 @@ export default ({ mode }: ConfigEnv): UserConfig => {
24
24
  server: {
25
25
  host: true,
26
26
  port: 7190,
27
+ allowedHosts: [
28
+ 'www.aofengcloud.com',
29
+ '.aofengcloud.com',
30
+ ],
27
31
  proxy: Object.assign({
28
32
  '/api/af-system/resource': {
29
33
  target: v4Server,
30
34
  ws: false,
31
35
  changeOrigin: true,
32
36
  },
37
+ '/api/af-system/user': {
38
+ target: 'http://127.0.0.1:9002/',
39
+ rewrite: (path: string) => path.replace(/^\/api\/af-system\//, '/'),
40
+ ws: false,
41
+ changeOrigin: true,
42
+ },
33
43
  '/api/invoice': {
34
44
  target: 'http://219.153.176.6:8400/',
35
45
  rewrite: (path: string) => path.replace(/^\/api\//, '/'),