jizhicms接口地址

发布于:2021-05-24 09:11:24

查询数据表信息

//微信自带请求
        wx.request({
            url:util.config.appApiUrl+'/GetData/index',
            data:{ key: util.config.accesskey, model:"sysconfig"},
            method:'POST',
            header: {  
                'content-type': 'application/x-www-form-urlencoded' 
              },
            dataType:'json',
            success:function(res){
                console.log(res);

            }

        });
        
        
   // 使用 app.api 接口 调取banenr 
   
           let _t = this;
        app.api('POST', 'GetData/index', {model:"collect",tid:1,isshow:1}, (res) => {
            console.log(res)
             _t.setData({imgUrls:res.data.data})
  
        })


接口参数


网站API接口为:/GetData/index
完整链接:https://域名/GetData/index
请求参数:
key : API访问密钥 [必填]
model : 查询的模块标识 [必填] 
limit : 查询条数 [非必填]
orders : 查询排序,如:id desc,addtime desc [非必填] 默认 id asc
fields : 查询字段,如:id,title,body [非必填] 默认全部
isshow : 查询是否显示 [非必填]
tid : 查询栏目ID [非必填]
其余参数,自行根据需求写

返回数据JSON格式:

{
    code : 0,
    data : [ ],
}
## 注释
code=0 为正确返回
code=1 为请求错误
data 为数组


数据表名称

内容    article     
栏目    classtype     
会员    member        
订单    orders       
商品    product      
会员分组    member_group   
评论    comment        
留言    message       
轮播图    collect      
友情链接    links    
TAG    tags      
单页    page


获取栏目数据

// 微信API请求
// 请求栏目链接: https://demo.jizhicms.cn/xinwen.html
// Ajax请求标识:ajax:1 【必须】
// 限制条数:limit:8 【默认跟后台设定显示数一样】

        wx.request({
            url:'https://demo.jizhicms.cn/xinwen.html',
            data:{ ajax:1,limit:8},
            method:'POST',
            header: {  
                'content-type': 'application/x-www-form-urlencoded' 
              },
            dataType:'json',
            success:function(res){
                console.log(res);

            }

        });
        
        
## 返回数据结构:
{
    code:0,//是否成功标识
    allpage:3,//总页数
    data:[ ],//数据列表数组
    sum:"19",//总条数--需要转换为 int类型
    type:[ ] //对应栏目的内容数据数组

}


获取详情页信息

// 利用微信API请求查询单条数据
// limit:1 必须为1,才是单条数据查询
wx.request({
            url:'https://demo.jizhicms.cn/GetData/index',
            data:{ key: 123456, model:"product", id:1, limit:1},
            method:'POST',
            header: {  
                'content-type': 'application/x-www-form-urlencoded' 
              },
            dataType:'json',
            success:function(res){
                console.log(res);

            }

        });


留言提交接口


https://demo.jizhicms.cn/message/index


wx.request({
            url:'https://demo.jizhicms.cn/message/index',
            data:{ 
                ajax:1,//ajax提交必填
                body:'测试留言内容',
                title:'测试留言标题',
                user:'测试用户名',
                tel:'13600136000',
                tid:1,//留言栏目ID

            },
            method:'POST',
            header: {  
                'content-type': 'application/x-www-form-urlencoded' 
              },
            dataType:'json',
            success:function(res){
                console.log(res);
            }



        });
## 返回说明
{
    code:0,//成功返回
    msg:'提交成功!我们会尽快回复您!',//返回信息
    url:'https://demo.jizhicms.cn'//网页端返回跳转链接-可忽略
}


小程序用户登录接口


//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    openid:'',
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  onLoad: function () {
 
  },
  getUserInfo: function(e) {
    
    var _this = this;
    var user = e.detail.userInfo;
    if(user && typeof(user) != "undefined"){

        
        app.user.userInfo = e.detail.userInfo
        this.setData({
          userInfo: e.detail.userInfo,
          hasUserInfo: true
        })
        //获取openid
        wx.login({
          success: function (res) {
            console.log(res.code)
            //发送请求获取openid
            app.api('POST', '/GetData/getOpenid', {code: res.code}, (res) => {
                  console.log(res.data);
                  app.user.openid = res.data.openid;
                  app.user.session_key = res.data.session_key;
                  app.api('POST', '/GetData/login', {
                    nickname:e.detail.userInfo.nickName,
                    avatarUrl:e.detail.userInfo.avatarUrl,
                    openid:res.data.openid
                  }, (res) => {
                        console.log(res.data);
                        
                        _this.setData({openid:app.user.openid});
                      
                        var user = {
                          userInfo: app.user.userInfo,
                          openid:app.user.openid,
                          session_key:app.user.session_key
                        }

                        wx.setStorageSync('user', user);

                        wx.showToast({
                          title: '登录成功',
                          icon:'none'
                        })   
                        setTimeout(function(){
                            wx.switchTab({
                              url: '/pages/index/index'
                            })
                        },500)
                  })
            })
          }
        })
    }
    else{
      // 拒绝登录返回首页
      setTimeout(function(){
          wx.switchTab({
            url: '/pages/index/index'
          })
      },500)
    }

  }
})


更新个人信息

        let _t = this;
        app.api('POST', 'GetData/UpUser', e.detail.value, (res) => {
            console.log(res)
             _t.setData({user:res.data.data})
  
        })


觉得有用请点个赞吧!
0 543