noteList.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="content">
  3. <view style="padding: 24rpx 0;">
  4. <view class="search-box">
  5. <view class="left">
  6. <image src="@/static/image/home/icon_search.png" mode=""></image>
  7. <input v-model="keyword" class="input-text" type="text" placeholder="搜索笔记内容"/>
  8. </view>
  9. <view class="right">
  10. <button class="button" @tap="refreshPage()">搜索</button>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="tabBg es-pt-10 es-pb-10 es-bc-white" style="z-index: 100;">
  15. <me-tabs :value="tabIndex" :tabs="mtabs" nameKey="dictLabel" @change="tabChange" :fixed="false" ></me-tabs>
  16. </view>
  17. <mescroll-uni ref="mescrollRef" style="background-color: #FAFAFA;" @init="mescrollInit" :top="mescrollTopY" bottom="0" :down="downOption" @down="downCallback" :up="upOption"
  18. @up="upCallback" @emptyclick="emptyClick">
  19. <view class="es-bc-white es-p-r" >
  20. <view class="es-view-w-x es-mt-10">
  21. <block v-for="(item, index) in dataList" :key="index" >
  22. <view v-if="index%3==0" @tap="goToMyNote(item)" class="es-br-20 es-bc-white es-pl-23 es-pr-23 es-pt-20 es-pb-20 es es-ac es-mt-20 es-mb-20 item_bg1">
  23. <view class="es-f1 es-ml-16 " >
  24. <view class="es es-ac">
  25. <view class="es-f1 es-omit es-fs-30 tit_color_1">{{item.courseName}}</view>
  26. <view v-if="item.noteType==2" class="es-bc-theme es-brc-yellow es-br-30 es-bc-ff es-fs-22 es-w-110 es-h-40 x-c" >转存笔记</view>
  27. </view>
  28. <view class="es-fs-26 es-mt-19 es-omit es-c-33">{{item.content }}</view>
  29. <view class="es es-ac es-mt-21">
  30. <view class="es-f1 es-omit es-fs-24 cor_6a">{{item.subCateName}}</view>
  31. <view class="es-fs-24 cor_6a">{{ $formatDate(item.createTime) }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-else-if="index%3==1" @tap="goToMyNote(item)" class="es-br-20 es-bc-white es-pl-23 es-pr-23 es-pt-20 es-pb-20 es es-ac es-mt-20 es-mb-20 item_bg2">
  36. <view class="es-f1 es-ml-16 item_bg2">
  37. <view class="es es-ac">
  38. <view class="es-f1 es-omit es-fs-30 tit_color_2">{{item.courseName}}</view>
  39. <view v-if="item.noteType==2" class="es-bc-theme es-brc-yellow es-br-30 es-bc-ff es-fs-22 es-w-110 es-h-40 x-c" >转存笔记</view>
  40. </view>
  41. <view class="es-fs-26 es-mt-19 es-omit es-c-33">{{item.content}}</view>
  42. <view class="es es-ac es-mt-21">
  43. <view class="es-f1 es-omit es-fs-24 cor_6a">{{item.subCateName}}</view>
  44. <view class="es-fs-24 cor_6a">{{ $formatDate(item.createTime) }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-else @tap="goToMyNote(item)" class="es-br-20 es-bc-white es-pl-23 es-pr-23 es-pt-20 es-pb-20 es es-ac es-mt-20 es-mb-20 item_bg3">
  49. <view class="es-f1 es-ml-16">
  50. <view class="es es-ac">
  51. <view class="es-f1 es-omit es-fs-30 tit_color_3">{{item.courseName}}</view>
  52. <view v-if="item.noteType==2" class="es-bc-theme es-brc-yellow es-br-30 es-bc-ff es-fs-22 es-w-110 es-h-40 x-c" >转存笔记</view>
  53. </view>
  54. <view class="es-fs-26 es-mt-19 es-omit es-c-33">{{item.content}}</view>
  55. <view class="es es-ac es-mt-21">
  56. <view class="es-f1 es-omit es-fs-24 cor_6a">{{item.subCateName}}</view>
  57. <view class="es-fs-24 cor_6a">{{ $formatDate(item.createTime) }}</view>
  58. </view>
  59. </view>
  60. </view>
  61. </block>
  62. </view>
  63. </view>
  64. </mescroll-uni>
  65. </view>
  66. </template>
  67. <script>
  68. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  69. import { getCourseCate,getCourseList,getMyCourseNoteList } from '@/api/course'
  70. export default {
  71. mixins: [MescrollMixin], // 使用mixin
  72. components: {
  73. },
  74. data() {
  75. return {
  76. headerHeight:44,
  77. navigationBarHeight:44,
  78. statusBarBG:"none",
  79. headerIndex:98,
  80. downOption: { //下拉刷新
  81. use:true,
  82. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  83. },
  84. upOption: { //上拉加载
  85. auto: false, // 不自动加载
  86. page: {
  87. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  88. size: 10 // 每页数据的数量
  89. },
  90. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  91. empty:{
  92. tip: '~ 暂无数据 ~', // 提示
  93. btnText: '刷新重试',
  94. icon:"../../static/image/nodata.png"
  95. }
  96. },
  97. imageList:["../../static/image/home/banner1.png"],
  98. tabIndex: 0, // tab下标
  99. current: 0,
  100. mtabs:[],
  101. fixedTop: false,
  102. tabTop:0,
  103. top:0,
  104. cateId:0,
  105. dataList:[],
  106. keyword:"",
  107. mescrollTopY:0,
  108. }
  109. },
  110. mounted() {
  111. const system = uni.getSystemInfoSync();
  112. let navigationBarHeight=0,tabHei=88,searchBarHei=120;
  113. let tempHei=navigationBarHeight;
  114. tempHei=tempHei+uni.upx2px(tabHei+searchBarHei);
  115. this.mescrollTopY=tempHei+"px";
  116. },
  117. onShow(){
  118. },
  119. onLoad(){
  120. this.getCourseCate();
  121. },
  122. created(){
  123. let that = this;
  124. uni.$on('refreshMyNote', function(data) {
  125. that.refreshPage();
  126. });
  127. },
  128. destroyed() {
  129. // 注销全局配置监听
  130. uni.$off('refreshMyNote');
  131. },
  132. methods: {
  133. /*下拉刷新的回调 */
  134. downCallback() {
  135. this.refreshPage();
  136. },
  137. /*上拉加载的回调*/
  138. upCallback(page) {
  139. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  140. let params={};
  141. if(this.cateId==0){
  142. params={"keyword":this.keyword};
  143. }else{
  144. params={"cateId":this.cateId,"keyword":this.keyword};
  145. }
  146. getMyCourseNoteList(params,page.num).then(res => {
  147. if(res.code==200){
  148. setTimeout(()=>{
  149. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  150. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  151. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  152. this.totalNum=res.data.total;
  153. },300);
  154. }else{
  155. this.mescroll.endByPage(0, 1);
  156. }
  157. },
  158. rej => {}
  159. ).catch(()=>{
  160. //联网失败, 结束加载
  161. this.mescroll.endErr();
  162. });
  163. },
  164. refreshPage(){
  165. this.mescroll.hideTopBtn();
  166. this.mescroll.resetUpScroll(true);
  167. },
  168. getCourseCate:function(){
  169. let that=this;
  170. getCourseCate().then(res => {
  171. if(res.code==200){
  172. this.mtabs=[{"dictValue": 0,"dictLabel": "全部"}];
  173. this.mtabs=this.mtabs.concat(res.data);
  174. if(this.mtabs.length>0){
  175. this.refreshPage();
  176. }
  177. }
  178. },
  179. rej => {}
  180. );
  181. },
  182. tabChange(index){
  183. this.tabIndex=index;
  184. const item=this.mtabs[index];
  185. if(item){
  186. this.cateId=item.dictValue;
  187. this.refreshPage();
  188. }
  189. },
  190. goToMyNote(item){
  191. //if(item.noteType!=2){
  192. this.$navTo('./myNote?noteId='+item.noteId+"&noteType="+item.noteType);
  193. //}
  194. },
  195. emptyClick() {
  196. },
  197. }
  198. }
  199. </script>
  200. <style scoped lang="scss">
  201. page{
  202. // height: 100%;
  203. background-color: #f7f7f7;
  204. }
  205. .search-box {
  206. width: calc(100% - 60rpx);
  207. height: 70rpx;
  208. display: flex;
  209. flex-direction: row;
  210. align-items: center;
  211. justify-content: space-between;
  212. background: #fff;
  213. border-radius: 35rpx;
  214. margin: 0 auto;
  215. padding-left: 30rpx;
  216. // position: relative;
  217. // z-index: 10;
  218. .left{
  219. display: flex;
  220. flex-direction: row;
  221. align-items: center;
  222. justify-content: flex-start;
  223. }
  224. image{
  225. width: 28upx;
  226. height: 28upx;
  227. margin-right: 16upx;
  228. }
  229. .input-text{
  230. color: #333;
  231. font-size: 24rpx;
  232. height: 70rpx;
  233. line-height:70rpx ;
  234. }
  235. .uni-input-placeholder{
  236. color:#999;
  237. }
  238. .button{
  239. background: #2583EB;
  240. border-radius: 29rpx;
  241. width: 108rpx;
  242. height: 54rpx;
  243. line-height: 54rpx;
  244. color: #fff;
  245. font-size: 26rpx;
  246. margin-right: 10rpx;
  247. }
  248. }
  249. .item_bg1{ background-color:#EBF2FB;}
  250. .tit_color_1{color: #0173FF;}
  251. .item_bg2{background-color:#FFF0EA;}
  252. .tit_color_2{color: #FF661A;}
  253. .item_bg3{background-color:#ECFBF1;}
  254. .tit_color_3{color: #00A31B;}
  255. .cor_6a{ color: #6A6A6A;}
  256. .tabBg{
  257. z-index: 20;
  258. position: relative;
  259. &::after{
  260. content: '';
  261. width: 100%;
  262. height:2rpx;
  263. position: absolute;
  264. left: 0;
  265. bottom: 0;
  266. background: #E5E5E5;
  267. }
  268. }
  269. .mescroll-uni-fixed{
  270. background-color: #f7f7f7 !important;
  271. }
  272. .mescroll-empty{
  273. background-color: #f7f7f7 !important;
  274. }
  275. </style>