From fa4a1bcecdd68421337ba3b5e985d00e9664ecde Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Thu, 1 Feb 2024 20:41:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9EIOT=E6=89=93=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.config.ts | 2 +- .../popup/popup-instrument-upload-tips.less | 64 +++++ .../popup/popup-instrument-upload-tips.tsx | 200 +++++++++++++++ src/pages/index/index.tsx | 7 +- src/pages/instrument/intro.tsx | 15 +- .../index.less | 35 ++- .../index.tsx | 236 +++++++++++++++--- src/store/features/deviceInfo.js | 25 ++ src/store/index.js | 4 +- src/utils/Interface.js | 34 ++- src/utils/bluetoothWXAPI.js | 31 +-- 11 files changed, 547 insertions(+), 106 deletions(-) create mode 100644 src/components/popup/popup-instrument-upload-tips.less create mode 100644 src/components/popup/popup-instrument-upload-tips.tsx rename src/pages/{instrument_clickin_upload => instrumentClickinUpload}/index.less (94%) rename src/pages/{instrument_clickin_upload => instrumentClickinUpload}/index.tsx (59%) create mode 100644 src/store/features/deviceInfo.js diff --git a/src/app.config.ts b/src/app.config.ts index f9bce9b..23b5b22 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -16,7 +16,7 @@ export default defineAppConfig({ "pages/instrument/intro", "pages/instrument_manage/index", "pages/instrument_detail/index", - "pages/instrument_clickin_upload/index", + "pages/instrumentClickinUpload/index", 'pages/privacyPolicy/privacyPolicy', 'pages/userPolicy/userPolicy', 'pages/about/about', diff --git a/src/components/popup/popup-instrument-upload-tips.less b/src/components/popup/popup-instrument-upload-tips.less new file mode 100644 index 0000000..a30d7f1 --- /dev/null +++ b/src/components/popup/popup-instrument-upload-tips.less @@ -0,0 +1,64 @@ +.site-popup-content-box { + margin: 0; +} +// .van-popup { +// background-color: transparent; +// } +.site-close { + position: absolute; + right: 36rpx; + top: 36rpx; + color: #fff; + font-size: 36rpx; + z-index: 100009; + background-color: #ababab; + border-radius: 50%; + padding: 8rpx; + box-sizing: border-box; +} + +.site-popup-btn { + position: absolute; + bottom: 100rpx; + left: calc(50% - 120rpx); + width: 240rpx; + height: 70rpx; + line-height: 70rpx; + font-size: 28rpx; + text-align: center; + border: 1rpx solid #000; + border-radius: 40rpx; + background-color: #000; + color: #fff; + box-sizing: border-box; +} + +.upload-tips-common-box { + padding: 50rpx 20rpx 44rpx 20rpx; + .tips-message { + margin-top: 30rpx; + text-align: center; + font-size: 28rpx; + line-height: 45rpx; + color: #666; + } +} + +.popup-btn-one { + display: flex; + margin-top: 60rpx; + justify-content: center; + .popup-btn { + width: 270rpx; + height: 90rpx; + line-height: 90rpx; + font-size: 32rpx; + font-weight: 500; + text-align: center; + border: 1rpx solid #000; + border-radius: 45rpx; + color: #fff; + background-color: #000; + font-family: PingFang SC; + } +} diff --git a/src/components/popup/popup-instrument-upload-tips.tsx b/src/components/popup/popup-instrument-upload-tips.tsx new file mode 100644 index 0000000..f29a017 --- /dev/null +++ b/src/components/popup/popup-instrument-upload-tips.tsx @@ -0,0 +1,200 @@ +import classnames from "classnames"; +import Taro from "@tarojs/taro"; +import { Component } from "react"; + +import { + Block, + View, + Image, + Text, + Button, + PageMeta, + Swiper, + SwiperItem, +} from "@tarojs/components"; + +import { Popup } from "@antmjs/vantui"; + +import "./popup.less"; +import "./popup-instrument-upload-tips.less"; +import "./fade.css"; + +import { go, goJump } from "../../utils/traoAPI"; + +/*** props + * isLarge 是否大尺寸 + * isShow 是否显示 + * data 数据 + * @confirm 关闭回调 + * ***/ +export default class PopupInstrumentUploadTips extends Component { + constructor(props) { + super(props); + this.state = { + name: "打卡介绍弹窗", + current: 0, + toRight: false, + isClick: false, + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + initData = () => { + if (this.props.siteData) { + let arr = JSON.parse(JSON.stringify(this.props.siteData)); + this.setState({ siteList: arr }); + } + }; + + onClose = () => { + this.props.close(); + }; + + onClickStop = (e) => { + e.stopPropagation(); + }; + + onChange(event) { + const current = event.detail.current; + const { current: curCurrent } = this.state; + const { siteData } = this.props; + if (curCurrent + 2 === siteData.length && current + 1 === siteData.length) { + this.setState({ toRight: true }); + } + this.setState({ current }); + } + onClickSwiperItem(item) { + goJump(item); + } + onFinish(event) { + const { current } = event.detail; + const { toRight, isClick } = this.state; + const { siteData } = this.props; + if (current === siteData.length - 1) { + if (toRight || isClick) { + this.setState({ toRight: false, isClick: false }); + } else { + // this.toHomePage(); + } + } + } + + onPrev = async () => { + let { current } = this.state; + this.setState({ current: current - 1 }); + }; + onNext = async () => { + let { current } = this.state; + + if (current === this.props.data.length) { + this.onClose(); + } else { + this.setState({ current: current + 1 }); + } + }; + + render() { + let { isShow, data, isLarge, title } = this.props; + let { current } = this.state; + + return ( + + + + + + + + {data.map((item, index) => { + return ( + + + + + + {item.message} + {item.message} + {item.message} + {item.message} + + + ); + })} + + + + + {data.length === 1 && ( + + + + )} + {data.length > 1 && current === 0 && ( + + + + )} + {data.length > 1 && ( + + + + + )} + + + + + ); + } +} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index ebc0e6b..3160af9 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -556,8 +556,11 @@ class Index extends Component { // 跳转仪器介绍页 goNursing = (item) => { console.log("goNursing", item); - setStorageSync("instrument_item", JSON.stringify(item)); - go("/pages/instrument_clickin_upload/index?id=" + item.id); + setStorageSync("instrument_detail", JSON.stringify(item)); + + setTimeout(() => { + go("/pages/instrumentClickinUpload/index?id=" + item.id); + }, 10); // go("/pages/instrument/intro?id=" + item.id); }; /* 扫码进入逻辑 */ diff --git a/src/pages/instrument/intro.tsx b/src/pages/instrument/intro.tsx index bf711de..7f345a2 100644 --- a/src/pages/instrument/intro.tsx +++ b/src/pages/instrument/intro.tsx @@ -16,11 +16,6 @@ import Navbar from "../../components/navbar/navbar"; // import PopupAlert from "../../components/popup/popup-alert"; /* 组件 */ -/*** redux ***/ -import { connect } from "react-redux"; -import { setInstrument } from "../../store/features/instrument"; -/*** redux end ***/ - import { InstrumentInfo } from "../../utils/Interface"; import { setStorageSync, getStorageSync, go } from "../../utils/traoAPI"; @@ -166,12 +161,4 @@ class Intro extends Component { } } -const mapStateToProps = (state) => ({ - instrument: state.instrument, -}); -const mapDispatchToProps = (dispatch) => ({ - setInstrument(data) { - dispatch(setInstrument(data)); - }, -}); -export default connect(mapStateToProps, mapDispatchToProps)(Intro); +export default Intro; diff --git a/src/pages/instrument_clickin_upload/index.less b/src/pages/instrumentClickinUpload/index.less similarity index 94% rename from src/pages/instrument_clickin_upload/index.less rename to src/pages/instrumentClickinUpload/index.less index b6b709c..71efa07 100644 --- a/src/pages/instrument_clickin_upload/index.less +++ b/src/pages/instrumentClickinUpload/index.less @@ -139,27 +139,20 @@ page { /*box-shadow: -2rpx 0 12rpx .5rpx rgba(129, 129, 129, 0.1);*/ border: 2rpx solid #dddddd; position: relative; -} -.infobox2 .info4 .content .textarea { - width: 100%; - height: 100%; - color: #000; - font-size: 28rpx; -} -.infobox2 .info4 .content .contenttip { - color: #e1e1e1; - font-size: 20rpx; - position: absolute; - right: 24rpx; - bottom: 18rpx; -} - -.infobox2 .info4 .content textarea { - width: 100%; - height: 100%; - font-size: 28rpx; - color: #000; - border-radius: 3rpx; + textarea { + width: 100%; + height: 100%; + font-size: 28rpx; + color: #000; + border-radius: 3rpx; + } + .tips-num { + color: #999; + font-size: 20rpx; + position: absolute; + right: 24rpx; + bottom: 18rpx; + } } .placeholder { font-size: 28rpx; diff --git a/src/pages/instrument_clickin_upload/index.tsx b/src/pages/instrumentClickinUpload/index.tsx similarity index 59% rename from src/pages/instrument_clickin_upload/index.tsx rename to src/pages/instrumentClickinUpload/index.tsx index 1997440..72d2777 100644 --- a/src/pages/instrument_clickin_upload/index.tsx +++ b/src/pages/instrumentClickinUpload/index.tsx @@ -16,12 +16,14 @@ import { } from "@tarojs/components"; import Navbar from "@/components/navbar/navbar"; +import PopupInstrumentUploadTips from "@/components/popup/popup-instrument-upload-tips"; import { InstrumentInfo } from "@/utils/Interface"; import "./index.less"; import { contraction, getImgInfo } from "@/utils/compressImage"; import PopupAlert from "@/components/popup/popup-alert"; +import { setStorageSync, getStorageSync, msg } from "@/utils/traoAPI"; export default class InstrumentClickInUpload extends Component { constructor(props) { @@ -40,17 +42,27 @@ export default class InstrumentClickInUpload extends Component { showVideoPlayBtn: true, duration: 0, + videoContext: {}, // 视频播放器 + isTipShow: false, + clockContent: "", // 默认展示 + instrumentDetail: {}, punchInInfo: { - imageList: [], - content: "", + clockImageList: [], + clockContent: "", instrumentId: "84", + firstClockImg: null, + secondClockImg: null, + thirdClockImg: null, }, // 现在选中的数据 currentInfo: { modeVideo: "", }, modeInfo: [], + nurseInfo: [], // 首次进入介绍弹窗 isModeLock: false, + + isSubmit: false, // 已提交则禁用提交按钮 }; } @@ -61,27 +73,58 @@ export default class InstrumentClickInUpload extends Component { componentWillUnmount() {} - componentDidShow() {} + componentDidShow() { + let videoContext = Taro.createVideoContext("myVideo"); + this.setState({ videoContext }); + } componentDidHide() {} async initData() { - this.firstNurseInfo(); - this.modeInfoList(); + let objStr = getStorageSync("instrument_detail"); + if (objStr) { + let instrumentDetail = JSON.parse(objStr); + this.setState({ instrumentDetail }); + } + + setTimeout(() => { + this.firstNurseInfo(); + this.getLatestClockRecord(); + this.modeInfoList(); + }, 10); } + // 打卡介绍 firstNurseInfo = async () => { + let { instrumentDetail } = this.state; let res = await InstrumentInfo.firstNurseInfo({ - instrumentId: "84", + instrumentId: instrumentDetail.id, }); - console.log("firstNurseInfo", res); + if (res.data.code === 200) { + let isTipShow = getStorageSync("first_instrument_" + instrumentDetail.id); + if (!isTipShow) { + // 首次进入页面:自动打开打卡介绍弹窗 + this.setState({ nurseInfo: res.data.data, isTipShow: true }); + } else { + this.setState({ nurseInfo: res.data.data }); + } + } }; - + // 获取最新一条打卡记录 + getLatestClockRecord = async () => { + let { punchInInfo } = this.state; + let res = await InstrumentInfo.apiClock.getLatestClockRecord(); + if (res.data.code === 200) { + punchInInfo.clockContent = res.data.data.clockContent; + punchInInfo.clockImageList = res.data.data.clockImg; + } + this.setState({ punchInInfo }); + }; + // 获取仪器模式列表 modeInfoList = async () => { let res = await InstrumentInfo.modeInfoList({ instrumentId: "84", }); - console.log("modeInfo", res); if (res.data.code === 200) { if (res.data.data.length) { this.setState({ @@ -96,7 +139,7 @@ export default class InstrumentClickInUpload extends Component { let { currentInfo, modeInfo, punchInInfo } = this.state; currentInfo = modeInfo[index]; if (currentInfo.lock) { - this.onModeLockOpen(); + this.onModeLockOpen(); // 点击了锁定模式 return; } this.setState({ zkmoshiindex: index, currentInfo }); @@ -117,15 +160,98 @@ export default class InstrumentClickInUpload extends Component { let compressImage = await contraction(img, "compressImage"); // 压缩后文件地址 let compressTempFilePath = compressImage.tempFilePath; - punchInInfo.imageList.push(compressTempFilePath); + punchInInfo.clockImageList.push(compressTempFilePath); + this.setState({ punchInInfo }); }, }); }; + // 删除打卡图片 handleDeleteImage = async (index) => { let { punchInInfo } = this.state; - punchInInfo.imageList.splice(index, 1); + punchInInfo.clockImageList.splice(index, 1); + + this.setState({ punchInInfo }); + }; + + // 提交打卡 + handleSubmit = async () => { + let { punchInInfo } = this.state; + let obj = punchInInfo; + if (obj.clockImageList.length === 0) { + msg("至少上传一张图片"); + return; + } + + let promiseTasks: any = []; + let imgList: any[] = []; + obj.clockImageList.map((imgUrl: string) => { + let isTmpFile = imgUrl.indexOf("//tmp") > -1; + let isWXFile = imgUrl.indexOf("wxfile://") > -1; + if (isTmpFile || isWXFile) { + let params = { + clockImg: imgUrl, + }; + promiseTasks.push(InstrumentInfo.apiClock.clockFileUpload(params)); + imgList.push("null"); + } else { + imgList.push(imgUrl); + } + }); + + if (promiseTasks.length) { + let res = await Promise.all(promiseTasks); + //具体处理写在如下 + if (res.length) { + res.map((item) => { + if (item.code === 200) { + let index = imgList.findIndex((url) => url === "null"); + if (index > -1) { + imgList[index] = item.data.url; + } + } + }); + } + } + + let clockParmas = { + clockImageList: imgList, + clockContent: obj.clockContent, + }; + let res = await InstrumentInfo.apiClock.postInsertClockLog(clockParmas); + if (res.data.code === 200) { + msg("打卡成功"); + setTimeout(() => { + Taro.switchTab({ + url: "/pages/index/index", + }); + }, 2000); + } + }; + + onPlayTap = async () => { + let { videoContext } = this.state; + videoContext.play(); + this.setState({ + showVideoPlayBtn: false, + }); + }; + + videoBindTimeUpdate = async () => {}; + + videoEnded = async () => {}; + + videoPause = async () => {}; + + videoPlay = async () => {}; + + videoLoadedMetaData = async () => {}; + + handleTextareaInput = async (e) => { + let { punchInInfo } = this.state; + punchInInfo.clockContent = e.detail.value; + this.setState({ punchInInfo }); }; @@ -136,9 +262,16 @@ export default class InstrumentClickInUpload extends Component { this.setState({ isModeLock: false }); }; - onTipShow = async () => {}; - - handleSubmit = async () => {}; + onTipShowOpen = async () => { + this.setState({ isTipShow: true }); + }; + onTipShowClose = async () => { + setStorageSync( + "first_instrument_" + this.state.instrumentDetail.id, + "true" + ); + this.setState({ isTipShow: false }); + }; render() { let { @@ -148,10 +281,12 @@ export default class InstrumentClickInUpload extends Component { scrollleft, zkmoshiindex, punchInInfo, - tipshow, + isTipShow, currentInfo, modeInfo, + nurseInfo, isModeLock, + isSubmit, } = this.state; return ( @@ -171,7 +306,15 @@ export default class InstrumentClickInUpload extends Component { isClose={false} close={this.onModeLockClose} confirm={this.onModeLockClose} - > + /> + + )} @@ -266,7 +411,7 @@ export default class InstrumentClickInUpload extends Component { 打卡上传 - + { - {punchInInfo.imageList.length > 0 && - punchInInfo.imageList.map((item, index) => { + {punchInInfo.clockImageList.length > 0 && + punchInInfo.clockImageList.map((item, index) => { return ( @@ -293,7 +438,7 @@ export default class InstrumentClickInUpload extends Component { ); })} - {punchInInfo.imageList.length < 3 && ( + {punchInInfo.clockImageList.length < 3 && ( { )} - {!tipshow && ( - - )} - - {tipshow && ( + + {/* {tipshow && ( - {punchInInfo.content - ? punchInInfo.content + {punchInInfo.clockContent + ? punchInInfo.clockContent : "请记录一下今天打卡的心得吧~"} - )} + )} */} + + {punchInInfo.clockContent.length}/100 + - - 提交打卡 - + + + {!isSubmit && ( + + 提交打卡 + + )} + {isSubmit && ( + + 提交打卡 + + )} ); } diff --git a/src/store/features/deviceInfo.js b/src/store/features/deviceInfo.js new file mode 100644 index 0000000..0c381f0 --- /dev/null +++ b/src/store/features/deviceInfo.js @@ -0,0 +1,25 @@ +import Taro from "@tarojs/taro"; +import { createSlice } from "@reduxjs/toolkit"; + +// 设备连接蓝牙 +const deviceInfoReducer = createSlice({ + name: "deviceinfo", // store的名字 + initialState: { + bluetoothInfo: { + deviceId: "", + servicesuuid: "", + characteristicsuuid0: "", + characteristicsuuid1: "", + characteristicId: "", + }, + }, + reducers: { + setDeviceInfo(state, { payload }) { + console.log("payload", payload); + state = JSON.parse(JSON.stringify(payload)); + }, + }, +}); + +export const { setDeviceInfo } = deviceInfoReducer.actions; +export default deviceInfoReducer.reducer; diff --git a/src/store/index.js b/src/store/index.js index 06a694a..75e90f5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,7 +5,7 @@ import navigationReducer from "./features/navigation"; import userInfoReducer from "./features/userInfo"; import globalStoreReducer from "./features/globalStore"; import otherSettingReducer from "./features/otherSetting"; -import instrumentReducer from "./features/instrument"; +import deviceInfoReducer from "./features/deviceInfo"; const store = configureStore({ reducer: { @@ -15,7 +15,7 @@ const store = configureStore({ userInfo: userInfoReducer, globalStore: globalStoreReducer, otherSetting: otherSettingReducer, - instrument: instrumentReducer, + deviceInfo: deviceInfoReducer, }, }); diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 2a58fc8..0087e79 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -153,65 +153,66 @@ export const GetMessageList = (data) => { }; // 积分页面 +/**分页获取用户积分列表*/ export const GetObtainUserIntegral = (data) => { - // 分页获取用户积分列表 return Ajax({ url: "/integralLog/obtainUserIntegral" + paramsToUrlQueryString(data), method: "get", }); }; +/**获取积分规则*/ export const GetIntegralRule = (data) => { - // 获取积分规则 return Ajax({ url: "/setting/getIntegralRule", method: "get", }); }; +/**查询用户是否关注公众号*/ export const GetIsAttentionOfficialAccount = (data) => { - // 查询用户是否关注公众号 return Ajax({ url: "/noRemind/isAttentionOfficialAccount", method: "get", }); }; +/**查询用户是否关闭提醒关注公众号*/ export const GetOfficialAccount = (data) => { - // 查询用户是否关闭提醒关注公众号 return Ajax({ url: "/noRemind/getOfficialAccount", method: "get", }); }; + +/**查询关闭提醒关注公众号*/ export const GetCloseOfficialAccount = (data) => { - // 查询关闭提醒关注公众号 return Ajax({ url: "/noRemind/closeOfficialAccount", method: "get", }); }; +/**站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块*/ export const GetSitePopupList = (data) => { - // 站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块 return Ajax({ url: "/siteInfo/popup/" + data, method: "get", }); }; +/**站点管理-轮播图*/ export const GetSiteCarousel = (data) => { - // 站点管理-轮播图 return Ajax({ url: "/siteInfo/carousel", method: "get", }); }; +/**站点管理-轮播图-添加标签 传值是id*/ export const GetSiteAddTag = (data) => { - // 站点管理-轮播图-添加标签 传值是id return Ajax({ url: "/siteInfo/addTag/" + data, method: "get", }); }; -// 仪器管理 +/**仪器管理*/ export const InstrumentInfo = { /**根据序列号获取仪器信息 serial 序列号*/ getInstrumentInfoBySerial: (data) => { @@ -325,7 +326,18 @@ export const InstrumentInfo = { }, /**打卡相关*/ - clock: { + apiClock: { + /**单文件上传*/ + clockFileUpload: (formData) => { + return AjaxUploadFile( + { + url: "/clock/upload", + filePath: formData.clockImg, + name: "clockImg", + }, + formData + ); + }, /**添加用户使用仪器记录 instrumentId*/ addClockInstrument: (data) => { return Ajax({ @@ -364,7 +376,7 @@ export const InstrumentInfo = { }, }, /**护理相关*/ - nursingLog: { + apiNursingLog: { /**新增用户护理日志*/ addLog: (data) => { return Ajax({ diff --git a/src/utils/bluetoothWXAPI.js b/src/utils/bluetoothWXAPI.js index f116f95..de4f03e 100644 --- a/src/utils/bluetoothWXAPI.js +++ b/src/utils/bluetoothWXAPI.js @@ -1,12 +1,15 @@ +import Taro from "@tarojs/taro"; +const deviceInfo = store.getState().deviceInfo; + import { msg, back, showModal, go, loading } from "./traoAPI"; -const app = getApp(); +// const app = getApp(); import { keywordTofilter } from "./util"; const log = require("./log"); import commandMap from "./commandMap"; export const getSystemInfo = () => { return new Promise((reslove, reject) => { - wx.getSystemInfo({ + Taro.getSystemInfo({ success(res) { reslove(res); }, @@ -16,7 +19,7 @@ export const getSystemInfo = () => { export const openBluetoothAdapter = () => { return new Promise((reslove, reject) => { - wx.openBluetoothAdapter({ + Taro.openBluetoothAdapter({ success(res) { reslove(res); }, @@ -29,7 +32,7 @@ export const openBluetoothAdapter = () => { export const startBluetoothDevicesDiscovery = () => { return new Promise((reslove, reject) => { - wx.startBluetoothDevicesDiscovery({ + Taro.startBluetoothDevicesDiscovery({ //开始搜索蓝牙 allowDuplicatesKey: false, success(res) { @@ -44,7 +47,7 @@ export const startBluetoothDevicesDiscovery = () => { export const createBLEConnection = (deviceId) => { return new Promise((reslove, reject) => { - wx.createBLEConnection({ + Taro.createBLEConnection({ deviceId, success(res) { reslove(res); @@ -58,7 +61,7 @@ export const createBLEConnection = (deviceId) => { export const closeBLEConnection = (deviceId) => { return new Promise((reslove, reject) => { - wx.closeBLEConnection({ + Taro.closeBLEConnection({ deviceId, success(res) { reslove(res); @@ -74,14 +77,14 @@ export const closeBLEConnection = (deviceId) => { //数组下标1读取 0写入 export const getBLEDeviceServices = (deviceId) => { return new Promise((reslove, reject) => { - wx.getBLEDeviceServices({ + Taro.getBLEDeviceServices({ //获取服务以及服务的uuid deviceId, success(res) { console.log("主要服务"); console.log(res); let servicesuuid = res.services[0].uuid; //主要服务 - wx.getBLEDeviceCharacteristics({ + Taro.getBLEDeviceCharacteristics({ //获取蓝牙低功耗设备某个服务中所有特征 (characteristic)。 deviceId, serviceId: servicesuuid, @@ -109,7 +112,7 @@ export const getBLEDeviceServices = (deviceId) => { export const notifyBLECharacteristicValueChange = (info) => { return new Promise((reslove, reject) => { - wx.notifyBLECharacteristicValueChange({ + Taro.notifyBLECharacteristicValueChange({ state: true, // 启用 notify 功能 deviceId: info.deviceId, serviceId: info.servicesuuid, @@ -126,7 +129,7 @@ export const notifyBLECharacteristicValueChange = (info) => { export const writeBLECharacteristicValue = (info, completeCallback) => { return new Promise((reslove, reject) => { - wx.writeBLECharacteristicValue({ + Taro.writeBLECharacteristicValue({ deviceId: info.deviceId, serviceId: info.servicesuuid, characteristicId: info.characteristicsuuid0, @@ -152,10 +155,10 @@ export const writeBLECharacteristicValue = (info, completeCallback) => { export const sendCommand = (info) => { return new Promise((reslove, reject) => { - wx.writeBLECharacteristicValue({ - deviceId: app.globalData.deviceInfo.deviceId, - serviceId: app.globalData.deviceInfo.servicesuuid, - characteristicId: app.globalData.deviceInfo.characteristicsuuid0, + Taro.writeBLECharacteristicValue({ + deviceId: deviceInfo.bluetoothInfo.deviceId, + serviceId: deviceInfo.bluetoothInfo.servicesuuid, + characteristicId: deviceInfo.bluetoothInfo.characteristicsuuid0, value: info.value, success(res) { console.log(info.value);