微信公众号获取图片素材接口

时间:2018-01-10 11:43:46   收藏:0   阅读:324

看代码

getImage(){
                this.$http.put(wechatapi+‘/token?access-token=‘+this.token).then((res)=> {

                    var postobj = {
                        ‘type‘:‘image‘,
                        ‘offset‘:this.listnum2,
                        ‘count‘:this.perpage2
                    }
                    postobj = JSON.stringify(postobj)
                    this.$http.post(‘/cgi-bin/material/batchget_material?access_token=‘+res.body,postobj,{emulateJSON: true}).then((res)=>{
                        console.log(res,6666)
                        this.data2 = res.body.item;
                        this.listTotal2 = res.body[‘total_count‘];
                        this.page2 =  Math.ceil((res.body[‘total_count‘])/(this.perpage2));
                    }).catch((res)=>{})
                }).catch((error)=> {})
                
 },

分页需要根据自定义页数perpage2去请求,offset参数就是请求到哪一个位置,count是页数

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!