article.js 5.6 KB

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