基金小程序
目录
全量基金公司列表
演示
![](https://image.shishitao.com:8440/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjE5MjQ4Ny8yMDIxMDMvMjE5MjQ4Ny0yMDIxMDMxMjE2NDUzMzI2OC0xNzEzNTk2MDIwLnBuZw%3D%3D.png?w=700&webp=1)
接口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() {
}
})
全量基金列表
演示
![](https://image.shishitao.com:8440/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjE5MjQ4Ny8yMDIxMDMvMjE5MjQ4Ny0yMDIxMDMxMjE2NTA1NTM2Ni0xMzYwNzY2MTQxLnBuZw%3D%3D.png?w=700&webp=1)
接口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
})
}
我的关注列表
演示
![](https://image.shishitao.com:8440/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjE5MjQ4Ny8yMDIxMDMvMjE5MjQ4Ny0yMDIxMDMxMjE2NTUwMDgxMC05MjQwMzM0NzkucG5n.png?w=700&webp=1)
接口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() {
}
})
基金实时估值
演示
![](https://image.shishitao.com:8440/aHR0cHM6Ly9pbWcyMDIwLmNuYmxvZ3MuY29tL2Jsb2cvMjE5MjQ4Ny8yMDIxMDMvMjE5MjQ4Ny0yMDIxMDMxMjE3MDIyMzI1OS0yMDU1NzE3ODIzLnBuZw%3D%3D.png?w=700&webp=1)
接口4-获取基金详情信息(含近几年趋势数据)
- 请求地址:http://fund.eastmoney.com/pingzhongdata/161725.js
- 请求方式:GET
- 请求参数:无
- 应答参数:自行查看
接口5-基金当日实时估值走势图
图片地址: http://j4.dfcfw.com/charts/pic6/161725.png
在线预览: