myInteractions.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. 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.id, "我是带过来的值")
  122. var id = e.currentTarget.dataset.item.id
  123. wx.navigateTo({
  124. url: '/pages/myInteractionsDetais/myInteractionsDetais?id=' + id,
  125. })
  126. },
  127. bindFormSubmit: function (e) {
  128. // var _this = this;
  129. wx.checkSession({
  130. success: () => {
  131. console.log("我有缓存")
  132. var sessionKey = wx.getStorageSync('sessionKey');
  133. var input_val = e.detail.value.textarea;
  134. console.log(input_val)
  135. if (input_val == "" || input_val == undefined) {
  136. wx.showToast({
  137. title: '反馈不能为空',
  138. icon: 'none',
  139. duration: 1000
  140. })
  141. return false;
  142. } else {
  143. wx.request({
  144. url: app.globalData.publicUrl3 + '/wx/board/add',
  145. method: "post",
  146. data: {
  147. content: input_val,
  148. sessionKey: sessionKey
  149. },
  150. success: function (res) {
  151. if (res.cede == 0) {
  152. wx.showModal({
  153. showCancel: false,
  154. content: "提交成功",
  155. success(res) {
  156. if (res.confirm) {
  157. wx.switchTab({
  158. url: '../personInfo/personInfo'
  159. })
  160. }
  161. }
  162. })
  163. }else{
  164. wx.showModal({
  165. showCancel: false,
  166. content: "提交失败",
  167. success(res) {
  168. if (res.confirm) {
  169. console.log("失败了")
  170. // wx.switchTab({
  171. // url: '../index/index'
  172. // })
  173. }
  174. }
  175. })
  176. }
  177. }
  178. })
  179. }
  180. },
  181. fail() {
  182. console.log("我没有缓存并去登录请求")
  183. wx.login({
  184. success(res) {
  185. console.log(res);
  186. var code = res.code
  187. wx.request({
  188. url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  189. method: "get",
  190. data: {
  191. code
  192. },
  193. success: function (res) {
  194. wx.setStorageSync('sessionKey', res.data.sessionKey);
  195. var sessionKey = res.data.sessionKey;
  196. wx.request({
  197. url: app.globalData.publicUrl3 + '/wx/board/add',
  198. method: "post",
  199. data: {
  200. content: input_val,
  201. sessionKey: sessionKey
  202. },
  203. success: function (res) {
  204. console.log("提交成功啦")
  205. }
  206. })
  207. }
  208. })
  209. }
  210. })
  211. }
  212. })
  213. // console.log(e.detail.value.textarea)
  214. },
  215. onLoad: function (options) {
  216. },
  217. /**
  218. * 生命周期函数--监听页面初次渲染完成
  219. */
  220. onReady: function () {
  221. },
  222. /**
  223. * 生命周期函数--监听页面显示
  224. */
  225. onShow: function () {
  226. },
  227. /**
  228. * 生命周期函数--监听页面隐藏
  229. */
  230. onHide: function () {
  231. },
  232. /**
  233. * 生命周期函数--监听页面卸载
  234. */
  235. onUnload: function () {
  236. },
  237. /**
  238. * 页面相关事件处理函数--监听用户下拉动作
  239. */
  240. onPullDownRefresh: function () {
  241. },
  242. /**
  243. * 页面上拉触底事件的处理函数
  244. */
  245. onReachBottom: function () {
  246. },
  247. /**
  248. * 用户点击右上角分享
  249. */
  250. onShareAppMessage: function () {
  251. }
  252. })