problem.vue 4.2 KB

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