// pages/ad/ad.js var app = getApp() var config = {}; var miucms = require('../../utils/miucms.js'); var WxParse = require('../../wxParse/wxParse.js'); Page({ /** * 页面的初始数据 */ data: { uniqid: '', template: [], imgUrls: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading() this.setData({ uniqid: options.uniqid || "", }) this.get_config() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: "寄托香港租房" } }, get_config() { var that = this; if (app.globalData.config.lists) { config = app.globalData.config; this.get_content(); } else { setTimeout(function () { that.get_config() }, 200) } }, copy(e) { wx.setClipboardData({ data: e.currentTarget.dataset.value, success: function (res) { wx.getClipboardData({ success: function (res) { wx.showToast({ title: '复制成功!', }) } }) } }) }, get_content() { let url = app.globalData.config.special.details; let that = this; var sendData = Object.assign({}, this.data.options, { session: wx.getStorageSync('session'), uniqid: that.data.uniqid, }) miucms.request(url, sendData).then(data => { wx.hideLoading() if (data.extraparam) { wx.showModal({ title: '提示', content: data.message, }) } else { let attachment = []; let imgUrls = []; data.data.template.map(item => { if (item['type'] == 'graytext' || item['type'] == 'text' || item['type'] == 'subtitle') { item.data.value = item.data.value.split('\n') } if (item['type'] == 'bigpicture' || item['type'] == 'image') { imgUrls.push(item.data.url) } }) that.setData({ template: data.data.template, imgUrls }) } }).catch(res => {}) }, // 预览图片 previewImg(e) { let img = e.currentTarget.dataset.img, that = this; wx.previewImage({ urls: that.data.imgUrls, current: img }) } })