comment.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. var app = getApp();
  2. // pages/comment/comment.js
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. url: app.globalData.urlImages,
  9. comm:1,
  10. productId:'',
  11. uinfo:[],
  12. alllength:'',
  13. newlength:'',
  14. piclength:''
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. app.setBarColor();
  21. app.setUserInfo();
  22. var productId = options.productId;
  23. this.setData({
  24. productId: productId
  25. })
  26. this.comment();
  27. this.alllen();
  28. this.newlen();
  29. this.piclen();
  30. },
  31. alllen:function(){
  32. var that = this;
  33. var productId = that.data.productId;
  34. var filter='all';
  35. wx.request({
  36. url: app.globalData.url + '/routine/auth_api/product_reply_list?uid=' + app.globalData.uid,
  37. data: { productId: productId, filter: filter },
  38. method: 'GET',
  39. success: function (res) {
  40. if (res.data.code == 200) {
  41. that.setData({
  42. alllength: res.data.data.length
  43. })
  44. } else {
  45. that.setData({
  46. alllength: ''
  47. })
  48. }
  49. }
  50. })
  51. },
  52. newlen: function () {
  53. var that = this;
  54. var productId = that.data.productId;
  55. var filter = 'new';
  56. wx.request({
  57. url: app.globalData.url + '/routine/auth_api/product_reply_list?uid=' + app.globalData.uid,
  58. data: { productId: productId, filter: filter },
  59. method: 'GET',
  60. success: function (res) {
  61. if (res.data.code == 200) {
  62. that.setData({
  63. newlength: res.data.data.length
  64. })
  65. } else {
  66. that.setData({
  67. newlength: ''
  68. })
  69. }
  70. }
  71. })
  72. },
  73. piclen: function () {
  74. var that = this;
  75. var productId = that.data.productId;
  76. var filter = 'pic';
  77. wx.request({
  78. url: app.globalData.url + '/routine/auth_api/product_reply_list?uid=' + app.globalData.uid,
  79. data: { productId: productId, filter: filter },
  80. method: 'GET',
  81. success: function (res) {
  82. if (res.data.code == 200) {
  83. that.setData({
  84. piclength: res.data.data.length
  85. })
  86. } else {
  87. that.setData({
  88. piclength: ''
  89. })
  90. }
  91. }
  92. })
  93. },
  94. comment: function (){
  95. var that=this;
  96. var comm = that.data.comm;
  97. var filter='';
  98. if (comm==1){
  99. filter = 'all';
  100. } else if (comm == 2){
  101. filter = 'new';
  102. } else if (comm == 3) {
  103. filter = 'pic';
  104. } else{
  105. return false;
  106. }
  107. var productId = that.data.productId;
  108. wx.request({
  109. url: app.globalData.url + '/routine/auth_api/product_reply_list?uid=' + app.globalData.uid,
  110. data: { productId: productId, filter: filter},
  111. method: 'GET',
  112. success: function (res) {
  113. if(res.data.code==200){
  114. that.setData({
  115. uinfo: res.data.data,
  116. replyCount: res.data.data.length
  117. })
  118. }else{
  119. that.setData({
  120. uinfo: [],
  121. replyCount:''
  122. })
  123. }
  124. }
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面初次渲染完成
  129. */
  130. onReady: function () {
  131. },
  132. commentap:function(e){
  133. var index = e.target.dataset.index;
  134. this.setData({
  135. comm: index
  136. })
  137. this.comment();
  138. },
  139. getImagePreview:function(e){//图片预览
  140. wx.previewImage({
  141. current: e.currentTarget.dataset.image, // 当前显示图片的http链接
  142. urls: e.currentTarget.dataset.images // 需要预览的图片http链接列表
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面显示
  147. */
  148. onShow: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面隐藏
  152. */
  153. onHide: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面卸载
  157. */
  158. onUnload: function () {
  159. },
  160. /**
  161. * 页面相关事件处理函数--监听用户下拉动作
  162. */
  163. onPullDownRefresh: function () {
  164. },
  165. /**
  166. * 页面上拉触底事件的处理函数
  167. */
  168. onReachBottom: function () {
  169. },
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {
  174. }
  175. })