amendCar.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var app = getApp()
  2. Page({
  3. data: {
  4. bikeNo: '', //车牌号
  5. boxNo: '', //车牌号
  6. bikeID: '', //车牌号
  7. value: ''
  8. },
  9. onLoad: function (options) {
  10. this.setData({
  11. bikeNo: options.bike_no,
  12. bikeID: options.id,
  13. boxNo: options.box_no
  14. })
  15. },
  16. // 扫车牌号
  17. scan1() {
  18. var that = this;
  19. wx.scanCode({
  20. onlyFromCamera: true,
  21. success(res) {
  22. let index = res.result.lastIndexOf("\=");
  23. var code = res.result.substring(index + 1, res.result.length);
  24. that.setData({
  25. bikeNo: code
  26. })
  27. app.request('bike/getBikeInfo?bike_no=' + code, '', 'GET').then(res => {
  28. that.setData({
  29. bikeID: res.data.bike_info.id
  30. })
  31. })
  32. }
  33. })
  34. },
  35. //扫描中控设备号
  36. scan2() {
  37. wx.scanCode({
  38. onlyFromCamera: true,
  39. success(res) {
  40. let index = res.result.lastIndexOf("\=");
  41. var code = res.result.substring(index + 1, res.result.length);
  42. that.setData({
  43. boxNo: code
  44. })
  45. }
  46. })
  47. },
  48. input: function (e) {
  49. this.setData({
  50. value: e.detail.value
  51. })
  52. },
  53. btn: function () {
  54. wx.showLoading({
  55. title: '修改中...',
  56. })
  57. var data = {
  58. bike_id: this.data.bikeID,
  59. bike_remarks: this.data.value,
  60. bike_no: this.data.bikeNo,
  61. box_no: this.data.boxNo,
  62. }
  63. app.request('bike/updateBikeInfo', data, 'POST').then(res => {
  64. wx.hideLoading()
  65. if (res.statusCode == 200) {
  66. wx.showToast({
  67. title: '修改成功',
  68. icon: 'none',
  69. success: function () {
  70. wx.navigateBack()
  71. }
  72. })
  73. }
  74. })
  75. },
  76. })