123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- // pages/guanlian/guanlian.js.
- var app = getApp();
- Page({
- data: {
- erweima: '',
- value: '',
- index: 0
- },
- onLoad: function (options) {
- },
- onShow: function () {
- wx.hideHomeButton()
- },
- tap: function (e) {
- this.setData({
- index: e.currentTarget.dataset.index,
- erweima: '',
- value: ''
- })
- },
- input2: function (e) {
- this.setData({
- value: e.detail.value
- })
- },
- input1: function (e) {
- this.setData({
- erweima: e.detail.value
- })
- },
- relieve: function () {
- //解除绑定
- var that = this;
- if (that.data.value == '') {
- wx.showModal({
- title: '提示',
- content: '请完善中控设备号',
- showCancel: false
- })
- } else {
- wx.showLoading({
- title: '解绑中...',
- })
- let data = {
- box_no: that.data.value
- }
- app.request('control/unbindingBike', data, 'POST').then(res => {
- wx.hideLoading();
- if (res.statusCode == 200) {
- wx.showToast({
- title: '解除成功',
- icon: 'none'
- })
- that.setData({
- value: ''
- })
- }
- })
- }
- },
- qued: function () {
- //点击立即绑定
- var that = this;
- if (that.data.erweima == '' || that.data.value == '') {
- wx.showModal({
- title: '提示',
- content: '请完善设备码或车辆编号',
- showCancel: false
- })
- } else {
- wx.showLoading({
- title: '绑定中...',
- })
- let data = {
- bike_no: that.data.erweima,
- box_no: that.data.value
- }
- app.request('control/addBike', data, 'POST').then(res => {
- wx.hideLoading();
- if (res.statusCode == 200) {
- wx.showToast({
- title: '绑定成功',
- icon: 'none'
- })
- that.setData({
- erweima: '',
- value: ''
- })
- }
- })
- }
- },
- tiaoxing: function () {
- //点击扫描条形码
- var that = this;
- wx.scanCode({
- success: function (res) {
- console.log(typeof (res.result))
- if (typeof (res.result) == 'string') {
- console.log(res.result)
- if (res.result.length == 9) {
- that.setData({
- value: res.result
- })
- } else {
- wx.showToast({
- title: '扫错了~',
- icon: 'none'
- })
- }
- }
- },
- fail: function () {
- wx.showToast({
- title: '扫码失败',
- icon: 'none'
- })
- }
- })
- },
- erwei: function () {
- //点击扫描二维码
- var that = this;
- wx.scanCode({
- success: function (res) {
- console.log(res)
- var code = decodeURIComponent(res.result);
- var code1 = code.lastIndexOf("\=");
- var source = code.substring(code1 + 1, code.length);
- that.setData({
- erweima: source
- })
- },
- fail: function () {
- wx.showToast({
- title: '扫码失败',
- icon: 'none'
- })
- }
- })
- },
- // scanCode:function(){
- // wx.scanCode({
- // success: function (res) {
- // console.log(res)
- // var code = decodeURIComponent(res.result);
- // var code1 = code.lastIndexOf("\=");
- // var source = code.substring(code1 + 1, code.length);
- // wx.request({
- // url: 'https://admin.weilaibike.com/app-api/open/bikeInfoByBikeNo?bike_no=' + source+'&token='+wx.getStorageSync('token'),
- // method: 'GET',
- // header: {
- // 'content-type': 'application/x-www-form-urlencoded'
- // },
- // success: function (res) {
- // console.log(res)
- // if (res.statusCode == 200) {
- // wx.navigateTo({
- // url: '../index/index?bike_id=' + res.data.bike_no + '&bike_no=' + res.data.box_no,
- // })
- // } else if (res.statusCode == 401) {
- // wx.clearStorageSync('token');
- // wx.redirectTo({
- // url: '../login/index',
- // })
- // }else {
- // wx.showToast({
- // title: res.data.message,
- // icon: 'none',
- // duration: 3000
- // })
- // }
- // }
- // })
- // },
- // fail: function () {
- // wx.showToast({
- // title: '扫码失败',
- // icon: 'none'
- // })
- // }
- // })
- // }
- })
|