- uni-app x官方无内置蓝牙API(文档明确见插件市场),为实现去插件化,工程整体迁移为uni-app vue3(vue/ts),App端内置完整BLE API,标准基座即可运行 - 新建src/BluetoothManager.ts:基于uni内置BLE API(createBLEConnection/notifyBLECharacteristicValueChange/writeBLECharacteristicValue(writeNoResponse)/setBLEMTU/getBLEDeviceRSSI等),保持原插件type约定,页面业务逻辑不变 - 删除uni_modules/android-ble及未使用的lime-*、uni-wifi;保留uni-icons、uni-scss - uts模块全部移植为ts(src/mcm、api、common):UTSJSONObject改Record<string,any>,适配vue3 getStorageSync空值返回空串的差异 - 7个页面uvue转vue:模板不变,显式import ref与生命周期钩子;OTA固件读取由java.io改为plus.io+uni.base64ToArrayBuffer - manifest.json去uni-app-x改app-plus结构,补Android 12+蓝牙权限;删除platformConfig.json;运行改用标准基座
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import { $http, JSONObject } from "@/api/httpInstance"
|
|
|
|
export type RegisteredUserReq = {
|
|
userName: string,
|
|
userPassword: string,
|
|
rndcode: string
|
|
}
|
|
// 获取pinCode
|
|
export async function GetPindCodeReqApi(params: RegisteredUserReq): Promise<JSONObject>{
|
|
const body: JSONObject = {
|
|
userName: params.userName,
|
|
userPassword: params.userPassword,
|
|
rndcode: params.rndcode
|
|
} as JSONObject
|
|
|
|
const res = await $http({
|
|
url: "/ocpp-mtapp-api/api/v1/users/getPinCode",
|
|
method: "POST",
|
|
data: body
|
|
})
|
|
return res
|
|
}
|
|
|
|
// 注册用户
|
|
export async function RegisteredUserReqApi(params: RegisteredUserReq): Promise<JSONObject>{
|
|
const body: JSONObject = {
|
|
userName: params.userName,
|
|
userPassword: params.userPassword,
|
|
rndcode: params.rndcode
|
|
} as JSONObject
|
|
|
|
const res = await $http({
|
|
url: "/ocpp-mtapp-api/api/v1/users/add",
|
|
method: "POST",
|
|
data: body
|
|
})
|
|
return res
|
|
}
|
|
|
|
export type LoginReq = {
|
|
username: string
|
|
password: string
|
|
}
|
|
// 登录请求
|
|
export async function LoginReqApi(params: LoginReq): Promise<JSONObject>{
|
|
const body: JSONObject = {
|
|
username: params.username,
|
|
password: params.password,
|
|
expirationTime: 0
|
|
} as JSONObject
|
|
|
|
const res = await $http({
|
|
url: "/ocpp-mtapp-api/api/v1/auth/login",
|
|
method: "POST",
|
|
data: body
|
|
})
|
|
return res
|
|
}
|
|
|
|
export type ModifyUserInfoReq = {
|
|
name?: string | null,
|
|
phone?: string | null,
|
|
password?: string | null,
|
|
nickName?: string | null
|
|
}
|
|
// 修改用户信息
|
|
export async function ModifyUserInfoReqApi(params: ModifyUserInfoReq): Promise<JSONObject>{
|
|
const body: JSONObject = {
|
|
name: params.name,
|
|
phone: params.phone,
|
|
password: params.password
|
|
} as JSONObject
|
|
|
|
const res = await $http({
|
|
url: `/ocpp-mtapp-api/api/v1/users/${params.name}`,
|
|
method: "GET",
|
|
data: body
|
|
})
|
|
return res
|
|
}
|