add_equ.vue 11 KB

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