迅睿CMS不僅僅是內(nèi)容管理系統(tǒng),它還能在多種終端來(lái)調(diào)用和展示這些內(nèi)容
PC網(wǎng)站終端
PC電腦傳統(tǒng)網(wǎng)站是通過(guò)HTML模板頁(yè)面來(lái)展示CMS內(nèi)容
移動(dòng)端H5終端
移動(dòng)端H5網(wǎng)站通過(guò)HTML5模板頁(yè)面來(lái)展示CMS內(nèi)容
App終端
iOS和安卓APP客戶(hù)端通過(guò)API接口獲取CMS內(nèi)容并展示在終端
小程序/輕應(yīng)用終端
小程序/輕應(yīng)用通過(guò)API接口獲取CMS內(nèi)容并展示在終端
安裝api插件,設(shè)置api密鑰字符串,用于終端請(qǐng)求
API請(qǐng)求地址格式為:https://www.網(wǎng)站.com/index.php?appid=2&appsecret=PHPCMF9BF840CB2139F
使用微信開(kāi)發(fā)者工具,創(chuàng)建小程序,獲取cms數(shù)據(jù)展示
《微信開(kāi)發(fā)者工具》需要在微信官網(wǎng)下載。
新建小程序項(xiàng)目
AppId選擇【測(cè)試號(hào)】
開(kāi)發(fā)模式選擇【小程序】
語(yǔ)言默認(rèn)選擇【JavaScript】
app.js 此文件是小程序項(xiàng)目的主心文件
我們把a(bǔ)pi請(qǐng)求地址參數(shù)定義在這個(gè)文件里面,以便后面的全局調(diào)用
globalData: {
userInfo: null,
http_api:"http://www.pcms.com/index.php?appid=2&appsecret=PHPCMF9BF840CB2139F&",
}
pages/index.js 此文件是小程序入口文件
我們來(lái)請(qǐng)求cms的文章模塊10條數(shù)據(jù)
var self = this;
wx.request({
url: app.globalData.http_api + "s=news&c=search&pagesize=10&api_call_function=module_search_news_list",
method: 'GET',
success: function (res) {
console.log(res);
if (res.data.code == 1) {
self.setData({
mynews: res.data.data,
});
} else {
console.log(res.data.msg);
}
}
});
<view class="container">
<block wx:for="{{mynews}}" wx:for-item="news">
<view class="news-view">
<view class="news-title">
{{news.title}}
</view>
</view>
</block>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
左邊圖片中的數(shù)據(jù)已經(jīng)成功的讀取出CMS后臺(tái)的文章標(biāo)題
如果存在讀不出來(lái)數(shù)據(jù)時(shí),可以在開(kāi)發(fā)工具右上角開(kāi)啟【不校驗(yàn)合法域名、不校驗(yàn)HTTPS認(rèn)證】