index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <u-popup :show="show" :round="36" mode="bottom" @close="close">
  3. <view class="bind_device">
  4. <div class="top adfacjb">
  5. <div class="pre adffcacjc" @tap="scanBind">
  6. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/7c56ff85-0a0d-43f4-90dc-6559423e1eec.png"></image>
  7. <text>扫码绑定设备</text>
  8. </div>
  9. <div class="pre adffcacjc" @tap="wifiBind">
  10. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/b45bc4e9-effb-4045-adce-98b14f3f6e8a.png"></image>
  11. <text>配网并绑定设备</text>
  12. </div>
  13. </div>
  14. <div class="close">
  15. <u-icon name="close" color="#5C5C5C" size="50" @tap="close"></u-icon>
  16. </div>
  17. </view>
  18. </u-popup>
  19. </template>
  20. <script>
  21. export default {
  22. data(){
  23. return {
  24. show:false
  25. }
  26. },
  27. methods:{
  28. close(){
  29. this.show = false;
  30. },
  31. scanBind(){
  32. this.show = false;
  33. let that = this;
  34. uni.scanCode({
  35. success: (res) => {
  36. let result = JSON.parse(res.result);
  37. if(res.errMsg==='scanCode:ok'){
  38. that.$api.post('/device/bind',{
  39. ...result,
  40. "type": "",
  41. "userId": 0,
  42. "agentId": ""
  43. }).then(res=>{
  44. if(res.data.code!==0) return that.$showToast(res.data.msg)
  45. uni.navigateTo({
  46. url:'/pagesMy/scanResult?deviceId='+res.data.data
  47. })
  48. })
  49. }
  50. }
  51. })
  52. },
  53. wifiBind(){
  54. this.show = false;
  55. uni.navigateTo({
  56. url:'/pagesMy/deviceAdd'
  57. })
  58. },
  59. }
  60. }
  61. </script>
  62. <style scoped lang="less">
  63. .bind_device{
  64. width: 100%;
  65. padding: 74rpx 74rpx 20rpx;
  66. box-sizing: border-box;
  67. .top{
  68. .pre{
  69. width: calc(50% - 51rpx);
  70. image{
  71. width: 110rpx;
  72. height: 110rpx;
  73. }
  74. text{
  75. font-family: PingFangSC, PingFang SC;
  76. font-weight: 400;
  77. font-size: 28rpx;
  78. color: #111111;
  79. line-height: 32rpx;
  80. text-align: center;
  81. margin-top: 24rpx;
  82. }
  83. }
  84. }
  85. .close{
  86. width: 100%;
  87. margin-top: 113rpx;
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. }
  92. }
  93. </style>