小程序 转化html

来源:互联网 发布:云梯vpn mac 编辑:程序博客网 时间:2024/06/15 01:33
var WxParse = require('../../wxParse/wxParse.js');

Page({
  data: {
    cid: '',
    title: '',
    mianshu: '',
    publish_time: ''
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    /**
    * WxParse.wxParse(bindName , type, data, target,imagePadding)
    * 1.bindName绑定的数据名(必填)
    * 2.type可以为html或者md(必填)
    * 3.data为传入的具体数据(必填)
    * 4.target为Page对象,一般为this(必填)
    * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
    */
   var id = 
options.id;
   console.log(options);
    var that = this;

    //WxParse.wxParse('article', 'html', article, that, 5);

        wx.request({  
            url: '
http://127.0.0.13/index.php/api/abx/article', 
            data:{
             id : id,
            },
            method: "POST", 
            header: {  
              'Content-Type': 'application/json'  
            },  
            success: function(res) {  
                console.log(res.data) 
                if(res.data.code == '200'){

                    that.setData({
                      cid: res.data.data.cid,
                      title: res.data.data.title,
                      mianshu: res.data.data.introduction,
                      publish_time: res.data.data.publish_time
                    })

                    var content = res.data.data.content;
                    WxParse.wxParse('article', 'html', content, that, 5); 
                }

                    

            }  
        }) 
  }

})





原创粉丝点击