123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- // pages/circlesDetail/circlesDetail.js
- const app = getApp();
- const request = require("../../utils/request.js");
- const login = require("../../utils/login.js");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- bannerIndex: 0,
- contentId: null,
- info: {},
- scale: 1,
- commentList: [],
- focusStatus: false,
- iptValue: '',
- iptPla: '喜欢就给个评论呗~',
- reply_params: {
- contentId: null,
- comment: '',
- parentCommentId: null,
- atUserId: null
- },
- handleStatus: true,
- commentId: null,
- scene: null,
- deleteStatus: true
- },
- previewMedia(event) {
- let sources = this.data.info.imgUrlList.map((item, index)=>{
- return {url: item}
- });
- let current = event.currentTarget.dataset.index;
- wx.previewMedia({
- sources: sources,
- current: current
- })
- },
- toReport() {
- wx.navigateTo({
- url: '../report/report?targetType=Comment&targetId=' + this.data.commentId
- })
- },
- deleteComFun() {
- let that = this;
- request.postData(
- 'app/cont/comment/del',
- {commentId: that.data.commentId},
- res => {
- that.getDetailData()
- that.getCommentList()
- that.setData({
- commentId: null,
- handleStatus: true
- })
- wx.showToast({
- title: '删除成功',
- icon: 'none',
- duration: 2000
- })
- }
- )
- },
- pressReplyComment(event) {
- let userId = event.currentTarget.dataset.userid;
- let userId2 = app.globalData.userInfo.userId ? app.globalData.userInfo.userId : null;
- this.data.commentId = event.currentTarget.dataset.commentid ? event.currentTarget.dataset.commentid : null;
- if(userId == userId2) {
- this.setData({
- deleteStatus: false,
- commentId: this.data.commentId,
- handleStatus: !this.data.handleStatus
- })
- }else{
- this.setData({
- deleteStatus: true,
- commentId: this.data.commentId,
- handleStatus: !this.data.handleStatus
- })
- }
-
- },
- tapReplyComment(event) {
- let that = this;
- that.data.reply_params.contentId = that.data.contentId;
- that.data.reply_params.parentCommentId = event.currentTarget.dataset.commentid;
- that.data.reply_params.atUserId = event.currentTarget.dataset.userid;
- this.setData({
- focusStatus: true,
- reply_params: that.data.reply_params,
- iptPla: '@' + event.currentTarget.dataset.name
- })
- },
- sendComment(event) {
- let that = this;
- if(that.data.reply_params.atUserId){
- that.data.reply_params.comment = event.detail.value;
- request.postData(
- 'app/cont/comment/reply',
- that.data.reply_params,
- res => {
- that.data.reply_params.atUserId = null;
- that.data.info.commentCount++;
- that.setData({
- iptValue: '',
- reply_params: that.data.reply_params,
- info: that.data.info
- })
- that.getCommentList();
- },
- res => {
- that.data.reply_params.atUserId = null;
- that.setData({
- iptValue: '',
- reply_params: that.data.reply_params
- })
- }
- )
- }else{
- let comment = event.detail.value;
- request.postData(
- 'app/cont/comment',
- {contentId: that.data.contentId, comment: comment},
- res => {
- that.data.info.commentCount++;
- that.getCommentList();
- that.setData({
- info: that.data.info,
- iptValue: ''
- })
- },
- res => {
- console.log(res)
- }
- )
- }
- },
- iptBlurFun() {
- this.setData({
- iptPla: '喜欢就给个评论呗~'
- })
- },
- iptFun() {
- this.setData({
- focusStatus: !this.data.focusStatus
- })
- },
- commentlikeFun(event) {
- let that = this;
- let commentId = event.currentTarget.dataset.commentid;
- request.postData(
- 'app/op/like',
- {recordType: 'CommentList', outBusiId: commentId},
- res => {
- that.getCommentList();
- },
- res => {
- console.log(res)
- }
- )
- },
- commentCellikeFun(event) {
- let that = this;
- let commentId = event.currentTarget.dataset.commentid;
- request.postData(
- 'app/op/like/cancel',
- {recordType: 'CommentList', outBusiId: commentId},
- res => {
- that.getCommentList();
- },
- res => {
- console.log(res)
- }
- )
- },
- contentlikeFun() {
- let that = this;
- request.postData(
- 'app/op/like',
- {recordType: 'ContentLike', outBusiId: that.data.contentId},
- res => {
- that.getDetailData();
- },
- res => {
- console.log(res)
- }
- )
- },
- contentCellikeFun() {
- let that = this;
- request.postData(
- 'app/op/like/cancel',
- {recordType: 'ContentLike', outBusiId: that.data.contentId},
- res => {
- that.getDetailData();
- },
- res => {
- console.log(res)
- }
- )
- },
- getCommentList() {
- let that = this;
- request.getData(
- 'app/cont/comment/list',
- {contentId : that.data.contentId},
- res => {
- that.setData({
- commentList: res.data.data
- })
- },
- res => {
- console.log(res)
- }
- )
- },
- toPersonHome(event) {
- let userId = event.currentTarget.dataset.userid;
- login.ifLogin('../personHome/personHome?userId=' + userId)
- },
- getDetailData() {
- let that = this;
- request.getData(
- 'app/cont/content/detail',
- {contentId : that.data.contentId},
- res => {
- let scale = request.getUrlKey(res.data.data.imgUrlList[0], 'scale');
- that.setData({
- info: res.data.data,
- scale: scale ? scale : 1
- })
- },
- res => {
- console.log(res)
- }
- )
- },
- backPge() {
- if(this.data.scene == 1007 || this.data.scene == 1008) {
- wx.switchTab({
- url: '../index/index'
- })
- }else{
- wx.navigateBack({
- delta: 1
- })
- }
- },
- bindchange(event) {
- this.setData({
- bannerIndex: event.detail.current
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- contentId: options.contentId
- })
- this.getDetailData()
- this.getCommentList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.setData({
- handleStatus: true
- })
- let EnterOptions = wx.getEnterOptionsSync()
- this.setData({
- scene: EnterOptions.scene
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- let that = this;
- if(that.data.commentList.length>0) {
- let lastCommentId = Number(that.data.commentList[that.data.commentList.length-1].commentId);
- request.getData(
- 'app/cont/comment/list',
- {contentId : that.data.contentId, lastCommentId: lastCommentId},
- res => {
- if(res.data.data.length > 0) {
- that.setData({
- commentList: that.data.commentList.concat(res.data.data)
- })
- }
- },
- res => {
- console.log(res)
- }
- )
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- let title = this.data.info.content
- let contentId = this.data.contentId
- let imageUrl = this.data.info.imgUrlList[0]
- return {
- title: title,
- imageUrl: imageUrl,
- path: '/pages/circlesDetail/circlesDetail?contentId=' + contentId
- }
- },
- onShareTimeline() {
- }
- })
|