zoukankan      html  css  js  c++  java
  • 微信小程序之轮播图(PHP)

    首先是wtml

    <swiper class="">//微信轮播图组件swiper
        <block wx:for="{{img_urls}}" wx:key="*this"> //block是标签
            <swiper-item>
                <image src="{{item.img}}" class=""></image>//轮播的图片
            </swiper-item>
        </block>   
     </swiper >

    然后是js,类似一个Ajax

    wx.request({ // 获取轮播图
          url: url,
          data: {
            custom_server: url2,
          },
          success: function (res) {
            that.setData({
              img_urls: 
            });
          }
        })

    后台获取轮播图的方法

    public function get_banner ($type = 2) {
            $where=array();
            $server=$_SERVER['SERVER_NAME'];
            $cate = I('cate');
            $where['type']=$type;
            if($server == ''){
                if($cate == $type){
                    $where['orderid']  = array('between','220,240');
                }else{
                    $where['orderid']  = array('not between','220,240');
                }
            }$img_list=M('img')->where($where)->order('orderid desc')->field('id,img,url,orderid')->select();
            if(!empty($img_list)){
                foreach($img_list as $k2=>$v2){
                    $arr2=explode(',',$v2['url']);
                    $info=$this->get_link($arr2['0'],$arr2['1'],$arr2['2']);
                    $img_list[$k2]['path']=$info['src'];
                    $img_list[$k2]['jump_type']=$info['jump_type'];
                }
            }else{
                $where['type']=1;
                $img_list=M('img')->where($where)->order('orderid desc')->field('id,img,url')->select();
            }
    
            $this->ajax_return('success', 1, $img_list);
            exit;
        }

    轮播图的数据库表img中字段

    img中存放的是图片的地址

  • 相关阅读:
    python 八进制数
    python hmac加盐
    python contextlib
    python hashlib
    python struct
    python namedtuple
    python datetime timezone 时区转化
    Android核心基础(手机卫士的一个知识点总结)
    TabHost结合RadioButton实现主页的导航效果
    Android SDK更新失败最新解决方案
  • 原文地址:https://www.cnblogs.com/luosong3/p/10564530.html
Copyright © 2011-2022 走看看