add_equ.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="box">
  3. <van-tabs v-model="active">
  4. <van-tab title="扫码">
  5. <view class="scan">
  6. <view class="scan_box">
  7. <image src="/static/img/scan.png" mode=""></image>
  8. </view>
  9. <view class="scan_btn" @click="scanQRCode">扫码</view>
  10. <view class="warn_text">
  11. <view class="text">
  12. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  13. 业务
  14. </view>
  15. </view>
  16. </view>
  17. </van-tab>
  18. <van-tab title="输入">
  19. <view class="input">
  20. <view class="text_box">
  21. <input type="text" placeholder="请输入设备ID号" v-model="text">
  22. </view>
  23. <view class="scan_btn" @click="next">
  24. <!-- <view class=""> -->
  25. 下一步
  26. <!-- </view> -->
  27. </view>
  28. <view class="warn_text">
  29. <view class="text">
  30. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  31. 业务
  32. </view>
  33. </view>
  34. </view>
  35. </van-tab>
  36. </van-tabs>
  37. <!-- <u-tabs :list="list" :current="current" @click="click" lineColor="#F35546" lineWidth="88" lineHeight="4"
  38. bg-color="#fff"></u-tabs>
  39. <view class="scan" v-if="current === 0">
  40. <view class="scan_box">
  41. <image src="/static/image/scan.png" mode=""></image>
  42. </view>
  43. <view class="scan_btn" @click="scanQRCode">扫码</view>
  44. <view class="warn_text">
  45. <view class="text">
  46. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  47. 业务
  48. </view>
  49. </view>
  50. </view>
  51. <view class="input" v-if="current === 1">
  52. <view class="text_box">
  53. <input type="text" placeholder="请输入设备ID号" v-model="text">
  54. </view>
  55. <view class="scan_btn" @click="next">
  56. 下一步
  57. </view>
  58. <view class="warn_text">
  59. <view class="text">
  60. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  61. 业务
  62. </view>
  63. </view>
  64. </view> -->
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. list: [{
  72. name: '扫码'
  73. }, {
  74. name: '输入'
  75. }],
  76. current: 0,
  77. text: ''
  78. }
  79. },
  80. onShow: function() {
  81. },
  82. methods: {
  83. click(item) {
  84. this.current = item.index;
  85. },
  86. next() {
  87. console.log(this.text, 777);
  88. if (this.text) {
  89. uni.navigateTo({
  90. url: `/pages/equ_list/bind?deviceCode=${this.text}`
  91. })
  92. } else {
  93. this.$util.Tips({
  94. title: '请输入设备ID号'
  95. });
  96. }
  97. },
  98. scanQRCode() {
  99. uni.scanCode({
  100. success: (res) => {
  101. console.log(res); // 打印扫码结果
  102. // 在这里可以对扫码结果进行处理
  103. uni.navigateTo({
  104. url: `/pages/equ_list/bind?deviceCode=${res.result}`
  105. })
  106. },
  107. fail: (res) => {
  108. console.log(res);
  109. // 处理扫码失败的情况
  110. this.$util.Tips({
  111. title:'扫码失败',
  112. icon:'error'
  113. })
  114. }
  115. });
  116. }
  117. // uni.scanCode({
  118. // success: res => {
  119. // let code = null
  120. // this.modelCode = null
  121. // if (res.result && res.result.indexOf('SN') == -1) {
  122. // code = +res.result
  123. // } else if (res.result && res.result.indexOf('"SN"') != -1) {
  124. // res.result = JSON.parse(res.result)
  125. // code = +res.result.SN
  126. // } else {
  127. // return uni.showToast({
  128. // icon: 'none',
  129. // title: '非法的TBOX编号',
  130. // })
  131. // }
  132. // const codeType = typeof code === 'number' && !isNaN(code)
  133. // if (!codeType) {
  134. // return uni.showToast({
  135. // icon: 'none',
  136. // title: '非法的TBOX编号',
  137. // })
  138. // }
  139. // // 数据重置
  140. // this.resetData()
  141. // this.tboxCode = code
  142. // this.scanning && this.getTBoxInfo(code)
  143. // },
  144. // fail: function() {
  145. // this.scanning = true
  146. // uni.hideLoading()
  147. // },
  148. // })
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. .box {
  154. width: 750rpx;
  155. height: 100vh;
  156. background-color: #fff;
  157. .scan {
  158. padding: 55rpx 32rpx 477rpx;
  159. text-align: center;
  160. background-color: #F7F7F7;
  161. .scan_box {
  162. image {
  163. width: 386rpx;
  164. height: 533rpx;
  165. }
  166. }
  167. .scan_btn {
  168. height: 98rpx;
  169. line-height: 98rpx;
  170. background: #F35546;
  171. border-radius: 9rpx;
  172. margin-top: 79rpx;
  173. font-size: 32rpx;
  174. font-weight: 500;
  175. color: #FFFFFF;
  176. }
  177. .warn_text {
  178. font-size: 24rpx;
  179. font-weight: 500;
  180. color: #777777;
  181. margin-top: 42rpx;
  182. text-align: start;
  183. line-height: 33rpx;
  184. }
  185. }
  186. .input {
  187. padding: 55rpx 32rpx 477rpx;
  188. // text-align: center;
  189. height: 100%;
  190. background-color: #F7F7F7;
  191. .text_box {
  192. background-color: #fff;
  193. height: 98rpx;
  194. line-height: 98rpx;
  195. padding: 0 32rpx;
  196. input {
  197. width: 100%;
  198. height: 100%;
  199. // width: 386rpx;
  200. // height: 533rpx;
  201. }
  202. }
  203. .scan_btn {
  204. height: 98rpx;
  205. line-height: 98rpx;
  206. text-align: center;
  207. background: #F35546;
  208. border-radius: 9rpx;
  209. margin-top: 131rpx;
  210. font-size: 32rpx;
  211. font-weight: 500;
  212. color: #FFFFFF;
  213. }
  214. .warn_text {
  215. font-size: 24rpx;
  216. font-weight: 500;
  217. color: #777777;
  218. margin-top: 42rpx;
  219. text-align: start;
  220. line-height: 33rpx;
  221. }
  222. }
  223. }
  224. /* ::v-deep .u-tabs__wrapper__nav{
  225. justify-content: center !important;
  226. } */
  227. ::v-deep .u-tabs__wrapper__nav__item[data-v-0de61367] {
  228. width: 375rpx;
  229. }
  230. ::v-deep uni-input[data-v-1b9e2be9] {
  231. width: 100% !important;
  232. height: 100% !important;
  233. }
  234. </style>