article.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //var api = require("../../api.js"), app = getApp(),
  2. var is_loading_more = !1,
  3. is_no_more = !1;
  4. var api = require('../../utils/api.js');
  5. Page({
  6. data: {
  7. page: 1,
  8. video_list: [],
  9. article_list: [],
  10. url: "",
  11. hide: "hide",
  12. show: !1,
  13. animationData: {},
  14. tabList: [{
  15. tab: 'video',
  16. title: '视频'
  17. }, {
  18. tab: 'article',
  19. title: '文章'
  20. }],
  21. selectedTab: 'video',
  22. },
  23. onLoad: function(a) {
  24. // app.pageOnLoad(this);
  25. this.loadMoreGoodsList('both');
  26. },
  27. swiperTab: function (e) {
  28. var that = this;
  29. console.log(e);
  30. that.setData({
  31. selectedTab: e.detail.currentItemId
  32. });
  33. },
  34. clickTab: function (e) {
  35. var that = this;
  36. console.log(e)
  37. if (this.data.selectedTab === e.target.dataset.current) {
  38. return false;
  39. } else {
  40. that.setData({
  41. selectedTab: e.target.dataset.current
  42. })
  43. }
  44. },
  45. onReady: function() {},
  46. onShow: function() {
  47. // app.pageOnShow(this);
  48. },
  49. onHide: function() {},
  50. onUnload: function() {},
  51. onPullDownRefresh: function() {},
  52. loadMoreGoodsList: function(tab) {
  53. var tab = tab || this.data.selectedTab;
  54. var o = this;
  55. // if (!is_loading_more) {
  56. // o.setData({
  57. // show_loading_bar: !0
  58. // }), is_loading_more = !0;
  59. var i = o.data.page;
  60. // var v = [{
  61. // "id":"234",
  62. // "title":"小程序项目整体介绍",
  63. // "url":"http://m1.beiyuesi.com/2.mp4",
  64. // "sort":"9",
  65. // "is_delete":"0",
  66. // "addtime":"1515120216",
  67. // "store_id":"20926",
  68. // "pic_url":"https://u5.9026.com/addons/swdz_mall/core/web/uploads/image/f0/f0734ad93d46497483344846864596a4.jpg",
  69. // "content":"想要自己开发APP,却备受组建开发团队的困扰更别说高昂的开发费用与漫长的开",
  70. // "type":"0",
  71. // "time":"01月05日",
  72. // "show":-1
  73. // },
  74. // {
  75. // "id": "235",
  76. // "title": "小程序模版介绍",
  77. // "url": "http://m1.beiyuesi.com/1.mp4",
  78. // "sort": "99",
  79. // "is_delete": "0",
  80. // "addtime": "1515120395",
  81. // "store_id": "20926",
  82. // "pic_url": "https://u5.9026.com/addons/swdz_mall/core/web/uploads/image/0e/0e739254177172e4b815d75f88da77b4.png",
  83. // "content": "小程序是腾讯旗下继朋友圈、公众号之后推出的又一款战略级的产品。是线下实体店实体零售转型升级、实现新突破的利器。小程序比公众号更容易传播和裂变,比传统电商更容易获客和成交,比朋友圈微商更专业和可信",
  84. // "type": "0",
  85. // "time": "01月05日",
  86. // "show": -1
  87. // },
  88. // ];
  89. wx.request({
  90. url: api.getMoreVideosAndArticlesUrl,
  91. method: 'GET',
  92. data: {
  93. 'video_offset': o.data.video_list.length,
  94. 'article_offset': o.data.article_list.length,
  95. 'type': tab
  96. },
  97. success: res => {
  98. if (res.data.list.length > 0) {
  99. if(res.data.type == 'video') {
  100. var t = o.data.video_list.concat(res.data.list);
  101. o.setData({
  102. video_list: t,
  103. page: i + 1
  104. });
  105. } else if (res.data.type == 'article') {
  106. var t = o.data.article_list.concat(res.data.list);
  107. o.setData({
  108. article_list: t,
  109. page: i + 1
  110. });
  111. } else if (res.data.type == 'both') {
  112. var t = o.data.video_list.concat(res.data.video_list);
  113. o.setData({
  114. video_list: t,
  115. page: i + 1
  116. });
  117. var t = o.data.article_list.concat(res.data.article_list);
  118. o.setData({
  119. article_list: t,
  120. page: i + 1
  121. });
  122. }
  123. } else {
  124. wx.showToast({
  125. title: '到底了',
  126. icon: 'none',
  127. duration: 800
  128. })
  129. }
  130. }
  131. })
  132. // app.request({
  133. // url: api.default.video_list,
  134. // data: {
  135. // page: i
  136. // },
  137. // success: function (a) {
  138. // 0 == a.data.list.length && (is_no_more = !0);
  139. // var t = o.data.video_list.concat(a.data.list);
  140. // o.setData({
  141. // video_list: t,
  142. // page: i + 1
  143. // });
  144. // },
  145. // complete: function () {
  146. // is_loading_more = !1, o.setData({
  147. // show_loading_bar: !1
  148. // });
  149. // }
  150. // });
  151. // }
  152. },
  153. play: function(a) {
  154. var t = a.currentTarget.dataset.index;
  155. wx.createVideoContext("video_" + this.data.show_video).pause(), this.setData({
  156. show_video: t,
  157. show: !0
  158. });
  159. },
  160. onReachBottom: function() {
  161. this.loadMoreGoodsList();
  162. // is_no_more || this.loadMoreGoodsList();
  163. },
  164. more: function(a) {
  165. var t = this,
  166. o = a.target.dataset.index,
  167. i = t.data.video_list,
  168. e = wx.createAnimation({
  169. duration: 1e3,
  170. timingFunction: "ease"
  171. });
  172. this.animation = e, -1 != i[o].show ? (e.rotate(0).step(), i[o].show = -1) : (e.rotate(0).step(),
  173. i[o].show = 0), t.setData({
  174. video_list: i,
  175. animationData: this.animation.export()
  176. });
  177. },
  178. redirectToArticle: function(e) {
  179. let id = e.currentTarget.dataset.id;
  180. wx.navigateTo({
  181. url: '/pages/article-detail/index?id=' + id
  182. })
  183. }
  184. });