article.js 5.9 KB

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