feedback.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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, { mobile: that.data.mobile, index: that.data.index, content: that.data.content}).then(function (res) {
  61. if (res.errno === 0) {
  62. wx.hideLoading();
  63. wx.showToast({
  64. title: res.data,
  65. icon: 'success',
  66. duration: 2000,
  67. complete: function () {
  68. that.setData({
  69. index: 0,
  70. content: '',
  71. contentLength: 0,
  72. mobile: ''
  73. });
  74. }
  75. });
  76. } else {
  77. util.showErrorToast(res.data);
  78. }
  79. });
  80. },
  81. onLoad: function (options) {
  82. getApp().checkNetStatu();
  83. },
  84. onReady: function () {
  85. },
  86. onShow: function () {
  87. },
  88. onHide: function () {
  89. // 页面隐藏
  90. },
  91. onUnload: function () {
  92. // 页面关闭
  93. }
  94. })