问星数据小程序

index.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // pages/liveDetail/index.js
  2. import * as echarts from '../../components/ec-canvas/echarts';
  3. var app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ec: {
  10. lazyLoad: true // 延迟加载
  11. },
  12. hotCommentList: [],
  13. newCommentList: [],
  14. noneHot:false,
  15. noneNew: false,
  16. checkType: 1,
  17. photo_id: '',
  18. user_id: '',
  19. infoObj: {},
  20. tab: 1,
  21. rewardList: [],
  22. productList: [],
  23. giftObj: {},
  24. targetTop: '',
  25. isFix: false,
  26. pages: 1,
  27. page: 1,
  28. pages1: 0,
  29. page1: 1,
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad(options) {
  35. console.log(options)
  36. var that = this;
  37. wx.showLoading({
  38. title: '加载中',
  39. })
  40. that.setData({
  41. 'photo_id':options.photoid,
  42. 'user_id': options.userid
  43. })
  44. wx.getSystemInfo({
  45. success(res) {
  46. that.setData({
  47. scrollHeight: res.windowHeight - 10
  48. });
  49. }
  50. });
  51. that.getInfo();
  52. that.getNew();
  53. var query = wx.createSelectorQuery();
  54. //选择id
  55. query.select('#tabItem').boundingClientRect()
  56. query.exec((res) => {
  57. //res就是 所有标签为mjltest的元素的信息 的数组
  58. that.setData({
  59. targetTop: res[0].top
  60. })
  61. })
  62. wx.setNavigationBarTitle({
  63. title: options.from?'广告详情':'视频详情'
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. // 热门评论
  87. getNew:function() {
  88. wx.showLoading({
  89. title: '加载中',
  90. })
  91. var that = this;
  92. app.func.req('/api/kwaiUser/commentList','post',{
  93. 'type': 0,
  94. 'photo_id':that.data.photo_id,
  95. 'user_id':that.data.user_id,
  96. 'page': that.data.page
  97. },
  98. function(res) {
  99. wx.hideLoading({
  100. title: '加载中',
  101. })
  102. if(res && res.errno == 0){
  103. //成功
  104. var data = res.rst;
  105. that.setData({
  106. newCommentList: that.data.newCommentList.concat(data.list),
  107. pages: data.pages
  108. })
  109. if(that.data.newCommentList.length==0) {
  110. that.setData({
  111. noneNew: true
  112. })
  113. }
  114. }
  115. },function(err){
  116. that.setData({
  117. noneNew: true
  118. })
  119. console.log(err)
  120. })
  121. },
  122. // 热门评论
  123. getHot:function() {
  124. var that = this;
  125. app.func.req('/api/kwaiUser/commentList','post',{
  126. 'type': 1,
  127. 'photo_id':that.data.photo_id,
  128. 'user_id':that.data.user_id,
  129. 'page': that.data.page1
  130. },
  131. function(res) {
  132. wx.hideLoading({
  133. title: '加载中',
  134. })
  135. if(res && res.errno == 0){
  136. //成功
  137. var data = res.rst;
  138. that.setData({
  139. hotCommentList: that.data.hotCommentList.concat(data.list),
  140. pages1: data.pages
  141. })
  142. if(that.data.hotCommentList.length==0) {
  143. that.setData({
  144. noneHot: true
  145. })
  146. }
  147. }
  148. },function(err){
  149. console.log(err)
  150. that.setData({
  151. noneHot: true
  152. })
  153. })
  154. },
  155. // 直播详情
  156. getInfo:function() {
  157. var that = this;
  158. app.func.req('/api/kwaiUser/ShowVideos','get',{
  159. 'photo_id':that.data.photo_id,
  160. 'user_id': that.data.user_id
  161. },
  162. function(res) {
  163. if(res && res.errno == 0){
  164. //成功
  165. var data = res.rst;
  166. that.setData({
  167. infoObj: data
  168. })
  169. }
  170. },function(err){
  171. console.log(err)
  172. })
  173. },
  174. // 滚动
  175. scroll(e) {
  176. let page = this,
  177. scrollTop = e.detail.scrollTop;
  178. if(scrollTop>=this.data.targetTop) {
  179. this.setData({
  180. isFix: true
  181. })
  182. }else {
  183. this.setData({
  184. isFix: false
  185. })
  186. }
  187. },
  188. bindDownLoad() {
  189. if(this.data.tab==1) {
  190. if(this.data.page<this.data.pages) {
  191. this.setData({
  192. page: ++this.data.page
  193. })
  194. this.getNew();
  195. }
  196. }else {
  197. if(this.data.page1<this.data.pages1) {
  198. this.setData({
  199. page1: ++this.data.page1
  200. })
  201. this.getHot();
  202. }
  203. }
  204. },
  205. check(e) {
  206. this.setData({
  207. tab: e.target.dataset.id
  208. })
  209. if(this.data.tab==2&&this.data.pages1==0) {
  210. this.getHot();
  211. }
  212. },
  213. /**
  214. * 页面相关事件处理函数--监听用户下拉动作
  215. */
  216. onPullDownRefresh: function () {
  217. },
  218. /**
  219. * 页面上拉触底事件的处理函数
  220. */
  221. onReachBottom: function () {
  222. },
  223. /**
  224. * 用户点击右上角分享
  225. */
  226. onShareAppMessage: function () {
  227. }
  228. })