try.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="">
  3. 获取人脸
  4. <img :src="pic" alt="">
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. msg: {
  12. deviceId: "b44f96f00ff0",
  13. },
  14. pic: '',
  15. gatewayDeviceId: 'd825b0036120',
  16. }
  17. },
  18. methods: {
  19. // 重置设备
  20. async resetDevice() {
  21. uni.showLoading({
  22. mask: true,
  23. icon: 'none',
  24. title: '正在重置设备',
  25. })
  26. let {
  27. data: res
  28. } = await uni.$http.post('/api/v1/test/bluetooth/resetDevice', this.msg)
  29. console.log(res);
  30. uni.hideLoading()
  31. if (res.code == 200) {
  32. this.$u.toast(`重置成功`)
  33. } else {
  34. this.$u.toast(`重置失败`)
  35. }
  36. },
  37. async getFacePic() {
  38. let {
  39. data: res
  40. } = await uni.$http.get(`/api/v1/test/user/facePic/${1}`)
  41. console.log(res.data);
  42. this.pic = 'data:image/jpg;base64,' + res.data
  43. },
  44. async gate() {
  45. const {
  46. data: res
  47. } = await uni.$http.get(
  48. `/api/v1/test/gateway/connection/${this.gatewayDeviceId}`)
  49. console.log(res);
  50. }
  51. },
  52. onLoad() {
  53. // this.resetDevice()
  54. // this.getFacePic()
  55. // this.gate()
  56. uni.showToast({
  57. title: '我在测试',
  58. duration: 10000,
  59. })
  60. setInterval(() => {
  61. uni.showToast({
  62. title: '2我在测试',
  63. duration: 10000,
  64. })
  65. }, 10000)
  66. }
  67. }
  68. </script>