control2.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="box">
  3. <view class="tab">
  4. <view @click="tap(0)" :class="index==0?'active':''">
  5. <text>立即绑定测试</text>
  6. </view>
  7. <view @click="tap(1)" :class="index==1?'active':''">
  8. <text>解除绑定</text>
  9. </view>
  10. </view>
  11. <block v-if="index==0">
  12. <view class='ma'>
  13. <view class="view">
  14. <input placeholder="请输入车辆编码" placeholder-style="color:#B6B6B6;" @input='input1' :value='erweima'></input>
  15. <view class="btn" @click="erwei"><text>扫描</text></view>
  16. </view>
  17. <view class="view">
  18. <input @input='input2' :value='value' placeholder="中控设备号" placeholder-style="color:#B6B6B6;"></input>
  19. <view class="btn" @click="tiaoxing"><text>扫描</text></view>
  20. </view>
  21. </view>
  22. <view class='btm' @click="qued">
  23. <text>立即绑定</text>
  24. </view>
  25. </block>
  26. <!-- 解除绑定 -->
  27. <block v-if="index==1">
  28. <view class='ma'>
  29. <view class="view">
  30. <input :value='value' @input='input2' placeholder="中控设备号" placeholder-style="color:#B6B6B6;"></input>
  31. <view class="btn" @click="tiaoxing(3)"><text>扫描</text></view>
  32. </view>
  33. </view>
  34. <view class='btm' @click='relieve'>
  35. <text>解除绑定 </text>
  36. </view>
  37. </block>
  38. <!-- <view class="scanCode" bindtap="scanCode">
  39. <text>扫一扫</text>
  40. </view> -->
  41. <!-- <view class="logo">
  42. <image src="http://resource.weilaibike.com/yunwei/logo.png" style="width:70rpx;height:70rpx;border-radius:50%;"></image>
  43. <text style="padding-top:16rpx;">闪现出行方便大学生出行</text>
  44. </view> -->
  45. <!-- 扫码页面 -->
  46. </view>
  47. </template>
  48. <script>
  49. var myDate = new Date();
  50. var hour = myDate.getHours(); //当前时间
  51. export default {
  52. data() {
  53. return {
  54. isShow: false,
  55. erweima: '',
  56. value: '',
  57. index: 0,
  58. barcode: null,
  59. flash: false,
  60. data: '',
  61. tip: '将二维码放入框中,即可自动扫描',
  62. }
  63. },
  64. onShow() {
  65. // var orderList=JSON.parse(data)
  66. // console.log(data)
  67. let pages = getCurrentPages();
  68. let currPage = pages[pages.length - 1]; // 当前页的实例
  69. let shuju = currPage.$vm.data
  70. var list = JSON.parse(shuju)
  71. // this.value=shuju
  72. console.log(typeof(list), "shuju")
  73. if (list.id == 1) {
  74. if (list.shuju.length !== 11) {
  75. uni.showToast({
  76. title: '扫错了~',
  77. icon: 'none'
  78. })
  79. this.erweima = ""
  80. // this.value=""
  81. } else {
  82. this.erweima = list.shuju
  83. }
  84. } else if (list.id == 2) {
  85. if (list.shuju.length !== 15) {
  86. uni.showToast({
  87. title: '扫错了~',
  88. icon: 'none'
  89. })
  90. this.value = ""
  91. } else {
  92. this.value = list.shuju
  93. }
  94. }
  95. },
  96. onLoad(options) {
  97. console.log(options)
  98. },
  99. mounted() {
  100. },
  101. methods: {
  102. input1: function(e) {
  103. this.erweima = e.detail.value
  104. console.log(e.detail.value, '这是input中的数据')
  105. },
  106. input2: function(e) {
  107. this.value = e.detail.value
  108. console.log(e.detail.value, '这是input中的数据')
  109. },
  110. //车辆二维码
  111. erwei: function() {
  112. let id = 1
  113. uni.navigateTo({
  114. url: './test?id=' + id
  115. })
  116. },
  117. //中控二维码
  118. tiaoxing: function(e) {
  119. let id = 2
  120. uni.navigateTo({
  121. url: './test?id=' + id
  122. })
  123. },
  124. //立即绑定
  125. qued: function() {
  126. var that = this;
  127. if (this.erweima == '' || this.value == '') {
  128. uni.showModal({
  129. title: '提示',
  130. content: '请完善设备码或车辆编号',
  131. showCancel: false
  132. })
  133. } else {
  134. uni.showLoading({
  135. title: '绑定中...',
  136. })
  137. let data = {
  138. bike_no: that.erweima,
  139. box_no: that.value
  140. }
  141. console.log()
  142. app.request('control/addBike', data, 'POST').then(res => {
  143. uni.hideLoading();
  144. if (res.statusCode == 200) {
  145. uni.showToast({
  146. title: '绑定成功',
  147. icon: 'none'
  148. })
  149. }
  150. })
  151. }
  152. },
  153. //解除绑定
  154. relieve: function() {
  155. //解除绑定
  156. var that = this;
  157. if (this.value == '') {
  158. uni.showModal({
  159. title: '提示',
  160. content: '请完善中控设备号',
  161. showCancel: false
  162. })
  163. } else {
  164. uni.showLoading({
  165. title: '解绑中...',
  166. })
  167. let data = {
  168. box_no: that.value
  169. }
  170. app.request('control/unbindingBike', data, 'POST').then(res => {
  171. uni.hideLoading();
  172. if (res.statusCode == 200) {
  173. uni.showToast({
  174. title: '解除成功',
  175. icon: 'none'
  176. })
  177. }
  178. })
  179. }
  180. },
  181. tap: function(e) { //绑定解绑标签切换
  182. this.index = e
  183. console.log(e, '这是绑定id')
  184. }
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. .box {
  190. width: 100%;
  191. height: 100%;
  192. display: flex;
  193. /* background-color: #cfe4ff; */
  194. flex-direction: column;
  195. align-items: center;
  196. }
  197. .tab {
  198. width: 85%;
  199. display: flex;
  200. justify-content: space-between;
  201. height: 75rpx;
  202. margin-top: 20rpx;
  203. border-radius: 30rpx;
  204. overflow: hidden;
  205. }
  206. .tab view {
  207. width: 49.9%;
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. background: #ccc;
  212. color: white;
  213. font-size: 28rpx;
  214. }
  215. .box .tab .active {
  216. background: #18D5B9;
  217. color: #FFFFFF !important;
  218. }
  219. .box .ma {
  220. width: 90%;
  221. display: flex;
  222. flex-direction: column;
  223. margin: 0 auto;
  224. padding-top: 80rpx;
  225. }
  226. .box .ma .view {
  227. width: 690rpx;
  228. height: 90rpx;
  229. background: rgba(255, 255, 255, 1);
  230. box-shadow: 0px 0px 4rpx 0px rgba(222, 222, 222, 1);
  231. border-radius: 10rpx;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-around;
  235. margin-top: 35rpx;
  236. }
  237. .box .ma .view .btn {
  238. width: 90rpx;
  239. height: 47rpx;
  240. background: rgba(229, 229, 229, 1);
  241. border-radius: 10rpx;
  242. font-size: 24rpx;
  243. font-family: PingFang SC;
  244. color: rgba(136, 136, 136, 1);
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. }
  249. .box .ma input {
  250. width: 70%;
  251. border-bottom: 1rpx solid gray;
  252. height: 60rpx;
  253. line-height: 60rpx;
  254. font-size: 26rpx;
  255. }
  256. .btm {
  257. /* position: absolute;
  258. z-index: 3000;
  259. bottom: 0; */
  260. width: 420rpx;
  261. height: 88rpx;
  262. background: rgba(24, 213, 185, 1);
  263. box-shadow: 0px 8rpx 13rpx 0px rgba(100, 239, 218, 1);
  264. border-radius: 44rpx;
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. font-size: 30rpx;
  269. color: white;
  270. margin-top: 200rpx;
  271. }
  272. .logo {
  273. width: 100%;
  274. display: flex;
  275. flex-direction: column;
  276. align-items: center;
  277. position: fixed;
  278. font-size: 22rpx;
  279. bottom: 30rpx;
  280. color: #999;
  281. }
  282. .scanCode {
  283. width: 420rpx;
  284. height: 88rpx;
  285. background: linear-gradient(163deg, rgba(255, 139, 102, 1) 0%, rgba(254, 87, 34, 1) 100%);
  286. border-radius: 44rpx;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. font-size: 30rpx;
  291. color: white;
  292. margin-top: 150rpx;
  293. }
  294. .wrap {
  295. height: calc(100vh);
  296. /* #ifdef H5 */
  297. height: calc(100vh - var(--window-top));
  298. /* #endif */
  299. display: flex;
  300. flex-direction: column;
  301. justify-content: center;
  302. align-items: center;
  303. }
  304. </style>