suggestionManage.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <!--pages/suggestList/suggestList.wxml-->
  3. <view style="padding-bottom: 10px;">
  4. <!-- 建议列表 -->
  5. <view class="suggestContainer">
  6. <view class="suggest" @click="toSuggestDetail(item)" v-for="(item, index) in suggestion" :key="item">
  7. <view class="suggestion">
  8. <view class="suggestHead">
  9. <view>标题</view>
  10. <view class="suggestTitle">{{item.adviseTitle}}</view>
  11. </view>
  12. <view class="suggestBody">
  13. <view>日期</view>
  14. <view class="suggestContent">{{item.fistDatetime}}</view>
  15. </view>
  16. </view>
  17. <view>
  18. <view class="dispose">{{item.status}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view v-if="isShow" class="toWriteSuggestion">
  23. <text class="writeSuggestion" @click="headPage()">首页</text>
  24. <text class="writeSuggestion" @click="frontPage()">上一页</text>
  25. <text style=" font-size: 35rpx; color: black;margin-left: 5px;padding-top: 5px;"> {{obj.pageNum}}/{{Math.ceil(total/obj.pageSize)}} </text>
  26. <text class="writeSuggestion" @click="nextPage()">下一页</text>
  27. <input v-model="search" style="border: lawngreen 1px solid;
  28. width: 30px;
  29. float: right;
  30. margin-left: 5px;
  31. height: 27px;
  32. text-align: center;
  33. background-color: #ffffff;
  34. "/>
  35. <text class="writeSuggestion" @click="goalPage()" style="float: right;margin-right: 10px;">跳转</text>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. suggestion: [],
  44. obj: {
  45. pageSize: 6,
  46. pageNum: 1
  47. },
  48. total: 0,
  49. currentList: [],
  50. search: '',
  51. isShow: false
  52. };
  53. },
  54. onPullDownRefresh() {
  55. this.obj.pageNum = 1;
  56. this.init();
  57. uni.stopPullDownRefresh();
  58. },
  59. /* onReachBottom() {
  60. // 判断是否有下一页的数据
  61. if (this.obj.pageNum * this.obj.pageSize >= this.total)
  62. return uni.$showMsg('已经是最后一页数据了!')
  63. this.obj.pageNum += 1
  64. this.init()
  65. }, */
  66. onShow(){
  67. this.obj.pageNum = 1;
  68. this.init();
  69. },
  70. created(){
  71. this.obj.pageNum = 1;
  72. this.init();
  73. },
  74. methods:{
  75. async init(){
  76. const { data: result } =await uni.$http.get('/education/my-suggestion/findAllAdvise',this.obj)
  77. this.suggestion = result.data.data;
  78. this.total = result.data.count;
  79. if(this.obj.pageNum==1){
  80. this.currentList = this.suggestion;
  81. }
  82. else{
  83. for(var item of this.suggestion)
  84. {
  85. this.currentList.push(item);
  86. }
  87. }
  88. this.isShow = true;
  89. },
  90. // 点击建议列表,跳转到对应的建议详情页
  91. toSuggestDetail(item){
  92. let suggestion = JSON.stringify(item)
  93. uni.navigateTo({
  94. url: '/subpkg/allsuggestionDetail/allsuggestionDetail?item=' + suggestion
  95. })
  96. },
  97. headPage(){
  98. this.obj.pageNum = 1;
  99. this.init();
  100. this.search = "";
  101. },
  102. frontPage(){
  103. if(this.obj.pageNum==1){
  104. uni.$showMsg('已经是第一页了')
  105. }else{
  106. this.obj.pageNum = this.obj.pageNum - 1;
  107. this.init();
  108. console.log("front",this.obj);
  109. }
  110. },
  111. nextPage(){
  112. if(this.obj.pageNum== Math.ceil(this.total/this.obj.pageSize)){
  113. uni.$showMsg('已经是最后一页了')
  114. }else{
  115. this.obj.pageNum = this.obj.pageNum + 1;
  116. this.init();
  117. console.log("next",this.obj);
  118. }
  119. },
  120. goalPage(){
  121. if(this.search.length==0){
  122. uni.$showMsg('请输入页码!')
  123. }
  124. else if(!/^\d+$/.test(this.search))
  125. {
  126. uni.$showMsg('请输入合法的页码!')
  127. }
  128. else{
  129. let current = parseInt(this.search);
  130. console.log("num",current);
  131. if(current < 1){
  132. uni.$showMsg('该页码不存在!')
  133. }
  134. else if(current > Math.ceil(this.total/this.obj.pageSize)){
  135. uni.$showMsg('超出页码范围!')
  136. }
  137. else{
  138. this.obj.pageNum = current;
  139. this.init();
  140. this.search = "";
  141. }
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss"scoped>
  148. /* pages/suggestList/suggestList.wxss */
  149. .toWriteSuggestion{
  150. display: flex;
  151. position: relative;
  152. justify-content: center;
  153. }
  154. /* 页面背景 */
  155. page{
  156. /* height: 100%; */
  157. /* height: auto !important; */
  158. background-color: #E2F0D9;
  159. }
  160. /* 建议列表区 */
  161. .suggestContainer{
  162. height: 100%;
  163. padding-bottom: 10rpx;
  164. }
  165. /* 单条建议的背景 */
  166. .suggest{
  167. display: flex;
  168. padding: 20rpx;
  169. margin: 20rpx 10rpx;
  170. height: 140rpx;
  171. border-radius: 30rpx;
  172. background-color: #FFF2CC;
  173. }
  174. /* 单条建议左侧标题和内容摘要 */
  175. .suggestion{
  176. width: 75%;
  177. }
  178. /* 标题和内容摘要布局 */
  179. .suggestHead,
  180. .suggestBody{
  181. display: flex;
  182. }
  183. /* 摘要 */
  184. .suggestBody{
  185. margin-top: 10rpx;
  186. }
  187. /* 标题详情和内容详情左边距 */
  188. .suggestTitle,
  189. .suggestContent{
  190. margin-left: 20rpx;
  191. }
  192. /* 标题内容详情 */
  193. .suggestTitle{
  194. width: 65%;
  195. white-space: nowrap;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. }
  199. /* 内容摘要详情 */
  200. .suggestContent{
  201. width: 80%;
  202. overflow: hidden;
  203. text-overflow: ellipsis;
  204. display: -webkit-box;
  205. -webkit-box-orient: vertical;
  206. -webkit-line-clamp: 2;
  207. }
  208. /* 处理状态 */
  209. .dispose{
  210. font-weight: bold;
  211. color: red;
  212. margin-left: 30rpx;
  213. }
  214. /* 写建议按钮 */
  215. .toWriteSuggestion{
  216. display: flex;
  217. position: relative;
  218. justify-content: center;
  219. }
  220. .writeSuggestion{
  221. background-color: #ffffff;
  222. font-size: 35rpx;
  223. color: gray;
  224. border: lawngreen solid 1px;
  225. padding: 10rpx 20rpx;
  226. margin-left: 6px;
  227. }
  228. </style>