微信小程序:今日头条

微信小程序:今日头条

2021-03-14
¥ 0 终身VIP免费 升级终身VIP
下载不了?请联系网站客服提交链接错误!
增值服务: 安装指导 环境配置 二次开发 网站建设 模板修改 源码安装 LOGO设计 图片设计
微信小程序:今日头条
最近更新 2021年03月14日
资源编号 15550

微信小程序:今日头条

郑重承诺丨总裁主题提供安全交易、信息保真!
增值服务:
安装指导
环境配置
二次开发
网站建设
模板修改
源码安装
¥ 0 (终身VIP免费 升级终身VIP开通VIP尊享优惠特权
立即下载 升级会员 最新活动
详情介绍

微信小程序:今日头条

项目为仿今日头条,使用了百度ApiStore接口查询数据,使用微信组件/api有 封装请求方法,底部tab,启动页动画,loading,scroll-view,swiper,列表页支持上下拉加载更多
效果图:
微信小程序:今日头条
启动欢迎页,几行代码可实现旋转与缩放:
  1. //flash.js
  2. onReady:function(){
  3.      // 页面渲染完成
  4.      var that = this,duration = 1500;
  5.      var animation = wx.createAnimation({
  6.          duration: duration,
  7.      });
  8.      //step() 方法表示一组动画的结束
  9.      animation.scale(2).rotate(360).step();
  10.      animation.scale(1).step();
  11.      this.setData({
  12.          animationData : animation.export()
  13.      });
  14.      var timestamp = new Date().getTime();
  15.      setTimeout(function(){
  16.        wx.redirectTo({
  17.          url: ‘../index/index?time=’+timestamp
  18.        })
  19.      },duration*2.5);
  20. },

复制代码

  1. //flash.wxml
  2. <image class=”flash-img” animation=”{{animationData}}” src=”{{src}}” ></image>

复制代码

网络请求方法:

  1. //app.js
  2.   req: function(url,data,param){
  3.     var requestData = {
  4.       url: url,
  5.       data: typeof data == ‘object’ ? data : {},
  6.       method: typeof param.method == ‘string’ && param.method.length > 0 ? param.method.toUpperCase() : ‘GET’,
  7.       header: typeof param.header == ‘object’ ? param.header : {},
  8.       success: function(res) {
  9.         typeof param.success == ‘function’ && param.success(res);
  10.       },
  11.       fail: function(res){
  12.         typeof param.fail == ‘function’ && param.fail(res);
  13.       },
  14.       complete: function(res){
  15.         typeof param.complete == ‘function’ && param.complete(res);
  16.       }
  17.     };
  18.     wx.request(requestData);
  19.   },

复制代码

列表页:

  1. //index.js
  2. var app = getApp(),currentPage = 1;
  3. const URL = “http://apis.baidu.com/showapi_open_bus/channel_news/search_news”;
  4. Page({
  5.   data:{
  6.     imgUrls: [
  7.       ‘http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg’,
  8.       ‘http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg’,
  9.       ‘http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg’
  10.     ],
  11.     toView: “”,
  12.     loadingHidden:true,
  13.     renderData:[],
  14.   },
  15.   onLoad:function(options){
  16.     this.loadDataFromServer();
  17.   },
  18.   //api读取数据
  19.   loadDataFromServer: function(){
  20.     var that = this;
  21.     that.changeLoadingStatus(false);
  22.     app.req(URL,{
  23.       page : currentPage,
  24.       needContent : 1,
  25.     },{
  26.       header: { apikey: app.globalData.apikey },
  27.       success:function(resp){
  28.         console.log(resp);
  29.         console.log(“成功加载页数 “+currentPage);
  30.         var tempData = resp.data.showapi_res_body.pagebean.contentlist;
  31.         var toViewId = currentPage % 2 == 0 ? “top-id” : “top-id2”; //需要改变值页面才会重新渲染
  32.         that.setData({
  33.            //renderData: that.data.renderData.concat(tempData),  合并数组容易超出长度,无法做到无限加载
  34.            renderData: tempData,
  35.            toView: toViewId,
  36.         });
  37.         that.changeLoadingStatus(true);
  38.       }
  39.     });
  40.   },
  41.   //加载上一页或者下拉刷新
  42.   refresh:function(e){
  43.       currentPage = currentPage > 1 ? –currentPage : 1;
  44.       this.loadDataFromServer();
  45.   },
  46.   //加载下一页
  47.   loadMore:function(e){
  48.       ++currentPage;
  49.       this.loadDataFromServer();
  50.   },
  51.   //改变loading状态
  52.   changeLoadingStatus: function(bool){
  53.     this.setData({
  54.       loadingHidden: bool
  55.     });
  56.   },
  57.   onReady:function(){
  58.     // 页面渲染完成
  59.     wx.setNavigationBarTitle({
  60.       title: ‘列表’
  61.     });
资源下载此资源仅限注册用户下载,请先
客服QQ:3482249445
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

所有文章为演示数据,不提供下载地址,版权归原作者所有,仅提供演示效果!

小程序网 小程序 微信小程序:今日头条 https://www.10000ii.com/15550.html

常见问题
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情
  • 最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用
查看详情

相关文章

微信小程序:今日头条-海报

分享本文封面