learning.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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/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/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. imageList:["../../static/image/home/banner1.png"],
  72. tabs: [
  73. {dictLabel:'在学课程', num:1, y:0, curPageLen:0, hasNext:false,hasInit:false},
  74. {dictLabel:'我的收藏', num:1, y:0, curPageLen:0, hasNext:true,hasInit:false}
  75. ],
  76. tabIndex: 0, // tab下标
  77. current: 0,
  78. mtabs:["精选","疾病","名医","养生","用药"],
  79. fixedTop: false,
  80. tabTop:0,
  81. }
  82. },
  83. created() {
  84. var system = uni.getSystemInfoSync();
  85. system.model = system.model.replace(' ', '');
  86. system.model = system.model.toLowerCase();
  87. if (system.model.indexOf('iphonex') != -1 || system.model.indexOf('iphone1') != -1) {
  88. this.iphoneXButtomHeight = uni.upx2px(50);
  89. }
  90. this.navigationBarHeight=78;
  91. //this.tabTop=uni.upx2px(this.statusBarHeight)+58;
  92. },
  93. methods: {
  94. /*下拉刷新的回调 */
  95. downCallback() {
  96. this.mescroll.resetUpScroll(true);
  97. var that=this;
  98. this.requestData();
  99. },
  100. /*上拉加载的回调*/
  101. upCallback(page) {
  102. this.mescroll.endByPage(1, 1);
  103. //this.mescroll.endSuccess(8,false);
  104. // if (page.num == 1) {
  105. // this.mescroll.endSuccess(8, false);
  106. // } else {
  107. // this.mescroll.endErr()
  108. // }
  109. },
  110. requestData(){
  111. },
  112. // 切换菜单
  113. tabChange (index) {
  114. // let preTab = this.tabs[this.preIndex]
  115. // preTab.y = this.mescroll.getScrollTop()
  116. // this.preIndex = index;
  117. this.tabIndex=index;
  118. // this.mescroll.optUp.use=this.tabIndex>0;
  119. // let curTab = this.tabs[index];
  120. // if(index==0){
  121. // this.mescroll.hideUpScroll();
  122. // this.mescroll.removeEmpty();
  123. // this.$nextTick(()=>{
  124. // this.mescroll.scrollTo(curTab.y, 0) // 恢复滚动条的位置
  125. // });
  126. // }
  127. this.$nextTick(()=>{
  128. const el = "mescrollItem"+ this.tabIndex
  129. let mescrollP=this.$refs[el];
  130. mescrollP.keyword= this.keyword;
  131. mescrollP.mescroll.resetUpScroll();
  132. })
  133. },
  134. inputEvent(event){
  135. // let vForItem = this.$refs["mescrollItem"+this.tabIndex];
  136. const el = "mescrollItem"+ this.tabIndex
  137. let mescrollP=this.$refs[el];
  138. this.keyword=event.detail.value;
  139. mescrollP.keyword= this.keyword;
  140. mescrollP.mescroll.resetUpScroll();
  141. },
  142. // 页面跳转
  143. navTo(url) {
  144. console.log("qxj url:"+url);
  145. uni.navigateTo({
  146. url: url
  147. })
  148. },
  149. goBack() {
  150. uni.navigateBack({
  151. delta:1,
  152. animationType: 'slide-out-right',
  153. animationDuration: 200
  154. });
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. page{
  161. height: 100%;
  162. background-color: #f7f7f7;
  163. }
  164. .grace-page-header {
  165. .grace-page-status-bar {
  166. width: 100%;
  167. height: var(--status-bar-height);
  168. }
  169. .grace-page-header-nav {
  170. width: 100%;
  171. display: flex;
  172. flex-direction: row;
  173. flex-wrap: nowrap;
  174. align-items: center;
  175. }
  176. .grace-header-main {
  177. width: 300rpx;
  178. flex: auto;
  179. overflow: hidden;
  180. margin:0 20rpx;
  181. height: 48rpx;
  182. text-align: center;
  183. color: #fff;
  184. }
  185. }
  186. .nav_bar {
  187. height: 44px;
  188. width: 100%;
  189. background: #FF5C03;
  190. padding: 25rpx 0;
  191. padding-top: 5rpx;
  192. .search-header-nav {
  193. width: 100%;
  194. display: flex;
  195. flex-direction: row;
  196. flex-wrap: nowrap;
  197. align-items: center;
  198. background: #FF5C03;
  199. }
  200. .search-header-main {
  201. width: 300rpx;
  202. flex: auto;
  203. overflow: hidden;
  204. margin:0 20rpx;
  205. height: 48rpx;
  206. background: #fff;
  207. border-radius: 35rpx;
  208. padding: 10rpx 20upx;
  209. display: flex;
  210. justify-content: flex-start;
  211. align-items: center;
  212. image{
  213. width: 28upx;
  214. height: 28upx;
  215. margin-right: 16upx;
  216. }
  217. }
  218. .input-text{
  219. color: #333;
  220. font-size: 24rpx;
  221. height: 50rpx;
  222. line-height:50rpx ;
  223. width: 100%;
  224. }
  225. .uni-input-placeholder{
  226. color:#999;
  227. }
  228. }
  229. .u-nav-back{
  230. display: flex;
  231. align-items: center;
  232. position: absolute;
  233. left:32rpx;
  234. .img{
  235. height: 42upx;
  236. }
  237. }
  238. .scroll{
  239. width: 100%;
  240. flex: 1;
  241. display: flex;
  242. flex-direction: column;
  243. overflow: hidden;
  244. }
  245. </style>