correction.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // pages/home/correction/correction.js
  2. const app = getApp()
  3. const url = require('../../../utils/url.js')
  4. var call = require("../../../utils/net.js")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. error1:true,
  11. error2:false,
  12. min:'1',
  13. max:'200',
  14. isSubmit:false,
  15. id: null,//内容详情的ID
  16. pos:'标题',//纠错的问题类型
  17. content:''//反馈内容
  18. },
  19. submit:function(){
  20. var that = this;
  21. let id = this.data.id;
  22. let uid = wx.getStorageSync('userId');
  23. let pos = this.data.pos;
  24. let content = this.data.content;
  25. var postData ={
  26. uid: uid,
  27. id: id,
  28. pos: pos,
  29. content: content
  30. }
  31. if (that.data.error1 == false && that.data.error2 == false){
  32. wx.showToast({
  33. icon: 'none',
  34. title: '请至少选择一个问题类型!',
  35. })
  36. } else if (content.match(/^\s*$/) || content == null || content == ''){
  37. wx.showToast({
  38. icon: 'none',
  39. title: '请输入反馈内容!',
  40. })
  41. }
  42. else{
  43. //请求
  44. call.request(url.host + url.postError,
  45. postData,
  46. res => {
  47. console.log(res)
  48. if (res.data.code == 200) {
  49. wx.showToast({
  50. title: '提交成功',
  51. icon: 'success',
  52. duration: 2000
  53. })
  54. setTimeout(function () {
  55. wx.navigateBack({
  56. delta: 1
  57. })
  58. }, 2000)
  59. } else {
  60. wx.showToast({
  61. icon: 'none',
  62. title: res.data.msg,
  63. })
  64. }
  65. },
  66. res => {
  67. console.log(res)
  68. })
  69. }
  70. },
  71. //选择出错项目
  72. clickTitle:function(){
  73. if (this.data.error1 == false) {
  74. this.setData({
  75. pos : '标题',
  76. error1: true,
  77. error2: false
  78. })
  79. }
  80. },
  81. clickMsg: function () {
  82. if (this.data.error2 == false) {
  83. this.setData({
  84. pos: '描述',
  85. error1: false,
  86. error2: true
  87. })
  88. }
  89. },
  90. //获取用户填写的出错内容
  91. getContent:function(e){
  92. let that = this
  93. if (e.detail.value){
  94. that.setData({
  95. content:e.detail.value
  96. })
  97. }
  98. },
  99. //字数限制
  100. inputs: function (e) {
  101. var value = e.detail.value;// 获取输入框的内容
  102. var len = parseInt(value.length);// 获取输入框内容的长度
  103. //最少字数限制
  104. if (len < this.data.min)
  105. this.setData({
  106. isSubmit: false
  107. })
  108. else if (len >= this.data.min)
  109. this.setData({
  110. isSubmit: true
  111. })
  112. if (len > this.data.max) return;//最多字数限制
  113. // 当输入框内容的长度大于最大长度限制(max)时,终止setData()的执行
  114. this.setData({
  115. currentWordNumber: len //当前字数
  116. });
  117. },
  118. /**
  119. * 生命周期函数--监听页面加载
  120. */
  121. onLoad: function (options) {
  122. var that = this
  123. that.setData({
  124. id:options.id
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面初次渲染完成
  129. */
  130. onReady: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面显示
  134. */
  135. onShow: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面隐藏
  139. */
  140. onHide: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面卸载
  144. */
  145. onUnload: function () {
  146. },
  147. /**
  148. * 页面相关事件处理函数--监听用户下拉动作
  149. */
  150. onPullDownRefresh: function () {
  151. },
  152. /**
  153. * 页面上拉触底事件的处理函数
  154. */
  155. onReachBottom: function () {
  156. },
  157. /**
  158. * 用户点击右上角分享
  159. */
  160. onShareAppMessage: function () {
  161. }
  162. })