// pages/transmit/transmit.js const app = getApp() const util = require('../../utils/util.js'); const APIClient = require('../../utils/APIClient.js'); const login = require('../../utils/loginSchedule.js'); Page({ /** * 页面的初始数据 */ data: { productionData: {}, favors: '', like: false, flag: true, loginType: 1 }, //跳转详情页 particulars: function (e) { const postId = e.currentTarget.dataset.postsid; wx.navigateTo({ url: '../../pages/particulars/particulars?postId=' + postId + '&type=2' }) }, /*预览图片*/ listenerButtonPreviewImage: function(e) { let imgUrl = []; imgUrl.push(e.target.dataset.img); wx.previewImage({ current: '', // 当前显示图片的http链接 urls: imgUrl, // 需要预览的图片http链接列表 //这根本就不走 success: function(res) { //console.log(res); }, //也根本不走 fail: function() { //console.log('fail') } }) }, /*点赞接口*/ like: function () { const postsId = util.getUrl().postId; //判断分享过来的参数是否有postId查询单挑显示 if(postsId) { login.getOpenidSessionKey(res => { APIClient.getLikeSchedule({ uid: res.data.data.uid }, { postsId, }).success(res => { console.log(res.data) if(res.data.success) { this.setData({ favors: res.data.data.favors, like: true }) } }) }, function() { wx.showModal({ title: '提示', content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用', showCancel: false, success: function (res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } } }) }); }; }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.type == "noTv") { this.setData({ loginType: "" }) } // wx.showModal({ // title: '提示', // content: 'aaa' + JSON.stringify(options), // showCancel: false, // success: function (res) { // if (res.confirm) { // console.log('用户点击确定') // } else if (res.cancel) { // console.log('用户点击取消') // } // } // }) const postsId = options.postId || ''; const shareKey = util.convertObject(decodeURIComponent(options.scene)).shareKey || ''; console.log('shareKey:' + util.convertObject(decodeURIComponent(options.scene)).shareKey); //判断分享过来的参数是否有postId查询单挑显示 if(postsId || shareKey) { login.getOpenidSessionKey(res => { APIClient.getOneSchedule({ uid: res.data.data.uid }, { postsId, shareKey }).success(res => { console.log(res.data) if(res.data.success) { this.setData({ productionData: res.data.data, favors:res.data.data.postsAttributeInfo.favors }) } }) }, () => { this.setData({ flag: !this.data.flag }) }, this.data.loginType); }; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /*获取个人信息弹框*/ jurisdiction: function () { this.setData({ flag: !this.data.flag }) this.onLoad(); } })