lookfuwu.js 2.9 KB
import {
  request
} from "../../request/index.js"
const a = getApp()
var WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    imagesUrl: a.globalData.baseUrl,
    content: '',
    s4_id: '',
  },
  onLoad: function (options) {
    //  console.log(options);
    this.setData({
      s4_id: options.s4_id || ''
    })
  },
  onShow: function () {
    this.getRuleBook()
  },
  golookfuwu() {
    wx.navigateTo({
      url: '/pages/lookfuwu/lookfuwu'
    })
  },
  async getRuleBook() {
    let that = this
    const {
      data: {
        data
      }
    } = await request({

      url: "api/shop/pingFw",
      data: {
        s4_id: that.data.s4_id
      }

    })
    that.setData({
      content: data.content
    })
    WxParse.wxParse('content', 'html', that.data.content, that, 5);

  },
  // 正则验证图标图片  

  text(details) {

    var texts = ''; //待拼接的内容

    while (details.indexOf('<img') != -1) { //寻找img 循环

      texts += details.substring('0', details.indexOf('<img') + 4); //截取到<img前面的内容

      details = details.substring(details.indexOf('<img') + 4); //<img 后面的内容

      if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {

        texts += details.substring(0, details.indexOf('style="') + 7) + "max-width:100%;height:auto;margin:0 auto;"; //从 <img 后面的内容 截取到style= 加上自己要加的内容

        details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接

      } else {

        texts += ' style="max-width:100%;height:auto;margin:0 auto;" ';

      }
    }

    while (details.indexOf('<td') != -1) { //寻找img 循环

      texts += details.substring('0', details.indexOf('<td') + 4); //截取到<img前面的内容

      details = details.substring(details.indexOf('<td') + 4); //<img 后面的内容

      if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {

        texts += details.substring(0, details.indexOf('style="') + 7) + "max-width:74!important;height:auto;margin:0 auto;"; //从 <img 后面的内容 截取到style= 加上自己要加的内容

        details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接

      } else {

        texts += ' style="max-width:100%;height:auto;margin:0 auto;" ';

      }
    }
    texts += details; //最后拼接的内容
    return texts

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

  },

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

  },

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

  },

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

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})