carDetails.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var app = getApp()
  2. Page({
  3. data: {
  4. carList: [
  5. //详情列表
  6. {
  7. id: 1,
  8. img_url: "http://resource.bike.hanyiyun.com/bike_yunwei/position.png",
  9. text: "车辆位置"
  10. },
  11. {
  12. id: 2,
  13. img_url: "http://resource.bike.hanyiyun.com/bike_yunwei/scan.png",
  14. text: "扫码位置"
  15. },
  16. {
  17. id: 3,
  18. img_url: "http://resource.bike.hanyiyun.com/bike_yunwei/order.png",
  19. text: "最近订单"
  20. },
  21. {
  22. id: 4,
  23. img_url: "http://resource.bike.hanyiyun.com/bike_yunwei/lock.png",
  24. text: "开关锁记录"
  25. },
  26. {
  27. id: 4,
  28. img_url: "http://resource.bike.hanyiyun.com/bike_yunwei/line.png",
  29. text: "上下线记录"
  30. }
  31. ],
  32. id: '',
  33. bike_no: '',
  34. detail: [],
  35. isDisabled: false, //备注是否修改
  36. textVal: '', //输入框内容
  37. },
  38. //点击跳转
  39. skip(e) {
  40. let that = this;
  41. let idx = parseInt(e.currentTarget.dataset.idx);
  42. let url = ''
  43. switch (idx) {
  44. case 0:
  45. url = '/pages/carPosition/carPosition';
  46. break;
  47. case 1:
  48. url = '/pages/scanRecord/scanRecord';
  49. break;
  50. case 2:
  51. url = '/pages/recentOrder/recentOrder';
  52. break;
  53. case 3:
  54. url = '/pages/lockRecord/lockRecord';
  55. break;
  56. case 4:
  57. url = '/pages/lineRecord/lineRecord';
  58. break;
  59. default:
  60. ;
  61. }
  62. console.log(that.data.bike_no)
  63. console.log(that.data.id)
  64. wx.navigateTo({
  65. url: url + '?bike_no=' + that.data.bike_no + '&&id=' + that.data.id,
  66. })
  67. },
  68. onLoad: function (options) {
  69. wx.showLoading({
  70. title: '加载中...',
  71. })
  72. let that = this;
  73. that.setData({
  74. bike_no: options.bike_no,
  75. id: options.id
  76. })
  77. app.request('bike/getBikeInfo?bike_no=' + options.bike_no, '', 'GET').then(res => {
  78. wx.hideLoading();
  79. that.setData({
  80. detail: res.data.bike_info
  81. })
  82. if (res.data.bike_info.remark) {
  83. that.setData({
  84. isDisabled: true
  85. })
  86. }
  87. })
  88. },
  89. getText(e) {
  90. this.setData({
  91. textVal: e.detail.value
  92. })
  93. },
  94. operate() {
  95. wx.showLoading({
  96. title: '加载中...',
  97. })
  98. let that = this;
  99. let dis = that.data.isDisabled;
  100. if (dis) {
  101. that.setData({
  102. isDisabled: false
  103. })
  104. } else {
  105. let data = {
  106. remark: this.data.textVal
  107. }
  108. app.request('bike/updateRemark/' + this.data.id, data, 'PUT').then(res => {
  109. wx.hideLoading();
  110. console.log(res);
  111. wx.showToast({
  112. title: '提交成功~',
  113. icon: 'none'
  114. })
  115. that.setData({
  116. isDisabled: true
  117. })
  118. })
  119. }
  120. },
  121. })