myInteractions.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. // pages/myInteractions/myInteractions.js
  2. const app = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. isshow1: false,
  9. isshow2: true,
  10. activebg: "#ffeae9",
  11. unactivebg: "#f2f2f2",
  12. mytip: "",
  13. listArr: []
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. tab1Show() {
  19. this.setData({
  20. isshow1: false,
  21. isshow2: true,
  22. activebg: "#ffeae9",
  23. unactivebg: "#f2f2f2"
  24. })
  25. },
  26. tab2Show() {
  27. var _this = this;
  28. _this.setData({
  29. isshow1: true,
  30. isshow2: false,
  31. activebg: "#f2f2f2",
  32. unactivebg: "#ffeae9"
  33. })
  34. wx.checkSession({
  35. success: () => {
  36. console.log("我有缓存")
  37. var sessionKey = wx.getStorageSync('sessionKey');
  38. if (sessionKey == "") {
  39. wx.login({
  40. success(res) {
  41. console.log(res);
  42. var code = res.code
  43. wx.request({
  44. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  45. method: "get",
  46. data: {
  47. code
  48. },
  49. success: function (res) {
  50. sessionKey = res.data.sessionKey;
  51. wx.setStorageSync('sessionKey', res.data.sessionKey);
  52. wx.request({
  53. url: app.globalData.publicUrl3 + '/wx/board/list',
  54. method: "post",
  55. data: {
  56. sessionKey: sessionKey
  57. },
  58. success: function (res) {
  59. console.log(res.data.list, "我是查到的列表")
  60. _this.setData({
  61. listArr: res.data.list
  62. })
  63. }
  64. })
  65. }
  66. })
  67. }
  68. })
  69. } else {
  70. wx.request({
  71. url: app.globalData.publicUrl3 + '/wx/board/list',
  72. method: "post",
  73. data: {
  74. sessionKey: sessionKey
  75. },
  76. success: function (res) {
  77. console.log(res.data.list, "我是查到的列表")
  78. _this.setData({
  79. listArr: res.data.list
  80. })
  81. }
  82. })
  83. }
  84. },
  85. fail() {
  86. console.log("我没有缓存并去登录请求")
  87. wx.login({
  88. success(res) {
  89. console.log(res);
  90. var code = res.code
  91. wx.request({
  92. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  93. method: "get",
  94. data: {
  95. code
  96. },
  97. success: function (res) {
  98. wx.setStorageSync('sessionKey', res.data.sessionKey);
  99. var sessionKey = res.data.sessionKey;
  100. wx.request({
  101. url: app.globalData.publicUrl3 + '/wx/board/list',
  102. method: "post",
  103. data: {
  104. sessionKey: sessionKey
  105. },
  106. success: function (res) {
  107. console.log(res.data.list, "我是查到的列表")
  108. _this.setData({
  109. listArr: res.data.list
  110. })
  111. }
  112. })
  113. }
  114. })
  115. }
  116. })
  117. }
  118. })
  119. },
  120. gojjDetails(e) {
  121. console.log(e.currentTarget.dataset.item, "我是带过来的值")
  122. let id = e.currentTarget.dataset.item.id
  123. if (e.currentTarget.dataset.item.replyContent == "" || e.currentTarget.dataset.item.replyContent == null) {
  124. wx.showModal({
  125. showCancel: false,
  126. content: "您还没收到回复哦",
  127. success(res) {}
  128. })
  129. } else {
  130. wx.navigateTo({
  131. url: '/pages/myInteractionsDetais/myInteractionsDetais?id=' + id,
  132. })
  133. }
  134. },
  135. bindFormSubmit: function (e) {
  136. // var _this = this;
  137. wx.checkSession({
  138. success: () => {
  139. console.log("我有缓存")
  140. var sessionKey = wx.getStorageSync('sessionKey');
  141. var input_val = e.detail.value.textarea;
  142. console.log(input_val)
  143. if (input_val == "" || input_val == undefined) {
  144. wx.showToast({
  145. title: '反馈不能为空',
  146. icon: 'none',
  147. duration: 1000
  148. })
  149. return false;
  150. } else {
  151. wx.request({
  152. url: app.globalData.publicUrl3 + '/wx/board/add',
  153. method: "post",
  154. data: {
  155. content: input_val,
  156. sessionKey: sessionKey
  157. },
  158. success: function (res) {
  159. if (res.data.code == 0) {
  160. wx.showModal({
  161. showCancel: false,
  162. content: "提交成功",
  163. success(res) {
  164. if (res.confirm) {
  165. wx.switchTab({
  166. url: '../personInfo/personInfo'
  167. })
  168. }
  169. }
  170. })
  171. } else {
  172. wx.showModal({
  173. showCancel: false,
  174. content: res.data.msg,
  175. success(res) {}
  176. })
  177. }
  178. }
  179. })
  180. }
  181. },
  182. fail() {
  183. console.log("我没有缓存并去登录请求")
  184. wx.login({
  185. success(res) {
  186. console.log(res);
  187. var code = res.code
  188. wx.request({
  189. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  190. method: "get",
  191. data: {
  192. code
  193. },
  194. success: function (res) {
  195. wx.setStorageSync('sessionKey', res.data.sessionKey);
  196. var sessionKey = res.data.sessionKey;
  197. wx.request({
  198. url: app.globalData.publicUrl3 + '/wx/board/add',
  199. method: "post",
  200. data: {
  201. content: input_val,
  202. sessionKey: sessionKey
  203. },
  204. success: function (res) {
  205. console.log("提交成功啦")
  206. }
  207. })
  208. }
  209. })
  210. }
  211. })
  212. }
  213. })
  214. // console.log(e.detail.value.textarea)
  215. },
  216. onLoad: function (options) {
  217. },
  218. /**
  219. * 生命周期函数--监听页面初次渲染完成
  220. */
  221. onReady: function () {
  222. },
  223. /**
  224. * 生命周期函数--监听页面显示
  225. */
  226. onShow: function () {
  227. },
  228. /**
  229. * 生命周期函数--监听页面隐藏
  230. */
  231. onHide: function () {
  232. },
  233. /**
  234. * 生命周期函数--监听页面卸载
  235. */
  236. onUnload: function () {
  237. },
  238. /**
  239. * 页面相关事件处理函数--监听用户下拉动作
  240. */
  241. onPullDownRefresh: function () {
  242. },
  243. /**
  244. * 页面上拉触底事件的处理函数
  245. */
  246. onReachBottom: function () {
  247. },
  248. /**
  249. * 用户点击右上角分享
  250. */
  251. onShareAppMessage: function () {
  252. }
  253. })