大数据平台的小程序版本

ruleInfo.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // pages/ruleInfo/ruleInfo.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. statusNavBarHeight:app.data.statusNavBarHeight,
  9. safeAreaTop: 30+app.data.safeAreaTop,
  10. type: ''
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.setData({
  17. id: options.id,
  18. user_hash: options.user_hash,
  19. allType: options.type?options.type:2,//视频号或视频
  20. follow_id: options.follow_id
  21. })
  22. this.getSet();
  23. this.getInfo();
  24. },
  25. goUserDetail(e){
  26. if(e.currentTarget.dataset.item.field_type!=0) {
  27. wx.navigateTo({
  28. url: '/pages/userDrtail/index?user_id='+e.currentTarget.dataset.id+'&type=2',
  29. })
  30. }
  31. },
  32. setType() {
  33. this.setData({
  34. showType: !this.data.showType
  35. })
  36. },
  37. checkType(e) {
  38. this.setData({
  39. type: e.currentTarget.dataset.type,
  40. videoList: [],
  41. showType: false
  42. })
  43. this.getInfo();
  44. },
  45. //消息获取
  46. getSet(){
  47. wx.showLoading({
  48. title: '加载中',
  49. })
  50. app.func.req('/api/notice/ruleList', 'get', {
  51. follow_type: this.data.allType,
  52. follow_id: this.data.follow_id
  53. }, (res) => {
  54. wx.hideLoading()
  55. wx.stopPullDownRefresh();
  56. if(res && res.errno == 0){
  57. this.setData({
  58. list: res.rst,
  59. showList: []
  60. })
  61. res.rst.forEach(item => {
  62. if(this.data.user_id) {
  63. item.field_type==4&&item.enable==1&&this.setData({
  64. fans_flag: true
  65. })
  66. item.field_type==5&&item.enable==1&&this.setData({
  67. public_flag: true
  68. })
  69. }else {
  70. item.field_type==1&&item.enable==1&&this.setData({
  71. like_flag: true
  72. })
  73. item.field_type==2&&item.enable==1&&this.setData({
  74. comment_flag: true
  75. })
  76. item.field_type==3&&item.enable==1&&this.setData({
  77. share_flag: true
  78. })
  79. }
  80. this.setData({
  81. [item.field_type==1?'like_id':item.field_type==2?'comment_id':item.field_type==3?'share_id':item.field_type==4?'fans_id':'public_id']:item.id,
  82. [item.field_type==1?'like_count':item.field_type==2?'comment_count':item.field_type==3?'share_count':item.field_type==4?'fans_count':'public_count']:item.threshold
  83. })
  84. })
  85. }else if(res.errno!=4003){
  86. wx.showToast({
  87. title: res.err,
  88. icon: 'none',
  89. duration: 2000
  90. })
  91. }
  92. },(err)=>{
  93. console.log(err)
  94. wx.hideLoading()
  95. })
  96. },
  97. getInfo(){
  98. wx.showLoading({
  99. title: '加载中',
  100. })
  101. app.func.req('/api/notice/msgList', 'get', {
  102. rule_id: this.data.id,
  103. user_hash: this.data.user_hash,
  104. field_type: this.data.type
  105. }, (res) => {
  106. wx.hideLoading()
  107. wx.stopPullDownRefresh();
  108. this.setData({
  109. hasAuno: res.auno==4403||res.errno==4003,
  110. pages: 1
  111. })
  112. if(res && res.errno == 0){
  113. //成功
  114. this.setData({
  115. videoList: res.rst,
  116. videoLength: res.rst.length>0?res.rst.length:-1
  117. })
  118. }else if(res.errno!=4003){
  119. wx.showToast({
  120. title: res.err,
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. }
  125. },(err)=>{
  126. console.log(err)
  127. wx.hideLoading()
  128. })
  129. },
  130. /**
  131. * 生命周期函数--监听页面卸载
  132. */
  133. onUnload: function () {
  134. },
  135. /**
  136. * 页面相关事件处理函数--监听用户下拉动作
  137. */
  138. onPullDownRefresh: function () {
  139. },
  140. /**
  141. * 页面上拉触底事件的处理函数
  142. */
  143. onReachBottom: function () {
  144. },
  145. /**
  146. * 用户点击右上角分享
  147. */
  148. onShareAppMessage: function (res) {
  149. return app.shareEvent(res)
  150. }
  151. })