problem.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="center">
  3. <view class="bg">
  4. <view class="title">问题反馈</view>
  5. </view>
  6. <scroll-view scroll-y="true" class="list">
  7. <view v-for="(item,index) in problemList" :key="index">
  8. <view class="problem">
  9. <view class="top flex">
  10. <image :src="userInfo.avatar"></image>
  11. <view class="font">
  12. <view class="title">{{ userInfo.nickname}}</view>
  13. <view class="time">2020-10-23 16:00</view>
  14. </view>
  15. </view>
  16. <view class="centent">
  17. {{ item.content }}
  18. </view>
  19. <view class="huif" v-if="item.reply != null">
  20. <text>老师回复:</text>{{ item.reply }}
  21. </view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. <view class="buttom" @click="nav('/pages/problem/problemAdd')">
  26. 新增问题
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { mapState, mapMutations } from 'vuex';
  32. import { getProblem } from '@/api/problem.js'
  33. export default {
  34. computed: {
  35. ...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
  36. },
  37. data(){
  38. return{
  39. page: 1,
  40. limit: 10,
  41. loadingType: 'more',
  42. problemList:[]
  43. }
  44. },
  45. onLoad() {
  46. this.loadData()
  47. },
  48. //下拉刷新
  49. onPullDownRefresh() {
  50. this.loadData('refresh');
  51. },
  52. //监听页面是否滚动到底部加载更多
  53. onReachBottom() {
  54. this.loadData();
  55. },
  56. methods: {
  57. async loadData(type = 'add', loading){
  58. let obj = this;
  59. if (type === 'add') {
  60. if (obj.loadingType === 'nomore') {
  61. return;
  62. }
  63. obj.loadingType = 'loading';
  64. } else {
  65. obj.loadingType = 'more';
  66. }
  67. if (type === 'refresh') {
  68. // 清空数组
  69. obj.courseList = [];
  70. obj.page = 1
  71. }
  72. //获取反馈列表
  73. getProblem({
  74. page: obj.page,
  75. limit: obj.limit
  76. }).then(e => {
  77. obj.problemList = obj.problemList.concat(e.data.data);
  78. console.log(obj.problemList);
  79. //判断是否还有下一页,有是more 没有是nomore
  80. if (obj.limit==e.data.length) {
  81. obj.page++
  82. obj.loadingType='more'
  83. } else{
  84. obj.loadingType='nomore'
  85. }
  86. if (type === 'refresh') {
  87. if (loading == 1) {
  88. uni.hideLoading();
  89. } else {
  90. uni.stopPullDownRefresh();
  91. }
  92. }
  93. })
  94. },
  95. nav(url) {
  96. uni.navigateTo({
  97. url: url
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .center {
  105. background: #F6F6F6;
  106. }
  107. .bg {
  108. height: 426rpx;
  109. background: #1CC7C7;
  110. position: relative;
  111. .title {
  112. position: absolute;
  113. top: 204rpx;
  114. left: 48rpx;
  115. font-size: 71rpx;
  116. font-family: 59--Regular;
  117. font-weight: 400;
  118. color: #FFFFFF;
  119. }
  120. }
  121. .problem {
  122. margin: 20rpx;
  123. background: #FFFFFF;
  124. padding: 28rpx 44rpx 32rpx 30rpx;
  125. .top {
  126. justify-content: start;
  127. margin-bottom: 34rpx;
  128. image {
  129. width: 95rpx;
  130. height: 95rpx;
  131. border-radius: 50%;
  132. }
  133. .font {
  134. margin-left: 18rpx;
  135. .title {
  136. font-size: 32rpx;
  137. font-weight: bold;
  138. color: #3D4458;
  139. }
  140. .time {
  141. font-size: 26rpx;
  142. font-weight: 500;
  143. color: #999999;
  144. }
  145. }
  146. }
  147. .centent {
  148. font-size: 30rpx;
  149. font-weight: 500;
  150. color: #999999;
  151. }
  152. .huif {
  153. margin-top: 38rpx;
  154. font-size: 30rpx;
  155. font-family: PingFang SC;
  156. font-weight: bold;
  157. color: #999999;
  158. text{
  159. color: #1CC7C7;
  160. }
  161. }
  162. }
  163. .buttom {
  164. width: 674rpx;
  165. height: 88rpx;
  166. margin: 20rpx auto;
  167. background: #1CC7C7;
  168. border-radius: 44rpx;
  169. text-align: center;
  170. font-size: 36rpx;
  171. font-weight: 500;
  172. color: #FFFFFF;
  173. line-height: 88rpx;
  174. }
  175. .list{
  176. height: 780rpx;
  177. }
  178. </style>