commentdoctordetail.js 6.4 KB
// pages/home/buildtextdetail/buildtextdetail.js
const app=getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        //图文编辑大图片和小图片
        edit_img: [
            // 'http://pi4orwnti.bkt.clouddn.com/editbig@2x.png',
            // 'http://pi4orwnti.bkt.clouddn.com/editbig@2x.png',
            // 'http://pi4orwnti.bkt.clouddn.com/editbig@2x.png',
        ],
        commentdoctorid:'',
        commentdoctordetail:'',
        newcommentdoctorid:''

    },

    /**
     * 生命周期函数--监听页面加载
     */


    onLoad: function (options) {
        var commentdoctorid=wx.getStorageSync('commentdoctorid');
        if(JSON.stringify(options)!='{}'){
            this.setData({
                newcommentdoctorid :options.doctorid
            })
        }else{
            this.setData({
                commentdoctorid :commentdoctorid
            })
        }


        this.getinfo()

    },

    getinfo(){
        let that=this;
        var url='/api/portal/hospital/getDoctorCommentDetail';
        if(that.data.newcommentdoctorid!=''){
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.newcommentdoctorid
            }
        }else{
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.commentdoctorid
            }
        }

        app.post(url, params).then((res) => {
            console.log(res)

            that.setData({
                commentdoctordetail:res,
                edit_img:res.content_imgs
            })

            if(that.data.commentdoctordetail.touch_num<=0){
                that.data.commentdoctordetail.touch_num=0
            }
        }).catch((err) => {

        })


    },
    //收藏
    collect:function(e){
        let that=this;

        let detailcollect=that.data.commentdoctordetail.ifCollect;
        let detailtext=that.data.commentdoctordetail
        if(detailcollect==false){
            that.data.commentdoctordetail.ifCollect=true
        }else if(detailcollect==true){
            that.data.commentdoctordetail.ifCollect=false

        }
        that.setData({
            commentdoctordetail:detailtext
        })

        //调取收藏的接口
        var url = '/api/portal/hospital/doDoctorCommentCollect';
        if(that.data.newcommentdoctorid!=''){
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.newcommentdoctorid
            }
        }else{
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.commentdoctorid
            }
        }
        app.post(url, params).then((res) => {
            // getCurrentPages()[getCurrentPages().length - 1].onLoad()

        }).catch((err) => {

        })

    },


    //点赞
    touchstar:function(e){

        let that=this;

        let detailtouch=that.data.commentdoctordetail.ifTouch;
        let detailtext=that.data.commentdoctordetail


        if(detailtouch==false){
            that.data.commentdoctordetail.ifTouch=true;
            that.data.commentdoctordetail.touch_num= that.data.commentdoctordetail.touch_num+1

        }else if(detailtouch==true){
            that.data.commentdoctordetail.ifTouch=false;
            that.data.commentdoctordetail.touch_num = that.data.commentdoctordetail.touch_num-1;
            // console.log(that.data.commentdoctordetail.touch_num)
            // if(that.data.commentdoctordetail.touch_num<=0){
            //     console.log(111)
            //     that.data.commentdoctordetail.touch_num=0
            // }
        }
        that.setData({
            commentdoctordetail:detailtext
        })

        //调取收藏的接口
        var url = '/api/portal/hospital/doDoctorCommentTouch';
        if(that.data.newcommentdoctorid!=''){
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.newcommentdoctorid
            }
        }else{
            var params = {
                token: wx.getStorageSync('token'),
                doctor_comment_id:that.data.commentdoctorid
            }
        }
        app.post(url, params).then((res) => {
            // getCurrentPages()[getCurrentPages().length - 1].onLoad()

        }).catch((err) => {

        })

    },

    //分享
    // buildshare(){
    //     wx.navigateTo({
    //         url: '../meshare/meshare',
    //     })
    // },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        let that=this;
        let doctorid=that.data.commentdoctorid;


        return {
            title: '评论医生详情分享', // 转发后 所显示的title
            // path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
            path:'/pages/index/index?doctorid='+doctorid+'&status='+3,//评论医生分享1
            // path:'',
            success: (res)=>{    // 成功后要做的事情
                console.log(res)
                // console.log(res.shareTickets[0])
                // console.log

                // wx.getShareInfo({
                //     shareTicket: res.shareTickets[0],
                //     success: (res)=> {
                //         that.setData({
                //             isShow:true
                //         })
                //         console.log(that.setData.isShow)
                //     },
                //     fail: function (res) { console.log(res) },
                //     complete: function (res) { console.log(res) }
                // })
            },
            fail: function (res) {
                // 分享失败
                console.log(res)
            }
        }
    }
})