index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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="http://106.54.209.120:8188/static/scan_bind.png"></image>
  7. <text>扫码绑定设备</text>
  8. </div>
  9. <div class="pre adffcacjc" @tap="wifiBind">
  10. <image src="http://106.54.209.120:8188/static/wifi_bind.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/bindAdd',{
  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. that.$showToast('绑定成功')
  46. setTimeout(()=>{
  47. that.show = false;
  48. uni.reLaunch({
  49. url:'/pages/home'
  50. })
  51. },1500)
  52. })
  53. }
  54. }
  55. })
  56. },
  57. wifiBind(){
  58. this.show = false;
  59. uni.navigateTo({
  60. url:'/pagesMy/deviceAdd'
  61. })
  62. },
  63. }
  64. }
  65. </script>
  66. <style scoped lang="less">
  67. .bind_device{
  68. width: 100%;
  69. padding: 74rpx 74rpx 20rpx;
  70. box-sizing: border-box;
  71. .top{
  72. .pre{
  73. width: calc(50% - 51rpx);
  74. image{
  75. width: 110rpx;
  76. height: 110rpx;
  77. }
  78. text{
  79. font-family: PingFangSC, PingFang SC;
  80. font-weight: 400;
  81. font-size: 28rpx;
  82. color: #111111;
  83. line-height: 32rpx;
  84. text-align: center;
  85. margin-top: 24rpx;
  86. }
  87. }
  88. }
  89. .close{
  90. width: 100%;
  91. margin-top: 113rpx;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. }
  96. }
  97. </style>