noteList.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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/images/course/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">{{ utils.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">{{ utils.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">{{ utils.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/images/icon_img_empty.png"
  94. }
  95. },
  96. tabIndex: 0, // tab下标
  97. current: 0,
  98. mtabs:[],
  99. fixedTop: false,
  100. tabTop:0,
  101. top:0,
  102. cateId:0,
  103. dataList:[],
  104. keyword:"",
  105. mescrollTopY:0,
  106. }
  107. },
  108. onPageScroll(e) {
  109. this.top=e.scrollTop;
  110. },
  111. computed: {
  112. // 计算属性的 getter
  113. headerBG:function() {
  114. var top=this.top/88;
  115. return 'rgba(255,92,3, ' + top + ')';
  116. },
  117. },
  118. mounted() {
  119. const system = uni.getSystemInfoSync();
  120. let navigationBarHeight=44,tabHei=110,searchBarHei=44;
  121. let tempHei=navigationBarHeight+searchBarHei+system.statusBarHeight;
  122. tempHei=tempHei+uni.upx2px(tabHei);
  123. this.mescrollTopY=tempHei+"px";
  124. },
  125. onShow(){
  126. },
  127. onLoad(){
  128. this.getCourseCate();
  129. },
  130. created(){
  131. let that = this;
  132. uni.$on('refreshMyNote', function(data) {
  133. that.refreshPage();
  134. });
  135. },
  136. destroyed() {
  137. // 注销全局配置监听
  138. uni.$off('refreshMyNote');
  139. },
  140. methods: {
  141. /*下拉刷新的回调 */
  142. downCallback() {
  143. this.refreshPage();
  144. },
  145. /*上拉加载的回调*/
  146. upCallback(page) {
  147. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  148. let params={};
  149. if(this.cateId==0){
  150. params={"keyword":this.keyword};
  151. }else{
  152. params={"cateId":this.cateId,"keyword":this.keyword};
  153. }
  154. getMyCourseNoteList(params,page.num).then(res => {
  155. if(res.code==200){
  156. setTimeout(()=>{
  157. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  158. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  159. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  160. this.totalNum=res.data.total;
  161. },300);
  162. }else{
  163. this.mescroll.endByPage(0, 1);
  164. }
  165. },
  166. rej => {}
  167. ).catch(()=>{
  168. //联网失败, 结束加载
  169. this.mescroll.endErr();
  170. });
  171. },
  172. refreshPage(){
  173. this.mescroll.hideTopBtn();
  174. this.mescroll.resetUpScroll(true);
  175. },
  176. getCourseCate:function(){
  177. let that=this;
  178. getCourseCate().then(res => {
  179. if(res.code==200){
  180. this.mtabs=[{"dictValue": 0,"dictLabel": "全部"}];
  181. this.mtabs=this.mtabs.concat(res.data);
  182. if(this.mtabs.length>0){
  183. this.refreshPage();
  184. }
  185. }
  186. },
  187. rej => {}
  188. );
  189. },
  190. tabChange(index){
  191. this.tabIndex=index;
  192. const item=this.mtabs[index];
  193. if(item){
  194. this.cateId=item.dictValue;
  195. this.refreshPage();
  196. }
  197. },
  198. goToMyNote(item){
  199. //if(item.noteType!=2){
  200. this.$navTo('./myNote?noteId='+item.noteId+"&noteType="+item.noteType);
  201. //}
  202. },
  203. emptyClick() {
  204. },
  205. }
  206. }
  207. </script>
  208. <style scoped lang="scss">
  209. page{
  210. height: 100%;
  211. background-color: #f7f7f7;
  212. }
  213. .content{
  214. /* #ifdef APP-PLUS */
  215. flex: 1;
  216. /* #endif */
  217. /* #ifndef APP-PLUS */
  218. //display: flex;
  219. /* #endif */
  220. display: flex;
  221. flex-direction: column;
  222. width: 100%;
  223. min-height: 100%;
  224. flex: 1;
  225. }
  226. .grace-page-header {
  227. width: 100%;
  228. position: fixed;
  229. left: 0;
  230. top: 0;
  231. z-index: 99;
  232. border-bottom: 0px solid #FFFFFF;
  233. .grace-page-status-bar {
  234. width: 100%;
  235. height: 0;
  236. }
  237. .grace-page-header-nav {
  238. width: 100%;
  239. display: flex;
  240. flex-direction: row;
  241. flex-wrap: nowrap;
  242. align-items: center;
  243. }
  244. .grace-header-main {
  245. width: 300rpx;
  246. flex: auto;
  247. overflow: hidden;
  248. margin:0 20rpx;
  249. height: 48rpx;
  250. text-align: center;
  251. color: #fff;
  252. }
  253. }
  254. .u-nav-back{
  255. display: flex;
  256. align-items: center;
  257. position: absolute;
  258. left:32rpx;
  259. .img{
  260. height: 42upx;
  261. }
  262. }
  263. .u-nav-right{
  264. position: absolute;
  265. right:20rpx;
  266. .right-icon{
  267. width: 35rpx;
  268. height: 33rpx;
  269. margin-right: 10rpx;
  270. }
  271. }
  272. .bg-img{
  273. position: fixed;
  274. width: 100%;
  275. height: 500rpx;
  276. top: 0;
  277. left: 0;
  278. right: 0;
  279. bottom: 0;
  280. z-index: 0;
  281. }
  282. .search-box {
  283. width: calc(100% - 60rpx);
  284. height: 70rpx;
  285. display: flex;
  286. flex-direction: row;
  287. align-items: center;
  288. justify-content: space-between;
  289. background: #fff;
  290. border-radius: 35rpx;
  291. margin:30rpx;
  292. margin-bottom: 20rpx;
  293. padding-left: 30rpx;
  294. position: relative;
  295. z-index: 10;
  296. .left{
  297. display: flex;
  298. flex-direction: row;
  299. align-items: center;
  300. justify-content: flex-start;
  301. }
  302. image{
  303. width: 28upx;
  304. height: 28upx;
  305. margin-right: 16upx;
  306. }
  307. .input-text{
  308. color: #333;
  309. font-size: 24rpx;
  310. height: 70rpx;
  311. line-height:70rpx ;
  312. }
  313. .uni-input-placeholder{
  314. color:#999;
  315. }
  316. .button{
  317. background: #FF5C03;
  318. border-radius: 29rpx;
  319. width: 108rpx;
  320. height: 54rpx;
  321. line-height: 54rpx;
  322. color: #fff;
  323. font-size: 26rpx;
  324. margin-right: 10rpx;
  325. }
  326. }
  327. .item_bg1{ background-color:#EBF2FB;}
  328. .tit_color_1{color: #0173FF;}
  329. .item_bg2{background-color:#FFF0EA;}
  330. .tit_color_2{color: #FF661A;}
  331. .item_bg3{background-color:#ECFBF1;}
  332. .tit_color_3{color: #00A31B;}
  333. .cor_6a{ color: #6A6A6A;}
  334. .tabBg{
  335. z-index: 20;
  336. position: relative;
  337. &::after{
  338. content: '';
  339. width: 100%;
  340. height:2rpx;
  341. position: absolute;
  342. left: 0;
  343. bottom: 0;
  344. background: #E5E5E5;
  345. }
  346. }
  347. .mescroll-uni-fixed{
  348. background-color: #f7f7f7 !important;
  349. }
  350. .mescroll-empty{
  351. background-color: #f7f7f7 !important;
  352. }
  353. </style>