myInteractions.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. isshow1: false,
  6. isshow2: true,
  7. activebg: "#ffeae9",
  8. unactivebg: "#f2f2f2",
  9. mytip: "",
  10. listArr: []
  11. },
  12. // tab1
  13. tab1Show() {
  14. this.setData({
  15. isshow1: false,
  16. isshow2: true,
  17. activebg: "#ffeae9",
  18. unactivebg: "#f2f2f2"
  19. })
  20. },
  21. //tab2
  22. async tab2Show() {
  23. const sessionKey = await tools.checkSessionAndLogin();
  24. wx.request({
  25. url: app.globalData.publicUrl + '/wx/board/list',
  26. method: "post",
  27. data: {
  28. sessionKey: sessionKey
  29. },
  30. success: (res) => {
  31. if (res.data.code == 0) {
  32. if (res.data.list.length == 0) {
  33. wx.showModal({
  34. showCancel: false,
  35. content: "您还没有提问哦"
  36. })
  37. } else {
  38. this.setData({
  39. listArr: res.data.list,
  40. isshow1: true,
  41. isshow2: false,
  42. activebg: "#f2f2f2",
  43. unactivebg: "#ffeae9"
  44. })
  45. }
  46. } else {
  47. wx.showModal({
  48. showCancel: false,
  49. content: "您还没有提问哦"
  50. })
  51. }
  52. }
  53. })
  54. },
  55. // 去解答的详情页
  56. gojjDetails(e) {
  57. let id = e.currentTarget.dataset.item.id
  58. if (e.currentTarget.dataset.item.replyContent == "" || e.currentTarget.dataset.item.replyContent == null) {
  59. wx.showModal({
  60. showCancel: false,
  61. content: "您还没收到回复哦"
  62. })
  63. } else {
  64. wx.navigateTo({
  65. url: '/pages/myInteractionsDetais/myInteractionsDetais?id=' + id,
  66. })
  67. }
  68. },
  69. // 禁止input框输入表情
  70. regStrFn(str) {
  71. // 转换一下编码
  72. let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g,
  73. indexArr = reg.exec(str);
  74. if (str.match(reg)) {
  75. str = str.replace(reg, '');
  76. }
  77. let obj = {
  78. val: str,
  79. index: indexArr
  80. }
  81. return obj
  82. },
  83. bindinput(e) {
  84. // let name = 'form.' + e.target.dataset.name
  85. let val = e.detail.value,
  86. pos = e.detail.cursor;
  87. let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g
  88. if (!reg.test(val)) {
  89. return
  90. }
  91. let obj = this.regStrFn(val)
  92. if (pos != -1 && obj.index) {
  93. //计算光标的位置
  94. pos = obj.index.index
  95. }
  96. return {
  97. value: obj.val,
  98. cursor: pos
  99. }
  100. },
  101. // 提交内容
  102. async bindFormSubmit(e) {
  103. wx.showLoading({
  104. mask: true,
  105. title: '加载中',
  106. })
  107. let input_val = e.detail.value.textarea;
  108. const sessionKey = await tools.checkSessionAndLogin();
  109. if (input_val == "" || input_val == undefined) {
  110. wx.hideLoading();
  111. wx.showToast({
  112. title: '反馈不能为空',
  113. icon: 'none',
  114. duration: 1000
  115. })
  116. return false;
  117. }
  118. wx.request({
  119. url: app.globalData.publicUrl + '/wx/board/add',
  120. method: "post",
  121. data: {
  122. content: input_val,
  123. sessionKey: sessionKey
  124. },
  125. success: (res) => {
  126. console.log(res,"00000000000")
  127. if (res.data.code == 0) {
  128. wx.hideLoading()
  129. wx.showModal({
  130. showCancel: false,
  131. content: "提交成功",
  132. success: (res) => {
  133. if (res.confirm) {
  134. this.setData({
  135. mytip: ""
  136. })
  137. }
  138. }
  139. })
  140. } else {
  141. wx.hideLoading()
  142. wx.showModal({
  143. showCancel: false,
  144. content: res.data.msg
  145. })
  146. }
  147. }
  148. })
  149. }
  150. })