123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- // pages/particulars/particulars.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: {},
- text: '',
- discussDatas: [],
- messageLength: '',
- type: '',
- favors: '',
- like: false,
- hike: false
- },
- /* 获取输入内容 */
- bindKeyInput (e) {
- this.setData({
- text: e.detail.value
- })
- },
- /*拉起键盘*/
- discuss() {
- this.setData({
- hike: true
- })
- },
- /* 发送评论 */
- sendText (e) {
- let text = this.data.text.trim();
- let postsId = e.currentTarget.dataset.id;
- let _this = this;
- if(text == ''){
- wx.showModal({
- title: '提示',
- content: '请输入评论内容',
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return false;
- }
- this.data.text = "";
- let data = {
- "postsId": postsId,
- "content": text
- };
- login.getOpenidSessionKey((res) => {
- //console.log(res.data.data.uid);
- APIClient.getDiscussSchedule({
- uid: res.data.data.uid
- }, data).success((res) => {
- if(res.data.success) {
- this.data.discussDatas.push(res.data.data);
- this.setData({
- discussDatas: this.data.discussDatas,
- messageLength: this.data.discussDatas.length
- });
- };
- });
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- this.setData({
- text: ''
- })
- },
- /*预览图片*/
- 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) {
- const type = options.type;
- this.setData({
- type: type
- })
- if(type == 2) {
- wx.setNavigationBarTitle({
- title: '作品展示'
- })
- }
- if(type == 1) {
- wx.setNavigationBarTitle({
- title: '答疑讨论'
- })
- }
- const postsId = options.postId || '';
- //判断分享过来的参数是否有postId查询单挑显示
- if(postsId) {
- login.getOpenidSessionKey(res => {
- APIClient.getOneSchedule({
- uid: res.data.data.uid
- }, {
- postsId,
- }).success(res => {
- console.log(res.data)
- if(res.data.success) {
- this.setData({
- productionData: res.data.data,
- discussDatas: res.data.data.replyList,
- messageLength: res.data.data.replyList.length,
- favors:res.data.data.postsAttributeInfo.favors
- })
- }
- })
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- };
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- })
|