@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.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/.versionrc ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "tagPrefix": "@lambo-design-mobile/js-bridge@",
3
+ "releaseCommitMessageFormat": "chore(release): @lambo-design-mobile/js-bridge@{{currentTag}}",
4
+ "path": ".",
5
+ "header": "# Changelog",
6
+ "types": [
7
+ {"type": "chore", "section":"'🎫 Chores | 其他更新", "hidden": false},
8
+ {"type": "revert", "section":"⏪ Reverts | 回退", "hidden": false},
9
+ {"type": "feat", "section": "✨ Features | 新功能", "hidden": false},
10
+ {"type": "fix", "section": "🐛 Bug Fixes | Bug 修复", "hidden": false},
11
+ {"type": "improvement", "section": "Feature Improvements", "hidden": false},
12
+ {"type": "docs", "section":"📝 Documentation | 文档", "hidden": false},
13
+ {"type": "style", "section":"💄 Styles | 风格", "hidden": false},
14
+ {"type": "refactor", "section":"♻️ Code Refactoring | 代码重构", "hidden": false},
15
+ {"type": "perf", "section":"⚡ Performance Improvements | 性能优化", "hidden": false},
16
+ {"type": "test", "section":"✅ Tests | 测试", "hidden": false},
17
+ {"type": "build", "section":"👷‍ Build System | 构建", "hidden": false},
18
+ {"type": "ci", "section":"🔧 Continuous Integration | CI 配置", "hidden":false}
19
+ ],
20
+ "commitUrlFormat": "http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/{{hash}}",
21
+ "compareUrlFormat": "http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/{{previousTag}}...{{currentTag}}",
22
+ "issueUrlFormat": "http://git.inspur.com/ecbh/lambo-design/lambo-design/-/issues/{{id}}"
23
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+ ## 1.0.0-beta.1 (2024-08-21)
3
+
4
+
5
+ ### 📝 Documentation | 文档
6
+
7
+ * **@lambo-design-mobile/js-bridge:** 新增初始化函数入参出参文档说明 ([6398076](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6398076b85c76d9fc86a0e964eb0d8224bd86721))
8
+ * **@lambo-design-mobile/js-bridge:** 新增openLocation相关文档 ([8b6d76f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/8b6d76f876ccf792770d39e0d2ef110a34bce16e))
9
+ * **@lambo-design-mobile/js-bridge:** 修改文档内容 ([76d2d4f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/76d2d4f2b6b0e76056566986c75048564c4b6ccc))
10
+ * **lambo-design-mobile/js-bridge:** 说明文档修改 ([5232d53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5232d53e97c7a94414b270104bda52c3dd530428))
11
+
12
+
13
+ ### 🐛 Bug Fixes | Bug 修复
14
+
15
+ * **@lambo-design-mobile/js-bridge:** 修复安卓上传图片至oss报错 ([89b4c3e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/89b4c3e46ddc1d99f84a73b8a87609414ac2113d))
16
+
17
+
18
+ ### ✅ Tests | 测试
19
+
20
+ * **@lambo-design-mobile/js-bridge:** 测试图片预览代码 ([21580d0](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/21580d0940ed11f8911f5cd1ab35782c64b7d4e8))
21
+ * **@lambo-design-mobile/js-bridge:** 测试图片预览代码 ([0f34ad8](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/0f34ad833be581f5345ebe758c062a9cb8e4c770))
22
+ * **@lambo-design-mobile/js-bridge:** oss上传图片测试 ([2b96afb](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2b96afb1d153afaf251f169a1679cef5b95ca6c6))
23
+
24
+
25
+ ### ✨ Features | 新功能
26
+
27
+ * **@lambo-design-mobile/js-bridge:** 更新浏览器页面接口 ([f7ebb25](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/f7ebb25794c1aded131ca4465e6dddf61758ce1b))
28
+ * **@lambo-design-mobile/js-bridge:** 更新浏览器页面接口 ([9c886d8](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9c886d8ca970f3030264369a3a6a11b28de08a8d))
29
+ * **@lambo-design-mobile/js-bridge:** 更新企业微信接口 ([4bb321c](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/4bb321cc0d05058560f5d79d1f1a80f0233f20b7))
30
+ * **@lambo-design-mobile/js-bridge:** 更新ossServerContext接口地址 ([af9f153](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/af9f153ab5aec110ac62343db5089fe35bd59e6b))
31
+ * **@lambo-design-mobile/js-bridge:** 更新takePhoto接口outputType ([6a686d5](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6a686d5f64d2cdd771ac02201da4103d7560ac35))
32
+ * **@lambo-design-mobile/js-bridge:** 更新takePhoto接口sourceType ([035b16e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/035b16ef2afe5887829679344cf70caf49baf394))
33
+ * **@lambo-design-mobile/js-bridge:** 添加appId为入参 ([5da0d99](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5da0d993e1734e9519e73ada8e002f07006bd980))
34
+ * **@lambo-design-mobile/js-bridge:** 微信接口拍照功能新增上传多张图片功能 ([9410191](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/941019106c18c0bec214f17e2e0b35a662d0288a))
35
+ * **@lambo-design-mobile/js-bridge:** 微信接口拍照功能新增上传多张图片预览功能 ([9cc5088](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9cc5088858c98d33bc0cb0bd88cc4a689618fa6e))
36
+ * **@lambo-design-mobile/js-bridge:** 微信接口新增openLocation方法 ([8567b78](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/8567b78c87dd4f50131b67c3e7d1100ac18549c1))
37
+ * **@lambo-design-mobile/js-bridge:** 微信上传照片新增oss接口 ([60347db](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/60347db9ae7d61dcae77a25f4f1b0aa2d58d2e41))
38
+ * **@lambo-design-mobile/js-bridge:** 新增企业微信openLocation接口 ([3ec0d0f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/3ec0d0f0d7de394194dec45d161ce0de1dcf25bc))
39
+ * **@lambo-design-mobile/js-bridge:** 新增上传图片预览 ([b33e525](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b33e5251d8fb17c82ab1c2ccbb3038de801c60ee))
40
+ * **@lambo-design-mobile/js-bridge:** 新增BrowserAdapter Mock数据 ([56160de](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/56160deb375747ef7611be449db6f031ea2fa541))
41
+ * **@lambo-design-mobile/js-bridge:** 修改变量默认值 ([c813d63](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c813d635832bcff59d059288f77745404e71f060))
42
+ * **@lambo-design-mobile/js-bridge:** 修改图片预览布局 ([5176b51](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5176b517d61e19536a4cbe2b0284e4402c84cdfc))
43
+ * **@lambo-design-mobile/js-bridge:** 修改微信scanCode接口返回值 ([08eec00](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/08eec00882059839b1d207b98ffec201a181f3d9))
44
+ * **@lambo-design-mobile/js-bridge:** 修改jsBridge默认参数值 ([7caeb91](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7caeb919d4ace6d198c047bab4a564561e8e4502))
45
+ * **@lambo-design-mobile/js-bridge:** 修改takePhoto接口返回 ([177f92e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/177f92e28251179e2c514414381ccd513d25301d))
46
+ * **@lambo-design-mobile/js-bridge:** 修改WeChat接口脚本加载方式 ([93445d3](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/93445d3779d6b734602003f0c86c9d9d4210b623))
47
+ * **@lambo-design-mobile/js-bridge:** 注释企业微信debug模式相关代码 ([ad3e2d7](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/ad3e2d732de2d7d4806f6c0a7d3718cb9f92895d))
48
+ * **@lambo-design-mobile/js-bridge:** getLocation接口新增支持百度bd09坐标系 ([9869b06](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9869b06a0e455e5ddd994da0dcf2efb3e0479fb9))
49
+ * **js-bridge:** 部分提交 ([2018f4e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2018f4eea620056036de0b73174999692b2e209d))
50
+ * **js-bridge:** 定位调试跑通 ([447623a](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/447623a97c0dac8e01407f07406676705ce94e83))
51
+ * **js-bridge:** init ([308e8f3](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/308e8f349b8098cdb789448813c9bd612fe3e18a))
52
+ * **lambo-design-mobile/js-bridge:** 新增BrowserAdapter ([6c25393](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6c25393c3cf7d6a2b4316dcf913a6064bd92c7b1))
53
+
54
+
55
+ ### ⚡ Performance Improvements | 性能优化
56
+
57
+ * **@lambo-design-mobile/js-bridge:** 删除代码中的日志输出 ([2787cae](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2787caed31dadcf764aa89234fdc63ef63b5633e))
58
+ * **@lambo-design-mobile/js-bridge:** 修改script加载方式 ([dc7bd53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/dc7bd533f6bde2a25700f05bb7293562400ecb70))
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # LamboJsBridge 示例
2
+
3
+ ### 介绍
4
+
5
+ LamboJsBridge 是一个js 适配sdk 用于处理H5应用和运行时环境的能力调用。支持微信、钉钉等环境。目前已适配微信(WechatAdapter)和企业微信(WeComAdapter)
6
+
7
+ ### 引入
8
+
9
+ ``` javascript
10
+ import Vue from 'vue';
11
+ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
12
+ ```
13
+
14
+ ## 代码演示
15
+
16
+ ### 初始化
17
+
18
+ ``` javascript
19
+ async created() {
20
+ const options = {
21
+ // 初始化参数,根据需要填写
22
+ wechatId:this.wechatId,
23
+ weComId:this.weComId,
24
+ dingTalkId:this.dingTalkId,
25
+ };
26
+ this.lamboBridge = new LamboJsBridge(options);
27
+ await this.getPlatform();
28
+ },
29
+
30
+ methods: {
31
+ async getPlatform() {
32
+ try {
33
+ const info = await this.lamboBridge.getPlatform(); // 获取初始化信息
34
+ this.initInfo = JSON.stringify(info, null, 2); // 美化输出
35
+ console.log('Init Info:', info);
36
+ } catch (error) {
37
+ console.error('Error getting init info:', error);
38
+ }
39
+ },
40
+ }
41
+ ```
42
+
43
+ ### 参数说明
44
+
45
+ `params`: Object
46
+
47
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
48
+ |------------|--------|--------|------|----------|------------|
49
+ | wechatId | string | | 是 | 微信 | 微信公众号appId |
50
+ | weComId | string | | 是 | 企业微信 | 企业微信corpId |
51
+ | dingTalkId | string | | 是 | 钉钉 | 钉钉id |
52
+
53
+ ### 返回说明
54
+
55
+ `params`: Object
56
+
57
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
58
+ |----------|--------|--------|------|----------|---------|
59
+ | appId | string | | 是 | 微信、企业微信、钉钉 | 对应平台的id |
60
+ | platform | string | | 是 | 微信、企业微信、钉钉 | 当前浏览器平台 |
61
+
62
+ ### 获取地理位置接口(getLocation)
63
+
64
+ 获取用户当前的地理位置信息。
65
+ ``` javascript
66
+ async getLocation() {
67
+ try {
68
+ const options ={
69
+ // 初始化参数,根据需要填写
70
+ };
71
+ const location = await this.lamboBridge.getLocation(options);
72
+ console.log("location",location)
73
+ this.location += `${JSON.stringify(location)}\n`; // 追加新数据
74
+ this.latitude = location.latitude; // 存储纬度
75
+ this.longitude = location.longitude; // 存储经度
76
+ console.log('Location:', location);
77
+ } catch (error) {
78
+ console.error('Error getting location:', error);
79
+ }
80
+ },
81
+ ```
82
+ ### 参数说明
83
+
84
+ `params`: Object
85
+
86
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
87
+ |------------------|----------|--------|------|-------|-----------------------------------------------------------------------------------------------|
88
+ | type | string | gcj02 | 否 | 微信、企业微信、钉钉 | 默认为gcj02的gps坐标,如果要使用标准坐标则传入wgs84 |
89
+ | targetAccuracy | string | | 否 | 钉钉 | 期望定位精度半径(单位米),定位结果尽量满足该参数要求,但是不一定能保证小于该误差,开发者需要读取返回结果的 accuracy 字段校验坐标精度。建议按照业务需求设置定位精度,推荐采用200m,可获得较好的精度和较短的响应时长。 |
90
+ | cacheTimeout | number | 30 | 否 | 钉钉 | 缓存过期时间,单位为秒。未过期的缓存数据会直接返回(速度快),缓存过期会重新定位(速度慢)。 |
91
+ | useCache | boolean | true | 否 | 钉钉 | 是否缓存地理位置信息。若为true,客户端会对定位的地理位置信息缓存,在缓存期内 (2分钟) 再次定位会返回旧的定位。 |
92
+ | withReGeocode | boolean | true | 否 | 钉钉 | 是否需要带有逆地理编码信息。该功能需要网络请求,请根据自己的业务场景使用。 |
93
+ | formattedAdress | number | 1 | 否 | 钉钉 | 获取经纬度和详细到区县级别的逆地理编码数据 |
94
+
95
+ ### 返回说明
96
+
97
+ `Promise<Object>`
98
+
99
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
100
+ |------------|--------|--------|------|----------|------------------------|
101
+ | latitude | number | | 是 | 微信、企业微信、钉钉 | 纬度,浮点数,范围为 90 ~ -90 |
102
+ | longitude | number | | 是 | 微信、企业微信、钉钉 | 经度,浮点数,范围为 180 ~ -180 |
103
+ | accuracy | number | | 是 | 微信、企业微信、钉钉 | 位置精度 |
104
+ | address | string | | 否 | 钉钉 | 格式化地址,type>0生效。 |
105
+ | province | string | | 否 | 钉钉 | 省份,type>0生效。 |
106
+ | city | string | | 否 | 钉钉 | 城市,type>0生效。 |
107
+
108
+ ### 调起扫一扫接口(scanCode)
109
+
110
+ 调用扫一扫功能。
111
+
112
+ ``` javascript
113
+ async scanCode() {
114
+ try {
115
+ const options ={
116
+ // 初始化参数,根据需要填写
117
+ };
118
+ const result = await this.lamboBridge.scanCode(options);
119
+ this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
120
+ console.log('Scan result:', result);
121
+ } catch (error) {
122
+ console.error('Error scanning code:', error);
123
+ }
124
+ },
125
+ ```
126
+
127
+ ### 参数说明
128
+
129
+ `params`: Object
130
+
131
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
132
+ |-----------|----------|--------|------|----------|----------------------------------------------------------------------------------------------|
133
+ | scanType | string[] | qr | 否 | 微信、企业微信、钉钉 | 扫码样式。qr:二维码扫码框,bar:条形码扫码框 |
134
+ | needResult| boolean | true | 否 | 微信、企业微信 | 扫描结果是否由微信或企业微信处理。为 false 时直接返回扫描结果 |
135
+
136
+ ### 返回说明
137
+
138
+ `Promise<Object>`
139
+
140
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
141
+ |------------|--------|--------|------|----------|-------------|
142
+ | resultStr | string | | 否 | 微信、企业微信、钉钉 | 扫码结果 |
143
+
144
+
145
+ ### 拍照或从手机相册中选图接口(takePhoto)
146
+
147
+ 拍照或从本地相册选择图片。
148
+ ``` javascript
149
+ async takePhoto() {
150
+ try {
151
+ const options = {
152
+ //初始化参数,根据需要填写、修改
153
+ outputType: ['oss','info','data'], // 根据需要包含 'info', 'data', 'oss'
154
+ ossServerContext: this.ossServerContext,
155
+ ossImgPutUrl: this.ossImgPutUrl,
156
+ ossImgGetUrl: this.ossImgGetUrl
157
+ };
158
+ const photo = await this.lamboBridge.takePhoto(options);
159
+ this.photoResult += `${JSON.stringify(photo)}\n`; // 追加新数据
160
+ console.log('Photo result:', photo);
161
+ } catch (error) {
162
+ console.error('Error taking photo:', error);
163
+ }
164
+ },
165
+ ```
166
+
167
+
168
+ ### 参数说明
169
+
170
+ `params`: Object
171
+
172
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
173
+ |---------------------|-----------|--------------------------|-----|----------|------------------------------------------------------------------|
174
+ | count | number | 1 | 否 | 微信、企业微信、钉钉 | 选择图片数量 |
175
+ | sizeType | string[] | ['camera', 'album'] | 否 | 微信、企业微信、钉钉 | 相册选取或者拍照。album:相册,camera:相机 |
176
+ | outputType | string[] | ['info', 'data', 'oss'] | 否 | 微信、企业微信、钉钉 | 图像输出格式。info 选定图像的本地信息,data 选定图像的base64数据,oss为上传oss-server |
177
+ | defaultCameraMode | string | | 否 | 企业微信 | 进入拍照界面的默认模式。normal 单拍,batch 连拍,front 前置摄像头单拍,batch_front 前置摄像头连拍 |
178
+ | isSaveToAlbum | boolean | true | 否 | 企业微信 | 拍照时是否保存到系统相册 |
179
+ | position | string | back | 否 | 钉钉 | 相机拍照使用的摄像头:front:前置摄像头,back:后置摄像头 |
180
+ | ossServerContext | string | | 是 | 微信、企业微信、钉钉 | 上传oss-server服务器地址 |
181
+ | ossImgPutUrl | string | | 是 | 微信、企业微信、钉钉 | 上传oss-server图片接口地址 |
182
+ | ossImgGetUrl | string | | 是 | 微信、企业微信、钉钉 | 下载oss-server图片接口地址 |
183
+
184
+ ### 返回说明
185
+
186
+ `Promise<Array>`
187
+
188
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
189
+ |-----------|-----------|--------|------|----------|---------------|
190
+ | imageInfo | string[] | | 否 | 微信、企业微信、钉钉 | 选定图像的本地信息 |
191
+ | imageData | string[] | | 否 | 微信、企业微信、钉钉 | 选定图像的base64数据 |
192
+ | imageOss | string[] | | 否 | 微信、企业微信、钉钉 | 选定图像的oss返回数据 |
193
+
194
+ ### 使用内置地图查看位置(openLocation)
195
+
196
+ 使用内置地图查看位置。
197
+ ``` javascript
198
+ async openLocation() {
199
+ try {
200
+ if (this.latitude !== null && this.longitude !== null) {
201
+ const options = {
202
+ //初始化参数,根据需要修改
203
+ latitude: this.latitude,
204
+ longitude: this.longitude,
205
+ name: this.name,
206
+ address: this.address,
207
+ scale: this.scale
208
+ };
209
+ await this.lamboBridge.openLocation(options);
210
+ this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
211
+ console.log('Location opened successfully');
212
+ } else {
213
+ this.openLocationResult = '没有可用的位置信息,请先获取定位。'; // 没有位置信息时存储错误信息
214
+ console.error('No location data available. Please get the location first.');
215
+ }
216
+ } catch (error) {
217
+ this.openLocationResult = `打开位置时出错: ${error.message}`; // 存储错误信息
218
+ console.error('Error opening location:', error);
219
+ }
220
+ }
221
+ ```
222
+
223
+
224
+ ### 参数说明
225
+
226
+ `params`: Object
227
+
228
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
229
+ |-----------|--|-----|-----|----------|------------------------------------------------------------------|
230
+ | latitude | number | | 是 | 微信、企业微信、钉钉 | 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 |
231
+ | longitude | number | | 是 | 微信、企业微信、钉钉 | 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 |
232
+ | name | string | | 钉钉 | 微信、企业微信、钉钉 | 位置名称 |
233
+ | address | string | | 钉钉 | 微信、企业微信、钉钉 | 详细位置 |
234
+ | scale | number | | 否 | 微信、企业微信 | 缩放比例,范围5~18 |
235
+
236
+ ### 返回说明
237
+
238
+
package/demo/index.vue ADDED
@@ -0,0 +1,223 @@
1
+ <template>
2
+ <demo-section>
3
+ <demo-block title="初始化信息">
4
+ <pre v-if="initInfo"><code>{{ initInfo }}</code></pre>
5
+ </demo-block>
6
+ <demo-block title="获取定位">
7
+ <van-button @click="getLocation">获取定位</van-button>
8
+ <pre v-if="location"><code>{{ location }}</code></pre>
9
+ </demo-block>
10
+ <demo-block title="扫码">
11
+ <van-button @click="scanCode">扫码</van-button>
12
+ <pre v-if="scanResult"><code>{{ scanResult }}</code></pre>
13
+ </demo-block>
14
+ <demo-block title="拍照">
15
+ <van-button @click="takePhoto">拍照</van-button>
16
+ <pre v-if="photoResult"><code>{{ photoResult }}</code></pre>
17
+ <div v-if="photoPreviews.length" :class="gridClass">
18
+ <div v-for="(preview, index) in photoPreviews" :key="index" class="photo-container">
19
+ <img :src="preview" alt="Photo Preview" class="photo">
20
+ </div>
21
+ </div>
22
+ </demo-block>
23
+ <demo-block title="打开位置">
24
+ <van-button @click="openLocation">打开位置</van-button>
25
+ <pre v-if="openLocationResult"><code>{{ openLocationResult }}</code></pre>
26
+ </demo-block>
27
+ </demo-section>
28
+ </template>
29
+
30
+
31
+
32
+
33
+ <script>
34
+ import LamboJsBridge from "../src/sdk/LamboJsBridge";
35
+
36
+ export default {
37
+ name: 'MyComponent',
38
+ data() {
39
+ return {
40
+ lamboBridge: null,
41
+ initInfo: '',
42
+ location: '',
43
+ scanResult: '',
44
+ photoResult: '',
45
+ openLocationResult: '', // 添加用于存储打开位置的返回值
46
+ latitude: null, // 存储纬度
47
+ longitude: null, // 存储经度
48
+ ossServerContext: 'ibp-upms-server',
49
+ ossImgPutUrl: '/oss/file/put',
50
+ ossImgGetUrl: '/oss/file/get/',
51
+ scale: 8,
52
+ name:'这里是位置名称name',
53
+ address:'这里是详细位置address',
54
+ wechatId: 'wx92fab9d3885b0298',
55
+ weComId: 'wx0eb3ba9d89eca3cb',
56
+ dingTalkId: '',
57
+ photoPreviews: []
58
+ };
59
+ },
60
+ computed: {
61
+ gridClass() {
62
+ const length = this.photoPreviews.length;
63
+ if (length === 1) {
64
+ return 'grid-single';
65
+ } else if (length > 1 && length <= 4) {
66
+ return 'grid-two';
67
+ } else if (length > 4) {
68
+ return 'grid-three';
69
+ }
70
+ return '';
71
+ }
72
+ },
73
+ async created() {
74
+ const script = document.createElement('script')
75
+ script.src = '//dev.sunquan.tech/inspect/target.js'
76
+ script.async = true
77
+ document.getElementsByTagName('head')[0].appendChild(script)
78
+ const options = {
79
+ // 初始化参数,根据需要填写
80
+ wechatId:this.wechatId,
81
+ weComId:this.weComId,
82
+ dingTalkId:this.dingTalkId,
83
+ };
84
+ this.lamboBridge = new LamboJsBridge(options);
85
+ await this.getPlatform();
86
+ },
87
+ methods: {
88
+ async getPlatform() {
89
+ try {
90
+ const info = await this.lamboBridge.getPlatform(); // 获取初始化信息
91
+ this.initInfo = JSON.stringify(info, null, 2); // 美化输出
92
+ console.log('Init Info:', info);
93
+ } catch (error) {
94
+ console.error('Error getting init info:', error);
95
+ }
96
+ },
97
+ async getLocation() {
98
+ try {
99
+ const options ={
100
+ // 初始化参数,根据需要填写
101
+ };
102
+ const location = await this.lamboBridge.getLocation(options);
103
+ console.log("location",location)
104
+ this.location += `${JSON.stringify(location)}\n`; // 追加新数据
105
+ this.latitude = location.latitude; // 存储纬度
106
+ this.longitude = location.longitude; // 存储经度
107
+ console.log('Location:', location);
108
+ } catch (error) {
109
+ console.error('Error getting location:', error);
110
+ }
111
+ },
112
+ async scanCode() {
113
+ try {
114
+ const options ={
115
+ // 初始化参数,根据需要填写
116
+ };
117
+ const result = await this.lamboBridge.scanCode(options);
118
+ this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
119
+ // console.log('Scan result:', result);
120
+ } catch (error) {
121
+ console.error('Error scanning code:', error);
122
+ }
123
+ },
124
+ async takePhoto() {
125
+ try {
126
+ const options = {
127
+ ossServerContext: this.ossServerContext,
128
+ ossImgPutUrl: this.ossImgPutUrl,
129
+ ossImgGetUrl: this.ossImgGetUrl
130
+ };
131
+ const photos = await this.lamboBridge.takePhoto(options);
132
+ this.photoResult += `${JSON.stringify(photos)}\n`;
133
+ console.log("Photo result:", photos); // 调试输出
134
+
135
+ photos.forEach(photo => {
136
+ if (photo.imageOss && photo.imageOss.url) {
137
+ this.photoPreviews.push(photo.imageOss.url); // 将图片URL添加到数组中
138
+ } else if (photo.imageData) {
139
+ this.photoPreviews.push(photo.imageData); // 如果OSS URL不存在,使用本地数据
140
+ }
141
+ });
142
+
143
+ console.log("Updated photoPreviews:", this.photoPreviews); // 调试输出
144
+ } catch (error) {
145
+ console.error('Error taking photo:', error);
146
+ }
147
+ },
148
+ async openLocation() {
149
+ try {
150
+ if (this.latitude !== null && this.longitude !== null) {
151
+ const options = {
152
+ //初始化参数,根据需要修改
153
+ latitude: this.latitude,
154
+ longitude: this.longitude,
155
+ name: this.name,
156
+ address: this.address,
157
+ scale: this.scale
158
+ };
159
+ await this.lamboBridge.openLocation(options);
160
+ this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
161
+ console.log('Location opened successfully');
162
+ } else {
163
+ this.openLocationResult = '没有可用的位置信息,请先获取定位。'; // 没有位置信息时存储错误信息
164
+ console.error('No location data available. Please get the location first.');
165
+ }
166
+ } catch (error) {
167
+ this.openLocationResult = `打开位置时出错: ${error.message}`; // 存储错误信息
168
+ console.error('Error opening location:', error);
169
+ }
170
+ }
171
+ },
172
+ beforeRouteEnter (to, from, next) {
173
+ next(vm => {
174
+ if (from.name !== null) {
175
+ vm.$nextTick(() => {
176
+ window.location.reload();
177
+ });
178
+ }
179
+ });
180
+ }
181
+ };
182
+ </script>
183
+
184
+
185
+
186
+ <style scoped>
187
+ pre {
188
+ background-color: #f5f5f5;
189
+ padding: 10px;
190
+ border-radius: 4px;
191
+ overflow: auto;
192
+ }
193
+
194
+ code {
195
+ white-space: pre-wrap;
196
+ }
197
+
198
+ .grid-single {
199
+ display: grid;
200
+ grid-template-columns: 1fr;
201
+ }
202
+
203
+ .grid-two {
204
+ display: grid;
205
+ grid-template-columns: repeat(2, 1fr);
206
+ gap: 10px;
207
+ }
208
+
209
+ .grid-three {
210
+ display: grid;
211
+ grid-template-columns: repeat(3, 1fr);
212
+ gap: 10px;
213
+ }
214
+
215
+ .photo-container {
216
+ margin-top: 10px;
217
+ }
218
+
219
+ .photo {
220
+ max-width: 100%;
221
+ border-radius: 4px;
222
+ }
223
+ </style>
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import LamboJsBridge from './src/sdk/LamboJsBridge'
2
+
3
+ export default LamboJsBridge
4
+
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@lambo-design-mobile/lambo-js-bridge",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "author": "lambo",
7
+ "license": "ISC",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "registry": "https://registry.npmjs.org/"
11
+ },
12
+ "dependencies": {},
13
+ "scripts": {
14
+ "release-js-bridge": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
15
+ "release-major": "standard-version --release-as major",
16
+ "release-minor": "standard-version --release-as minor",
17
+ "release-patch": "standard-version --release-as patch",
18
+ "release-beta": "standard-version --prerelease beta",
19
+ "re-publish": "pnpm publish --access public --no-git-checks"
20
+ }
21
+ }
@@ -0,0 +1,63 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable no-undef */
3
+
4
+ class BrowserAdapter {
5
+ constructor(_options) {
6
+ // this.appId = _options.appId; // 保存 appId 以便在 getInitInfo 中使用
7
+ // 由于是假数据,不需要加载任何实际的脚本
8
+ this.init(_options);
9
+ }
10
+
11
+ async init(options) {
12
+ console.log("Initializing with options:", options);
13
+ // 模拟初始化操作
14
+ return Promise.resolve({
15
+ success: true,
16
+ message: "Initialized successfully"
17
+ });
18
+ }
19
+
20
+ async getLocation(options) {
21
+ console.log(options);
22
+ // 返回假位置数据
23
+ return Promise.resolve({
24
+ latitude: 37.7749, // 假数据
25
+ longitude: -122.4194, // 假数据
26
+ accuracy: 30 // 假数据
27
+ });
28
+ }
29
+
30
+ async openLocation(options) {
31
+ console.log(options);
32
+ // 模拟打开位置操作
33
+ return Promise.resolve({
34
+ success: true,
35
+ message: "Location opened successfully"
36
+ });
37
+ }
38
+
39
+ async scanCode(options) {
40
+ console.log(options);
41
+ // 返回假扫码数据
42
+ return Promise.resolve({resultStr:"SCAN_CODE_RESULT"});
43
+ }
44
+
45
+ async takePhoto(options) {
46
+ console.log(options);
47
+ // 返回假照片数据
48
+ return Promise.resolve({
49
+ imageInfo: "FAKE_IMAGE_INFO",
50
+ imageData: "FAKE_IMAGE_DATA"
51
+ });
52
+ }
53
+
54
+ async getPlatform(options = {}) {
55
+ // 获取初始化信息
56
+ return {
57
+ appId: 'Example_appId',
58
+ platform: 'Browser'
59
+ };
60
+ }
61
+ }
62
+
63
+ export default BrowserAdapter;
@@ -0,0 +1,21 @@
1
+ class CordovaAdapter {
2
+ async getLocation(options) {
3
+ // 实现Cordova获取位置逻辑,可能涉及到cordova-plugin-geolocation插件的使用
4
+ console.log('Cordova: Getting location with options', options);
5
+ // 这里应替换为Cordova API的实际调用
6
+ }
7
+
8
+ async scanCode(options) {
9
+ // 实现Cordova扫码逻辑,可能需要集成第三方插件
10
+ console.log('Cordova: Scanning code with options', options);
11
+ // 这里应替换为Cordova插件调用或自定义实现
12
+ }
13
+
14
+ async takePhoto(options) {
15
+ // 实现Cordova拍照或选择图片逻辑,可能使用cordova-plugin-camera插件
16
+ console.log('Cordova: Taking photo with options', options);
17
+ // 这里应替换为Cordova插件调用
18
+ }
19
+ }
20
+
21
+ export default CordovaAdapter;