@zfqh/uniapp 0.1.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.
Files changed (310) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -0
  4. package/docs/api/apis/core.md +189 -0
  5. package/docs/api/apis/index.md +82 -0
  6. package/docs/api/apis/request.md +369 -0
  7. package/docs/api/configs/api.md +32 -0
  8. package/docs/api/configs/app.md +43 -0
  9. package/docs/api/configs/brand.md +43 -0
  10. package/docs/api/configs/cdn.md +35 -0
  11. package/docs/api/configs/color.md +144 -0
  12. package/docs/api/configs/env.md +120 -0
  13. package/docs/api/configs/index.md +394 -0
  14. package/docs/api/configs/link.md +33 -0
  15. package/docs/api/configs/log.md +27 -0
  16. package/docs/api/configs/mp.md +34 -0
  17. package/docs/api/configs/navigate.md +27 -0
  18. package/docs/api/configs/page.md +32 -0
  19. package/docs/api/configs/path.md +27 -0
  20. package/docs/api/configs/storage.md +24 -0
  21. package/docs/api/configs/tabbar.md +29 -0
  22. package/docs/api/configs/toast.md +35 -0
  23. package/docs/api/configs/update.md +25 -0
  24. package/docs/api/configs/upload.md +45 -0
  25. package/docs/api/configs/ver.md +32 -0
  26. package/docs/api/configs/web.md +28 -0
  27. package/docs/api/hooks/index.md +182 -0
  28. package/docs/api/hooks/useI18n.md +27 -0
  29. package/docs/api/hooks/useOverlay.md +37 -0
  30. package/docs/api/hooks/usePopup.md +35 -0
  31. package/docs/api/hooks/useVersion.md +23 -0
  32. package/docs/api/index.md +269 -0
  33. package/docs/api/mixins/app.md +29 -0
  34. package/docs/api/mixins/badge.md +23 -0
  35. package/docs/api/mixins/debounce.md +32 -0
  36. package/docs/api/mixins/deep.md +29 -0
  37. package/docs/api/mixins/index.md +23 -0
  38. package/docs/api/mixins/login.md +22 -0
  39. package/docs/api/mixins/model.md +26 -0
  40. package/docs/api/mixins/redirect.md +26 -0
  41. package/docs/api/mixins/share.md +29 -0
  42. package/docs/api/mixins/show.md +27 -0
  43. package/docs/api/mixins/webview.md +27 -0
  44. package/docs/api/modules/app.md +30 -0
  45. package/docs/api/modules/dict.md +28 -0
  46. package/docs/api/modules/im.md +22 -0
  47. package/docs/api/modules/index.md +44 -0
  48. package/docs/api/modules/launch.md +26 -0
  49. package/docs/api/modules/location.md +25 -0
  50. package/docs/api/modules/login.md +35 -0
  51. package/docs/api/modules/network.md +26 -0
  52. package/docs/api/modules/system.md +29 -0
  53. package/docs/api/utils/audio.md +84 -0
  54. package/docs/api/utils/consts.md +201 -0
  55. package/docs/api/utils/cos.md +269 -0
  56. package/docs/api/utils/debounce.md +89 -0
  57. package/docs/api/utils/file.md +78 -0
  58. package/docs/api/utils/index.md +547 -0
  59. package/docs/api/utils/locale.md +32 -0
  60. package/docs/api/utils/message.md +81 -0
  61. package/docs/api/utils/navigate.md +267 -0
  62. package/docs/api/utils/pages.md +205 -0
  63. package/docs/api/utils/permission.md +28 -0
  64. package/docs/api/utils/permit.md +62 -0
  65. package/docs/api/utils/query.md +89 -0
  66. package/docs/api/utils/request.md +34 -0
  67. package/docs/api/utils/storage.md +145 -0
  68. package/docs/api/utils/subscribe.md +77 -0
  69. package/docs/api/utils/throttle.md +101 -0
  70. package/docs/api/utils/toast.md +164 -0
  71. package/docs/api/utils/uni.md +28 -0
  72. package/docs/api/utils/update.md +165 -0
  73. package/docs/components/g-back-button.md +76 -0
  74. package/docs/components/g-checkbox-list.md +101 -0
  75. package/docs/components/g-container.md +93 -0
  76. package/docs/components/g-data-list.md +106 -0
  77. package/docs/components/g-dot-text.md +79 -0
  78. package/docs/components/g-env.md +75 -0
  79. package/docs/components/g-float.md +83 -0
  80. package/docs/components/g-grid-image.md +91 -0
  81. package/docs/components/g-grid-swiper.md +99 -0
  82. package/docs/components/g-icon.md +106 -0
  83. package/docs/components/g-mask.md +82 -0
  84. package/docs/components/g-money.md +90 -0
  85. package/docs/components/g-more.md +78 -0
  86. package/docs/components/g-page-container.md +170 -0
  87. package/docs/components/g-permission-popup.md +117 -0
  88. package/docs/components/g-polyline-chat.md +102 -0
  89. package/docs/components/g-polyline-view.md +67 -0
  90. package/docs/components/g-popup.md +144 -0
  91. package/docs/components/g-refresh-view.md +118 -0
  92. package/docs/components/g-render-image.md +83 -0
  93. package/docs/components/g-search.md +120 -0
  94. package/docs/components/g-share-photo.md +77 -0
  95. package/docs/components/g-share-view.md +83 -0
  96. package/docs/components/g-share-weixin.md +81 -0
  97. package/docs/components/g-skeleton-view.md +71 -0
  98. package/docs/components/g-skeleton.md +64 -0
  99. package/docs/components/g-tag-editor.md +134 -0
  100. package/docs/components/g-timer.md +72 -0
  101. package/docs/components/g-trtc-room.md +116 -0
  102. package/docs/components/g-trtc-tui.md +84 -0
  103. package/docs/components/g-trtc.md +124 -0
  104. package/docs/components/g-upload.md +117 -0
  105. package/docs/components/g-waterfall.md +84 -0
  106. package/docs/components/index.md +109 -0
  107. package/docs/components/styles/base-styles.md +367 -0
  108. package/docs/components/styles/global-vars.md +150 -0
  109. package/docs/components/usage.md +112 -0
  110. package/docs/faq/index.md +78 -0
  111. package/docs/guide/getting-started.md +195 -0
  112. package/docs/guide/project-frame.md +297 -0
  113. package/docs/index.md +80 -0
  114. package/lib/apis/core.d.ts +12 -0
  115. package/lib/apis/core.js +13 -0
  116. package/lib/apis/index.d.ts +2 -0
  117. package/lib/apis/index.js +2 -0
  118. package/lib/apis/request.d.ts +4 -0
  119. package/lib/apis/request.js +27 -0
  120. package/lib/components/g-back-button/g-back-button.vue +141 -0
  121. package/lib/components/g-checkbox-list/g-checkbox-list.vue +156 -0
  122. package/lib/components/g-container/g-container.vue +159 -0
  123. package/lib/components/g-data-list/g-data-list.vue +192 -0
  124. package/lib/components/g-dot-text/g-dot-text.vue +114 -0
  125. package/lib/components/g-env/g-env.vue +123 -0
  126. package/lib/components/g-float/g-float.vue +131 -0
  127. package/lib/components/g-grid-image/g-grid-image.vue +84 -0
  128. package/lib/components/g-grid-swiper/g-grid-swiper.vue +224 -0
  129. package/lib/components/g-icon/g-icon.vue +72 -0
  130. package/lib/components/g-mask/g-mask.vue +126 -0
  131. package/lib/components/g-money/g-money.vue +174 -0
  132. package/lib/components/g-more/g-more.vue +68 -0
  133. package/lib/components/g-page-container/g-page-container.vue +470 -0
  134. package/lib/components/g-permission-popup/g-permission-popup.vue +80 -0
  135. package/lib/components/g-polyline-chat/g-polyline-chat.vue +255 -0
  136. package/lib/components/g-polyline-view/g-polyline-view.vue +104 -0
  137. package/lib/components/g-popup/g-popup.vue +449 -0
  138. package/lib/components/g-refresh-view/g-refresh-view.vue +213 -0
  139. package/lib/components/g-render-image/g-render-image.vue +222 -0
  140. package/lib/components/g-search/g-search.vue +274 -0
  141. package/lib/components/g-share-photo/g-share-photo.vue +75 -0
  142. package/lib/components/g-share-view/g-share-view.vue +157 -0
  143. package/lib/components/g-share-weixin/g-share-weixin.vue +106 -0
  144. package/lib/components/g-skeleton/g-skeleton.vue +55 -0
  145. package/lib/components/g-skeleton-view/g-skeleton-view.vue +78 -0
  146. package/lib/components/g-tag-editor/g-tag-editor.vue +482 -0
  147. package/lib/components/g-timer/g-timer.vue +61 -0
  148. package/lib/components/g-trtc/g-trtc.vue +347 -0
  149. package/lib/components/g-trtc-room/g-trtc-room.vue +524 -0
  150. package/lib/components/g-trtc-room/iconfont.scss +59 -0
  151. package/lib/components/g-trtc-tui/g-trtc-tui.vue +245 -0
  152. package/lib/components/g-upload/g-upload.vue +294 -0
  153. package/lib/components/g-waterfall/g-waterfall.vue +101 -0
  154. package/lib/configs/api.d.ts +7 -0
  155. package/lib/configs/api.js +6 -0
  156. package/lib/configs/app.d.ts +26 -0
  157. package/lib/configs/app.js +50 -0
  158. package/lib/configs/brand.d.ts +22 -0
  159. package/lib/configs/brand.js +26 -0
  160. package/lib/configs/cdn.d.ts +13 -0
  161. package/lib/configs/cdn.js +12 -0
  162. package/lib/configs/color.d.ts +62 -0
  163. package/lib/configs/color.js +66 -0
  164. package/lib/configs/env.d.ts +37 -0
  165. package/lib/configs/env.js +71 -0
  166. package/lib/configs/index.d.ts +170 -0
  167. package/lib/configs/index.js +82 -0
  168. package/lib/configs/link.d.ts +11 -0
  169. package/lib/configs/link.js +3 -0
  170. package/lib/configs/log.d.ts +9 -0
  171. package/lib/configs/log.js +8 -0
  172. package/lib/configs/mp.d.ts +15 -0
  173. package/lib/configs/mp.js +9 -0
  174. package/lib/configs/navigate.d.ts +17 -0
  175. package/lib/configs/navigate.js +5 -0
  176. package/lib/configs/page.d.ts +18 -0
  177. package/lib/configs/page.js +14 -0
  178. package/lib/configs/path.d.ts +11 -0
  179. package/lib/configs/path.js +10 -0
  180. package/lib/configs/storage.d.ts +7 -0
  181. package/lib/configs/storage.js +6 -0
  182. package/lib/configs/tabbar.d.ts +7 -0
  183. package/lib/configs/tabbar.js +6 -0
  184. package/lib/configs/toast.d.ts +18 -0
  185. package/lib/configs/toast.js +29 -0
  186. package/lib/configs/update.d.ts +45 -0
  187. package/lib/configs/update.js +6 -0
  188. package/lib/configs/upload.d.ts +30 -0
  189. package/lib/configs/upload.js +7 -0
  190. package/lib/configs/ver.d.ts +8 -0
  191. package/lib/configs/ver.js +28 -0
  192. package/lib/configs/web.d.ts +5 -0
  193. package/lib/configs/web.js +2 -0
  194. package/lib/hooks/index.d.ts +4 -0
  195. package/lib/hooks/index.js +4 -0
  196. package/lib/hooks/useI18n.d.ts +2 -0
  197. package/lib/hooks/useI18n.js +19 -0
  198. package/lib/hooks/useOverlay.d.ts +1 -0
  199. package/lib/hooks/useOverlay.js +17 -0
  200. package/lib/hooks/usePopup.d.ts +1 -0
  201. package/lib/hooks/usePopup.js +14 -0
  202. package/lib/hooks/useVersion.d.ts +6 -0
  203. package/lib/hooks/useVersion.js +21 -0
  204. package/lib/index.d.ts +26 -0
  205. package/lib/index.js +33 -0
  206. package/lib/mixins/app.d.ts +14 -0
  207. package/lib/mixins/app.js +105 -0
  208. package/lib/mixins/badge.d.ts +24 -0
  209. package/lib/mixins/badge.js +44 -0
  210. package/lib/mixins/debounce.d.ts +6 -0
  211. package/lib/mixins/debounce.js +11 -0
  212. package/lib/mixins/deep.d.ts +6 -0
  213. package/lib/mixins/deep.js +8 -0
  214. package/lib/mixins/index.d.ts +8 -0
  215. package/lib/mixins/index.js +8 -0
  216. package/lib/mixins/login.d.ts +4 -0
  217. package/lib/mixins/login.js +25 -0
  218. package/lib/mixins/model.d.ts +22 -0
  219. package/lib/mixins/model.js +29 -0
  220. package/lib/mixins/redirect.d.ts +8 -0
  221. package/lib/mixins/redirect.js +94 -0
  222. package/lib/mixins/share.d.ts +15 -0
  223. package/lib/mixins/share.js +55 -0
  224. package/lib/mixins/show.d.ts +9 -0
  225. package/lib/mixins/show.js +16 -0
  226. package/lib/mixins/webview.d.ts +26 -0
  227. package/lib/mixins/webview.js +225 -0
  228. package/lib/modules/app.d.ts +5 -0
  229. package/lib/modules/app.js +19 -0
  230. package/lib/modules/dict.d.ts +8 -0
  231. package/lib/modules/dict.js +43 -0
  232. package/lib/modules/im.d.ts +6 -0
  233. package/lib/modules/im.js +105 -0
  234. package/lib/modules/index.d.ts +8 -0
  235. package/lib/modules/index.js +8 -0
  236. package/lib/modules/launch.d.ts +5 -0
  237. package/lib/modules/launch.js +32 -0
  238. package/lib/modules/location.d.ts +5 -0
  239. package/lib/modules/location.js +57 -0
  240. package/lib/modules/login.d.ts +5 -0
  241. package/lib/modules/login.js +72 -0
  242. package/lib/modules/network.d.ts +5 -0
  243. package/lib/modules/network.js +39 -0
  244. package/lib/modules/system.d.ts +5 -0
  245. package/lib/modules/system.js +65 -0
  246. package/lib/styles/animate-vue.scss +3 -0
  247. package/lib/styles/animate.scss +27 -0
  248. package/lib/styles/bg-vue.scss +21 -0
  249. package/lib/styles/bg.scss +93 -0
  250. package/lib/styles/border.scss +218 -0
  251. package/lib/styles/flex-nvue.scss +64 -0
  252. package/lib/styles/flex-vue.scss +75 -0
  253. package/lib/styles/font.scss +59 -0
  254. package/lib/styles/index.scss +25 -0
  255. package/lib/styles/layout-nvue.scss +24 -0
  256. package/lib/styles/layout-vue.scss +30 -0
  257. package/lib/styles/layout.scss +76 -0
  258. package/lib/styles/opacity.scss +10 -0
  259. package/lib/styles/reset-vue.scss +46 -0
  260. package/lib/styles/shadow.scss +12 -0
  261. package/lib/styles/sizing-vue.scss +21 -0
  262. package/lib/styles/sizing.scss +21 -0
  263. package/lib/styles/spacing.scss +234 -0
  264. package/lib/styles/text-nvue.scss +21 -0
  265. package/lib/styles/text-vue.scss +70 -0
  266. package/lib/styles/text.scss +122 -0
  267. package/lib/styles/var.module.scss +29 -0
  268. package/lib/utils/audio.d.ts +14 -0
  269. package/lib/utils/audio.js +43 -0
  270. package/lib/utils/consts.d.ts +30 -0
  271. package/lib/utils/consts.js +52 -0
  272. package/lib/utils/cos.d.ts +15 -0
  273. package/lib/utils/cos.js +140 -0
  274. package/lib/utils/debounce.d.ts +2 -0
  275. package/lib/utils/debounce.js +30 -0
  276. package/lib/utils/file.d.ts +28 -0
  277. package/lib/utils/file.js +292 -0
  278. package/lib/utils/index.d.ts +166 -0
  279. package/lib/utils/index.js +485 -0
  280. package/lib/utils/locale.d.ts +6 -0
  281. package/lib/utils/locale.js +19 -0
  282. package/lib/utils/message.d.ts +9 -0
  283. package/lib/utils/message.js +63 -0
  284. package/lib/utils/navigate.d.ts +27 -0
  285. package/lib/utils/navigate.js +183 -0
  286. package/lib/utils/pages.d.ts +21 -0
  287. package/lib/utils/pages.js +79 -0
  288. package/lib/utils/permission.d.ts +16 -0
  289. package/lib/utils/permission.js +291 -0
  290. package/lib/utils/permit.d.ts +30 -0
  291. package/lib/utils/permit.js +181 -0
  292. package/lib/utils/query.d.ts +13 -0
  293. package/lib/utils/query.js +14 -0
  294. package/lib/utils/request.d.ts +8 -0
  295. package/lib/utils/request.js +126 -0
  296. package/lib/utils/storage.d.ts +53 -0
  297. package/lib/utils/storage.js +145 -0
  298. package/lib/utils/subscribe.d.ts +7 -0
  299. package/lib/utils/subscribe.js +94 -0
  300. package/lib/utils/throttle.d.ts +2 -0
  301. package/lib/utils/throttle.js +32 -0
  302. package/lib/utils/toast.d.ts +17 -0
  303. package/lib/utils/toast.js +66 -0
  304. package/lib/utils/uni.d.ts +1 -0
  305. package/lib/utils/uni.js +147 -0
  306. package/lib/utils/update.d.ts +9 -0
  307. package/lib/utils/update.js +376 -0
  308. package/package.json +49 -0
  309. package/types/index.d.ts +25 -0
  310. package/types/virtual.d.ts +1 -0
@@ -0,0 +1,245 @@
1
+ <template>
2
+ <g-mask :show="visible" :customStyle="maskStyle" :maskClickAble="false">
3
+ <g-trtc-room
4
+ ref="room"
5
+ v-if="roomId"
6
+ :title="profile.title"
7
+ :avatar="profile.avatar"
8
+ :description="profile.description"
9
+ :roomId="roomId"
10
+ :appId="imInfo.appId"
11
+ :userId="imInfo.userId"
12
+ :userSig="imInfo.userSig"
13
+ :callType="callType"
14
+ @zoom="zoom"
15
+ @hangup="hangup"
16
+ @accept="accept"
17
+ @leave="hangup('leave')"
18
+ />
19
+ </g-mask>
20
+ </template>
21
+
22
+ <script>
23
+ import TUIChatEngine, { TUIUserService, TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
24
+
25
+ export default {
26
+ props: {
27
+ // 房间名称
28
+ title: {
29
+ type: String,
30
+ default: '',
31
+ },
32
+ // 房间头像
33
+ avatar: {
34
+ type: String,
35
+ default: '',
36
+ },
37
+ // 房间简介
38
+ description: {
39
+ type: String,
40
+ default: '',
41
+ },
42
+ },
43
+ data() {
44
+ return {
45
+ visible: false,
46
+ float: false,
47
+ roomId: 0,
48
+ callType: 1,
49
+ calling: {
50
+ conversationID: '',
51
+ conversationType: '',
52
+ },
53
+ inviter: {},
54
+ userList: [],
55
+ };
56
+ },
57
+ watch: {
58
+ visible(e) {
59
+ if (e) {
60
+ this.$refs.room?.createBells();
61
+ } else {
62
+ this.$refs.room?.destroyBells();
63
+ }
64
+ },
65
+ },
66
+ computed: {
67
+ maskStyle() {
68
+ if (this.float) {
69
+ // 解决缩小通话界面无法点击底部问题
70
+ return { width: 0, height: 0 };
71
+ } else {
72
+ return {};
73
+ }
74
+ },
75
+ imInfo() {
76
+ return this.$store.state.im.info;
77
+ },
78
+ profile() {
79
+ const inviter = this.inviter || {};
80
+ const title = this.title || inviter.nick;
81
+ const avatar = this.avatar || inviter.avatar;
82
+ const description = this.description || inviter.description;
83
+ return {
84
+ title,
85
+ avatar,
86
+ description,
87
+ };
88
+ },
89
+ },
90
+ methods: {
91
+ zoom(e) {
92
+ this.float = e;
93
+ },
94
+ hangup(type) {
95
+ const { data, callData, conversationID, conversationType } = this.calling;
96
+ const { room } = this.$refs;
97
+ if (room.duration) {
98
+ data.actionType = 1;
99
+ callData.call_end = room.duration;
100
+ if (type === 'leave') {
101
+ this.sendMessage({
102
+ conversationID,
103
+ conversationType,
104
+ data,
105
+ callData,
106
+ });
107
+ uni.showToast({
108
+ icon: 'none',
109
+ position: 'bottom',
110
+ title: '对方已挂断,通话结束',
111
+ });
112
+ }
113
+ } else {
114
+ data.actionType = 4;
115
+ this.sendMessage({
116
+ conversationID,
117
+ conversationType,
118
+ data,
119
+ callData,
120
+ });
121
+ }
122
+ this.visible = false;
123
+ setTimeout(() => {
124
+ this.roomId = 0;
125
+ }, 500);
126
+ },
127
+ accept() {
128
+ const { data, callData, conversationID, conversationType } = this.calling;
129
+ this.sendMessage({
130
+ conversationID,
131
+ conversationType,
132
+ data: {
133
+ ...data,
134
+ actionType: 3,
135
+ },
136
+ callData,
137
+ });
138
+ },
139
+ async getMemberList(e) {
140
+ try {
141
+ const userIDList = e.map(({ userID }) => userID);
142
+ const { data } = await TUIUserService.getUserProfile({ userIDList });
143
+ this.userList = data;
144
+ } catch (e) {}
145
+ },
146
+ sendMessage({ data, callData, conversationID, conversationType }) {
147
+ TUIChatEngine.chat.sendMessage(
148
+ TUIChatEngine.chat.createCustomMessage({
149
+ conversationType,
150
+ to: conversationID.substring(conversationType.length),
151
+ payload: {
152
+ data: JSON.stringify({
153
+ ...data,
154
+ data: JSON.stringify(callData),
155
+ }),
156
+ },
157
+ }),
158
+ );
159
+ },
160
+ receivedMessage(event) {
161
+ event.data.forEach((message) => {
162
+ const { conversationID, conversationType, flow, type, from, payload } = message;
163
+ if (type === TUIChatEngine.TYPES.MSG_CUSTOM) {
164
+ try {
165
+ const data = JSON.parse(payload.data);
166
+ // 1呼叫、1结束(call_end > 0)、2挂断、3接听、4拒接、4忙线(line_busy="line_busy")、5无人接听
167
+ if (data.actionType != null) {
168
+ const callData = JSON.parse(data.data || '{}');
169
+ if (flow === 'in') {
170
+ TUIChatEngine.chat.setMessageRead({
171
+ conversationID,
172
+ });
173
+ if (data.actionType === 1) {
174
+ // 对方发起音视频通话
175
+ if (!callData.call_end) {
176
+ if (!this.visible) {
177
+ // 当前未通话
178
+ this.inviter = this.userList.find(({ userID }) => userID === from);
179
+ if (this.inviter) {
180
+ // 通话发起人是群成员,才能显式通话界面
181
+ this.visible = true;
182
+ this.callType = callData.call_type;
183
+ this.roomId = callData.room_id;
184
+ this.calling = {
185
+ conversationID,
186
+ conversationType,
187
+ data,
188
+ callData,
189
+ };
190
+ }
191
+ } else {
192
+ // 通话中,提示忙线
193
+ this.sendMessage({
194
+ conversationID,
195
+ conversationType,
196
+ data: {
197
+ ...data,
198
+ actionType: 4,
199
+ },
200
+ callData: {
201
+ ...callData,
202
+ line_busy: 'line_busy',
203
+ },
204
+ });
205
+ }
206
+ } else {
207
+ // 自己结束通话
208
+ this.visible = false;
209
+ }
210
+ } else if (conversationID === this.calling.conversationID) {
211
+ if ([2, 4, 5].includes(data.actionType)) {
212
+ this.visible = false;
213
+ uni.showToast({
214
+ icon: 'none',
215
+ position: 'bottom',
216
+ title: '对方取消通话',
217
+ });
218
+ }
219
+ }
220
+ } else {
221
+ // 其他设备接听或挂断,当前设备关闭通话
222
+ if ([3, 4].includes(data.actionType)) {
223
+ this.visible = false;
224
+ }
225
+ }
226
+ }
227
+ } catch (e) {}
228
+ }
229
+ });
230
+ },
231
+ },
232
+ mounted() {
233
+ TUIStore.watch(StoreName.GRP, {
234
+ currentGroupMemberList: this.getMemberList,
235
+ });
236
+ TUIChatEngine.chat.on(TUIChatEngine.EVENT.MESSAGE_RECEIVED, this.receivedMessage);
237
+ },
238
+ beforeUnmount() {
239
+ TUIStore.unwatch(StoreName.GRP, {
240
+ currentGroupMemberList: this.getMemberList,
241
+ });
242
+ TUIChatEngine.chat.off(TUIChatEngine.EVENT.MESSAGE_RECEIVED, this.receivedMessage);
243
+ },
244
+ };
245
+ </script>
@@ -0,0 +1,294 @@
1
+ <template>
2
+ <view class="upload" :style="[_customStyle]">
3
+ <view
4
+ v-for="(item, i) in list"
5
+ :key="i"
6
+ class="upload-item"
7
+ :class="[item.title ? 'has-title' : '']"
8
+ :style="[_itemStyle]"
9
+ @tap="previewImage(item)"
10
+ >
11
+ <view class="upload-loading" v-if="!item.url" :style="[_loadingStyle]">
12
+ <uv-loading-icon mode="circle" :size="loadingSize" />
13
+ </view>
14
+ <view v-if="!disabled" class="upload-close" @tap.stop="removeFile(item, i)" :style="[_closeStyle]">
15
+ <uv-icon name="close-circle-fill" :size="closeSize" :color="closeColor" />
16
+ </view>
17
+ <view class="upload-title" v-if="item.title">
18
+ <text>{{ item.title }}</text>
19
+ </view>
20
+ <image :src="item.path || compress(item.url)" style="max-width: 100%; max-height: 100%" mode="aspectFit" />
21
+ </view>
22
+ <template v-if="!disabled">
23
+ <view v-if="list.length < count" class="upload-item" :style="[_itemStyle]" @tap="$uv.throttle(chooseImage)">
24
+ <slot name="default">
25
+ <uv-icon name="plus" :size="iconSize" :color="iconColor" />
26
+ </slot>
27
+ </view>
28
+ </template>
29
+ </view>
30
+ </template>
31
+
32
+ <script>
33
+ import { cosCompress } from '../../utils';
34
+ import { requestPermission } from '../../utils/permit';
35
+ import deep from '../../mixins/deep';
36
+ import model from '../../mixins/model';
37
+ import color from '../../configs/color';
38
+
39
+ export default {
40
+ mixins: [
41
+ deep,
42
+ model({
43
+ type: Array,
44
+ default: null,
45
+ }),
46
+ ],
47
+ props: {
48
+ files: {
49
+ type: Array,
50
+ default: () => [],
51
+ },
52
+ size: {
53
+ type: [String, Number],
54
+ default: 70,
55
+ },
56
+ iconSize: {
57
+ type: [String, Number],
58
+ default: 30,
59
+ },
60
+ iconColor: {
61
+ type: String,
62
+ default: () => color.borderColor,
63
+ },
64
+ loadingSize: {
65
+ type: [String, Number],
66
+ default: 20,
67
+ },
68
+ col: {
69
+ type: [String, Number],
70
+ default: 4,
71
+ },
72
+ count: {
73
+ type: [String, Number],
74
+ default: 8,
75
+ },
76
+ disabled: {
77
+ type: Boolean,
78
+ default: false,
79
+ },
80
+ custom: {
81
+ type: Boolean,
82
+ default: false,
83
+ },
84
+ border: {
85
+ type: Boolean,
86
+ default: true,
87
+ },
88
+ borderStyle: {
89
+ type: String,
90
+ default: 'solid',
91
+ },
92
+ borderColor: {
93
+ type: String,
94
+ default: () => color.borderColor,
95
+ },
96
+ borderRadius: {
97
+ type: [String, Number],
98
+ default: 4,
99
+ },
100
+ customStyle: {
101
+ type: Object,
102
+ default: () => ({}),
103
+ },
104
+ itemStyle: {
105
+ type: Object,
106
+ default: () => ({}),
107
+ },
108
+ gutter: {
109
+ type: [Array, Number, String],
110
+ default: () => 8,
111
+ },
112
+ bgColor: {
113
+ type: String,
114
+ default: '#fff',
115
+ },
116
+ closeSize: {
117
+ type: [String, Number],
118
+ default: 16,
119
+ },
120
+ closeColor: {
121
+ type: String,
122
+ default: () => color.contentColor,
123
+ },
124
+ closeStyle: {
125
+ type: Object,
126
+ default: () => ({}),
127
+ },
128
+ action: {
129
+ type: Function,
130
+ default: () => {},
131
+ },
132
+ },
133
+ data() {
134
+ return {
135
+ list: this.files,
136
+ };
137
+ },
138
+ computed: {
139
+ _gutter({ gutter }) {
140
+ return [].concat(gutter);
141
+ },
142
+ _customStyle({ _gutter, col, customStyle }) {
143
+ const [_row, _col] = _gutter;
144
+ return Object.assign(
145
+ {
146
+ display: col ? 'grid' : 'flex',
147
+ gridGap: `${uni.$uv.addUnit(_row)} ${uni.$uv.addUnit(_col || _row)}`,
148
+ gridTemplateColumns: new Array(Number(col))
149
+ .fill(undefined)
150
+ .map(() => '1fr')
151
+ .join(' '),
152
+ },
153
+ customStyle,
154
+ );
155
+ },
156
+ _itemStyle({ itemStyle, borderColor, borderStyle, border, borderRadius, bgColor, size }) {
157
+ const style = {
158
+ height: uni.$uv.addUnit(size),
159
+ width: uni.$uv.addUnit(size),
160
+ borderRadius: uni.$uv.addUnit(borderRadius),
161
+ backgroundColor: bgColor,
162
+ };
163
+ if (border) {
164
+ style.border = `1px ${borderStyle} ${borderColor}`;
165
+ }
166
+ return Object.assign(style, itemStyle);
167
+ },
168
+ _loadingStyle({ borderRadius }) {
169
+ return {
170
+ borderRadius: uni.$uv.addUnit(borderRadius),
171
+ };
172
+ },
173
+ _closeStyle({ closeSize, closeStyle }) {
174
+ const unit = String(closeSize).replace(/\d+/, '');
175
+ const offsetValue = uni.$uv.addUnit(-1 * (parseFloat(closeSize) / 2) + unit);
176
+ return Object.assign(
177
+ {
178
+ top: offsetValue,
179
+ right: offsetValue,
180
+ },
181
+ closeStyle,
182
+ );
183
+ },
184
+ },
185
+ watch: {
186
+ files: {
187
+ immediate: true,
188
+ handler(e) {
189
+ this.list = e;
190
+ },
191
+ },
192
+ value: {
193
+ immediate: true,
194
+ handler(e) {
195
+ if (e) {
196
+ if (e.length !== this.list.length) {
197
+ this.list = e.map((url) => ({ url }));
198
+ } else {
199
+ e?.forEach((url, i) => {
200
+ this.list[i].url = url;
201
+ });
202
+ }
203
+ }
204
+ },
205
+ },
206
+ list(e) {
207
+ this.$emit('update:files', e);
208
+ this.updateModel(e.map(({ url }) => url || ''));
209
+ },
210
+ },
211
+ methods: {
212
+ compress(url) {
213
+ if (url) {
214
+ let width = parseFloat(this.size);
215
+ if (String(this.size).endsWith('rpx')) {
216
+ width = uni.upx2px(width);
217
+ }
218
+ return cosCompress(url, `${width}x`);
219
+ }
220
+ return '';
221
+ },
222
+ previewImage({ path, url }) {
223
+ uni.previewImage({
224
+ urls: this.list.map(({ path, url }) => path || url),
225
+ current: path || url,
226
+ longPressActions: true,
227
+ });
228
+ },
229
+ removeFile(file, index) {
230
+ this.list = this.list.slice(0, index).concat(this.list.slice(index + 1));
231
+ },
232
+ chooseSuccess({ tempFiles }) {
233
+ const newList = [];
234
+ tempFiles.forEach((file) => {
235
+ if (/\.(png|jpg|jpeg|gif|bmp|webp)$/i.test(file.name || file.path)) {
236
+ newList.push(file);
237
+ this.action(file)?.then((data) => {
238
+ this.list = this.list.map((item) => {
239
+ if (item.path === file.path) {
240
+ file.url = data.url;
241
+ return file;
242
+ }
243
+ return item;
244
+ });
245
+ });
246
+ }
247
+ });
248
+ this.list = this.list.concat(newList);
249
+ },
250
+ async chooseImage() {
251
+ const count = this.count - this.list.length;
252
+ if (this.custom) {
253
+ this.$emit('choose', { count });
254
+ } else {
255
+ await requestPermission('storage');
256
+ await requestPermission('camera');
257
+ uni.chooseImage({
258
+ count,
259
+ success: this.chooseSuccess,
260
+ });
261
+ }
262
+ },
263
+ },
264
+ };
265
+ </script>
266
+
267
+ <style lang="scss" scoped>
268
+ .upload {
269
+ flex-wrap: wrap;
270
+ &-item {
271
+ position: relative;
272
+ display: flex;
273
+ justify-content: center;
274
+ align-items: center;
275
+ }
276
+ &-close {
277
+ position: absolute;
278
+ z-index: 1;
279
+ }
280
+ &-loading {
281
+ position: absolute;
282
+ top: 0;
283
+ left: 0;
284
+ right: 0;
285
+ bottom: 0;
286
+ background: rgba(0, 0, 0, 0.4);
287
+ overflow: hidden;
288
+ display: flex;
289
+ align-items: center;
290
+ justify-content: center;
291
+ z-index: 1;
292
+ }
293
+ }
294
+ </style>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <view class="flex items-start" id="waterfall-container">
3
+ <view class="flex-1 w-0" id="waterfall-column-left">
4
+ <slot name="left" :data="leftList" :props="props"></slot>
5
+ </view>
6
+ <view class="flex-1 w-0" id="waterfall-column-right" :style="[marginStyle]">
7
+ <slot name="right" :data="rightList" :props="props"></slot>
8
+ </view>
9
+ </view>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ props: {
15
+ list: {
16
+ type: Array,
17
+ default: () => [],
18
+ },
19
+ gutter: {
20
+ type: [String, Number],
21
+ default: 16,
22
+ },
23
+ props: {
24
+ type: Object,
25
+ default: () => ({}),
26
+ },
27
+ },
28
+ data() {
29
+ return {
30
+ leftList: [],
31
+ rightList: [],
32
+ tempList: [],
33
+ };
34
+ },
35
+ watch: {
36
+ list(newList, oldList) {
37
+ if (newList.length > oldList.length && this.leftList.length > 0) {
38
+ this.push(newList.slice(oldList.length));
39
+ } else {
40
+ this.update(newList);
41
+ }
42
+ },
43
+ },
44
+ computed: {
45
+ marginStyle({ gutter }) {
46
+ return {
47
+ marginLeft: uni.$uv.addUnit(gutter),
48
+ };
49
+ },
50
+ },
51
+ methods: {
52
+ async calc(data) {
53
+ if (!data) {
54
+ return;
55
+ }
56
+ let leftRect = { height: 0 };
57
+ let rightRect = { height: 0 };
58
+ if (this.leftList.length) {
59
+ leftRect = await this.$uvGetRect('#waterfall-column-left');
60
+ }
61
+ if (this.rightList.length) {
62
+ rightRect = await this.$uvGetRect('#waterfall-column-right');
63
+ }
64
+ if (rightRect.height < leftRect.height || (!this.rightList.length && this.leftList.length > 0)) {
65
+ this.rightList = this.rightList.concat(data);
66
+ } else {
67
+ this.leftList = this.leftList.concat(data);
68
+ }
69
+ await this.$nextTick();
70
+ // #ifdef MP
71
+ await this.$uvGetRect('#waterfall-container');
72
+ // #endif
73
+ if (this.tempList.length) {
74
+ const [data] = this.tempList.splice(0, 1);
75
+ this.calc(data);
76
+ }
77
+ },
78
+ push(list) {
79
+ this.tempList = [].concat(list);
80
+ const [data] = this.tempList.splice(0, 1);
81
+ this.$nextTick(() => {
82
+ this.calc(data);
83
+ });
84
+ },
85
+ clear() {
86
+ this.leftList = [];
87
+ this.rightList = [];
88
+ this.tempList = [];
89
+ },
90
+ update(list) {
91
+ this.clear();
92
+ this.push(list);
93
+ },
94
+ },
95
+ mounted() {
96
+ this.push(this.list);
97
+ },
98
+ };
99
+ </script>
100
+
101
+ <style></style>
@@ -0,0 +1,7 @@
1
+ /** 接口配置 */
2
+ declare const api: {
3
+ /** 接口请求地址 */
4
+ baseUrl: string;
5
+ };
6
+ export type ApiConfig = Partial<typeof api>;
7
+ export default api;
@@ -0,0 +1,6 @@
1
+ /** 接口配置 */
2
+ const api = {
3
+ /** 接口请求地址 */
4
+ baseUrl: '',
5
+ };
6
+ export default api;
@@ -0,0 +1,26 @@
1
+ /** 应用配置 */
2
+ declare const $app: {
3
+ /** 应用标识 */
4
+ code: string;
5
+ /** 应用名称 */
6
+ name: string;
7
+ /** 应用主题色 */
8
+ primary: string;
9
+ /** APP应用ID */
10
+ appId: string;
11
+ /** 小程序应用ID */
12
+ weappId: string;
13
+ /** 小程序应用原始ID */
14
+ weappOrigId: string;
15
+ /** 应用渠道标识 */
16
+ channel: number;
17
+ };
18
+ type App = typeof $app;
19
+ type Keys = keyof App;
20
+ export type AppConfig = {
21
+ [key in Keys]?: string;
22
+ };
23
+ export declare const app: {
24
+ [key in 'patient' | 'doctor' | 'merchant']: App;
25
+ };
26
+ export default $app;