feedback.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. array: ['请选择反馈类型', '商品相关', '物流状况', '客户服务', '优惠活动', '功能异常', '产品建议', '其他'],
  7. index: 0,
  8. content:'',
  9. contentLength:0,
  10. mobile:''
  11. },
  12. bindPickerChange: function (e) {
  13. this.setData({
  14. index: e.detail.value
  15. });
  16. },
  17. mobileInput: function (e) {
  18. let that = this;
  19. this.setData({
  20. mobile: e.detail.value,
  21. });
  22. },
  23. contentInput: function (e) {
  24. let that = this;
  25. this.setData({
  26. contentLength: e.detail.cursor,
  27. content: e.detail.value,
  28. });
  29. },
  30. cleanMobile:function(){
  31. let that = this;
  32. },
  33. sbmitFeedback : function(e){
  34. let that = this;
  35. if (that.data.index == 0){
  36. util.showErrorToast('请选择反馈类型');
  37. return false;
  38. }
  39. if (that.data.content == '') {
  40. util.showErrorToast('请输入反馈内容');
  41. return false;
  42. }
  43. if (that.data.mobile == '') {
  44. util.showErrorToast('请输入手机号码');
  45. return false;
  46. }
  47. if (!that.data.mobile.match(/^1[3-9][0-9]\d{8}$/)) {
  48. wx.showModal({
  49. title: '温馨提示',
  50. content: '手机号格式不正确,仅支持国内手机号码'
  51. });
  52. return false
  53. }
  54. wx.showLoading({
  55. title: '提交中...',
  56. mask:true,
  57. success: function () {
  58. }
  59. });
  60. util.request(api.FeedbackAdd,
  61. { phoneNum: that.data.mobile, type: that.data.index, typeDesc: that.data.array[that.data.index], content: that.data.content},
  62. 'POST',
  63. 'application/json'
  64. ).then(function (res) {
  65. if (res.code === 0) {
  66. wx.hideLoading();
  67. wx.showToast({
  68. title: '反馈成功',
  69. icon: 'success',
  70. duration: 2000,
  71. complete: function () {
  72. that.setData({
  73. index: 0,
  74. content: '',
  75. contentLength: 0,
  76. mobile: ''
  77. });
  78. }
  79. });
  80. } else {
  81. util.showErrorToast(res.data);
  82. }
  83. });
  84. },
  85. onLoad: function (options) {
  86. getApp().checkNetStatu();
  87. },
  88. onReady: function () {
  89. },
  90. onShow: function () {
  91. },
  92. onHide: function () {
  93. // 页面隐藏
  94. },
  95. onUnload: function () {
  96. // 页面关闭
  97. }
  98. })