noteList.vue 9.9 KB

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