聯(lián)系官方銷售客服
1835022288
028-61286886
請(qǐng)問小程序 新聞內(nèi)頁中,如何調(diào)用出自定義字段?
比如我要調(diào)用出縮略圖字段 thumb、多圖字段 images、
模塊為案例 anli,是使用news的show去改的
show.js為
var WxParse = require('../../wxParse/wxParse.js'); var app = getApp(); var http_url = app.globalData.http_api + "s=anli&c=show"; http_url += '&api_call_function='; var member_url = app.globalData.http_api + "s=api&app=anli&c=module&api_auth_code=" + wx.getStorageSync('member_auth') + "&api_auth_uid=" + wx.getStorageSync('member_uid'); Page({ data: { id: '', content: '', supports: 0, upsImg: "../../icons/ups.png", collectImg: "../../icons/collect.png", }, onLoad: function (options) { app.showModel(); var self = this; wx.request({ url: http_url, data: { id: options.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (res) { if (res.data.code == 1) { // 是否收藏 wx.request({ url: member_url + '&m=is_favorite', data: { id: options.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (sc) { if (sc.data.code == 1) { self.setData( { collectImg: "../../icons/collect-active.png", }) } } }); // 格式化文章內(nèi)容 var article = res.data.data.content; WxParse.wxParse('data', 'html', article, self); self.setData({ content: res.data.data, supports: res.data.data.support, id: options.id }) wx.hideToast(); } else { wx.showModal({ showCancel: false, content: res.data.msg }) } } }) }, getCommentList: function () {//評(píng)論跳轉(zhuǎn) wx.navigateTo({ url: '../news/comment?id=' + this.data.content.id }) }, up: function () {//點(diǎn)贊 var self = this; wx.request({ url: member_url + '&m=digg&value=1', data: { id: self.data.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (sc) { if (sc.data.code == 1) { wx.showToast({ icon: 'success', title: sc.data.msg, duration: 2000 }); self.setData( { supports: sc.data.data, }) } else { wx.showModal({ showCancel: false, content: sc.data.msg }) } } }); }, collect: function () {//收藏 var self = this; wx.request({ url: member_url + '&m=favorite', data: { id: self.data.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (sc) { if (sc.data.code == 1) { wx.showToast({ icon: 'success', title: sc.data.msg, duration: 2000 }); if (sc.data.msg == '收藏成功') { self.setData( { collectImg: "../../icons/collect-active.png", }) } else { self.setData( { collectImg: "../../icons/collect.png", }) } } else { wx.showModal({ showCancel: false, content: sc.data.msg }) } } }); } })
show.wxml使用這個(gè)去調(diào)的,但是調(diào)不到
<image class="l_xqsa" mode="widthFix" src="{{content.thumb}}"></image>
要寫回調(diào)函數(shù)
在回調(diào)函數(shù)里面將縮略圖的id號(hào)轉(zhuǎn)換為詳細(xì)路徑
回復(fù)@易學(xué)習(xí)請(qǐng)問多圖要怎么寫?
第一個(gè)是縮略圖,第二個(gè)是多圖,請(qǐng)問多圖的寫法要怎么寫?
多圖是什么類型,image還是files?
回復(fù)@易學(xué)習(xí)
Files
圖片 / images/ Files
files需要把函數(shù)體全部代碼發(fā)來我給你改
回復(fù)@易學(xué)習(xí)
我沒有自定義,之前定義了一個(gè)是用在列表頁的,可以一起用嗎?