import httpRequestApi from '../../../utils/APIClient';
Page({
    data: {
        fullScreenBtn: false,
        playBtn: false,
        gesture: true,
        user: [{
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            },
            {
                nickName: '萝莉小猫咪',
                image: '../../../static/image/timg.jpg',
            }
        ],
        inputValue: 'smdx',
        text: '总有一天我将实质性操作死去而你我的\xa0\xa0\xa0\xa0\xa0\xa0\xa0儿子自行车在啊实打实大苏打撒旦将加冕为王'
    },
    onLoad: function (option) {
        console.log(option)
        if (option.title) {
            wx.setNavigationBarTitle({
                title: option.title //页面标题为路由参数
            })
            this.setData({
                title: option.title,
                id: option.id
            })
        }
        let uid = 1;
        httpRequestApi.getWorksDetail(uid, option.id).success((res) => {
            console.log(res);
            this.getReply();
        });
    },
    goToReading: function () {
        let id = this.data.id;
        let title = this.data.title;
        wx.navigateTo({
            url: `../../main/reading/reading?id=${id}&title=${title}`
        })
    },
    onShareAppMessage: function (res) {
        if (res.from === 'button') {
            // 来自页面内转发按钮
            console.log(res.target)
        }
        return {
            title: '测试',
            path: '/pages/social/works/works'
        }
    },
    follow: function () {
        let uid = 1;
        let followUid = 2;
        httpRequestApi.followUser(uid, followUid).success((res) => {
            console.log(res)
        });
    },
    // 去其他用户的作品页
    goToOthers: function (e) {
        wx.navigateTo({
            url: `../../main/reading/reading?id=${id}&title=${title}`
        })
    },
    // 查询回复
    getReply: function () {
        let uid = 1;
        let columnId = 1001;
        let pageNo = 1;
        let pageSize = 10;
        httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
            console.log(res);
        });
    },
    // 打开回复详情页
    goToDetail: function (e) {
        let id = e.currentTarget.dataset.id;
        let num = e.currentTarget.dataset.num;
        console.log(e);
        wx.navigateTo({
            url: `../../social/replyDetail/replyDetail?id=${id}&num=${num}`
        })
    },
    //  绑定输入框内容
    inputValue: function (e) {
        this.setData({
            inputValue: e.detail.value
        });
    },
    // 发布回复
    sendHandler: function () {
        console.log(this.data.inputValue);
        if (this.data.inputValue !== '') {
            // let uid = 1;
            // let data = {
            //     "postId": 1,
            //     "content": this.data.inputValue
            // }
            // httpRequestApi.postReplyComment(uid, data).success(res => {
            //     console.log(res);
            // });
            let uid = 1;
            let data = {
                "columnId": '1541403885738293',
                colunmNames: '金色巴掌',
                "detailDesc": this.data.inputValue
            }
            httpRequestApi.postReply(uid, data).success(res => {
                console.log(res);
            });
        }
    }
})