control.vue 7.2 KB

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