msgReceipt.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. // const update = require('../../../api/update.js');
  6. Page({
  7. data: {
  8. max:5,
  9. uploadShow:true,
  10. isFinish:false,
  11. content:'',
  12. feedbackInfo:{
  13. noticeType:'',
  14. sendTime:'',
  15. },
  16. fileList: [],
  17. pictures:[],
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. console.log(options);
  24. if(options.id){
  25. this.setData({id:options.id});
  26. this.getDetail();
  27. }
  28. },
  29. getDetail(){
  30. util.request(api.getDetail, {id:this.data.id
  31. }, 'GET').then(res=> {
  32. if (res.errno === 0) {
  33. this.setData({
  34. isFinish:res.data.feedbackComment==''?false:true,
  35. feedbackInfo:res.data,
  36. content:res.data.feedbackComment
  37. });
  38. if(this.data.isFinish){
  39. let imgs=res.data.feedbackImgs;
  40. if(imgs==''){
  41. this.setData({
  42. uploadShow:false,
  43. });
  44. }else{
  45. let list=imgs.split(',');
  46. let current=[];
  47. list.forEach(item=>{
  48. let obj={
  49. url:item
  50. };
  51. current.push(obj);
  52. });
  53. this.setData({
  54. fileList:current,
  55. max:current.length,
  56. });
  57. }
  58. }
  59. }
  60. });
  61. },
  62. bindContent(e){
  63. this.setData({
  64. content:e.detail.value
  65. })
  66. },
  67. deleteImage (event) {
  68. const { fileList = [] } = this.data;
  69. fileList.splice(event.detail.index, 1)
  70. this.setData({
  71. fileList: fileList
  72. })
  73. let urls=[];
  74. fileList.forEach(function(e){
  75. urls.push(e.url);
  76. })
  77. this.setData({
  78. "pictures": urls
  79. })
  80. },
  81. afterRead(event) {
  82. console.log(event);
  83. const { file } = event.detail
  84. let that = this;
  85. const uploadTask = wx.uploadFile({
  86. url: api.StorageUpload(),
  87. filePath: file.url,
  88. name: 'file',
  89. success: function (res) {
  90. console.log(res);
  91. var _res = JSON.parse(res.data);
  92. if (_res.errno === 0) {
  93. var url = _res.data.fileUrl;
  94. that.data.pictures.push(url)
  95. const { fileList = [] } = that.data;
  96. fileList.push({ ...file, url: url });
  97. that.setData({
  98. fileList: fileList
  99. })
  100. }
  101. },
  102. fail: function (e) {
  103. wx.showModal({
  104. title: '错误',
  105. content: '上传失败',
  106. showCancel: false
  107. })
  108. },
  109. })
  110. },
  111. submit(){
  112. if(this.data.content==''){
  113. wx.showToast({
  114. title: '请填写您的反馈',
  115. icon:'none'
  116. })
  117. }else{
  118. let imgs=[];
  119. this.data.fileList.forEach(item=>{
  120. imgs.push(item.url)
  121. });
  122. util.request(api.commitFeedback, {
  123. id:this.data.id,
  124. comment:this.data.content,
  125. imgs:imgs.join(',')
  126. }, 'GET').then(res=> {
  127. if (res.errno === 0) {
  128. wx.showToast({
  129. title: '提交成功',
  130. icon:'none'
  131. });
  132. this.getDetail();
  133. }
  134. });
  135. }
  136. },
  137. onReachBottom() {
  138. // if (this.data.totalPages > this.data.page) {
  139. // this.setData({
  140. // page: this.data.page + 1
  141. // });
  142. // this.getGoodsList();
  143. // } else {
  144. // wx.showToast({
  145. // title: '没有更多商品了',
  146. // icon: 'none',
  147. // duration: 2000
  148. // });
  149. // return false;
  150. // }
  151. },
  152. /**
  153. * 生命周期函数--监听页面初次渲染完成
  154. */
  155. onReady: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面显示
  159. */
  160. onShow: function () {
  161. },
  162. onHide: function () {
  163. },
  164. onUnload: function () {
  165. },
  166. /**
  167. * 页面相关事件处理函数--监听用户下拉动作
  168. */
  169. onPullDownRefresh: function () {
  170. },
  171. /**
  172. * 页面上拉触底事件的处理函数
  173. */
  174. onReachBottom: function () {
  175. },
  176. /**
  177. * 用户点击右上角分享
  178. */
  179. onShareAppMessage: function () {
  180. },
  181. })