接口标识:slide
接口url:https://你的网站/api.php/index/slide
接口参数:
字段名称 | 字段说明 | 类型 | 必填 | 备注 |
---|---|---|---|---|
gid | 幻灯片id | num | 必填 | |
unm | 幻灯片数量 | num | 可不填默认10 |
小程序代码
前端调用:
- swan.request({
- url: that.globalData.api + "slide",
- data: {
- gid:gid,
- num:num,
- aid: that.globalData.aid
- },
- method: 'GET',
- header: {
- 'content-type': 'application/json', // 默认值
- 'x-safecode': that.globalData.safecode
- },
- success: function (res) {
- let list = res.data;
- resolve(list);
- console.log("promise读取幻灯列表")
- },
- fail(e) {
- console.log('获取幻灯失败,请重试');
- }
- })
- <swiper indicator-dots="{{true}}" indicator-color='rgb(0,0,0,0.8)' indicator-active-color="red" autoplay="{{true}}"
- class="banner">
- <block s-for="{{banner}}" s-for-index="idx">
- <swiper-item>
- <navigator url="{{item.url}}">
- <image src="{{item.pic}}" class="slide-image"></image>
- </navigator>
- </swiper-item>
- </block>
- </swiper>