uuid.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view>
  3. <view class="tips">请输入您的设备MAC地址:</view>
  4. <!-- 搜索框 -->
  5. <view class="search_container">
  6. <input
  7. type="text"
  8. v-model="inputValue"
  9. class="search_public"
  10. focus="true"
  11. confirm-type="done"
  12. placeholder=""
  13. />
  14. <button class="search_btn" type="submit" @click="getSubmit">绑定</button>
  15. </view>
  16. <view class="explain">
  17. MAC地址获取途径:设备页-当前连接设备-右上角箭头标展开详情-点击关于本机-单机MAC地址复制
  18. <br />(绑定验证成功文字提示:“绑定成功”并跳转下个页面,绑定验证MAC地址不正确提示文字“MAC地址不正确,请确认后重新输入,绑定成功后该页面不再展示”)
  19. <br />每个MAC地址限一个远程操作账号绑定,即只存在一个当前绑定远程操作账号,最新绑定的为当前绑定账号,其他账号自动失效,以此类推。</view
  20. >
  21. </view>
  22. </template>
  23. <script>
  24. import { deviceBind, deviceBindInfo, getUserInfo } from "@/api/public.js";
  25. export default {
  26. data() {
  27. return {
  28. code: "",
  29. state: "",
  30. openId: "",
  31. inputValue: "",
  32. };
  33. },
  34. onLoad(e) {
  35. this.code = e.code;
  36. this.state = e.state;
  37. this.getUserInfo();
  38. },
  39. methods: {
  40. ///获取用户信息
  41. getUserInfo() {
  42. getUserInfo({
  43. code: this.code,
  44. }).then((res) => {
  45. if (res.code === 0) {
  46. this.openId = res.data.openid;
  47. }
  48. });
  49. },
  50. // http://ptt.radio1964.com/v1/device/get-wifi?UUId=AIrSMArT_210052355545
  51. getSubmit() {
  52. if (this.inputValue.trim().length === 0) {
  53. uni.showToast({
  54. title: "MAC地址不能为空",
  55. icon: "none",
  56. mask: true,
  57. duration: 2000,
  58. });
  59. return;
  60. }
  61. deviceBindInfo({
  62. state: this.state,
  63. openId: this.openId,
  64. }).then((res) => {
  65. if (res.code === 0) {
  66. var isBind = res.data.isBind;
  67. ///已经绑定
  68. if (isBind) {
  69. uni.redirectTo({
  70. url: `/pages/public/remote?state=${this.state}&openId=${this.openId}`,
  71. });
  72. } else {
  73. deviceBind({
  74. deviceMac: this.inputValue,
  75. state: this.state,
  76. openId: this.openId,
  77. }).then((res) => {
  78. if (res.code === 0) {
  79. uni.redirectTo({
  80. url: `/pages/public/remote?state=${this.state}&openId=${this.openId}`,
  81. });
  82. } else {
  83. uni.showToast({
  84. title: res.message,
  85. icon: "none",
  86. mask: true,
  87. duration: 2000,
  88. });
  89. }
  90. });
  91. }
  92. }
  93. });
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .tips {
  100. padding-top: 40%;
  101. margin-left: 40rpx;
  102. margin-right: 40rpx;
  103. font-size: 30rpx;
  104. }
  105. .search_container {
  106. display: flex;
  107. flex-direction: row;
  108. margin-top: 20rpx;
  109. }
  110. .search_public {
  111. background: #ededed;
  112. height: 80rpx;
  113. line-height: 80rpx;
  114. margin-left: 40rpx;
  115. margin-right: 20rpx;
  116. border-radius: 50rpx;
  117. align-items: center;
  118. justify-content: center;
  119. text-align: start;
  120. color: black;
  121. }
  122. .search_btn {
  123. height: 80rpx;
  124. line-height: 80rpx;
  125. margin-top: 20rpx;
  126. width: 200rpx;
  127. align-items: center;
  128. justify-content: center;
  129. text-align: center;
  130. font-size: 30rpx;
  131. border-radius: 50rpx;
  132. margin-right: 4%;
  133. }
  134. .explain {
  135. font-size: 25rpx;
  136. margin-top: 40rpx;
  137. margin-left: 40rpx;
  138. margin-right: 40rpx;
  139. }
  140. </style>