一对一免费咨询:189-6833-3365

1、微信JS文件,发送请求调用: //将返回接口(interface)数据(data),写入Page({data})里面//获取热点新闻,这个也是写在onload:function(){//code)里面的 wx。request({ url: 'httPHOTOSHOP://m。xxiangfang。com/index。php/Home/Xiaoxxf/activ 。。
1、微信JS文件,发送请求调用: //将返回接口(interface)数据,写入Page({data})里面
//获取(obtain)热点新闻,这个也是写在onload:function(){//code)里面的
   wx。request({
  
   url: 'httPHOTOSHOP://m。xxiangfang。com/index。php/Home/Xiaoxxf/activityis_hot=1',//热点新闻
  
   data: {},
  
   method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  
  header: {'Content-Type': 'application/json'
  
   },
  
   success: function (res) {console。宁波微信小程序开发其中,通过公众号关联,用户可以实现公众号与小程序之间相互跳转。小程序体现了“用完即走”的理念,用户不用关心是否安装太多应用的问题。应用将无处不在,随时可用,但又无需安装卸载。 log(res。data)that。setData({
  
   notices: res。data //一维数组,只取两条数据})
  
   },
  
   fail: function () {// fail},
  
   complete: function () {// complete}
   })
2、后台php处理:
使用curl调用即可,记得传参和token(key)标识
3、JS文件里面【热点新闻滚动展示】:
onLoad: function (res) { startNotice: function() {
   var me = this;
  
   var notices = me。data。notices || [];
   //console。宁波小程序开发对于开发者而言,小程序开发门槛相对较低,难度不及APP,能够满足简单的基础应用,适合生活服务类线下商铺以及非刚需低频应用的转换。log(this。data。notices)
  //就是这里有问题,数据(data)还没从接口返回就跑到这里了 xzz-6。2
  
   if( notices。length == 0 ) {
  
  //return;
   //是这里的问题,数据没加载过来,导致程序(procedure)return;
  
   }
  
   var animation = me。animation;
  
   //animation。translateY( -12 )。opacity( 0 )。step();
  
   // animation。translateY( 0 )。opacity( 1 )。step( { duration: 0 });
  
   // me。setData( { animationNotice: animation。export() });
  
   var noticeIdx = me。data。noticeIdx + 1;
   console。log(notices。length);
  
   if( noticeIdx == notices。length ) {
  
  noticeIdx = 0;
  
   }
  
   // 更换数据
  
   setTimeOUT(出局)( function() {
  
  me。setData( {
  
   noticeIdx: noticeIdx
  
  });
  
   }, 400 );
  
   // 启动下一次动画
  
   setTimeout( function() {
  
  me。startNotice();
  
   }, 5000 );},onShow: function() {
   this。宁波小程序开发对于用户来说,能够节约使用时间成本和手机内存空间;对于开发者来说也能节约开发和推广成本。startNotice();},
4、wxml的前段代码(code):
lt;span style="color:#999999" gt;热门活动 lt;/span gt; lt;span style="color:#3273c3" gt;{{notices[noticeIdx]}} lt;/span gt;
作者:PHP急先锋
原文:http://www。cnblogs。com/xuzhengzong/p/6943307。html

© 2008-2019 浙江东美 ALL RIGHTS RESERVED. XMLBAIDU

免责申明:部分内容来自互联网,若侵犯了您的权益,请告知我们删除!

浙ICP备19019195号-1
找网站建设公司就上东美!
189-6833-3365
tel+86-189-6833-3365