problem.vue 5.2 KB

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