@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.13 → 1.0.0-beta.15
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 +23 -23
- package/CHANGELOG.md +220 -211
- package/README.md +279 -279
- package/demo/index.vue +245 -243
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/sdk/BrowserAdapter.js +63 -63
- package/src/sdk/CordovaAdapter.js +20 -20
- package/src/sdk/DingTalkAdapter.js +20 -20
- package/src/sdk/LamboJsBridge.js +80 -80
- package/src/sdk/WeComAdapter.js +306 -306
- package/src/sdk/YunTuAdapter.js +239 -239
- package/src/sdk/yuntu.js +55 -55
package/demo/index.vue
CHANGED
|
@@ -1,243 +1,245 @@
|
|
|
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-block title="文件预览">
|
|
28
|
-
<a href="javascript:void(0);" @click="previewFile">点击这里预览文件</a>
|
|
29
|
-
</demo-block>
|
|
30
|
-
</demo-section>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<script>
|
|
37
|
-
import LamboJsBridge from "../src/sdk/LamboJsBridge";
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
name: 'MyComponent',
|
|
41
|
-
data() {
|
|
42
|
-
return {
|
|
43
|
-
lamboBridge: null,
|
|
44
|
-
initInfo: '',
|
|
45
|
-
location: '',
|
|
46
|
-
scanResult: '',
|
|
47
|
-
photoResult: '',
|
|
48
|
-
openLocationResult: '', // 添加用于存储打开位置的返回值
|
|
49
|
-
latitude: 117.129, // 存储纬度
|
|
50
|
-
longitude: 36.662, // 存储经度
|
|
51
|
-
ossServerContext: 'ibp-upms-server',
|
|
52
|
-
ossImgPutUrl: '/oss/file/put',
|
|
53
|
-
ossImgGetUrl: '/oss/file/get/',
|
|
54
|
-
scale: 8,
|
|
55
|
-
name:'这里是位置名称name',
|
|
56
|
-
address:'这里是详细位置address',
|
|
57
|
-
wechatId: 'wx92fab9d3885b0298',
|
|
58
|
-
weComId: 'wx0eb3ba9d89eca3cb',
|
|
59
|
-
agentId:'1000065',
|
|
60
|
-
dingTalkId: '',
|
|
61
|
-
photoPreviews: []
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
computed: {
|
|
65
|
-
gridClass() {
|
|
66
|
-
const length = this.photoPreviews.length;
|
|
67
|
-
if (length === 1) {
|
|
68
|
-
return 'grid-single';
|
|
69
|
-
} else if (length > 1 && length <= 4) {
|
|
70
|
-
return 'grid-two';
|
|
71
|
-
} else if (length > 4) {
|
|
72
|
-
return 'grid-three';
|
|
73
|
-
}
|
|
74
|
-
return '';
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
async created() {
|
|
78
|
-
const script = document.createElement('script')
|
|
79
|
-
script.src = '//dev.sunquan.tech/inspect/target.js'
|
|
80
|
-
script.async = true
|
|
81
|
-
document.getElementsByTagName('head')[0].appendChild(script)
|
|
82
|
-
const options = {
|
|
83
|
-
// 初始化参数,根据需要填写
|
|
84
|
-
wechatId:this.wechatId,
|
|
85
|
-
weComId:this.weComId,
|
|
86
|
-
agentId:this.agentId,
|
|
87
|
-
dingTalkId:this.dingTalkId,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
console.
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
console.
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.photoPreviews.push(photo.
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
console.
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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-block title="文件预览">
|
|
28
|
+
<a href="javascript:void(0);" @click="previewFile">点击这里预览文件</a>
|
|
29
|
+
</demo-block>
|
|
30
|
+
</demo-section>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import LamboJsBridge from "../src/sdk/LamboJsBridge";
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
name: 'MyComponent',
|
|
41
|
+
data() {
|
|
42
|
+
return {
|
|
43
|
+
lamboBridge: null,
|
|
44
|
+
initInfo: '',
|
|
45
|
+
location: '',
|
|
46
|
+
scanResult: '',
|
|
47
|
+
photoResult: '',
|
|
48
|
+
openLocationResult: '', // 添加用于存储打开位置的返回值
|
|
49
|
+
latitude: 117.129, // 存储纬度
|
|
50
|
+
longitude: 36.662, // 存储经度
|
|
51
|
+
ossServerContext: 'ibp-upms-server',
|
|
52
|
+
ossImgPutUrl: '/oss/file/put',
|
|
53
|
+
ossImgGetUrl: '/oss/file/get/',
|
|
54
|
+
scale: 8,
|
|
55
|
+
name:'这里是位置名称name',
|
|
56
|
+
address:'这里是详细位置address',
|
|
57
|
+
wechatId: 'wx92fab9d3885b0298',
|
|
58
|
+
weComId: 'wx0eb3ba9d89eca3cb',
|
|
59
|
+
agentId:'1000065',
|
|
60
|
+
dingTalkId: '',
|
|
61
|
+
photoPreviews: []
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
computed: {
|
|
65
|
+
gridClass() {
|
|
66
|
+
const length = this.photoPreviews.length;
|
|
67
|
+
if (length === 1) {
|
|
68
|
+
return 'grid-single';
|
|
69
|
+
} else if (length > 1 && length <= 4) {
|
|
70
|
+
return 'grid-two';
|
|
71
|
+
} else if (length > 4) {
|
|
72
|
+
return 'grid-three';
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async created() {
|
|
78
|
+
const script = document.createElement('script')
|
|
79
|
+
script.src = '//dev.sunquan.tech/inspect/target.js'
|
|
80
|
+
script.async = true
|
|
81
|
+
document.getElementsByTagName('head')[0].appendChild(script)
|
|
82
|
+
const options = {
|
|
83
|
+
// 初始化参数,根据需要填写
|
|
84
|
+
wechatId:this.wechatId,
|
|
85
|
+
weComId:this.weComId,
|
|
86
|
+
agentId:this.agentId,
|
|
87
|
+
dingTalkId:this.dingTalkId,
|
|
88
|
+
pluginConfig:["localAuthPlugin","myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin"],
|
|
89
|
+
};
|
|
90
|
+
this.$lamboJsBridge = new LamboJsBridge(options);
|
|
91
|
+
await this.getPlatform();
|
|
92
|
+
await this.$lamboJsBridge.initializePlugin(options.pluginConfig);
|
|
93
|
+
},
|
|
94
|
+
methods: {
|
|
95
|
+
async getPlatform() {
|
|
96
|
+
try {
|
|
97
|
+
const info = await this.$lamboJsBridge.getPlatform(); // 获取初始化信息
|
|
98
|
+
this.initInfo = JSON.stringify(info, null, 2); // 美化输出
|
|
99
|
+
console.log('Init Info:', info);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Error getting init info:', error);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
async getLocation() {
|
|
105
|
+
try {
|
|
106
|
+
const options ={
|
|
107
|
+
// 初始化参数,根据需要填写
|
|
108
|
+
};
|
|
109
|
+
const location = await this.$lamboJsBridge.getLocation(options);
|
|
110
|
+
// console.log("location",location)
|
|
111
|
+
this.location += `${JSON.stringify(location)}\n`; // 追加新数据
|
|
112
|
+
this.latitude = location.latitude; // 存储纬度
|
|
113
|
+
this.longitude = location.longitude; // 存储经度
|
|
114
|
+
console.log("this.latitude:",this.latitude);
|
|
115
|
+
console.log("this.longitude:",this.longitude);
|
|
116
|
+
// console.log('Location:', location);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('Error getting location:', error);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
async scanCode() {
|
|
122
|
+
try {
|
|
123
|
+
const options ={
|
|
124
|
+
// 初始化参数,根据需要填写
|
|
125
|
+
};
|
|
126
|
+
const result = await this.$lamboJsBridge.scanCode(options);
|
|
127
|
+
this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
|
|
128
|
+
// console.log('Scan result:', result);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error('Error scanning code:', error);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
async takePhoto() {
|
|
134
|
+
try {
|
|
135
|
+
const options = {
|
|
136
|
+
ossServerContext: this.ossServerContext,
|
|
137
|
+
ossImgPutUrl: this.ossImgPutUrl,
|
|
138
|
+
ossImgGetUrl: this.ossImgGetUrl,
|
|
139
|
+
// sourceType: 'gallery'
|
|
140
|
+
};
|
|
141
|
+
const photos = await this.$lamboJsBridge.takePhoto(options);
|
|
142
|
+
this.photoResult += `${JSON.stringify(photos)}\n`;
|
|
143
|
+
console.log("Photo result:", photos); // 调试输出
|
|
144
|
+
|
|
145
|
+
photos.forEach(photo => {
|
|
146
|
+
if (photo.imageOss && photo.imageOss.url) {
|
|
147
|
+
this.photoPreviews.push(photo.imageOss.url); // 将图片URL添加到数组中
|
|
148
|
+
} else if (photo.imageData) {
|
|
149
|
+
this.photoPreviews.push(photo.imageData); // 如果OSS URL不存在,使用本地数据
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
console.log("Updated photoPreviews:", this.photoPreviews); // 调试输出
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error('Error taking photo:', error);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
async openLocation() {
|
|
159
|
+
try {
|
|
160
|
+
if (this.latitude !== null && this.longitude !== null) {
|
|
161
|
+
const options = {
|
|
162
|
+
//初始化参数,根据需要修改
|
|
163
|
+
latitude: this.latitude,
|
|
164
|
+
longitude: this.longitude,
|
|
165
|
+
name: this.name,
|
|
166
|
+
address: this.address,
|
|
167
|
+
scale: this.scale
|
|
168
|
+
};
|
|
169
|
+
await this.$lamboJsBridge.openLocation(options);
|
|
170
|
+
this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
|
|
171
|
+
console.log('Location opened successfully');
|
|
172
|
+
} else {
|
|
173
|
+
this.openLocationResult = '没有可用的位置信息,请先获取定位。'; // 没有位置信息时存储错误信息
|
|
174
|
+
console.error('No location data available. Please get the location first.');
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
this.openLocationResult = `打开位置时出错: ${error.message}`; // 存储错误信息
|
|
178
|
+
console.error('Error opening location:', error);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
async previewFile() {
|
|
182
|
+
try {
|
|
183
|
+
const options = {
|
|
184
|
+
title: '预览文件.txt', // 文件的标题
|
|
185
|
+
path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' // 文件的URL路径
|
|
186
|
+
};
|
|
187
|
+
const result = await this.$lamboJsBridge.filePreview(options);
|
|
188
|
+
console.log('File preview result:', result);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error('Error previewing file:', error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
beforeRouteEnter (to, from, next) {
|
|
195
|
+
next(vm => {
|
|
196
|
+
if (from.name !== null) {
|
|
197
|
+
vm.$nextTick(() => {
|
|
198
|
+
window.location.reload();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
<style scoped>
|
|
209
|
+
pre {
|
|
210
|
+
background-color: #f5f5f5;
|
|
211
|
+
padding: 10px;
|
|
212
|
+
border-radius: 4px;
|
|
213
|
+
overflow: auto;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
code {
|
|
217
|
+
white-space: pre-wrap;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.grid-single {
|
|
221
|
+
display: grid;
|
|
222
|
+
grid-template-columns: 1fr;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.grid-two {
|
|
226
|
+
display: grid;
|
|
227
|
+
grid-template-columns: repeat(2, 1fr);
|
|
228
|
+
gap: 10px;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.grid-three {
|
|
232
|
+
display: grid;
|
|
233
|
+
grid-template-columns: repeat(3, 1fr);
|
|
234
|
+
gap: 10px;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.photo-container {
|
|
238
|
+
margin-top: 10px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.photo {
|
|
242
|
+
max-width: 100%;
|
|
243
|
+
border-radius: 4px;
|
|
244
|
+
}
|
|
245
|
+
</style>
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import LamboJsBridge from './src/sdk/LamboJsBridge'
|
|
2
|
-
|
|
3
|
-
export default LamboJsBridge
|
|
1
|
+
import LamboJsBridge from './src/sdk/LamboJsBridge'
|
|
2
|
+
|
|
3
|
+
export default LamboJsBridge
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,63 +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;
|
|
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;
|