problem.vue 4.1 KB

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