remote.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <view class="tips"></view>
  4. <view class="search_container">
  5. <input
  6. type="text"
  7. v-model="inputValue1"
  8. class="search_public"
  9. confirm-type="done"
  10. disabled="true"
  11. />
  12. <button class="search_btn" type="submit" @click="getSubmit1">前往</button>
  13. </view>
  14. <view class="search_container marTop20">
  15. <input
  16. type="text"
  17. v-model="inputValue2"
  18. class="search_public"
  19. disabled="true"
  20. />
  21. <button class="search_btn" type="submit" @click="getSubmit2">前往</button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { deviceUrlInfo } from "@/api/public.js";
  27. export default {
  28. data() {
  29. return {
  30. state: "",
  31. openId: "",
  32. flowUrl: "",
  33. wifiUrl: "",
  34. inputValue1: "流量充值",
  35. inputValue2: "远程配网",
  36. };
  37. },
  38. onLoad(e) {
  39. this.state = e.state;
  40. this.openId = e.openId;
  41. this.deviceUrlInfo();
  42. },
  43. methods: {
  44. ///获取用户信息
  45. deviceUrlInfo() {
  46. deviceUrlInfo({
  47. state: this.state,
  48. openId: this.openId,
  49. }).then((res) => {
  50. if (res.code === 0) {
  51. this.flowUrl = res.data.flowUrl;
  52. this.wifiUrl = res.data.wifiUrl;
  53. }
  54. });
  55. },
  56. getSubmit1() {
  57. if (this.flowUrl.length === 0) {
  58. deviceUrlInfo({
  59. state: this.state,
  60. openId: this.openId,
  61. }).then((res) => {
  62. if (res.code === 0) {
  63. this.flowUrl = res.data.flowUrl;
  64. this.wifiUrl = res.data.wifiUrl;
  65. window.location.href = this.flowUrl;
  66. } else {
  67. uni.showToast({
  68. title: res.message,
  69. icon: "none",
  70. mask: true,
  71. duration: 2000,
  72. });
  73. }
  74. });
  75. } else {
  76. window.location.href = this.flowUrl;
  77. }
  78. },
  79. getSubmit2() {
  80. if (this.wifiUrl.length === 0) {
  81. deviceUrlInfo({
  82. state: this.state,
  83. openId: this.openId,
  84. }).then((res) => {
  85. if (res.code === 0) {
  86. this.flowUrl = res.data.flowUrl;
  87. this.wifiUrl = res.data.wifiUrl;
  88. window.location.href = this.wifiUrl;
  89. } else {
  90. uni.showToast({
  91. title: res.message,
  92. icon: "none",
  93. mask: true,
  94. duration: 2000,
  95. });
  96. }
  97. });
  98. } else {
  99. window.location.href = this.wifiUrl;
  100. }
  101. },
  102. },
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. .tips {
  107. padding-top: 45%;
  108. margin-left: 20rpx;
  109. margin-right: 20rpx;
  110. font-size: 30rpx;
  111. }
  112. .search_container {
  113. display: flex;
  114. flex-direction: row;
  115. margin-top: 20rpx;
  116. }
  117. .search_public {
  118. background: #ededed;
  119. height: 80rpx;
  120. line-height: 80rpx;
  121. margin-left: 40rpx;
  122. margin-right: 20rpx;
  123. border-radius: 50rpx;
  124. align-items: center;
  125. justify-content: center;
  126. text-align: center;
  127. color: black;
  128. }
  129. .search_btn {
  130. height: 80rpx;
  131. line-height: 80rpx;
  132. margin-top: 20rpx;
  133. width: 200rpx;
  134. align-items: center;
  135. justify-content: center;
  136. text-align: center;
  137. font-size: 30rpx;
  138. border-radius: 50rpx;
  139. margin-right: 40rpx;
  140. }
  141. .marTop20 {
  142. margin-top: 50rpx;
  143. }
  144. .explain {
  145. font-size: 25rpx;
  146. margin-top: 40rpx;
  147. margin-left: 20rpx;
  148. margin-right: 20rpx;
  149. }
  150. </style>