// pages/myInteractions/myInteractions.js const app = require('../../utils/util.js'); Page({ /** * 页面的初始数据 */ data: { isshow1: false, isshow2: true, activebg: "#ffeae9", unactivebg: "#fff", mytip: "", listArr: [] }, /** * 生命周期函数--监听页面加载 */ tab1Show() { this.setData({ isshow1: false, isshow2: true, activebg: "#ffeae9", unactivebg: "#fff" }) }, tab2Show() { var _this = this; _this.setData({ isshow1: true, isshow2: false, activebg: "#fff", unactivebg: "#ffeae9" }) wx.checkSession({ success: () => { console.log("我有缓存") var sessionKey = wx.getStorageSync('sessionKey'); if (sessionKey == "") { wx.login({ success(res) { console.log(res); var code = res.code wx.request({ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login', method: "get", data: { code }, success: function (res) { sessionKey = res.data.sessionKey; wx.setStorageSync('sessionKey', res.data.sessionKey); wx.request({ url: app.globalData.publicUrl3 + '/wx/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data.list, "我是查到的列表") _this.setData({ listArr: res.data.list }) } }) } }) } }) } else { wx.request({ url: app.globalData.publicUrl3 + '/wx/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data.list, "我是查到的列表") _this.setData({ listArr: res.data.list }) } }) } }, fail() { console.log("我没有缓存并去登录请求") wx.login({ success(res) { console.log(res); var code = res.code wx.request({ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login', method: "get", data: { code }, success: function (res) { wx.setStorageSync('sessionKey', res.data.sessionKey); var sessionKey = res.data.sessionKey; wx.request({ url: app.globalData.publicUrl3 + '/wx/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data.list, "我是查到的列表") _this.setData({ listArr: res.data.list }) } }) } }) } }) } }) }, gojjDetails(e) { console.log(e.currentTarget.dataset.item.id, "我是带过来的值") var id = e.currentTarget.dataset.item.id wx.navigateTo({ url: '/pages/myInteractionsDetais/myInteractionsDetais?id=' + id, }) }, bindFormSubmit: function (e) { // var _this = this; wx.checkSession({ success: () => { console.log("我有缓存") var sessionKey = wx.getStorageSync('sessionKey'); var input_val = e.detail.value.textarea; console.log(input_val) if (input_val == "" || input_val == undefined) { wx.showToast({ title: '反馈不能为空', icon: 'none', duration: 1000 }) return false; } else { wx.request({ url: app.globalData.publicUrl3 + '/wx/board/add', method: "post", data: { content: input_val, sessionKey: sessionKey }, success: function (res) { console.log("提交成功啦") } }) } }, fail() { console.log("我没有缓存并去登录请求") wx.login({ success(res) { console.log(res); var code = res.code wx.request({ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login', method: "get", data: { code }, success: function (res) { wx.setStorageSync('sessionKey', res.data.sessionKey); var sessionKey = res.data.sessionKey; wx.request({ url: app.globalData.publicUrl3 + '/wx/board/add', method: "post", data: { content: input_val, sessionKey: sessionKey }, success: function (res) { console.log("提交成功啦") } }) } }) } }) } }) // console.log(e.detail.value.textarea) }, onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })