feedback.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // feedback.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. urlHttp : '',
  9. textareaCont : '',
  10. telphone : '',
  11. hiddenmodal: true, //弹窗
  12. modalCont: ''
  13. },
  14. onLoad: function (options) {
  15. var that = this;
  16. var host = getApp().globalData.servsers;
  17. that.setData({
  18. urlHttp: host
  19. });
  20. },
  21. textareaInput:function(e){//反馈内容赋值
  22. var that = this;
  23. that.setData({
  24. textareaCont: e.detail.value
  25. })
  26. },
  27. telphoneInput:function(e){//手机号赋值
  28. var that = this;
  29. that.setData({
  30. telphone: e.detail.value
  31. })
  32. },
  33. feedback:function(e){
  34. var host = getApp().globalData.servsers;
  35. var un_id = getApp().globalData.un_id;
  36. var openid = getApp().globalData.openid;
  37. var that = this;
  38. if (that.data.textareaCont == ''){
  39. that.setData({
  40. hiddenmodal: false,
  41. modalCont : '反馈内容不得为空'
  42. })
  43. setTimeout(function () {
  44. that.setData({
  45. hiddenmodal: true
  46. })
  47. }, 1000)
  48. return false;
  49. }
  50. var nickName = getApp().globalData.userInfo.nickName;
  51. var avatarUrl = getApp().globalData.userInfo.avatarUrl;
  52. if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)){
  53. wx.navigateTo({
  54. url: '/pages/authorize/authorize?link=feedback',
  55. })
  56. }else{
  57. wx.request({
  58. url: host + "feedbackapi/insertadd",
  59. data: {
  60. user_id: un_id,
  61. textareaCont: that.data.textareaCont,//反馈内容
  62. telphone: that.data.telphone,//手机号码(选填)
  63. nickName: nickName,//用户昵称(选填)
  64. avatarUrl: avatarUrl//头像(选填)
  65. },
  66. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  67. header: {
  68. 'Accept': 'application/json'
  69. },
  70. success: function (res) {
  71. that.setData({
  72. hiddenmodal: false,
  73. modalCont: '提交成功'
  74. })
  75. setTimeout(function () {
  76. that.setData({
  77. hiddenmodal: true
  78. })
  79. wx.navigateBack({})
  80. }, 1000)
  81. if (res == null || res.data == null) {
  82. console.error('网络请求失败');
  83. return;
  84. }
  85. }
  86. })
  87. }
  88. },
  89. })
  90. var Util = require('../../utils/util.js');