// pages/myInteractions/myInteractions.js const app = require('../../utils/util.js'); Page({ /** * 页面的初始数据 */ data: { isshow1: false, isshow2: true, activebg: "#ffeae9", unactivebg: "#f2f2f2", mytip: "", listArr: [] }, /** * 生命周期函数--监听页面加载 */ tab1Show() { this.setData({ isshow1: false, isshow2: true, activebg: "#ffeae9", unactivebg: "#f2f2f2" }) }, tab2Show() { var _this = this; 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, "我是查到的列表") if (res.data.code == 0) { if (res.data.list.length == 0) { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } else { _this.setData({ listArr: res.data.list, isshow1: true, isshow2: false, activebg: "#f2f2f2", unactivebg: "#ffeae9" }) } } else { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } } }) } }) } }) } else { wx.request({ url: app.globalData.publicUrl3 + '/wx/board/list', method: "post", data: { sessionKey: sessionKey }, success: function (res) { if (res.data.code == 0) { if (res.data.list.length == 0) { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } else { _this.setData({ listArr: res.data.list, isshow1: true, isshow2: false, activebg: "#f2f2f2", unactivebg: "#ffeae9" }) } } else { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } } }) } }, 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,"66666") if (res.data.code == 0) { if (res.data.list.length == 0) { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } else { _this.setData({ listArr: res.data.list, isshow1: true, isshow2: false, activebg: "#f2f2f2", unactivebg: "#ffeae9" }) } } else { wx.showModal({ showCancel: false, content: "您还没有提问哦" }) } } }) } }) } }) } }) }, gojjDetails(e) { console.log(e.currentTarget.dataset.item, "我是带过来的值") let id = e.currentTarget.dataset.item.id if (e.currentTarget.dataset.item.replyContent == "" || e.currentTarget.dataset.item.replyContent == null) { wx.showModal({ showCancel: false, content: "您还没收到回复哦", success(res) {} }) } else { 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) { if (res.data.code == 0) { wx.showModal({ showCancel: false, content: "提交成功", success(res) { if (res.confirm) { wx.switchTab({ url: '../personInfo/personInfo' }) } } }) } else { wx.showModal({ showCancel: false, content: res.data.msg, success(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; 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 () { } })