learning.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="content" >
  3. <u-sticky offsetTop="0" customNavHeight="0">
  4. <view class="grace-page-header" :style="{background:headerBG }">
  5. <!-- 沉浸式状态栏 -->
  6. <view class="grace-page-status-bar"></view>
  7. <!-- 头部核心 -->
  8. <view class="grace-page-header-nav" id="gracePageHeader" :style="{minHeight:headerHeight+'px', height:headerHeight+'px', overflow:'hidden'}">
  9. <view class="u-nav-back" @click="goBack">
  10. <image class="img" src="@/static/images/course/icon_back_w.png" mode="heightFix"></image>
  11. </view>
  12. <view class="grace-header-main">在学课程</view>
  13. </view>
  14. </view>
  15. <view class="nav_bar">
  16. <view class="search-header-nav" style="box-sizing:content-box;">
  17. <view class="search-header-main" style="height: auto;">
  18. <image src="/static/images/course/icon_search.png" mode=""></image>
  19. <input class="input-text" @input="inputEvent" type="text" placeholder="搜索课程内容"/>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="sticky-tabs">
  24. <me-tabs :value="tabIndex" :tabs="tabs" :height="88" @change="tabChange"></me-tabs>
  25. </view>
  26. </u-sticky>
  27. <!-- <mescroll-uni ref="mescrollRef" style="background-color: #EEEEEE;" :top="88" bottom="20" :down="downOption" :up="upOption"
  28. @down="downCallback" @up="upCallback"> -->
  29. <view class="cont-box">
  30. <view class="scroll">
  31. <learning-page :i="0" v-show="tabIndex == 0" :index="tabIndex" ref="mescrollItem0"></learning-page>
  32. <favorite-page :i="1" v-show="tabIndex == 1" :index="tabIndex" ref="mescrollItem1"></favorite-page>
  33. </view>
  34. </view>
  35. <!-- </mescroll-uni> -->
  36. </view>
  37. </template>
  38. <script>
  39. import MescrollCompMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-comp.js";
  40. import MescrollMoreMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more.js";
  41. import learningPage from "./learningPage.vue"
  42. import favoritePage from "./favoritePage.vue"
  43. export default {
  44. mixins: [ MescrollCompMixin,MescrollMoreMixin], //mescroll-body写在子组件时
  45. components: {
  46. learningPage,
  47. favoritePage,
  48. },
  49. data() {
  50. return {
  51. headerHeight:44,
  52. navigationBarHeight:44,
  53. headerBG:"#FF5C03",
  54. statusBarBG:"none",
  55. downOption: { //下拉刷新
  56. use:false,
  57. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  58. },
  59. upOption: { //上拉加载
  60. auto: false, // 不自动加载
  61. page: {
  62. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  63. size: 10 // 每页数据的数量
  64. },
  65. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  66. empty: {
  67. tip: '~ 空空如也 ~' // 提示
  68. // btnText: '去看看'
  69. }
  70. },
  71. tabs: [
  72. {dictLabel:'在学课程', num:1, y:0, curPageLen:0, hasNext:false,hasInit:false},
  73. {dictLabel:'我的收藏', num:1, y:0, curPageLen:0, hasNext:true,hasInit:false}
  74. ],
  75. tabIndex: 0, // tab下标
  76. current: 0,
  77. mtabs:["精选","疾病","名医","养生","用药"],
  78. fixedTop: false,
  79. tabTop:0,
  80. }
  81. },
  82. created() {
  83. var system = uni.getSystemInfoSync();
  84. system.model = system.model.replace(' ', '');
  85. system.model = system.model.toLowerCase();
  86. if (system.model.indexOf('iphonex') != -1 || system.model.indexOf('iphone1') != -1) {
  87. this.iphoneXButtomHeight = uni.upx2px(50);
  88. }
  89. this.navigationBarHeight=78;
  90. //this.tabTop=uni.upx2px(this.statusBarHeight)+58;
  91. },
  92. methods: {
  93. /*下拉刷新的回调 */
  94. downCallback() {
  95. this.mescroll.resetUpScroll(true);
  96. var that=this;
  97. this.requestData();
  98. },
  99. /*上拉加载的回调*/
  100. upCallback(page) {
  101. this.mescroll.endByPage(1, 1);
  102. //this.mescroll.endSuccess(8,false);
  103. // if (page.num == 1) {
  104. // this.mescroll.endSuccess(8, false);
  105. // } else {
  106. // this.mescroll.endErr()
  107. // }
  108. },
  109. requestData(){
  110. },
  111. // 切换菜单
  112. tabChange (index) {
  113. // let preTab = this.tabs[this.preIndex]
  114. // preTab.y = this.mescroll.getScrollTop()
  115. // this.preIndex = index;
  116. this.tabIndex=index;
  117. // this.mescroll.optUp.use=this.tabIndex>0;
  118. // let curTab = this.tabs[index];
  119. // if(index==0){
  120. // this.mescroll.hideUpScroll();
  121. // this.mescroll.removeEmpty();
  122. // this.$nextTick(()=>{
  123. // this.mescroll.scrollTo(curTab.y, 0) // 恢复滚动条的位置
  124. // });
  125. // }
  126. this.$nextTick(()=>{
  127. const el = "mescrollItem"+ this.tabIndex
  128. let mescrollP=this.$refs[el];
  129. mescrollP.keyword= this.keyword;
  130. mescrollP.mescroll.resetUpScroll();
  131. })
  132. },
  133. inputEvent(event){
  134. // let vForItem = this.$refs["mescrollItem"+this.tabIndex];
  135. const el = "mescrollItem"+ this.tabIndex
  136. let mescrollP=this.$refs[el];
  137. this.keyword=event.detail.value;
  138. mescrollP.keyword= this.keyword;
  139. mescrollP.mescroll.resetUpScroll();
  140. },
  141. // 页面跳转
  142. navTo(url) {
  143. console.log("qxj url:"+url);
  144. uni.navigateTo({
  145. url: url
  146. })
  147. },
  148. goBack() {
  149. uni.navigateBack({
  150. delta:1,
  151. animationType: 'slide-out-right',
  152. animationDuration: 200
  153. });
  154. },
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. page{
  160. height: 100%;
  161. background-color: #f7f7f7;
  162. }
  163. .grace-page-header {
  164. .grace-page-status-bar {
  165. width: 100%;
  166. height: var(--status-bar-height);
  167. }
  168. .grace-page-header-nav {
  169. width: 100%;
  170. display: flex;
  171. flex-direction: row;
  172. flex-wrap: nowrap;
  173. align-items: center;
  174. }
  175. .grace-header-main {
  176. width: 300rpx;
  177. flex: auto;
  178. overflow: hidden;
  179. margin:0 20rpx;
  180. height: 48rpx;
  181. text-align: center;
  182. color: #fff;
  183. }
  184. }
  185. .nav_bar {
  186. height: 44px;
  187. width: 100%;
  188. background: #FF5C03;
  189. padding: 25rpx 0;
  190. padding-top: 5rpx;
  191. .search-header-nav {
  192. width: 100%;
  193. display: flex;
  194. flex-direction: row;
  195. flex-wrap: nowrap;
  196. align-items: center;
  197. background: #FF5C03;
  198. }
  199. .search-header-main {
  200. width: 300rpx;
  201. flex: auto;
  202. overflow: hidden;
  203. margin:0 20rpx;
  204. height: 48rpx;
  205. background: #fff;
  206. border-radius: 35rpx;
  207. padding: 10rpx 20upx;
  208. display: flex;
  209. justify-content: flex-start;
  210. align-items: center;
  211. image{
  212. width: 28upx;
  213. height: 28upx;
  214. margin-right: 16upx;
  215. }
  216. }
  217. .input-text{
  218. color: #333;
  219. font-size: 24rpx;
  220. height: 50rpx;
  221. line-height:50rpx ;
  222. width: 100%;
  223. }
  224. .uni-input-placeholder{
  225. color:#999;
  226. }
  227. }
  228. .u-nav-back{
  229. display: flex;
  230. align-items: center;
  231. position: absolute;
  232. left:32rpx;
  233. .img{
  234. height: 42upx;
  235. }
  236. }
  237. .scroll{
  238. width: 100%;
  239. flex: 1;
  240. display: flex;
  241. flex-direction: column;
  242. overflow: hidden;
  243. }
  244. </style>