index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // pages/zl_detail/create_evaluation/index.js
  2. const {
  3. request,
  4. serverName
  5. } = require('../../../utils/services');
  6. const {
  7. newRequestFns,
  8. newServerName
  9. } = require('../../../utils/newServices.js');
  10. // const WxParse = require('../../../common/component/wxParse/wxParse.js');
  11. const wxStar = require('../../../common/component/wxStar/wxStar/wxStar.js');
  12. const {
  13. Toast
  14. } = require('../../../utils/util.js');
  15. const {
  16. defaultImg
  17. } = require('../../../utils/images');
  18. const app = getApp();
  19. Page({
  20. /**
  21. * 页面的初始数据
  22. */
  23. data: {
  24. full_star_img: "../../../imgs/icon/full.png",
  25. currentStar: 0,
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function(options) {
  31. wxStar.wxStar(this, 0, true);
  32. let currentStar = this.wxStarCont();
  33. this.setData({
  34. defaultImg,
  35. exhibitionId: options.id,
  36. serverName,
  37. currentStar
  38. })
  39. },
  40. starChangeCb: function() {
  41. let currentStar = this.wxStarCont();
  42. this.setData({
  43. currentStar
  44. })
  45. },
  46. clearComment: function() {
  47. this.setData({
  48. content: ""
  49. });
  50. },
  51. getContent: function(e) {
  52. this.setData({
  53. content: e.detail.value || ""
  54. });
  55. console.log('change', e.detail.value);
  56. },
  57. submit: function() {
  58. let {
  59. content,
  60. exhibitionId
  61. } = this.data;
  62. let currentStar = this.wxStarCont() / 2;
  63. let loginSessionKey = wx.getStorageSync('token') || "";
  64. if (content && currentStar) {
  65. newRequestFns["writtenComments"]({
  66. comment: content,
  67. exhibitionId,
  68. score: currentStar,
  69. loginSessionKey
  70. }, "post", res => {
  71. if (res.data.code > -1) {
  72. Toast.showToast('tip', "评论成功", success => {
  73. wx.navigateBack({
  74. url: `../../../pages/zl_detail/index?id=${exhibitionId}`,
  75. success: function (res) { },
  76. fail: function (res) { },
  77. complete: function (res) { },
  78. })
  79. })
  80. // wx.navigateBack({
  81. // delta: 1,
  82. // })
  83. }
  84. }, err => {
  85. // wx.showToast({
  86. // title: '您已经发表过评论,不能重复评论。',
  87. // icon: 'none',
  88. // })
  89. }, complete => {
  90. })
  91. } else if (currentStar){
  92. Toast.showToast('tip', "写几句短评吧", success => {
  93. })
  94. }else{
  95. Toast.showToast('tip', "给看展打个分吧", success => {
  96. })
  97. }
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady: function() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow: function() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide: function() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload: function() {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh: function() {
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function() {
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage: function() {
  133. }
  134. })