userDetail.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var app = getApp()
  2. Page({
  3. data: {
  4. user: [],
  5. userId: '', //用户id
  6. isDisabled: false, //备注是否修改
  7. textVal: '', //输入框内容
  8. // firstBind: 0
  9. },
  10. onLoad: function (options) {
  11. wx.showLoading({
  12. title: '加载中...',
  13. })
  14. let that = this;
  15. that.setData({
  16. userId: options.id
  17. })
  18. app.request('user/detail?user_id=' + options.id, '', 'GET').then(res => {
  19. wx.hideLoading();
  20. console.log(res.data)
  21. that.setData({
  22. user: res.data
  23. })
  24. if (res.data.remark) {
  25. that.setData({
  26. isDisabled: true
  27. })
  28. }
  29. })
  30. },
  31. tap: function () {
  32. wx.navigateTo({
  33. url: '/pages/historicalOrder/historicalOrder?id=' + this.data.userId,
  34. })
  35. },
  36. operate() {
  37. wx.showLoading({
  38. title: '加载中...',
  39. })
  40. let that = this;
  41. let dis = that.data.isDisabled;
  42. if (dis) {
  43. that.setData({
  44. isDisabled: false
  45. })
  46. } else {
  47. let data = {
  48. remark: this.data.textVal
  49. }
  50. app.request('user/updateRemark/' + this.data.userId, data, 'PUT').then(res => {
  51. wx.hideLoading();
  52. wx.showToast({
  53. title: '提交成功~',
  54. icon: 'none'
  55. })
  56. that.setData({
  57. isDisabled: true
  58. })
  59. })
  60. }
  61. },
  62. getText(e) {
  63. this.setData({
  64. textVal: e.detail.value
  65. })
  66. },
  67. finish() {
  68. if (!this.data.textVal) {
  69. wx.showToast({
  70. title: '输入内容不能为空',
  71. icon: 'none'
  72. })
  73. } else {
  74. let data = {
  75. remark: this.data.textVal
  76. }
  77. app.request('user/updateRemark/' + this.data.userId, data, 'PUT').then(res => {
  78. console.log(res);
  79. })
  80. }
  81. },
  82. // doubleClick(e) {
  83. // console.log(e);
  84. // console.log(e.timeStamp)
  85. // let that = this;
  86. // if (this.data.firstBind == 0) {
  87. // this.setData({
  88. // firstBind: e.timeStamp
  89. // })
  90. // }
  91. // let curTime = e.timeStamp;
  92. // let lastTime = that.data.firstBind
  93. // console.log(curTime,'curTime')
  94. // console.log(lastTime,'lastTime')
  95. // if (curTime - lastTime < 300) {
  96. // console.log(11111)
  97. // this.setData({
  98. // isDisabled: false
  99. // })
  100. // }
  101. // }
  102. })