report.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // pages/report/report.js
  2. const request = require("../../utils/request.js");
  3. const login = require("../../utils/login.js");
  4. const uploadImage = require('../../utils/uploadFile.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. uploadURL: request._debug ? 'test/toktok/report/report_image/' : 'toktok/report/report_image/',
  11. TypeList: [
  12. {name: '违法违规', value:'Illegal'},
  13. {name: '色情低俗', value:'Porn'},
  14. {name: '虚假不实', value:'Fake'},
  15. {name: '谩骂攻击', value:'Obloquy'},
  16. {name: '其他', value:'Other'}
  17. ],
  18. imgList: [],
  19. parmas: {
  20. targetType: '',
  21. reason: '',
  22. targetId: '',
  23. reportType: '',
  24. imgUrls: ''
  25. }
  26. },
  27. submitFun() {
  28. let that = this;
  29. that.data.parmas.imgUrls = that.data.imgList.join(';'),
  30. request.postData(
  31. 'app/op/report',
  32. that.data.parmas,
  33. res => {
  34. wx.showToast({
  35. title: '举报成功',
  36. icon: 'none',
  37. duration: 2000
  38. })
  39. setTimeout(function () {
  40. wx.navigateBack({
  41. delta: 1
  42. })
  43. }, 3000)
  44. }
  45. )
  46. },
  47. delFun(event) {
  48. let index = event.currentTarget.dataset.idx;
  49. this.data.imgList.splice(index,1)
  50. this.setData({
  51. imgList: this.data.imgList
  52. })
  53. },
  54. uploadImg() {
  55. let that = this;
  56. let count = Number(3 - that.data.imgList.length);
  57. wx.chooseMedia({
  58. count: count,
  59. mediaType: ['image'],
  60. sourceType: ['album', 'camera'],
  61. success(res) {
  62. console.log(res)
  63. const tempFiles = res.tempFiles;
  64. tempFiles.forEach(function(value, index) {
  65. uploadImage(value.tempFilePath, that.data.uploadURL,
  66. function(res) {
  67. that.data.imgList.push(res)
  68. that.setData({
  69. imgList: that.data.imgList
  70. })
  71. },
  72. function(res) {
  73. console.log(res)
  74. })
  75. })
  76. }
  77. })
  78. },
  79. getbindinput(event) {
  80. this.data.parmas.reason = event.detail.value;
  81. this.setData({
  82. parmas: this.data.parmas
  83. })
  84. },
  85. checkTypeFun(event) {
  86. this.data.parmas.reportType = event.currentTarget.dataset.value;
  87. this.setData({
  88. parmas: this.data.parmas
  89. })
  90. },
  91. /**
  92. * 生命周期函数--监听页面加载
  93. */
  94. onLoad(options) {
  95. login.getAssumeRole()
  96. this.data.parmas.targetType = options.targetType;
  97. this.data.parmas.targetId = options.targetId;
  98. this.setData({
  99. parmas: this.data.parmas
  100. })
  101. },
  102. /**
  103. * 生命周期函数--监听页面初次渲染完成
  104. */
  105. onReady() {
  106. },
  107. /**
  108. * 生命周期函数--监听页面显示
  109. */
  110. onShow() {
  111. },
  112. /**
  113. * 生命周期函数--监听页面隐藏
  114. */
  115. onHide() {
  116. },
  117. /**
  118. * 生命周期函数--监听页面卸载
  119. */
  120. onUnload() {
  121. },
  122. /**
  123. * 页面相关事件处理函数--监听用户下拉动作
  124. */
  125. onPullDownRefresh() {
  126. },
  127. /**
  128. * 页面上拉触底事件的处理函数
  129. */
  130. onReachBottom() {
  131. },
  132. /**
  133. * 用户点击右上角分享
  134. */
  135. onShareAppMessage() {
  136. }
  137. })