problem.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="center">
  3. <view class="bg">
  4. <view class="back" @click="back">
  5. <image src="../../static/img/fanhui.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.real_name}}</view>
  16. <view class="time">{{ item.add_time }}</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(({data}) => {
  101. for(let i = 0;i<data.count;i++){
  102. console.log(data.data[i])
  103. data.data[i].add_time = obj.timestampToTime(data.data[i].add_time);
  104. }
  105. obj.problemList = obj.problemList.concat(data.data);
  106. console.log(obj.problemList);
  107. //判断是否还有下一页,有是more 没有是nomore
  108. if (obj.limit==data.data.length) {
  109. obj.page++
  110. obj.loadingType='more'
  111. } else{
  112. obj.loadingType='nomore'
  113. }
  114. if (type === 'refresh') {
  115. if (loading == 1) {
  116. uni.hideLoading();
  117. } else {
  118. uni.stopPullDownRefresh();
  119. }
  120. }
  121. })
  122. },
  123. nav(url) {
  124. uni.navigateTo({
  125. url: url
  126. })
  127. },
  128. back(){
  129. uni.navigateBack();
  130. },
  131. timestampToTime(timestamp) {
  132. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  133. var Y = date.getFullYear() + '/';
  134. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '/';
  135. var D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  136. var h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  137. var m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  138. var s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  139. return Y+M+D+h+m+s;
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. .center {
  146. background: #F6F6F6;
  147. }
  148. .bg {
  149. height: 426rpx;
  150. background: #1CC7C7;
  151. position: relative;
  152. .title {
  153. position: absolute;
  154. top: 204rpx;
  155. left: 48rpx;
  156. font-size: 71rpx;
  157. font-family: 59--Regular;
  158. font-weight: 400;
  159. color: #FFFFFF;
  160. }
  161. .back{
  162. position: absolute;
  163. top: 54rpx;
  164. left: 24rpx;
  165. width: 46rpx;
  166. height: 46rpx;
  167. background: rgba(245,244,250,0.23);
  168. // opacity: ;
  169. border-radius: 50%;
  170. text-align: center;
  171. display: flex;
  172. align-items: center;
  173. image {
  174. position: relative;
  175. margin: 0 auto;
  176. line-height: 46rpx;
  177. width: 18rpx;
  178. height: 24rpx;
  179. border-radius: 50%;
  180. }
  181. }
  182. }
  183. .problem {
  184. margin: 20rpx;
  185. background: #FFFFFF;
  186. padding: 28rpx 44rpx 32rpx 30rpx;
  187. .top {
  188. justify-content: start;
  189. margin-bottom: 34rpx;
  190. image {
  191. width: 95rpx;
  192. height: 95rpx;
  193. border-radius: 50%;
  194. }
  195. .font {
  196. margin-left: 18rpx;
  197. .title {
  198. font-size: 32rpx;
  199. font-weight: bold;
  200. color: #3D4458;
  201. }
  202. .time {
  203. margin-top: 18rpx;
  204. font-size: 26rpx;
  205. font-weight: 500;
  206. color: #999999;
  207. }
  208. }
  209. }
  210. .centent {
  211. font-size: 30rpx;
  212. font-weight: 500;
  213. color: #999999;
  214. }
  215. .huif {
  216. margin-top: 38rpx;
  217. font-size: 30rpx;
  218. font-family: PingFang SC;
  219. font-weight: bold;
  220. color: #999999;
  221. text{
  222. color: #1CC7C7;
  223. }
  224. }
  225. }
  226. .buttom {
  227. width: 674rpx;
  228. height: 88rpx;
  229. margin: 20rpx auto;
  230. background: #1CC7C7;
  231. border-radius: 44rpx;
  232. text-align: center;
  233. font-size: 36rpx;
  234. font-weight: 500;
  235. color: #FFFFFF;
  236. line-height: 88rpx;
  237. }
  238. .list{
  239. height: 780rpx;
  240. }
  241. </style>