article.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.status == 'success') {
  99. if (res.data.type != 'both' && res.data.list.length <= 0) {
  100. wx.showToast({
  101. title: '到底了',
  102. icon: 'none',
  103. duration: 800
  104. })
  105. } else {
  106. if (res.data.type == 'video') {
  107. var t = o.data.video_list.concat(res.data.list);
  108. o.setData({
  109. video_list: t,
  110. page: i + 1
  111. });
  112. } else if (res.data.type == 'article') {
  113. var t = o.data.article_list.concat(res.data.list);
  114. o.setData({
  115. article_list: t,
  116. page: i + 1
  117. });
  118. } else if (res.data.type == 'both') {
  119. var t = o.data.video_list.concat(res.data.video_list);
  120. o.setData({
  121. video_list: t,
  122. page: i + 1
  123. });
  124. var t = o.data.article_list.concat(res.data.article_list);
  125. o.setData({
  126. article_list: t,
  127. page: i + 1
  128. });
  129. }
  130. }
  131. }
  132. }
  133. })
  134. // app.request({
  135. // url: api.default.video_list,
  136. // data: {
  137. // page: i
  138. // },
  139. // success: function (a) {
  140. // 0 == a.data.list.length && (is_no_more = !0);
  141. // var t = o.data.video_list.concat(a.data.list);
  142. // o.setData({
  143. // video_list: t,
  144. // page: i + 1
  145. // });
  146. // },
  147. // complete: function () {
  148. // is_loading_more = !1, o.setData({
  149. // show_loading_bar: !1
  150. // });
  151. // }
  152. // });
  153. // }
  154. },
  155. play: function (a) {
  156. var t = a.currentTarget.dataset.index;
  157. wx.createVideoContext("video_" + this.data.show_video).pause(), this.setData({
  158. show_video: t,
  159. show: !0
  160. });
  161. },
  162. onReachBottom: function () {
  163. this.loadMoreGoodsList();
  164. // is_no_more || this.loadMoreGoodsList();
  165. },
  166. more: function (a) {
  167. var t = this,
  168. o = a.target.dataset.index,
  169. i = t.data.video_list,
  170. e = wx.createAnimation({
  171. duration: 1e3,
  172. timingFunction: "ease"
  173. });
  174. this.animation = e, -1 != i[o].show ? (e.rotate(0).step(), i[o].show = -1) : (e.rotate(0).step(),
  175. i[o].show = 0), t.setData({
  176. video_list: i,
  177. animationData: this.animation.export()
  178. });
  179. },
  180. redirectToArticle: function (e) {
  181. let id = e.currentTarget.dataset.id;
  182. wx.navigateTo({
  183. url: '/pages/article-detail/index?id=' + id
  184. })
  185. }
  186. });