AI销管
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

346 linhas
8.1 KiB

  1. <template>
  2. <view class="detail">
  3. <view class="de-t1">{{info.name}}</view>
  4. <view class="de-label">蓝牙连接</view>
  5. <view class="de-input">
  6. <view class="de-input-t1">蓝牙</view>
  7. <view @click.stop="connectTO()" class="de-input-t2">{{connectDev.deviceId != info.deviceId?'未连接':'已连接'}}</view>
  8. <image src="/static/images/jiantop.png" />
  9. </view>
  10. <template v-if="connectDev.deviceId != info.deviceId">
  11. <view class="empty">
  12. <image mode="widthFix" src="/static/images/bluetooth-empty.png" />
  13. <view class="empty-l">设备状态与配置请在连接蓝牙后查询</view>
  14. </view>
  15. </template>
  16. <template v-else>
  17. <!-- wifi列表 -->
  18. <view class="de-label">设备配置</view>
  19. <view class="de-lic">
  20. <view class="de-lic-li line">
  21. <view class="de-lic-1">WIFI</view>
  22. </view>
  23. <view @click="goWifi()" class="de-lic-li">
  24. <view class="de-lic-1">设置WIFI状态</view>
  25. <view class="de-lic-2">
  26. {{(wifiDetail && wifiDetail.connect == 1)?wifiDetail.ssid+"已连接":"未连接"}}
  27. </view>
  28. <image @click.stop="goWdetial()" style="width: 36rpx;height: 36rpx;margin-left: 12rpx;"
  29. :src="'/static/images/bluetooth-ghh'+ ((wifiDetail && wifiDetail.connect == 1)?'-ac':'') +'.png'" />
  30. </view>
  31. </view>
  32. <!-- 设备状态 -->
  33. <view @click="getDevInfo" class="de-label">
  34. 设备状态 <text>刷新</text>
  35. </view>
  36. <view class="de-lic" style="margin-bottom: 60rpx;">
  37. <view class="de-lic-li line">
  38. <view class="de-lic-1">设备SN</view>
  39. <view class="de-lic-2">{{detail.sn?detail.sn:'--'}}</view>
  40. </view>
  41. <view @click="onOffRec()" class="de-lic-li line">
  42. <view class="de-lic-1">录音</view>
  43. <view class="de-lic-2">{{detail.rec == 1?"已开启":"未开启"}}</view>
  44. </view>
  45. <view class="de-lic-li line">
  46. <view class="de-lic-1">电量</view>
  47. <view class="de-lic-2">{{detail.rsoc?detail.rsoc:0}}%</view>
  48. </view>
  49. <view class="de-lic-li line">
  50. <view class="de-lic-1">存储空间</view>
  51. <view class="de-lic-2">{{detail.df?detail.df:0}}MB/{{detail.total_df?detail.total_df:0}}MB</view>
  52. </view>
  53. <view class="de-lic-li line">
  54. <view class="de-lic-1">信号强度</view>
  55. <view class="de-lic-2">{{(wifiDetail && wifiDetail.connect == 1)?wifiDetail.rssi+"dbm":"未连接"}}</view>
  56. </view>
  57. <view class="de-lic-li line">
  58. <view class="de-lic-1">固件版本</view>
  59. <view class="de-lic-2">{{detail.v?detail.v:'0.0.0'}}</view>
  60. </view>
  61. <view class="de-lic-li line">
  62. <view class="de-lic-1">USB接入</view>
  63. <view class="de-lic-2">{{detail.usb == 1?"插入":"未插入"}}</view>
  64. </view>
  65. <view class="de-lic-li">
  66. <view class="de-lic-1">时钟</view>
  67. <view class="de-lic-2">{{detail.time?detail.time:"--:--:--"}}</view>
  68. </view>
  69. </view>
  70. </template>
  71. </view>
  72. </template>
  73. <script>
  74. import { connectBlue,sendData,closeBlue,setNotification,ab2hex,cnum } from "@/utils/blue.js";
  75. import { mapState, mapMutations } from 'vuex';
  76. export default {
  77. data() {
  78. return {
  79. info : "",
  80. wifiList : [],
  81. detail: "",
  82. wifiDetail: "",
  83. type : 0,
  84. }
  85. },
  86. computed: {
  87. ...mapState(['connectDev','connectState']),
  88. },
  89. onShow() {
  90. //设定异步通知
  91. this.info = uni.getStorageSync("lyDetail")
  92. this.notiInit();
  93. },
  94. onLoad() {
  95. },
  96. methods: {
  97. //连接设备
  98. connectTO() {
  99. var that = this;
  100. if (this.connectDev.deviceId != this.info.deviceId) {
  101. uni.showModal({
  102. title: '链接蓝牙',
  103. content: '确定要链接此蓝牙吗?',
  104. cancelText: '取消',
  105. confirmText: '确定',
  106. success(res) {
  107. //设置设置通知
  108. if (res.confirm) {
  109. connectBlue(that.info).then(() => {
  110. setTimeout(() => {
  111. that.notiInit()
  112. },1000)
  113. });
  114. }
  115. }
  116. })
  117. } else {
  118. uni.showModal({
  119. title: '断开蓝牙',
  120. content: '确定要断开蓝牙连接吗?',
  121. cancelText: '取消',
  122. confirmText: '确定',
  123. success(res) {
  124. if (res.confirm) {
  125. uni.setStorageSync("connectNum",4);
  126. closeBlue().then(() => {
  127. that.getDevInfo();
  128. });
  129. }
  130. }
  131. })
  132. }
  133. },
  134. //开启录音/关闭录音
  135. onOffRec() {
  136. var that = this
  137. uni.showModal({
  138. title: '提示',
  139. content: this.detail.rec == 1?'确定要关闭录音吗?':'确定要开启录音吗?',
  140. cancelText: '取消',
  141. confirmText: '确定',
  142. success(res) {
  143. if (res.confirm) {
  144. uni.showLoading({
  145. title:"操作中...",
  146. icon: "none"
  147. })
  148. if (that.detail.rec == 1) {
  149. sendData([0xA0,0x59,0x00])
  150. } else {
  151. sendData([0xA0,0x5A,0x00])
  152. }
  153. }
  154. }
  155. })
  156. },
  157. //获取设备/wifi信息
  158. getDevInfo() {
  159. uni.showLoading({
  160. title:"获取中...",
  161. icon: "none"
  162. })
  163. sendData([0xA0,0x80,0x00]);
  164. },
  165. notiInit() {
  166. var that = this;
  167. if (this.connectDev && this.connectDev.deviceId == this.info.deviceId) {
  168. setNotification().then(() => {
  169. that.getDevInfo();
  170. uni.onBLECharacteristicValueChange((res) => {
  171. let data = ab2hex(res.value);
  172. if (data.pre[1] == "80") {
  173. that.detail = JSON.parse(data.value)
  174. sendData([0xA0,0x81,0x00]);
  175. }
  176. if (data.pre[1] == "81") {
  177. that.wifiDetail = JSON.parse(data.value)
  178. }
  179. if (data.pre[1] == "5a" || data.pre[1] == "59") {
  180. sendData([0xA0,0x80,0x00]);
  181. }
  182. try{
  183. uni.hideLoading();
  184. }catch(e){
  185. console.log(e.message)
  186. }
  187. console.log('特性值改变:',data); // 打印接收到的数据
  188. });
  189. })
  190. }
  191. },
  192. //详情
  193. goWdetial() {
  194. if (this.wifiDetail && this.wifiDetail.connect == 1) {
  195. uni.setStorageSync("wifiDetail",this.wifiDetail);
  196. uni.navigateTo({
  197. url:"/pages/bluetooth/wdetail"
  198. })
  199. }
  200. },
  201. goWifi(){
  202. uni.navigateTo({
  203. url:"/pages/bluetooth/wifi"
  204. })
  205. },
  206. dkBlue() {
  207. closeBlue();
  208. }
  209. }
  210. }
  211. </script>
  212. <style scoped lang="scss">
  213. .detail {
  214. background-color: #F1F2F4;
  215. min-height: 100vh;
  216. width: 100%;
  217. box-sizing: border-box;
  218. padding: 40rpx 28rpx 0;
  219. .de-t1 {
  220. background: #FFFFFF;
  221. border-radius: 12rpx;
  222. padding: 28rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. font-size: 28rpx;
  227. color: #333333;
  228. box-sizing: border-box;
  229. }
  230. .de-input {
  231. box-sizing: border-box;
  232. padding: 28rpx;
  233. background: #FFFFFF;
  234. border-radius: 12rpx;
  235. display: flex;
  236. align-items: center;
  237. justify-content: space-between;
  238. margin-top: 20rpx;
  239. .de-input-t1 {
  240. font-weight: 400;
  241. font-size: 28rpx;
  242. color: #333333;
  243. }
  244. .de-input-t2 {
  245. font-weight: 400;
  246. font-size: 28rpx;
  247. color: #666666;
  248. margin-left: auto;
  249. }
  250. image {
  251. width: 12rpx;
  252. height: 28rpx;
  253. margin-left: 16rpx;
  254. }
  255. }
  256. .de-label {
  257. width: 100%;
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. margin-top: 40rpx;
  262. font-weight: 400;
  263. font-size: 26rpx;
  264. color: #666666;
  265. text {
  266. font-weight: 400;
  267. font-size: 28rpx;
  268. color: #2671E2;
  269. margin-left: auto;
  270. transform: translateY(2rpx);
  271. }
  272. }
  273. .de-lic {
  274. box-sizing: border-box;
  275. padding: 0 28rpx;
  276. background: #FFFFFF;
  277. border-radius: 12rpx;
  278. margin-top: 20rpx;
  279. .de-lic-li {
  280. height: 84rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. .de-lic-1 {
  285. font-weight: 400;
  286. font-size: 28rpx;
  287. color: #333333;
  288. }
  289. .de-lic-2 {
  290. font-weight: 400;
  291. font-size: 26rpx;
  292. color: #666;
  293. margin-left: auto;
  294. }
  295. image {
  296. width: 28rpx;
  297. height: 28rpx;
  298. margin-left: 8rpx;
  299. }
  300. }
  301. .line {
  302. border-bottom: 1rpx dashed #f5f5f5;
  303. }
  304. }
  305. .empty {
  306. margin-top: 16rpx;
  307. height: 275rpx;
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. flex-direction: column;
  312. background-color: #fff;
  313. border-radius: 12rpx;
  314. image {
  315. width: 180rpx;
  316. }
  317. .empty-l {
  318. font-weight: 400;
  319. font-size: 26rpx;
  320. color: #999999;
  321. margin-top: 16rpx;
  322. }
  323. }
  324. }
  325. </style>