基金小程序
目錄
全量基金公司列表
演示

接口1-獲取全量基金公司列表數據
- 請求地址:http://fund.eastmoney.com/js/jjjz_gs.js
- 請求方式:GET
- 請求參數:無
- 應答參數:自己查看
請求代碼
//僅列舉部分代碼
wx.request({
url: "http://fund.eastmoney.com/js/jjjz_gs.js",
data: {
},
method: 'GET',
header: {
"Content-Type": "application/json"
},
success: (res) => {
if(200 == res.statusCode) {
var cpList = JSON.parse(res.data.split('=')[1].replace("op:","").replace('{','').replace('}',''));
this.setData({
companyList : cpList,
updateTime: res.header['Last-Modified']
});
} else {
console.error(res.errMsg);
}
wx.stopPullDownRefresh();
},
fail: function() {
}
})
全量基金列表
演示

接口2-獲取全量基金列表
- 請求地址:http://fund.eastmoney.com/js/fundcode_search.js
- 請求方式:GET
- 請求參數:無
- 應答參數:自己查看
請求代碼
wx.request({
url: "http://fund.eastmoney.com/js/fundcode_search.js",
data: {
},
method: 'GET',
header: {
"Content-Type": "application/json"
},
success: (res) => {
if(200 == res.statusCode) {
let cpList = res.data.split('= ')[1].replace("[[","[").replace("]];","]");
this.setData({
allList: cpList,
updateTime: res.header['Last-Modified'],
});
this.setDateSize();
} else {
console.error(res.errMsg);
}
},
fail: function() {
}
})
setDateSize: function() {
//初始化變量
let cpList = this.data.allList;
let page = this.data.page;
let initSize = this.data.initSize;
//數據格式轉換
let cppList = "";
for(let i = (page-1)*initSize;i<page*initSize;i++) {
if(undefined == cpList.split(",[")[i]) {
break;
}
cppList += cpList.split(",[")[i];
}
//判斷是否為尾頁
if("" == cppList || null == cppList || undefined == cppList) {
Toast.fail("已經是最后一頁啦~");
let nextPage = this.data.page - 1;
this.setData({
page: nextPage
})
return;
}
if(1 != page) cppList = "[[" + cppList;
else cppList = "[" + cppList;
cppList += "]";
cppList = cppList.replaceAll("]\"","],[\"");
//轉為json對象
cpList = JSON.parse(cppList);
this.setData({
jList: cpList
})
}
我的關注列表
演示

接口3-獲取基金估值信息
- 請求地址:http://fundgz.1234567.com.cn/js/161725.js
- 請求方式:GET
- 請求參數:無
- 應答參數:
jsonpgz({"fundcode":"161725","name":"招商中證白酒指數(LOF)","jzrq":"2021-03-11","dwjz":"1.2119","gsz":"1.2167","gszzl":"0.40","gztime":"2021-03-12 15:00"});
應答參數 | 說明 |
---|---|
fundcode | 基金代碼 |
name | 基金名稱 |
jzrq | 凈值日期 |
dwjz | 當日凈值 |
gsz | 估算凈值 |
gszzl | 估算漲跌百分比 |
gztime | 估值時間 |
請求代碼
wx.request({
url: url,
method: 'GET',
success: (res) => {
if(200 == res.statusCode) {
let objStr = res.data.replaceAll("jsonpgz({","{").replaceAll("});", "}");
objStr = JSON.parse(objStr);
this.setData({
name: objStr.name,
jzrq: objStr.jzrq,
dwjz: objStr.dwjz,
gsz: objStr.gsz,
gszzl: objStr.gszzl,
gztime: objStr.gztime,
})
} else {
console.error(res.errMsg);
}
},
fail: function() {
}
})
基金實時估值
演示

接口4-獲取基金詳情信息(含近幾年趨勢數據)
- 請求地址:http://fund.eastmoney.com/pingzhongdata/161725.js
- 請求方式:GET
- 請求參數:無
- 應答參數:自行查看
接口5-基金當日實時估值走勢圖
圖片地址: http://j4.dfcfw.com/charts/pic6/161725.png
在線預覽: