// 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'); wx.request({ url: app.globalData.publicUrl3 + '/education/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res.data.rows, "我是查到的列表") _this.setData({ listArr: res.data.rows }) } }) }, 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 + '/education/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { console.log(res, "我是查到的列表") } }) } }) } }) } }) }, 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 + '/education/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 + '/education/board/add', method: "post", data: { content: input_val, sessionKey: sessionKey }, success: function (res) { console.log("提交成功啦") } }) } }) } }) } }) // console.log(e.detail.value.textarea) }, // 提交我的问题 // submit() { // var _this = this; // console.log(_this.data.mytip) // wx.checkSession({ // success: () => { // console.log("我有缓存") // var sessionKey = wx.getStorageSync('sessionKey'); // wx.request({ // url: app.globalData.publicUrl3 + '/education/board/add', // method: "post", // data: { // content: _this.data.mytip // }, // success: function (res) { // console.log(res) // } // }) // }, // 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 // } // }) // } // }) // } // }) // }, onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })