C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.3 KiB

  1. // pages/complaint/complaint.js
  2. const Http = require("../../utils/HttpBasics");
  3. var config = require("../../config/config.js");
  4. var app = getApp();
  5. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. navigationBarHeight,
  12. titleVale: "", //标题
  13. descrideVal: "", //描述
  14. },
  15. setDescrideVal(e) { //赋值标题
  16. let descrideVal = e.detail.value
  17. this.setData({
  18. descrideVal: descrideVal
  19. })
  20. },
  21. setTitVal(e) { //赋值描述
  22. let titleVale = e.detail.value
  23. this.setData({
  24. titleVale: titleVale
  25. })
  26. },
  27. save() { //提交
  28. if (!this.data.titleVale){
  29. wx.showToast({
  30. title: '请输入标题',
  31. icon: "none",
  32. duration: 2000
  33. })
  34. return
  35. }else if(!this.data.descrideVal){
  36. wx.showToast({
  37. title: '请输入类容',
  38. icon:"none",
  39. duration:2000
  40. })
  41. return
  42. }
  43. let parameter = {
  44. title: this.data.titleVale,
  45. explains: this.data.descrideVal
  46. }
  47. Http.post({
  48. url: config.api.suggest,
  49. data: parameter
  50. }).then(item=>{
  51. wx.showToast({
  52. title: "提交成功!",
  53. icon: 'none',
  54. duration: 2000,
  55. success: () => {
  56. setTimeout(() => {
  57. wx.switchTab({
  58. url: '/index/index'
  59. })
  60. }, 2000)
  61. }
  62. });
  63. }).catch(err => {
  64. wx.showToast({
  65. title: err.errMsg,
  66. icon: 'none',
  67. duration: 2000,
  68. // mask: false
  69. });
  70. })
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad: function(options) {
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. */
  80. onReady: function() {
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow: function() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面隐藏
  89. */
  90. onHide: function() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. onUnload: function() {
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function() {
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function() {
  106. },
  107. /**
  108. * 用户点击右上角分享
  109. */
  110. onShareAppMessage: function() {
  111. }
  112. })