myInteractions.js 6.1 KB

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