reply.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="container">
  3. <swiper class="swiper-box">
  4. <swiper-item>
  5. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadDate">
  6. <!-- 评论列表 -->
  7. <view v-for="(item, index) in list" :key="index" class="eva-box">
  8. <view class="flex_item">
  9. <image class="portrait" :src="item.avatar" mode="aspectFill"></image>
  10. <view class="right">
  11. <view class="flex">
  12. <view class="name">{{ item.name }}</view>
  13. <view class="time">{{ item.comment_time }}</view>
  14. </view>
  15. <view class="Rate"><uniRate activeColor="#F10F3C" disabled="false" text="1" size="10" margin="0" :value="item.score"></uniRate></view>
  16. </view>
  17. </view>
  18. <view class="content-box">
  19. <text class="con">{{ item.comment }}</text>
  20. <view class="con_box">
  21. <view class="con_image" v-for="ls in item.pics"><image @click.stop="imgInfo(ls)" :src="ls"></image></view>
  22. </view>
  23. </view>
  24. </view>
  25. <uni-load-more :status="loadingType"></uni-load-more>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. </view>
  30. </template>
  31. <script>
  32. import { allComment } from '@/api/doctor.js';
  33. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  34. import uniRate from '@/components/uni-rate/uni-rate.vue';
  35. import { getTime } from '@/utils/rocessor.js';
  36. export default {
  37. components: {
  38. uniRate
  39. },
  40. watch: {},
  41. data() {
  42. return {
  43. list:[], //评论列表
  44. uid:'',
  45. limit: 10, //每次加载数据条数
  46. page: 1, //当前页数
  47. loadingType: 'more', //加载更多状态
  48. loading:0,//判断是否为点击搜索按钮跳转加载
  49. };
  50. },
  51. //下拉刷新
  52. onPullDownRefresh() {
  53. this.page = 1
  54. this.getDoctorList('refresh');
  55. },
  56. onLoad(option) {
  57. this.uid = option.id;
  58. this.loadDate();
  59. },
  60. methods: {
  61. async loadDate(type) {
  62. let obj = this;
  63. //这里是将订单挂载到tab列表下
  64. if (type !== 'refresh') {
  65. //没有更多数据直接跳出方法
  66. if (obj.loadingType === 'nomore') {
  67. return;
  68. } else {
  69. // 设置当前为数据载入中
  70. obj.loadingType = 'loading';
  71. }
  72. } else {
  73. //当重新加载数据时更新状态为可继续添加数据
  74. obj.loadingType = 'more';
  75. }
  76. allComment({
  77. page: obj.page,
  78. limit: obj.limit,
  79. uid:obj.uid
  80. })
  81. .then(({ data }) => {
  82. if (type === 'refresh') {
  83. obj.list = [];
  84. }
  85. let arr = data.map(e => {
  86. e.comment_time = getTime(e.comment_time);
  87. return e;
  88. });
  89. obj.list = obj.list.concat(arr);
  90. //判断是否还有下一页,有是more 没有是nomore
  91. if (obj.limit == arr.length) {
  92. obj.page++;
  93. obj.loadingType = 'more';
  94. } else {
  95. obj.loadingType = 'nomore';
  96. }
  97. // 判断是否为刷新数据
  98. if (type === 'refresh') {
  99. // 判断是否为点击搜索按钮跳转加载
  100. if (obj.loading == 1) {
  101. uni.hideLoading();
  102. } else {
  103. uni.stopPullDownRefresh();
  104. }
  105. }
  106. })
  107. .catch(e => {
  108. console.log(e)
  109. obj.loadingType = 'nomore';
  110. // obj.$api.msg(e.message);
  111. uni.hideLoading();
  112. });
  113. },
  114. //点击图片显示大图
  115. imgInfo(i) {
  116. let tempList = [];
  117. tempList.push(i);
  118. console.log(tempList);
  119. //显示图片
  120. uni.previewImage({
  121. current: i,
  122. loop: false,
  123. urls: tempList,
  124. indicator: 'default'
  125. });
  126. },
  127. }
  128. };
  129. </script>
  130. <style lang="scss">
  131. page {
  132. background: #ffffff;
  133. height: 100%;
  134. .container {
  135. height: 100%;
  136. padding: 25rpx 25rpx;
  137. .swiper-box {
  138. height: 100%;
  139. .list-scroll-content {
  140. height: 100%;
  141. }
  142. }
  143. }
  144. }
  145. .reply_btn {
  146. padding: 15rpx 0rpx;
  147. position: fixed;
  148. // top: 50px;
  149. .btn {
  150. padding: 10rpx 25rpx;
  151. font-size: 24rpx;
  152. background: #f4f4f4;
  153. margin-right: 25rpx;
  154. }
  155. .current {
  156. background-color: #e93323 !important;
  157. color: #ffffff !important;
  158. }
  159. }
  160. .eva-box {
  161. padding: 30rpx 0;
  162. .portrait {
  163. flex-shrink: 0;
  164. width: 80rpx;
  165. height: 80rpx;
  166. border-radius: 100px;
  167. }
  168. .right {
  169. flex: 1;
  170. display: flex;
  171. flex-direction: column;
  172. font-size: $font-base;
  173. color: $font-color-base;
  174. padding-left: 26rpx;
  175. }
  176. .Rate{
  177. padding-top: 25rpx;
  178. }
  179. }
  180. .content-box{
  181. padding: 20rpx 0;
  182. .con {
  183. font-size: $font-base;
  184. color: $font-color-dark;
  185. }
  186. .bot {
  187. display: flex;
  188. justify-content: space-between;
  189. font-size: $font-sm;
  190. color: $font-color-light;
  191. }
  192. }
  193. .con_image {
  194. width: 130rpx;
  195. height: 130rpx;
  196. display: inline-block;
  197. padding: 15rpx;
  198. image {
  199. width: 100%;
  200. height: 100%;
  201. }
  202. }
  203. </style>