add_equ.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <view class="box">
  3. <!-- v-model="active" -->
  4. <!-- #ifdef MP -->
  5. <van-tabs>
  6. <van-tab title="扫码">
  7. <view class="scan">
  8. <view class="scan_box">
  9. <image src="/static/img/scan.png" mode=""></image>
  10. </view>
  11. <view class="scan_btn" @click="scanQRCode">扫码</view>
  12. <view class="warn_text">
  13. <view class="text">
  14. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  15. 业务
  16. </view>
  17. </view>
  18. </view>
  19. </van-tab>
  20. <van-tab title="输入">
  21. <view class="input">
  22. <view class="text_box">
  23. <input type="text" placeholder="请输入设备ID号" v-model="text">
  24. </view>
  25. <view class="scan_btn" @click="next">
  26. <!-- <view class=""> -->
  27. 下一步
  28. <!-- </view> -->
  29. </view>
  30. <view class="warn_text">
  31. <view class="text">
  32. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  33. 业务
  34. </view>
  35. </view>
  36. </view>
  37. </van-tab>
  38. </van-tabs>
  39. <!-- #endif -->
  40. <!-- #ifdef APP-PLUS -->
  41. <!-- <view class="" style="margin-top: var(--status-bar-height);">
  42. <uni-nav-bar title="添加设备" left-icon="left" backgroundColor="#F35546" color="#fff" @clickLeft="back"></uni-nav-bar>
  43. </view> -->
  44. <!-- #endif -->
  45. <!-- #ifdef APP-PLUS -->
  46. <view class="" style="margin-top: var(--status-bar-height);">
  47. <uni-nav-bar title="添加设备" left-icon="left" backgroundColor="#F35546" color="#fff"
  48. @clickLeft="back"></uni-nav-bar>
  49. </view>
  50. <view class="tab_contant">
  51. <view class="tab">
  52. <view :class="active1" @click="chenked(1)">
  53. <view class="tab_itemtitle">扫码</view>
  54. <view class="tab_itembot" v-if="isActive==1">
  55. <!-- <view class="scan">
  56. <view class="scan_box">
  57. <image src="/static/img/scan.png" mode=""></image>
  58. </view>
  59. <view class="scan_btn" @click="scanQRCode">扫码</view>
  60. <view class="warn_text">
  61. <view class="text">
  62. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  63. 业务
  64. </view>
  65. </view>
  66. </view> -->
  67. </view>
  68. </view>
  69. <view :class="active2" @click="chenked(2)">
  70. <view class="tab_itemtitle">输入</view>
  71. <view class="tab_itembot" v-if="isActive==2">
  72. <!-- <view class="input">
  73. <view class="text_box">
  74. <input type="text" placeholder="请输入设备ID号" v-model="text">
  75. </view>
  76. <view class="scan_btn" @click="next">
  77. 下一步
  78. </view>
  79. <view class="warn_text">
  80. <view class="text">
  81. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  82. 业务
  83. </view>
  84. </view>
  85. </view> -->
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="scan" v-if="isActive==1">
  91. <view class="scan_box">
  92. <image src="/static/img/scan.png" mode=""></image>
  93. </view>
  94. <view class="scan_btn" @click="scanQRCode">扫码</view>
  95. <view class="warn_text">
  96. <view class="text">
  97. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  98. 业务
  99. </view>
  100. </view>
  101. </view>
  102. <view class="input" v-if="isActive==2">
  103. <view class="text_box">
  104. <input type="text" placeholder="请输入设备ID号" v-model="text">
  105. </view>
  106. <view class="scan_btn" @click="next">
  107. 下一步
  108. </view>
  109. <view class="warn_text">
  110. <view class="text">
  111. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  112. 业务
  113. </view>
  114. </view>
  115. </view>
  116. <!-- #endif -->
  117. <!-- <u-tabs :list="list" :current="current" @click="click" lineColor="#F35546" lineWidth="88" lineHeight="4"
  118. bg-color="#fff"></u-tabs>
  119. <view class="scan" v-if="current === 0">
  120. <view class="scan_box">
  121. <image src="/static/image/scan.png" mode=""></image>
  122. </view>
  123. <view class="scan_btn" @click="scanQRCode">扫码</view>
  124. <view class="warn_text">
  125. <view class="text">
  126. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  127. 业务
  128. </view>
  129. </view>
  130. </view>
  131. <view class="input" v-if="current === 1">
  132. <view class="text_box">
  133. <input type="text" placeholder="请输入设备ID号" v-model="text">
  134. </view>
  135. <view class="scan_btn" @click="next">
  136. 下一步
  137. </view>
  138. <view class="warn_text">
  139. <view class="text">
  140. 请确保设备插卡并且处于开机状态,SIM卡有效并且开通GPRS
  141. 业务
  142. </view>
  143. </view>
  144. </view> -->
  145. </view>
  146. </template>
  147. <script>
  148. export default {
  149. data() {
  150. return {
  151. list: [{
  152. name: '扫码'
  153. }, {
  154. name: '输入'
  155. }],
  156. current: 0,
  157. text: '',
  158. isActive: 1
  159. }
  160. },
  161. onShow: function() {},
  162. computed: {
  163. active1() {
  164. return this.isActive == 1 ? 'active' : 'active1'
  165. },
  166. active2() {
  167. return this.isActive == 2 ? 'active' : 'active1'
  168. },
  169. active3() {
  170. return this.isActive == 3 ? 'active' : 'active1'
  171. }
  172. },
  173. methods: {
  174. chenked(type) {
  175. this.isActive = type
  176. },
  177. back() {
  178. uni.navigateBack()
  179. },
  180. rightClick() {
  181. console.log('rightClick');
  182. },
  183. leftClick() {
  184. console.log('leftClick');
  185. },
  186. click(item) {
  187. this.current = item.index;
  188. },
  189. next() {
  190. console.log(this.text, 777);
  191. if (this.text) {
  192. uni.navigateTo({
  193. url: `/pages/equ_list/bind?deviceCode=${this.text}`
  194. })
  195. } else {
  196. this.$util.Tips({
  197. title: '请输入设备ID号'
  198. });
  199. }
  200. },
  201. scanQRCode() {
  202. uni.scanCode({
  203. success: (res) => {
  204. console.log(res); // 打印扫码结果
  205. // 在这里可以对扫码结果进行处理
  206. uni.navigateTo({
  207. url: `/pages/equ_list/bind?deviceCode=${res.result}`
  208. })
  209. },
  210. fail: (res) => {
  211. console.log(res);
  212. // 处理扫码失败的情况
  213. this.$util.Tips({
  214. title: '扫码失败',
  215. icon: 'error'
  216. })
  217. }
  218. });
  219. }
  220. // uni.scanCode({
  221. // success: res => {
  222. // let code = null
  223. // this.modelCode = null
  224. // if (res.result && res.result.indexOf('SN') == -1) {
  225. // code = +res.result
  226. // } else if (res.result && res.result.indexOf('"SN"') != -1) {
  227. // res.result = JSON.parse(res.result)
  228. // code = +res.result.SN
  229. // } else {
  230. // return uni.showToast({
  231. // icon: 'none',
  232. // title: '非法的TBOX编号',
  233. // })
  234. // }
  235. // const codeType = typeof code === 'number' && !isNaN(code)
  236. // if (!codeType) {
  237. // return uni.showToast({
  238. // icon: 'none',
  239. // title: '非法的TBOX编号',
  240. // })
  241. // }
  242. // // 数据重置
  243. // this.resetData()
  244. // this.tboxCode = code
  245. // this.scanning && this.getTBoxInfo(code)
  246. // },
  247. // fail: function() {
  248. // this.scanning = true
  249. // uni.hideLoading()
  250. // },
  251. // })
  252. }
  253. }
  254. </script>
  255. <style lang="scss">
  256. .tab_contant {
  257. // position: absolute;
  258. width: 750rpx;
  259. // height: 634px;
  260. // left: 0px;
  261. // top: 0rpx;
  262. background: #FFFFFF;
  263. border-radius: 28rpx 28rpx 0px 0px;
  264. display: flex;
  265. flex-direction: column;
  266. align-items: center;
  267. .tab {
  268. width: 480rpx;
  269. height: 100rpx;
  270. display: flex;
  271. flex-direction: row;
  272. justify-content: space-between;
  273. margin-top: 26px;
  274. // 选中的样式
  275. .active {
  276. width: 64px;
  277. height: 50px;
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. .tab_itemtitle {
  282. font-family: 'PingFang SC';
  283. font-style: normal;
  284. font-weight: 400;
  285. font-size: 16px;
  286. line-height: 155%;
  287. /* identical to box height, or 25px */
  288. text-align: center;
  289. color: #000000;
  290. }
  291. .tab_itembot {
  292. width: 36px;
  293. height: 0px;
  294. /* 五分钟蓝 */
  295. margin-top: 5px;
  296. border: 2px solid #F35546;
  297. border-radius: 50px;
  298. }
  299. }
  300. // 未选中的样式
  301. .active1 {
  302. width: 64px;
  303. height: 50px;
  304. display: flex;
  305. flex-direction: column;
  306. align-items: center;
  307. .tab_itemtitle {
  308. font-family: 'PingFang SC';
  309. font-style: normal;
  310. font-weight: 400;
  311. font-size: 12px;
  312. line-height: 155%;
  313. /* identical to box height, or 19px */
  314. text-align: center;
  315. color: #000000;
  316. opacity: 0.6;
  317. }
  318. .tab_itembot {
  319. width: 15.02px;
  320. height: 0px;
  321. margin-top: 10px;
  322. border: 2px solid #B9B9B9;
  323. border-radius: 50px;
  324. .scan {
  325. padding: 55rpx 32rpx 477rpx;
  326. text-align: center;
  327. background-color: #F7F7F7;
  328. .scan_box {
  329. image {
  330. width: 386rpx;
  331. height: 533rpx;
  332. }
  333. }
  334. .scan_btn {
  335. height: 98rpx;
  336. line-height: 98rpx;
  337. background: #F35546;
  338. border-radius: 9rpx;
  339. margin-top: 79rpx;
  340. font-size: 32rpx;
  341. font-weight: 500;
  342. color: #FFFFFF;
  343. }
  344. .warn_text {
  345. font-size: 24rpx;
  346. font-weight: 500;
  347. color: #777777;
  348. margin-top: 42rpx;
  349. text-align: start;
  350. line-height: 33rpx;
  351. }
  352. }
  353. .input {
  354. padding: 55rpx 32rpx 477rpx;
  355. // text-align: center;
  356. height: 100%;
  357. background-color: #F7F7F7;
  358. .text_box {
  359. background-color: #fff;
  360. height: 98rpx;
  361. line-height: 98rpx;
  362. padding: 0 32rpx;
  363. input {
  364. width: 100%;
  365. height: 100%;
  366. // width: 386rpx;
  367. // height: 533rpx;
  368. }
  369. }
  370. .scan_btn {
  371. height: 98rpx;
  372. line-height: 98rpx;
  373. text-align: center;
  374. background: #F35546;
  375. border-radius: 9rpx;
  376. margin-top: 131rpx;
  377. font-size: 32rpx;
  378. font-weight: 500;
  379. color: #FFFFFF;
  380. }
  381. .warn_text {
  382. font-size: 24rpx;
  383. font-weight: 500;
  384. color: #777777;
  385. margin-top: 42rpx;
  386. text-align: start;
  387. line-height: 33rpx;
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .box {
  395. width: 750rpx;
  396. height: 100vh;
  397. background-color: #fff;
  398. .scan {
  399. padding: 55rpx 32rpx 477rpx;
  400. text-align: center;
  401. background-color: #F7F7F7;
  402. .scan_box {
  403. image {
  404. width: 386rpx;
  405. height: 533rpx;
  406. }
  407. }
  408. .scan_btn {
  409. height: 98rpx;
  410. line-height: 98rpx;
  411. background: #F35546;
  412. border-radius: 9rpx;
  413. margin-top: 79rpx;
  414. font-size: 32rpx;
  415. font-weight: 500;
  416. color: #FFFFFF;
  417. }
  418. .warn_text {
  419. font-size: 24rpx;
  420. font-weight: 500;
  421. color: #777777;
  422. margin-top: 42rpx;
  423. text-align: start;
  424. line-height: 33rpx;
  425. }
  426. }
  427. .input {
  428. padding: 55rpx 32rpx 477rpx;
  429. // text-align: center;
  430. height: 100%;
  431. background-color: #F7F7F7;
  432. .text_box {
  433. background-color: #fff;
  434. height: 98rpx;
  435. line-height: 98rpx;
  436. padding: 0 32rpx;
  437. input {
  438. width: 100%;
  439. height: 100%;
  440. // width: 386rpx;
  441. // height: 533rpx;
  442. }
  443. }
  444. .scan_btn {
  445. height: 98rpx;
  446. line-height: 98rpx;
  447. text-align: center;
  448. background: #F35546;
  449. border-radius: 9rpx;
  450. margin-top: 131rpx;
  451. font-size: 32rpx;
  452. font-weight: 500;
  453. color: #FFFFFF;
  454. }
  455. .warn_text {
  456. font-size: 24rpx;
  457. font-weight: 500;
  458. color: #777777;
  459. margin-top: 42rpx;
  460. text-align: start;
  461. line-height: 33rpx;
  462. }
  463. }
  464. }
  465. /* ::v-deep .u-tabs__wrapper__nav{
  466. justify-content: center !important;
  467. } */
  468. ::v-deep .u-tabs__wrapper__nav__item[data-v-0de61367] {
  469. width: 375rpx;
  470. }
  471. ::v-deep uni-input[data-v-1b9e2be9] {
  472. width: 100% !important;
  473. height: 100% !important;
  474. }
  475. </style>