business_tms_program 0.0.0

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.
Files changed (136) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintrc-auto-import.json +113 -0
  3. package/.eslintrc.js +121 -0
  4. package/.prettierrc.js +9 -0
  5. package/.stylelintignore +4 -0
  6. package/README.md +43 -0
  7. package/components.d.ts +23 -0
  8. package/index.html +20 -0
  9. package/package.json +70 -0
  10. package/shims-uni.d.ts +10 -0
  11. package/src/App.vue +81 -0
  12. package/src/api/afterSale.ts +184 -0
  13. package/src/api/context.ts +26 -0
  14. package/src/api/device.ts +134 -0
  15. package/src/api/index.ts +80 -0
  16. package/src/api/installtion.ts +155 -0
  17. package/src/api/model/index.ts +15 -0
  18. package/src/api/model/userModel.ts +62 -0
  19. package/src/api/order.ts +49 -0
  20. package/src/api/system.ts +19 -0
  21. package/src/api/user.ts +171 -0
  22. package/src/auto-imports.d.ts +108 -0
  23. package/src/components/ConfirmDialog.vue +101 -0
  24. package/src/components/DaySelect.vue +212 -0
  25. package/src/components/Drawer.vue +104 -0
  26. package/src/components/DrawerSelect.vue +105 -0
  27. package/src/components/DropMenu.vue +144 -0
  28. package/src/components/Empty.vue +49 -0
  29. package/src/components/Loading.vue +41 -0
  30. package/src/components/RippleBtn.vue +159 -0
  31. package/src/components/SinglePick.vue +120 -0
  32. package/src/components/Skeleton.vue +43 -0
  33. package/src/components/Timeline.vue +85 -0
  34. package/src/components/Upload.vue +217 -0
  35. package/src/config/app.ts +32 -0
  36. package/src/config/env.ts +29 -0
  37. package/src/dict/afterSale.ts +161 -0
  38. package/src/dict/device.ts +29 -0
  39. package/src/dict/installtion.ts +141 -0
  40. package/src/dict/systems.ts +4 -0
  41. package/src/env.d.ts +8 -0
  42. package/src/hooks/useForm.ts +222 -0
  43. package/src/hooks/useUpload.ts +80 -0
  44. package/src/main.ts +8 -0
  45. package/src/manifest.json +39 -0
  46. package/src/pages/acceptance/DeviceInfo.vue +132 -0
  47. package/src/pages/acceptance/list.vue +276 -0
  48. package/src/pages/afterSale/DeviceInfo.vue +128 -0
  49. package/src/pages/afterSale/Step.vue +0 -0
  50. package/src/pages/afterSale/faultReport.vue +552 -0
  51. package/src/pages/afterSale/orderDetail.vue +327 -0
  52. package/src/pages/afterSale/orderFinish.vue +517 -0
  53. package/src/pages/afterSale/orderList.vue +305 -0
  54. package/src/pages/afterSale/returnVisit.vue +288 -0
  55. package/src/pages/afterSale/searchDeviceList.vue +148 -0
  56. package/src/pages/device/Search.vue +201 -0
  57. package/src/pages/device/acceptance.vue +270 -0
  58. package/src/pages/device/detail.vue +165 -0
  59. package/src/pages/device/index.vue +322 -0
  60. package/src/pages/device/info.vue +140 -0
  61. package/src/pages/device/list.vue +219 -0
  62. package/src/pages/device/materialTowerCode.vue +589 -0
  63. package/src/pages/device/searchList.vue +224 -0
  64. package/src/pages/installtion/Record.vue +145 -0
  65. package/src/pages/installtion/StatusTimeline.vue +85 -0
  66. package/src/pages/installtion/addAcceptance.vue +409 -0
  67. package/src/pages/installtion/addRecord.vue +338 -0
  68. package/src/pages/installtion/orderDetail.vue +220 -0
  69. package/src/pages/installtion/orderList.vue +100 -0
  70. package/src/pages/user/component/PersonAgree.vue +226 -0
  71. package/src/pages/user/component/PrivayAgree.vue +221 -0
  72. package/src/pages/user/component/SliderCode.vue +173 -0
  73. package/src/pages/user/forgetPassword.vue +249 -0
  74. package/src/pages/user/index.vue +139 -0
  75. package/src/pages/user/login.vue +342 -0
  76. package/src/pages/user/register.vue +348 -0
  77. package/src/pages/user/repassword.vue +329 -0
  78. package/src/pages/user/utils/mcaptcha.js +75 -0
  79. package/src/pages/user/utils/verifyCode.ts +41 -0
  80. package/src/pages/workspace/index.vue +225 -0
  81. package/src/pages.json +203 -0
  82. package/src/shime-uni.d.ts +6 -0
  83. package/src/static/icon/system/breeder_icon.png +0 -0
  84. package/src/static/icon/system/check.png +0 -0
  85. package/src/static/icon/system/factory_icon.png +0 -0
  86. package/src/static/icon/system/plus.png +0 -0
  87. package/src/static/icon/system/right.png +0 -0
  88. package/src/static/icon/system/unCheck.png +0 -0
  89. package/src/static/icon/tab/search.png +0 -0
  90. package/src/static/icon/tab/user.png +0 -0
  91. package/src/static/icon/tab/user_active.png +0 -0
  92. package/src/static/icon/tab/workspace.png +0 -0
  93. package/src/static/icon/tab/workspace_active.png +0 -0
  94. package/src/static/img/active_dot.png +0 -0
  95. package/src/static/img/afterSale_icon.png +0 -0
  96. package/src/static/img/check.png +0 -0
  97. package/src/static/img/close.png +0 -0
  98. package/src/static/img/confirm.png +0 -0
  99. package/src/static/img/empty.png +0 -0
  100. package/src/static/img/equipment_icon.png +0 -0
  101. package/src/static/img/fault_icon.png +0 -0
  102. package/src/static/img/install_icon.png +0 -0
  103. package/src/static/img/login_bg2.png +0 -0
  104. package/src/static/img/movable_right.png +0 -0
  105. package/src/static/img/navigation.png +0 -0
  106. package/src/static/img/psw_off.png +0 -0
  107. package/src/static/img/psw_on.png +0 -0
  108. package/src/static/img/scan.png +0 -0
  109. package/src/static/img/scan_icon.png +0 -0
  110. package/src/static/img/search.png +0 -0
  111. package/src/static/img/turn_right.png +0 -0
  112. package/src/static/img/unActive_dot.png +0 -0
  113. package/src/static/img/verifyBg.png +0 -0
  114. package/src/stores/index.ts +11 -0
  115. package/src/stores/modules/customer.ts +146 -0
  116. package/src/stores/modules/installtion.ts +30 -0
  117. package/src/stores/modules/system.ts +56 -0
  118. package/src/stores/modules/user.ts +133 -0
  119. package/src/stores/types.ts +16 -0
  120. package/src/stores/utils.ts +6 -0
  121. package/src/styles/index.less +63 -0
  122. package/src/types/chengyiApi.d.ts +36 -0
  123. package/src/types/index.d.ts +95 -0
  124. package/src/utils/address.ts +17 -0
  125. package/src/utils/cipher.ts +61 -0
  126. package/src/utils/form.ts +155 -0
  127. package/src/utils/httpEnum.ts +31 -0
  128. package/src/utils/image.ts +21 -0
  129. package/src/utils/index.ts +111 -0
  130. package/src/utils/request.ts +139 -0
  131. package/src/utils/requestCancelHandle.ts +67 -0
  132. package/stylelint.config.js +87 -0
  133. package/tsconfig.docs.json +11 -0
  134. package/tsconfig.json +30 -0
  135. package/typedoc.json +6 -0
  136. package/vite.config.ts +55 -0
package/src/pages.json ADDED
@@ -0,0 +1,203 @@
1
+ {
2
+ "easycom": {
3
+ "autoscan": true,
4
+ "custom": {
5
+ "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
6
+ }
7
+ },
8
+ "pages": [
9
+ {
10
+ "path": "pages/workspace/index",
11
+ "style": {
12
+ "navigationBarTitleText": "工作台",
13
+ "navigationBarBackgroundColor": "#FBFBFB",
14
+ "backgroundColor": "#F5F5F5"
15
+ }
16
+ },
17
+ {
18
+ "path": "pages/user/register",
19
+ "style": {
20
+ "navigationBarTitleText": "用户注册",
21
+ "navigationBarBackgroundColor": "#F5F5F5"
22
+ }
23
+ },
24
+ {
25
+ "path": "pages/user/login",
26
+ "style": {
27
+ "navigationStyle": "custom",
28
+ "navigationBarTitleText": ""
29
+ }
30
+ },
31
+ {
32
+ "path": "pages/afterSale/faultReport",
33
+ "style": {
34
+ "navigationBarTitleText": "故障提报",
35
+ "navigationBarBackgroundColor": "#FBFBFB",
36
+ "backgroundColor": "#F5F5F5"
37
+ }
38
+ },
39
+ {
40
+ "path": "pages/afterSale/searchDeviceList",
41
+ "style": {
42
+ "navigationBarTitleText": "设备搜索",
43
+ "navigationBarBackgroundColor": "#FBFBFB",
44
+ "backgroundColor": "#F5F5F5"
45
+ }
46
+ },
47
+ {
48
+ "path": "pages/device/detail",
49
+ "style": {
50
+ "navigationBarTitleText": "设备管理详情"
51
+ }
52
+ },
53
+ {
54
+ "path": "pages/device/searchList",
55
+ "style": {
56
+ "navigationBarTitleText": "设备搜索"
57
+ }
58
+ },
59
+ {
60
+ "path": "pages/device/acceptance",
61
+ "style": {
62
+ "navigationBarTitleText": "设备管理验收"
63
+ }
64
+ },
65
+ {
66
+ "path": "pages/device/materialTowerCode",
67
+ "style": {
68
+ "navigationBarTitleText": "编辑料塔编码"
69
+ }
70
+ },
71
+ {
72
+ "path": "pages/device/info",
73
+ "style": {
74
+ "navigationBarTitleText": "设备信息"
75
+ }
76
+ },
77
+ {
78
+ "path": "pages/device/index",
79
+ "style": {
80
+ "navigationBarTitleText": "设备管理",
81
+ "navigationBarBackgroundColor": "#FBFBFB",
82
+ "backgroundColor": "#F5F5F5"
83
+ }
84
+ },
85
+ {
86
+ "path": "pages/user/index",
87
+ "style": {
88
+ "navigationBarTitleText": "我的",
89
+ "navigationBarBackgroundColor": "#FBFBFB",
90
+ "backgroundColor": "#F5F5F5"
91
+ }
92
+ },
93
+ {
94
+ "path": "pages/acceptance/list",
95
+ "style": {
96
+ "navigationBarTitleText": "安装工单验收"
97
+ }
98
+ },
99
+ {
100
+ "path": "pages/installtion/orderList",
101
+ "style": {
102
+ "navigationBarTitleText": "安装工单",
103
+ "navigationBarBackgroundColor": "#FBFBFB",
104
+ "backgroundColor": "#F5F5F5"
105
+ }
106
+ },
107
+ {
108
+ "path": "pages/installtion/addAcceptance",
109
+ "style": {
110
+ "navigationBarTitleText": "新增验收记录"
111
+ }
112
+ },
113
+ {
114
+ "path": "pages/installtion/addRecord",
115
+ "style": {
116
+ "navigationBarTitleText": "新增工作记录"
117
+ }
118
+ },
119
+ {
120
+ "path": "pages/installtion/orderDetail",
121
+ "style": {
122
+ "navigationBarTitleText": "工单详情",
123
+ "navigationBarBackgroundColor": "#FBFBFB",
124
+ "backgroundColor": "#F5F5F5"
125
+ }
126
+ },
127
+ {
128
+ "path": "pages/afterSale/orderList",
129
+ "style": {
130
+ "navigationBarTitleText": "售后工单",
131
+ "navigationBarBackgroundColor": "#FBFBFB",
132
+ "backgroundColor": "#F5F5F5"
133
+ }
134
+ },
135
+ {
136
+ "path": "pages/afterSale/returnVisit",
137
+ "style": {
138
+ "navigationBarTitleText": "新增工作记录",
139
+ "navigationBarBackgroundColor": "#FBFBFB",
140
+ "backgroundColor": "#F5F5F5"
141
+ }
142
+ },
143
+ {
144
+ "path": "pages/afterSale/orderFinish",
145
+ "style": {
146
+ "navigationBarTitleText": "新增工作记录",
147
+ "navigationBarBackgroundColor": "#FBFBFB",
148
+ "backgroundColor": "#F5F5F5"
149
+ }
150
+ },
151
+ {
152
+ "path": "pages/afterSale/orderDetail",
153
+ "style": {
154
+ "navigationBarTitleText": "售后工单",
155
+ "navigationBarBackgroundColor": "#FBFBFB",
156
+ "backgroundColor": "#F5F5F5"
157
+ }
158
+ },
159
+
160
+ {
161
+ "path": "pages/user/rePassword",
162
+ "style": {
163
+ "navigationBarTitleText": "忘记密码",
164
+ "navigationBarBackgroundColor": "#F5F5F5"
165
+ }
166
+ },
167
+ {
168
+ "path": "pages/user/forgetPassword",
169
+ "style": {
170
+ "navigationBarTitleText": "修改密码",
171
+ "navigationBarBackgroundColor": "#F5F5F5"
172
+ }
173
+ }
174
+ ],
175
+ "globalStyle": {
176
+ "navigationBarTextStyle": "black",
177
+ "navigationBarTitleText": "uni-app",
178
+ "navigationBarBackgroundColor": "#FBFBFB",
179
+ "backgroundColor": "#F5F5F5"
180
+ },
181
+ "tabBar": {
182
+ "color": "#656C74",
183
+ "selectedColor": "#1D6FE9",
184
+ "borderStyle": "black",
185
+ "backgroundColor": "#ffffff",
186
+ "height": "180rpx",
187
+ "iconWidth": "54rpx",
188
+ "list": [
189
+ {
190
+ "pagePath": "pages/workspace/index",
191
+ "iconPath": "static/icon/tab/workspace.png",
192
+ "selectedIconPath": "static/icon/tab/workspace_active.png",
193
+ "text": "工作台"
194
+ },
195
+ {
196
+ "pagePath": "pages/user/index",
197
+ "iconPath": "static/icon/tab/user.png",
198
+ "selectedIconPath": "static/icon/tab/user_active.png",
199
+ "text": "我的"
200
+ }
201
+ ]
202
+ }
203
+ }
@@ -0,0 +1,6 @@
1
+ export {}
2
+
3
+ declare module "vue" {
4
+ type Hooks = App.AppInstance & Page.PageInstance;
5
+ interface ComponentCustomOptions extends Hooks {}
6
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,11 @@
1
+ import type { App } from "vue";
2
+ // 数据持久化插件
3
+ import piniaPluginPersist from 'pinia-plugin-persist-uni';
4
+ import { createPinia } from "pinia";
5
+ const store = createPinia();
6
+ store.use(piniaPluginPersist);
7
+ export function setupStore(app: App<Element>) {
8
+ app.use(store);
9
+ }
10
+
11
+ export { store };
@@ -0,0 +1,146 @@
1
+ import { defineStore } from 'pinia';
2
+ import { type customerStateType, store } from '../utils';
3
+ import { useSystemStore } from '@/stores/modules/system';
4
+ import { type CustomerRecord, type CustomerFollowRecord, FollowType, type formDataType } from '@/api/model/custom';
5
+ import { IntentionStatusOptions } from '@/dict/customer';
6
+ import { updateIntentionstatus, addFollow, updateFollow, deleteFollow, getContactsList } from '@/api/customer';
7
+ import { FOLLOW_PURPOSE, FOLLOW_RESULT } from '@/dict/customer';
8
+ import { formatDateTime } from '@/utils';
9
+ import * as model from '@/api/model/custom'
10
+
11
+ export type CustomerInfo = CustomerRecord & { avatarUrl: string;};
12
+ export const useCustomerStore = defineStore('customer', {
13
+ state: (): customerStateType => {
14
+ return {
15
+ customerInfo: {
16
+ customerName: '',
17
+ areaName: '',
18
+ contactsName: '',
19
+ contactsMobile: '',
20
+ intentionStatus: '',
21
+ avatarUrl: '',
22
+ employeeNameList: [],
23
+ },
24
+ followInfo: {
25
+ attachmentList: [],
26
+ },
27
+ followType: 'add', // 跟进类型,新增或编辑
28
+ loading: false, // 加载中
29
+ contactsList: [], // 联系人列表
30
+ };
31
+ },
32
+ getters: {},
33
+ actions: {
34
+ setFollowType(type: 'add' | 'edit') {
35
+ this.followType = type;
36
+ },
37
+ getCustomerInfo(): CustomerInfo {
38
+ return this.customerInfo;
39
+ },
40
+ setCustomerInfo(info: CustomerInfo) {
41
+ this.customerInfo = info;
42
+ },
43
+ getFollowInfo(): CustomerFollowRecord {
44
+ return this.followInfo;
45
+ },
46
+ setFollowInfo(info: CustomerFollowRecord) {
47
+ this.followInfo = info;
48
+ },
49
+ async selectIntentionStatus(index: number) {
50
+ try {
51
+ const selectedValue = IntentionStatusOptions[index].value;
52
+ const res = await updateIntentionstatus({
53
+ customerCode: this.customerInfo.customerCode,
54
+ customerType: this.customerInfo.customerType,
55
+ intentionStatus: selectedValue,
56
+ updateBy: 1,
57
+ });
58
+ if (res) {
59
+ this.customerInfo.intentionStatus = selectedValue;
60
+ } else {
61
+ uni.showToast({ title: '更新客户状态失败', icon: 'error' });
62
+ }
63
+ } catch (error) {
64
+ console.log(error);
65
+ }
66
+ },
67
+ async addFollow(info: formDataType) {
68
+ const { attachmentList, followTime } = info;
69
+ // 只取图片id
70
+ const attachmentIdList = attachmentList?.map((item: any) => Number(item.id));
71
+ const { customerCode } = this.customerInfo;
72
+ const data = {
73
+ ...info,
74
+ attachmentIdList,
75
+ followPurposeDictCode: FOLLOW_PURPOSE,
76
+ followResultDictCode: FOLLOW_RESULT,
77
+ followTime: formatDateTime(followTime),
78
+ customerCode: customerCode,
79
+ followType: FollowType.Visit,
80
+ }
81
+ if (this.followType === 'edit') {
82
+ const res = await updateFollow({
83
+ ...data,
84
+ id: Number(this.followInfo.id),
85
+ });
86
+ if (res) {
87
+ uni.showToast({ title: '成功编辑拜访记录', icon: 'success' });
88
+ }
89
+ } else {
90
+ const res = await addFollow(data);
91
+ if (res) {
92
+ uni.showToast({ title: '已添加拜访记录', icon: 'success' });
93
+ }
94
+ }
95
+ uni.$emit('follow-updated'); // 触发全局事件
96
+ setTimeout(() => uni.navigateBack(), 1000);
97
+ },
98
+ async deleteFollow(id: number) {
99
+ try {
100
+ const res = await deleteFollow(id);
101
+ if (res) {
102
+ uni.showToast({ title: '成功删除该记录', icon: 'success' });
103
+ return true;
104
+ } else {
105
+ uni.showToast({ title: '更新客户状态失败', icon: 'error' });
106
+ return false;
107
+ }
108
+ } catch (error) {
109
+ console.log(error);
110
+ }
111
+ },
112
+ async initVisitDict() {
113
+ const systemStore = useSystemStore(store);
114
+ // 使用Promise.all处理并行请求
115
+ try {
116
+ await systemStore.getDictList(FOLLOW_PURPOSE)
117
+ await systemStore.getDictList(FOLLOW_RESULT)
118
+ const res = await getContactsList({
119
+ size: 200,
120
+ current: 1,
121
+ customerCode: this.customerInfo.customerCode
122
+ });
123
+ this.contactsList = res.map((item: { contactsName: any; contactsJob: any; contactsMobile: any; }) => {
124
+ return {
125
+ contactsName:`${item.contactsName} - ${item.contactsJob} - ${item.contactsMobile}`
126
+ }
127
+ });
128
+ } catch (error) {
129
+ console.error('初始化字典失败', error);
130
+ }
131
+ },
132
+ async getContacts(params: model.contactsListParams) {
133
+ try {
134
+ const res = await getContactsList(params);
135
+ return res;
136
+ } catch (error) {
137
+ console.log(error);
138
+ }
139
+ }
140
+ },
141
+ });
142
+
143
+ export function useCustomerStoreHook() {
144
+ return useCustomerStore(store);
145
+ }
146
+
@@ -0,0 +1,30 @@
1
+ import { defineStore } from 'pinia';
2
+ import { getDictList as getDictListReq } from '@/api/index'
3
+ import { store } from '../utils';
4
+
5
+ // 微信相关信息
6
+ export const useInstalltionStore = defineStore('installtion', {
7
+ state: () => {
8
+ return {
9
+ info: {
10
+ status: 0,
11
+ recordList: [],
12
+ }
13
+ };
14
+ },
15
+ getters: {
16
+ getSystemInfo(): any {
17
+ return this.info;
18
+ },
19
+ },
20
+ actions: {
21
+ setSystemInfo(info: any) {
22
+ this.info = info;
23
+ },
24
+ },
25
+ });
26
+
27
+ export function useInstalltionStoreHook() {
28
+ return useInstalltionStore(store);
29
+ }
30
+
@@ -0,0 +1,56 @@
1
+ import { defineStore } from 'pinia';
2
+ import { getDictList as getDictListReq } from '@/api/index'
3
+ import { type systemStateType, store } from '../utils';
4
+
5
+ // 微信相关信息
6
+ export const useSystemStore = defineStore('system', {
7
+ state: (): systemStateType => {
8
+ return {
9
+ activeTab: 'customer', // 未定义
10
+ userType: 'factory', // 未定义
11
+ nickName: '',
12
+ avatarUrl: '',
13
+ dict: {
14
+ 'FOLLOW_PURPOSE': [], // 拜访目的字典code
15
+ 'FOLLOW_RESULT': [], // 拜访结果字典code
16
+ },
17
+ };
18
+ },
19
+ getters: {
20
+ getSystemInfo(): { avatarUrl: string; nickName?: string; } {
21
+ return {
22
+ nickName: this.nickName || uni.getStorageSync('nickName'),
23
+ avatarUrl: this.avatarUrl || uni.getStorageSync('avatarUrl'),
24
+ }
25
+ },
26
+ },
27
+ actions: {
28
+ changeTab(type: activeTab) {
29
+ this.activeTab = type;
30
+ },
31
+ setSystemInfo(info: { avatarUrl: string; nickName?: string; }) {
32
+ this.nickName = info?.nickName;
33
+ this.avatarUrl = info?.avatarUrl;
34
+ uni.setStorage({ key: 'nickName', data: info?.nickName });
35
+ uni.setStorage({ key: 'avatarUrl', data: info?.avatarUrl });
36
+ },
37
+ async getDictList(dictCode: string) {
38
+ const res = await getDictListReq({
39
+ size: 100,
40
+ current: 1,
41
+ dictCode
42
+ })
43
+ if (res) {
44
+ this.dict[dictCode] = res
45
+ }
46
+ }
47
+ },
48
+ persist: {
49
+ enabled: true
50
+ }
51
+ });
52
+
53
+ export function useSystemStoreHook() {
54
+ return useSystemStore(store);
55
+ }
56
+
@@ -0,0 +1,133 @@
1
+ import { defineStore } from 'pinia';
2
+ import { doLogout,
3
+ getLoginInfo as getLoginInfoApi,
4
+ getUserInfoApi, accountLogin } from '@/api/user';
5
+ import { store } from '@/stores';
6
+ import { APPID } from '@/config/app';
7
+
8
+ interface UserInfo {
9
+ id?: string;
10
+ accessToken?: string;
11
+ tokenType?: string;
12
+ refreshToken?: string;
13
+ nickname?: string;
14
+ account?: string;
15
+ avatar?: string;
16
+ expiresIn?: string;
17
+ authority?: string;
18
+ userCode?: string;
19
+ }
20
+
21
+ interface UserState {
22
+ userInfo: null | UserInfo;
23
+ token?: string;
24
+ lastUpdateTime: number;
25
+ loginIng: boolean;
26
+ menuList: any[];
27
+ permsList: any[];
28
+ }
29
+
30
+ export const useUserStore = defineStore('app-user', {
31
+ state: (): UserState => ({
32
+ userInfo: null,
33
+ token: undefined,
34
+ lastUpdateTime: 0,
35
+ loginIng: false,
36
+ menuList: [],
37
+ permsList: []
38
+ }),
39
+ getters: {
40
+ getUserInfo(): UserInfo {
41
+ return this.userInfo || uni.getStorageSync('userInfo');
42
+ },
43
+ getToken(): string {
44
+ return this.token || uni.getStorageSync('token');
45
+ },
46
+ getMenuList(): any[] {
47
+ return this.menuList || uni.getStorageSync('menuList');
48
+ },
49
+ getPermsList(): any[] {
50
+ return this.permsList || uni.getStorageSync('permsList');
51
+ }
52
+ },
53
+ actions: {
54
+ setToken(token: string | undefined) {
55
+ this.token = token || '';
56
+ uni.setStorage({ key: 'token', data: token });
57
+ },
58
+ async getLoginInfo() {
59
+ const res = await getLoginInfoApi()
60
+ if (res) {
61
+ this.setLoginInfo(res)
62
+ }
63
+ },
64
+ async getUserInfoFunc(cb) {
65
+ const res = await getUserInfoApi()
66
+ if (res) {
67
+ this.userInfo = res;
68
+ cb && cb();
69
+ }
70
+ },
71
+ setLoginInfo(info: any) {
72
+ const { menuList, permsList } = info
73
+ this.menuList = menuList || [];
74
+ this.permsList = permsList || [];
75
+ uni.setStorage({ key: 'menuList', data: menuList });
76
+ uni.setStorage({ key: 'permsList', data: permsList });
77
+ },
78
+ setUserInfo(info: null | UserInfo) {
79
+ this.userInfo = info;
80
+ this.lastUpdateTime = new Date().getTime();
81
+ uni.setStorage({ key: 'userInfo', data: info });
82
+ },
83
+ resetState() {
84
+ this.userInfo = null;
85
+ this.token = '';
86
+ },
87
+ resetLoginStatus() {
88
+ this.loginIng = false
89
+ },
90
+ /**
91
+ * @description: logout
92
+ */
93
+ async logout() {
94
+ this.setToken(undefined);
95
+ this.setUserInfo(null);
96
+ uni.navigateTo({ url: '/pages/user/login' })
97
+ },
98
+ hasPerms(permission: string) {
99
+ const permsList = this.permsList;
100
+ return permsList.includes(`${APPID}:${permission}`);
101
+ },
102
+ hasEntry(permission: string) {
103
+ const permsList = this.permsList;
104
+ return permsList.includes(permission);
105
+ },
106
+ async toLogin(formData: {
107
+ name: string | number,
108
+ password: string,
109
+ }){
110
+ uni.showLoading({ title: '登录中...' })
111
+ const res = await accountLogin({
112
+ account: formData.name,
113
+ password: formData.password,
114
+ })
115
+ if (res) {
116
+ this.setToken(res?.token)
117
+ this.setLoginInfo(res)
118
+ uni.switchTab({ url: '/pages/workspace/index' })
119
+ }
120
+ }
121
+ },
122
+ persist: {
123
+ enabled: true
124
+ }
125
+ });
126
+
127
+ // 用于组件外使用
128
+ export function useUserStoreWithOut() {
129
+ return useUserStore(store);
130
+ }
131
+
132
+ // 用于 storeToRefs 及 自动导入 https://github.com/Allen-1998/pinia-auto-refs
133
+ export default useUserStore;
@@ -0,0 +1,16 @@
1
+
2
+ export type systemStateType = {
3
+ activeTab: activeTab;
4
+ userType: UserType;
5
+ nickName: string | undefined;
6
+ avatarUrl: string | undefined;
7
+ dict: { [key: string]: any };
8
+ };
9
+
10
+ export type customerStateType = {
11
+ customerInfo: any;
12
+ followInfo: any;
13
+ followType: 'add' | 'edit'; // 跟进类型,新增或编辑
14
+ loading: boolean; // 加载中
15
+ contactsList: any; // 联系人列表
16
+ };