comment.js 4.0 KB

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