index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. showUploadTip: false,
  7. haveGetRecord: false,
  8. envId: '',
  9. record: ''
  10. },
  11. onLoad(options) {
  12. this.setData({
  13. envId: options.envId
  14. });
  15. wx.showLoading({
  16. title: '',
  17. });
  18. wx.cloud.callFunction({
  19. name: 'quickstartFunctions',
  20. data: {
  21. type: 'selectRecord'
  22. }
  23. }).then((resp) => {
  24. this.setData({
  25. record: resp.result.data
  26. });
  27. wx.hideLoading();
  28. }).catch((e) => {
  29. console.log(e);
  30. this.setData({
  31. showUploadTip: true
  32. });
  33. wx.hideLoading();
  34. });
  35. },
  36. updateRecord() {
  37. wx.showLoading({
  38. title: '',
  39. });
  40. wx.cloud.callFunction({
  41. name: 'quickstartFunctions',
  42. data: {
  43. type: 'updateRecord',
  44. data: this.data.record
  45. }
  46. }).then((resp) => {
  47. wx.navigateTo({
  48. url: `/pages/updateRecordSuccess/index`,
  49. });
  50. wx.hideLoading();
  51. }).catch((e) => {
  52. console.log(e);
  53. this.setData({
  54. showUploadTip: true
  55. });
  56. wx.hideLoading();
  57. });
  58. },
  59. bindInput (e) {
  60. const index = e.currentTarget.dataset.index;
  61. const record = this.data.record;
  62. record[index].sales = Number(e.detail.value);
  63. this.setData({
  64. record
  65. });
  66. },
  67. });