聯(lián)系官方銷售客服
1835022288
028-61286886
請問小程序前端SHOW詳情頁怎么調(diào)用多圖字段顯示
我使用http.php文件中的自帶的news_list_data讀取不出任何數(shù)據(jù)出來。
所以請問下
1:詳情頁自定義回調(diào)接口要怎么寫,為啥用http.php的自帶參數(shù)后,訪問JSON,得不到任何數(shù)據(jù)。
2:這個自定義字段要怎么調(diào),比如多圖字段,files,字段為:圖片 / images/ Files
http.php
//自帶 public function news_list_data($data) { $rt = []; if ($data) { foreach ($data as $t) { $rt[] = [ 'title' => $t['title'], 'id' => $t['id'], 'thumb' => dr_thumb($t['thumb'], 200, 200), 'updatetime' => dr_date($t['_updatetime'], 'Y-m-d H:i:s'), ]; } } return $rt; }
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=news_list_data'; 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 () {//評論跳轉(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 }) } } }); } })
你發(fā)的自帶的函數(shù)里面根本沒有多圖字段的回調(diào)啊,要自己寫一個回調(diào)方法
回復(fù)@易學(xué)習(xí)
是沒有呀,我就是不知道怎么寫。我是兩個問題
第一個問題:我用默認(rèn)自帶的news_list_data這個參數(shù),訪問JSON,為啥任何數(shù)據(jù)都沒有?去掉這個參數(shù)就可以得到詳情數(shù)據(jù)。
第二個問題:我這個多圖files要怎么寫回調(diào),不懂寫呀
瀏覽器訪問api看看duotu有木有值
回復(fù)@易學(xué)習(xí)
還是沒數(shù)據(jù),就是空的,
我就直接訪問這個JSON得到的就是空數(shù)據(jù)
https://www.***.com/index.php?appid=**&appsecret=密鑰***&s=anli&c=show&id=58&api_call_function=anli_show_data
如果把文章ID號改一下,會提示沒有這篇文章的JSON。所以沒搞明白是咋回事!
不對哦,你這個是show頁面的接口,我給你寫的list頁面的接口,肯定不能用啊
回復(fù)@易學(xué)習(xí)
哈,大佬,我就是要SHOW頁呀,show頁的怎么寫,是在http這個文件嗎?還是要怎么處理?
回復(fù)@易學(xué)習(xí)
現(xiàn)在能獲取到圖片,但是地址是錯的。我改了下字段,多圖字段為images,但是還是是空數(shù)據(jù)
得到的圖片地址數(shù)量是對的,但是數(shù)據(jù)名稱和后綴全沒出來。
如:
/uploadfile/Arrayfile"
/uploadfile/Arrayfile"
/uploadfile/Arrayfile"
/uploadfile/Arrayfile"
全部是這樣的數(shù)據(jù)
忘記語法了,寫成模板標(biāo)簽了,可以QQ私聊