index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. id: "",
  9. shopOrder: {},
  10. value: 3.5,
  11. fileList: {},
  12. content: null,
  13. },
  14. onChange(event) {
  15. this.setData({
  16. value: event.detail,
  17. });
  18. },
  19. blur(e) {
  20. let name = e.currentTarget.dataset.name
  21. this.setData({
  22. [name]: e.detail.value
  23. })
  24. },
  25. changeFile(e) {
  26. console.log(e);
  27. let fileList = e.detail
  28. this.setData({
  29. fileList
  30. })
  31. },
  32. async getShopOrder() {
  33. let id = this.data.id
  34. console.log(id);
  35. let ShopOrder = new Parse.Query('ShopOrder')
  36. let shopOrder = await ShopOrder.get(id)
  37. this.setData({
  38. shopOrder: shopOrder.attributes
  39. })
  40. console.log(this.data.shopOrder);
  41. },
  42. async submit() {
  43. const _this = this
  44. let images = []
  45. for (let index = 0; index < this.data.fileList.length; index++) {
  46. let item = this.data.fileList[index];
  47. images.push(item.url)
  48. }
  49. console.log(this.data.content, images, this.data.value);
  50. if (!this.data.content || !images) {
  51. wx.showToast({
  52. title: '请填写完整信息',
  53. icon: 'none'
  54. })
  55. return
  56. }
  57. let shopOrder
  58. let query = new Parse.Query("ShopOrder")
  59. shopOrder = await query.get(this.data.id)
  60. shopOrder.set("content", this.data.content)
  61. shopOrder.set("images", images)
  62. shopOrder.set("status", 800)
  63. shopOrder.set("score", this.data.value)
  64. shopOrder.save().then(res => {
  65. console.log(res)
  66. wx.showToast({
  67. title: '修改成功',
  68. icon: 'none'
  69. })
  70. _this.setData({
  71. })
  72. wx.navigateBack({
  73. delta: 1,
  74. });
  75. })
  76. },
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad: function(options) {
  81. let id = options.id
  82. this.setData({
  83. id: id
  84. })
  85. this.getShopOrder()
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady: function() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow: function() {
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function() {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function() {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function() {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function() {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage: function() {
  121. }
  122. })