evalList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view>
  3. <view class="text">
  4. <text style="font-size: 15px;margin-left: 20rpx;">全部评价({{ total }})
  5. <text style="float: right;margin-right: 20rpx;font-weight: bold;" @click="inputDialogToggle">添加评价</text>
  6. </text>
  7. </view>
  8. <view v-for="(item,index) in listData" :key="index" class="text" style="padding: 0 20rpx;margin-top: 6rpx;">
  9. <view>
  10. <text>{{ item.evaluate }}</text>
  11. </view>
  12. <view style="text-align: right;color: #909399;font-size: 13px;">
  13. <text>{{ item.createTime }}</text>
  14. </view>
  15. </view>
  16. <view>
  17. <!-- 输入框示例 -->
  18. <uni-popup ref="inputDialog" type="dialog">
  19. <uni-popup-dialog ref="inputClose" mode="input" title="评价房源" value=""
  20. @confirm="submitEval">
  21. <textarea v-model="ownevalu" placeholder="请输入评价"></textarea>
  22. </uni-popup-dialog>
  23. </uni-popup>
  24. </uni-popup>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. houseId: null,
  33. listData: [],
  34. pageNum: 1,
  35. pageSize: 20,
  36. scrollTop: 0,
  37. reload: false,
  38. loadStatus: 'loadmore',
  39. status: 'more',
  40. total: 0,
  41. ownevalu: '',
  42. userId: null
  43. };
  44. },
  45. onLoad(option) {
  46. this.houseId = option.houseId; //上个页面传递的参数。
  47. this.getList();
  48. },
  49. onPageScroll(e) {
  50. this.scrollTop = e.scrollTop;
  51. },
  52. onReachBottom() {
  53. this.loadStatus = 'loading';
  54. // 获取数据
  55. this.getList()
  56. },
  57. // 下拉刷新
  58. onPullDownRefresh() {
  59. this.pageNum = 1
  60. this.$refs.uWaterfall.clear();
  61. // 获取数据
  62. this.getList();
  63. // 关闭刷新
  64. uni.stopPullDownRefresh();
  65. },
  66. methods: {
  67. getList() {
  68. let url = "/api/houseApi/selectHouseEvals";
  69. let defaultData = {
  70. houseId: this.houseId,
  71. pageNum: this.pageNum,
  72. pageSize: this.pageSize
  73. }
  74. this.$u.get(url, {...defaultData}).then(result => {
  75. console.log(result);
  76. const data = result.rows;
  77. this.total = result.total;
  78. if (this.pageNum > 0 && data.length < this.pageSize) {
  79. this.loadStatus = 'nomore';
  80. } else {
  81. ++this.pageNum
  82. this.loadStatus = 'loadmore';
  83. }
  84. this.listData = data;
  85. });
  86. },
  87. inputDialogToggle() {
  88. // 判断是否有userId
  89. let lifeData = uni.getStorageSync('lifeData');
  90. let vuex_user = lifeData.vuex_user
  91. if (!vuex_user) {
  92. // 没有userId 则跳转到登录
  93. return uni.reLaunch({
  94. url: '../login/login'
  95. })
  96. }
  97. this.userId = vuex_user.userId;
  98. this.$refs.inputDialog.open();
  99. //判断是否有评价权限
  100. // let url = "api/houseApi/checkAuthEvals";
  101. // this.$u.get(url, {
  102. // houseId: this.houseId,
  103. // userId:this.userId
  104. // }).then(result => {
  105. // if(result.code === 200 && result.data.length>0){
  106. // this.$refs.inputDialog.open();
  107. // }else{
  108. // this.$mytip.toast("只有租客才能进行评论!");
  109. // }
  110. // });
  111. },
  112. submitEval() {
  113. let url = "api/houseApi/saveHouseEvals";
  114. this.$u.get(url, {
  115. houseId: this.houseId,
  116. evalu: this.ownevalu,
  117. userId: this.userId
  118. }).then(result => {
  119. this.$mytip.toast('评价成功')
  120. this.$refs.inputDialog.close()
  121. this.getList();
  122. });
  123. }
  124. }
  125. };
  126. </script>
  127. <style>
  128. .text {
  129. background-color: #fff;
  130. line-height: 80 rpx;
  131. }
  132. </style>