const WxParse = require('../../wxParse/wxParse.js')
const $ = global

new $.Page({
    onLoad(options) {
        const id = options.id;
        const name = options.name || '';
        if (id) {
            $.request(`server_info/${id}`, 'GET', {}, true).then((res) => {
                var article = res.data && res.data.content || '';
                /**
                 * WxParse.wxParse(bindName , type, data, target,imagePadding)
                 * 1.bindName绑定的数据名(必填)
                 * 2.type可以为html或者md(必填)
                 * 3.data为传入的具体数据(必填)
                 * 4.target为Page对象,一般为this(必填)
                 * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
                 */
                WxParse.wxParse('article', 'html', article, this, 5)
            });
        }
        this.setData({
            name,
            id
        });
    },
    bookServer() {
        const {
            name,
            id
        } = this.data;
        if (name && name.includes('月嫂') || id == 6) {
            $.router.goto({
                path: '/pages/yuesao/index',
                query: {
                    id
                }
            });
        } else {
            $.router.goto({
                path: '/pages/bookService/index',
                query: {
                    id
                }
            });
        }
    }
})