C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

133 行
2.4 KiB

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