index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. <template>
  2. <view class="container">
  3. <!-- 加载状态 -->
  4. <view v-if="pageLoading" class="page-loading">
  5. <view class="loading-content">
  6. <view class="loading-spinner"></view>
  7. <text class="loading-text">加载中...</text>
  8. </view>
  9. </view>
  10. <!-- <image class="home_top_bg" src="@/static/newYear/home_top_bg.png" mode="widthFix" :lazy-load="false"></image> -->
  11. <image class="home_top_bg" src="@/static/image/hall/home_top_bg.png" mode="widthFix" :lazy-load="false"></image>
  12. <view class="tabbox">
  13. <u-tabs
  14. ref="uTabs"
  15. :list="tabList"
  16. :current="activeTab"
  17. :scrollable="true"
  18. :lineColor="`url(${lineBg}) 40rpx 12rpx`"
  19. lineWidth="40rpx"
  20. lineHeight="12rpx"
  21. :inactiveStyle="{
  22. fontWeight: 600,
  23. fontSize: '32rpx',
  24. color: '#222222',
  25. lineHeight: '88rpx',
  26. }"
  27. :activeStyle="{
  28. fontWeight: 600,
  29. fontSize: '40rpx',
  30. color: '#FF5C03',
  31. lineHeight: '88rpx',
  32. }"
  33. itemStyle="margin: 10rpx 0"
  34. @change="handleTab"></u-tabs>
  35. </view>
  36. <!-- 新手指引 -->
  37. <view class="guidebox" v-if="showGuide" @touchmove.stop.prevent @click="closeGuide('mask')">
  38. <view class="guide" :style="guideStyle" @click.stop.prevent>
  39. <!-- 学习中心新手指引 -->
  40. <!-- <view class="guide-step-tips" :style="tipPosition" v-if="activeTab == 1">
  41. <image class="Frame2612" src="@/static/images/guide/Frame2612.png" mode="aspectFill"></image>
  42. 你可以在这里查询在学课程、学习笔记、收藏课程,对你学习进度进行跟踪。
  43. </view> -->
  44. <!-- 名医讲堂新手指引 -->
  45. <view class="guide3-step-tips2" :style="tipPosition" v-if="activeTab == 0">
  46. <view class="guide3-toptip">
  47. <view class="guide3-toptip-head">
  48. <image class="Frame2611" src="@/static/images/guide/Frame2611.png" mode="aspectFill"></image>
  49. <text>知名中医大师、达人亲自授课</text>
  50. <image class="guide3-toptip-headbg" src="@/static/images/guide/Frame2614.png" mode="widthFix"></image>
  51. </view>
  52. <view>分享他们在各自专业领域的丰富经验和独到见解。 </view>
  53. </view>
  54. <view :style="tipsCenter"></view>
  55. <view class="guide3-btn" @click="closeGuide()">我知道啦</view>
  56. </view>
  57. </view>
  58. <!-- 名医讲堂新手指引(图片模式) -->
  59. <!-- <view class="guide" v-if="activeTab ==0" @click.stop.prevent>
  60. <view class="guide3-step-tips">
  61. <view class="guide3-step-tipsbox">
  62. <view class="guide3-toptip">
  63. <view class="guide3-toptip-head">
  64. <image class="Frame2611" src="@/static/images/guide/Frame2611.png" mode="aspectFill"></image>
  65. <text>知名中医大师、达人亲自授课</text>
  66. <image class="guide3-toptip-headbg" src="@/static/images/guide/Frame2614.png" mode="widthFix"></image>
  67. </view>
  68. <view>分享他们在各自专业领域的丰富经验和独到见解。 </view>
  69. </view>
  70. <image class="Frame2291" src="@/static/images/guide/Frame2291.png" mode="widthFix"></image>
  71. </view>
  72. <view class="guide3-btn" @click="closeGuide()">我知道啦</view>
  73. </view>
  74. </view> -->
  75. </view>
  76. <!-- 内容 -->
  77. <swiper :current="activeTab" @change="onSwiperChange" :style="'height:' + (clientHeight || '100vh') + 'px;'">
  78. <swiper-item>
  79. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" :scroll-top="scrollTopHall" @scroll="scroll($event,'scrollTopHall')" :refresher-enabled="true"
  80. :refresher-triggered="triggered"
  81. @refresherrefresh="handleRefresher">
  82. <doctorHall ref="doctorHall" :swiperAutoplay="swiperAutoplay" @loadFamousCourse="loadFamousCourse(0)"/>
  83. </scroll-view>
  84. </swiper-item>
  85. <swiper-item>
  86. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" :scroll-top="scrollTopStudy" @scroll="scroll($event,'scrollTopStudy')" :refresher-enabled="true"
  87. :refresher-triggered="triggered"
  88. @refresherrefresh="handleRefresher">
  89. <studyCenter ref="studyCenter"/>
  90. </scroll-view>
  91. </swiper-item>
  92. <!-- <swiper-item>
  93. <scroll-view
  94. scroll-y="true"
  95. :style="'height:' + clientHeight + 'px;'"
  96. :scroll-top="scrollTopGoods"
  97. @scrolltolower="scrolltolower"
  98. @scroll="scroll($event,'scrollTopGoods')"
  99. :refresher-enabled="true"
  100. :refresher-triggered="triggered"
  101. @refresherrefresh="handleRefresher">
  102. <integralGoods ref="integralGoods"></integralGoods>
  103. <view class="back-top" v-show="scrollTopGoods>clientHeight" @click="goTop">
  104. <image src="https://www.mescroll.com/img/mescroll-totop.png" mode="aspectFill"></image>
  105. </view>
  106. </scroll-view>
  107. </swiper-item> -->
  108. <swiper-item>
  109. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'">
  110. <homeIndex ref="homeIndex" source="course" />
  111. </scroll-view>
  112. </swiper-item>
  113. <swiper-item v-if="!isXiaomi">
  114. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'">
  115. <watchIndex ref="watchIndex" source="course" />
  116. </scroll-view>
  117. </swiper-item>
  118. </swiper>
  119. <!-- 新用户72h内弹免费领礼品弹窗 -->
  120. <giftPopup ref="giftPopup"></giftPopup>
  121. <activityPop class="activityPop" ref="activityPop" />
  122. <!-- 签到弹窗 -->
  123. <signPop ref="signPop" :userSign="userSign" />
  124. </view>
  125. </template>
  126. <script>
  127. import { getUserSign} from '@/api/integral.js';
  128. import watchIndex from "@/pages/index/components/watchIndex.vue";
  129. import homeIndex from "@/pages/index/components/homeIndex.vue";
  130. import {getUserActiveWindow} from "@/api/activity.js"
  131. // import integralGoods from './components/integralGoods.vue';
  132. import doctorHall from './components/doctorHall.vue';
  133. import studyCenter from './components/studyCenter.vue';
  134. import giftPopup from './components/giftPopup.vue';
  135. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  136. import mescrollBody from "@/uni_modules/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  137. import { getDictByKey } from '@/api/common'
  138. import { getCourseCate,getCourseList } from '@/api/course'
  139. import { getAdvList} from '@/api/adv.js'
  140. import { isCreateAd } from '@/api/user.js'
  141. import { Igexin } from '@/pages_im/util/common.js';
  142. import activityPop from "@/components/signPop/activityPop.vue"
  143. const lineBg = "/static/image/hall/hall_on_icon.png";
  144. export default {
  145. mixins: [MescrollMixin], // 使用mixin
  146. components: {
  147. mescrollBody,
  148. doctorHall,
  149. studyCenter,
  150. giftPopup,
  151. // integralGoods,
  152. activityPop,
  153. watchIndex,
  154. homeIndex
  155. },
  156. data() {
  157. return {
  158. lineBg,
  159. tabsLineShow: false,
  160. headerHeight:44,
  161. statusBarBG:"none",
  162. headerIndex:98,
  163. isXiaomi:false,
  164. pageLoading: true, // 页面加载状态
  165. downOption: { //下拉刷新
  166. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  167. },
  168. upOption: { //上拉加载
  169. auto: false, // 不自动加载
  170. page: {
  171. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  172. size: 10 // 每页数据的数量
  173. },
  174. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  175. empty: {
  176. tip: '~ 空空如也 ~' // 提示
  177. // btnText: '去看看'
  178. }
  179. },
  180. //imageList:["../../static/image/home/banner.png"],
  181. imageList:[],
  182. advs:[],
  183. mtabs:[],
  184. tabIndex: 0, // 当前tab的下标
  185. fixedTop: false,
  186. top:0,
  187. cateId:0,
  188. isBest:false,
  189. dataList:[],
  190. recommendList:[],
  191. swHeightArr:{},
  192. swHeight: "400px",
  193. keyWord:"",
  194. dataItem:{},
  195. swiperAutoplay:true,
  196. famousItemHei:0,
  197. scrollTopHall: 0,
  198. scrollTopStudy: 0,
  199. scrollTopGoods: 0,
  200. old: {
  201. scrollTopStudy: 0,
  202. scrollTopHall: 0,
  203. scrollTopGoods: 0
  204. },
  205. activeTab: 0,
  206. indicatorLineLeft: 0,
  207. indicatorLineWidth: 0,
  208. tabList: [
  209. {
  210. id: "tab01",
  211. name: '名家讲堂'
  212. }, {
  213. id: "tab02",
  214. name: '学习中心'
  215. },{
  216. id: "tab03",
  217. name: '医疗服务'
  218. }
  219. ],
  220. clientHeight:0,
  221. scrollViewId:'scrollView0',
  222. showGuide: false, // 是否显示引导
  223. guideStyle: "",
  224. tipPosition: "",
  225. tipsCenter: "",
  226. isShowGiftPopup: false,
  227. triggered: false,
  228. statusBarHeight: 0,
  229. haveFamousCourse: false,
  230. userSign:{},
  231. initializedTabs: new Set(), // 已初始化的tab索引
  232. }
  233. },
  234. onPageScroll(e) {
  235. this.top=e.scrollTop;
  236. this.scrollTopGoods = e.scrollTop;
  237. },
  238. computed: {
  239. // 计算属性的 getter
  240. headerBG:function() {
  241. var top=this.top/88;
  242. return 'rgba(255,92,3, ' + top + ')';
  243. },
  244. },
  245. onReady() {
  246. // 同步获取系统信息,避免异步延迟
  247. try {
  248. const systemInfo = uni.getSystemInfoSync();
  249. this.clientHeight = systemInfo.windowHeight - uni.upx2px(120) - systemInfo.statusBarHeight;
  250. } catch (e) {
  251. // 降级到异步获取
  252. uni.getSystemInfo({
  253. success: (res) => {
  254. this.clientHeight = res.windowHeight - uni.upx2px(120) - res.statusBarHeight;
  255. }
  256. });
  257. }
  258. this.tabListSize = {};
  259. const resizeTabs = () => {
  260. this.$refs.uTabs && this.$refs.uTabs.resize();
  261. };
  262. // 合并多个 setTimeout,减少延迟
  263. this.$nextTick(() => {
  264. resizeTabs();
  265. // 使用 requestAnimationFrame 优化渲染时机
  266. const finishInit = () => {
  267. resizeTabs();
  268. this.tabsLineShow = true;
  269. // 标记页面已加载(在关键渲染完成后)
  270. this.pageLoading = false;
  271. // 延迟初始化非当前tab的组件
  272. setTimeout(() => {
  273. if (this.$refs.homeIndex) {
  274. this.$refs.homeIndex.initShow();
  275. }
  276. if (this.$refs.watchIndex) {
  277. this.$refs.watchIndex.initShow();
  278. }
  279. }, 100);
  280. };
  281. if (typeof requestAnimationFrame !== 'undefined') {
  282. requestAnimationFrame(finishInit);
  283. } else {
  284. setTimeout(finishInit, 50);
  285. }
  286. });
  287. },
  288. onShow(){
  289. // #ifdef APP-PLUS
  290. if (this.$isAgreePrivacy()) {
  291. if (plus.runtime.channel == 'baidu') {
  292. let bdCmdType = uni.getStorageSync('bdCmdType');
  293. if (this.$isEmpty(bdCmdType)) {
  294. this.$registerIdCode('activate', 0, 0);
  295. }
  296. }
  297. }
  298. // #endif
  299. if(!this.$isLogin()){
  300. uni.navigateTo({
  301. url: '/pages/auth/loginIndex'
  302. })
  303. return;
  304. }
  305. // 非阻塞操作,延迟执行
  306. this.$updateMsgDot()
  307. this.swiperAutoplay=true;
  308. // 延迟执行非关键操作,避免阻塞渲染
  309. this.$nextTick(() => {
  310. this.$refs.uTabs && this.$refs.uTabs.resize();
  311. // 只初始化当前可见的tab,其他tab延迟加载
  312. this.initCurrentTab();
  313. // 延迟执行非关键操作
  314. setTimeout(() => {
  315. this.getCreateAd();
  316. }, 300);
  317. });
  318. },
  319. onHide() {
  320. this.swiperAutoplay=false;
  321. },
  322. onLoad(options){
  323. if(options.activeTab){
  324. this.activeTab = options.activeTab
  325. }
  326. // 同步获取系统信息,避免延迟
  327. try {
  328. const systemInfo = uni.getSystemInfoSync();
  329. this.statusBarHeight = systemInfo.statusBarHeight;
  330. // 提前设置 clientHeight,避免布局闪烁
  331. this.clientHeight = systemInfo.windowHeight - uni.upx2px(120) - systemInfo.statusBarHeight;
  332. this.isXiaomi=plus.runtime.channel == 'xiaomi';
  333. //this.isXiaomi=true;
  334. if(!this.isXiaomi){
  335. this.tabList.push({
  336. id: "tab04",
  337. name: '健康管理',
  338. });
  339. }
  340. } catch (e) {
  341. this.statusBarHeight = 0;
  342. }
  343. this.guideIndex=uni.getStorageSync("doctorHallGuide");
  344. // 延迟执行非关键操作,优先渲染页面
  345. if(this.$isLogin()){
  346. // 延迟获取签到信息,避免阻塞首屏渲染
  347. setTimeout(() => {
  348. this.getUserSign();
  349. }, 200);
  350. }else{
  351. let signStr="[{\"signNum\":10,\"sort\":1,\"day\":\"第1天\"},{\"signNum\":20,\"sort\":2,\"day\":\"第2天\"},{\"signNum\":30,\"sort\":3,\"day\":\"第3天\"},{\"signNum\":40,\"sort\":4,\"day\":\"第4天\"},{\"signNum\":50,\"sort\":5,\"day\":\"第5天\"},{\"signNum\":50,\"sort\":6,\"day\":\"第6天\"},{\"signNum\":50,\"sort\":7,\"day\":\"第7天\"}]";
  352. this.userSign={"signNum":0,"isDaySign":0,"integral":0,"sign":JSON.parse(signStr)};
  353. // 延迟显示弹窗,避免阻塞渲染
  354. this.$nextTick(()=>{
  355. if(this.source!='course' && this.$refs.signPop){
  356. setTimeout(() => {
  357. this.$refs.signPop.open();
  358. }, 500);
  359. }
  360. });
  361. }
  362. // #ifdef APP-PLUS
  363. if(this.$isAgreePrivacy()) {
  364. if(plus.runtime.channel=="baidu"){ //获取渠道标识
  365. let bdCmdType=uni.getStorageSync("bdCmdType");
  366. console.log("qxj bdCmdType:"+bdCmdType);
  367. if(this.$isEmpty(bdCmdType)){
  368. this.$registerIdCode("activate",0,0);
  369. }
  370. }
  371. }
  372. // #endif
  373. uni.$on('loginOut', function() {
  374. let IMUserID = uni.getStorageSync('IMUserID');
  375. //Igexin.unbindAlias(IMUserID);
  376. uni.removeStorage({key: "IMUserID"});
  377. uni.setStorageSync("AppToken",null);
  378. uni.removeStorage({ key: 'IMToken' });
  379. uni.removeStorageSync("onLaunch",null)
  380. uni.removeStorageSync("imUnread",null);
  381. uni.removeStorageSync("companyUser");
  382. uni.removeStorageSync("CompanyUserToken");
  383. uni.$emit("refreshUserInfo");
  384. let pages = getCurrentPages();
  385. let url = pages[ pages.length - 1]; //当前页页面实例
  386. //如果登录界面已打开,自动关闭
  387. if(url!=undefined&&url.route=="pages/auth/loginIndex"){
  388. return;
  389. }
  390. uni.navigateTo({
  391. url: '/pages/auth/loginIndex'
  392. });
  393. });
  394. },
  395. mounted() {
  396. try {
  397. const system = uni.getSystemInfoSync();
  398. let itemWid=(system.windowWidth-40-32)*0.5*0.95;
  399. let tempHei=itemWid*0.5;
  400. tempHei=uni.upx2px(tempHei)+30;
  401. this.famousItemHei=tempHei;
  402. } catch (e) {
  403. }
  404. // 延迟执行活动弹窗检查,避免阻塞首屏
  405. setTimeout(() => {
  406. this.activityFun();
  407. }, 500);
  408. },
  409. methods: {
  410. getUserSign(){
  411. getUserSign().then(res => {
  412. if(res.code==200){
  413. this.userSign={"signNum":res.signNum,"isDaySign":res.isDaySign,"integral":res.integral,"sign":JSON.parse(res.sign)};
  414. // 延迟显示弹窗,避免阻塞渲染
  415. this.$nextTick(()=>{
  416. if(!res.isDaySign && this.$refs.signPop){
  417. setTimeout(() => {
  418. this.$refs.signPop.open();
  419. }, 500);
  420. }
  421. });
  422. }
  423. },
  424. rej => {}
  425. );
  426. },
  427. activityFun(){
  428. // 防抖处理,避免重复请求
  429. if (this._activityTimer) {
  430. clearTimeout(this._activityTimer);
  431. }
  432. this._activityTimer = setTimeout(() => {
  433. getUserActiveWindow().then(res=>{
  434. if(res.code == 200){
  435. if (res.isOpen && this.$refs.activityPop) {
  436. // 延迟显示弹窗,避免阻塞渲染
  437. setTimeout(() => {
  438. this.$refs.activityPop.open();
  439. }, 800);
  440. }
  441. }else{
  442. // 静默失败,不显示错误提示
  443. console.warn('获取活动窗口失败:', res.msg);
  444. }
  445. }).catch(err => {
  446. console.warn('获取活动窗口异常:', err);
  447. });
  448. }, 300);
  449. },
  450. goTop() {
  451. setTimeout(()=>{
  452. this.old.scrollTopGoods = 0
  453. this.scrollTopGoods = 0
  454. })
  455. },
  456. scroll(e,type) {
  457. this.old[type] = e.detail.scrollTop
  458. this.scrollTopGoods = this.old[type]
  459. },
  460. handleTab(e) {
  461. this.activeTab = e.index
  462. // if(this.haveFamousCourse) {
  463. // // 防止在没有名医讲堂数据的时候有指引弹窗
  464. // this.changeGuide(this.activeTab);
  465. // console.log("=handleTab=")
  466. // }
  467. // this.$nextTick(()=>{
  468. // this.selectorQuery()
  469. // })
  470. },
  471. loadFamousCourse(val){
  472. this.haveFamousCourse = true
  473. // this.changeGuide(val);
  474. },
  475. updateIndicator(left, width) {
  476. this.indicatorLineLeft = left;
  477. this.indicatorLineWidth = width;
  478. },
  479. selectorQuery() {
  480. uni.createSelectorQuery().in(this).selectAll('.tabbar-item').boundingClientRect((rects) => {
  481. rects.forEach((rect) => {
  482. this.tabListSize[rect.id] = rect;
  483. })
  484. this.updateIndicator(this.tabListSize[this.activeTab].left, this.tabListSize[this.activeTab].width);
  485. }).exec();
  486. },
  487. // swiper划动
  488. onSwiperChange(e){
  489. this.changeIdx(e.detail.current);
  490. },
  491. // 更新当前页
  492. changeIdx(index){
  493. if(this.activeTab === index) return;
  494. this.activeTab = index;
  495. this.scrollViewId = 'scrollView'+this.activeTab;
  496. // 初始化当前tab(懒加载)
  497. this.initCurrentTab();
  498. },
  499. // 初始化当前tab(懒加载优化)
  500. initCurrentTab() {
  501. if (this.initializedTabs.has(this.activeTab)) {
  502. return; // 已初始化,跳过
  503. }
  504. this.$nextTick(() => {
  505. if(this.activeTab == 0) {
  506. // tab 0 由 doctorHall 组件自己处理
  507. this.initializedTabs.add(0);
  508. } else if(this.activeTab == 1) {
  509. if(this.$refs['studyCenter']) {
  510. this.$refs['studyCenter'].initShow();
  511. this.initializedTabs.add(1);
  512. }
  513. } else if(this.activeTab == 2) {
  514. if(this.$refs.homeIndex) {
  515. this.$refs.homeIndex.initShow();
  516. this.initializedTabs.add(2);
  517. }
  518. } else if(this.activeTab == 3) {
  519. if(this.$refs.watchIndex) {
  520. this.$refs.watchIndex.initShow();
  521. this.initializedTabs.add(3);
  522. }
  523. }
  524. });
  525. },
  526. /*下拉刷新的回调 */
  527. downCallback() {
  528. this.mescroll.resetUpScroll(true);
  529. var that=this;
  530. this.requestData();
  531. },
  532. /*上拉加载的回调*/
  533. upCallback(page) {
  534. this.mescroll.endByPage(1, 1);
  535. },
  536. requestData(){
  537. //this.getCourseCate();
  538. },
  539. getCourseCate:function(){
  540. let that=this;
  541. getCourseCate().then(res => {
  542. if(res.code==200){
  543. this.mtabs=res.data;
  544. let findIdx=this.mtabs.findIndex(item=>item.dictLabel=='精选');
  545. // console.log("qxj findIdx:"+findIdx);
  546. if(findIdx==-1){
  547. let dictItem={"dictValue":0,"dictLabel": "精选"};
  548. this.mtabs.unshift(dictItem);
  549. }
  550. this.isBest=true;
  551. if(this.mtabs.length>0){
  552. this.cateId=this.mtabs[0].dictValue;
  553. for (let i = 0; i < this.mtabs.length; i++) {
  554. if(i<=4){
  555. this.tabChange(i);
  556. }
  557. }
  558. //this.tabIndex=0;
  559. //this.dataItem=this.dataList[this.tabIndex.toString()]
  560. this.tabChange(0);
  561. }
  562. }
  563. },
  564. rej => {}
  565. );
  566. },
  567. getFamousCourseList(index){
  568. let that=this;
  569. let params={};
  570. if(this.isBest){
  571. params={"isBest":1};
  572. }else{
  573. params={"cateId":this.cateId};
  574. }
  575. if(this.dataList.hasOwnProperty(index+"")){
  576. this.updateSwiperHeight(index);
  577. return;
  578. }
  579. getCourseList(params,1,6).then(res => {
  580. if(res.code==200){
  581. this.dataList[index+""]=res.data.list;
  582. //this.$nextTick(() => {
  583. this.updateSwiperHeight(index);
  584. //});
  585. }
  586. },
  587. rej => {}
  588. );
  589. },
  590. getRecommendList:function(){
  591. let that=this;
  592. const params={"isTui":1};
  593. getCourseList(params,1,10).then(res => {
  594. if(res.code==200){
  595. this.recommendList=res.data.list;
  596. }
  597. },
  598. rej => {}
  599. );
  600. },
  601. swiperChange(e){
  602. // console.log("qxj swiperChange");
  603. this.tabIndex = e.detail.current;
  604. this.tabChange(this.tabIndex);
  605. },
  606. tabChange(index){
  607. console.log("qxj tabChange index:",index);
  608. this.tabIndex=index;
  609. const item=this.mtabs[index];
  610. if(item){
  611. if(item.dictLabel=='精选'){
  612. this.isBest=true;
  613. }else{
  614. this.isBest=false;
  615. }
  616. this.cateId=item.dictValue;
  617. this.getFamousCourseList(index);
  618. }
  619. },
  620. onTransition(){
  621. },
  622. animationfinish(){
  623. this.updateSwiperHeight();
  624. },
  625. onSwiperResize() {
  626. //console.log("qxj onSwiperResize");
  627. },
  628. updateSwiperHeight() {
  629. let dataArr=this.dataList[this.tabIndex.toString()];
  630. if(dataArr==undefined || dataArr.length==0){
  631. this.swHeight=150;
  632. }else{
  633. uni.createSelectorQuery().in(this).select('#swiper-content').boundingClientRect(rect => {
  634. //console.log("qxj swHeight:"+this.swHeight);
  635. if(rect!=null){
  636. this.swHeight = rect.height+20;
  637. }
  638. if(this.swHeight<=100){
  639. //所以(total + pagesize -1) / pagesize就得到总页数
  640. // console.log("qxj famousItemHei:"+this.famousItemHei);
  641. this.swHeight=(dataArr.length+1)/2*this.famousItemHei;
  642. return;
  643. }
  644. }).exec();
  645. }
  646. },
  647. getAdvList() {
  648. //联网加载数据
  649. var that = this;
  650. var data = { advType:12,status:1}
  651. getAdvList(data).then(res => {
  652. if(res.code==200){
  653. that.imageList=[];
  654. that.advs=[];
  655. res.data.forEach(function(element) {
  656. if(element.imageUrl!=null&&element.imageUrl!=""){
  657. that.advs.push(element);
  658. that.imageList.push(element.imageUrl);
  659. }
  660. });
  661. }else{
  662. uni.showToast({icon:'none',title: "请求失败"});
  663. }
  664. });
  665. },
  666. goToMsg(){
  667. if(!this.$isLogin()){
  668. this.$showLoginPage();
  669. return;
  670. }else{
  671. let registrationID=uni.getStorageSync("registrationID");
  672. let token = uni.getStorageSync('AppToken');
  673. }
  674. },
  675. // 页面跳转
  676. navTo(url) {
  677. console.log("qxj url:"+url);
  678. uni.navigateTo({
  679. url: url
  680. });
  681. },
  682. loginNavTo(url){
  683. if(!this.$isLogin()){
  684. this.$showLoginPage();
  685. return;
  686. }
  687. this.$navTo(url);
  688. },
  689. changeImg(){
  690. },
  691. handleAdvClick(index){
  692. var ad=this.advs[index];
  693. if(ad.showType==1){
  694. uni.setStorageSync('url',ad.appAdvUrl);
  695. uni.navigateTo({
  696. url:"h5"
  697. });
  698. }
  699. else if(ad.showType==2){
  700. // console.log(ad.appAdvUrl);
  701. uni.navigateTo({
  702. url:ad.appAdvUrl
  703. });
  704. }
  705. else if(ad.showType==3){
  706. uni.setStorageSync('content',ad.content);
  707. uni.navigateTo({url:"content"});
  708. }
  709. },
  710. changeGuide(val){
  711. if(this.activeTab==0||this.activeTab==1){
  712. let guide = ''
  713. let ele = ""
  714. if(this.activeTab == 1) {
  715. // guide = uni.getStorageSync("studyCenterGuide");
  716. // ele = "#guide4"
  717. }
  718. else if(this.activeTab == 0){
  719. guide = uni.getStorageSync("doctorHallGuide");
  720. ele = "#guide3"
  721. }
  722. if ((guide!=undefined && !guide) &&ele) {
  723. setTimeout(e=>{
  724. if(this.showGuide||this.activeTab==1) return
  725. this.showGuide = true;
  726. this.getGuideInfo(ele,1);
  727. },val==0?1000:500);
  728. } else {
  729. this.showGuide = false;
  730. }
  731. }
  732. },
  733. getGuideInfo(el,type) {
  734. const refname = this.activeTab == 1 ? 'studyCenter' : this.activeTab == 0 ? 'doctorHall': ''
  735. if(!refname) return
  736. const query = uni.createSelectorQuery().in(this.$refs[refname]);
  737. this.$nextTick(function() {
  738. query.select(el).boundingClientRect()
  739. let _this = this;
  740. query.exec(function(res) {
  741. if(!res) return
  742. const {
  743. width,
  744. height,
  745. left,
  746. top,
  747. style = 'border-radius: 12rpx;margin: 0'
  748. } = res[0]
  749. if(el == '#guide3') {
  750. // 滑动至顶部(减去导航栏高度)
  751. _this.scrollTopHall = top - uni.upx2px(220) - 44 - _this.statusBarHeight
  752. _this.getGuide3item(res[0],_this.scrollTopHall)
  753. } else {
  754. _this.scrollTopStudy = _this.old.scrollTopStudy
  755. _this.scrollTopGoods = _this.old.scrollTopGoods
  756. _this.$nextTick(()=> {
  757. _this.scrollTopStudy = 0
  758. _this.scrollTopGoods = 0
  759. });
  760. // 减去我的评价宽度
  761. const relwidth = width
  762. let newstyle = "width:" + relwidth + "px;";
  763. newstyle += "height:" + height + "px;";
  764. newstyle += "left:" + uni.upx2px(24) + "px;";
  765. newstyle += "top:" + top + "px;";
  766. newstyle += style;
  767. _this.guideStyle = newstyle
  768. let tipsTop = height + uni.upx2px(20);
  769. _this.tipPosition = "top:" + tipsTop + 'px;left:' + uni.upx2px(88) + "px;";
  770. }
  771. })
  772. });
  773. },
  774. getGuide3item(res,scrollTopHall) {
  775. const {
  776. width,
  777. height,
  778. left,
  779. top,
  780. style = 'border-radius: 12rpx;margin: 0'
  781. } = res
  782. const refname = this.activeTab == 1 ? 'studyCenter' : this.activeTab == 0 ? 'doctorHall': ''
  783. if(!refname) return
  784. const query = uni.createSelectorQuery().in(this.$refs[refname]);
  785. let _this = this;
  786. query.select(".guide3item").boundingClientRect((data) => {
  787. if(!data) return
  788. if(data.height<80) data.height = uni.upx2px(538)
  789. const relwidth = width + uni.upx2px(24)
  790. const relheight = height + data.height + uni.upx2px(30)
  791. // console.log("qxj getGuide3item top:"+top+" scrollTopHall:"+ _this.scrollTopHall);
  792. // const reltop = top;
  793. const reltop = top - _this.scrollTopHall
  794. let newstyle = "width:" + relwidth + "px;";
  795. newstyle += "height:" + relheight + "px;";
  796. newstyle += "left:" + uni.upx2px(14) + "px;";
  797. newstyle += "top:" + reltop + "px;";
  798. newstyle += style;
  799. // console.log("qxj guide3Style:"+JSON.stringify(newstyle));
  800. _this.guideStyle = newstyle
  801. const tipsCenter = relheight + uni.upx2px(50)
  802. _this.tipsCenter = "height:" + tipsCenter +"px";
  803. let tipsTop = - uni.upx2px(180);
  804. _this.tipPosition = "top:" + tipsTop + 'px;left:' + uni.upx2px(66) + "px;";
  805. }).exec();
  806. },
  807. closeGuide(type) {
  808. if(type == 'mask' && this.activeTab==0) {
  809. return
  810. }
  811. this.showGuide = false;
  812. if(this.activeTab == 1) {
  813. uni.setStorageSync("studyCenterGuide", true);
  814. // setTimeout(e=>{
  815. // uni.switchTab({url: '/pages/course/video/living-app' });
  816. // },500);
  817. }else if(this.activeTab == 0) {
  818. uni.setStorageSync("doctorHallGuide", true);
  819. // this.handleTab(1);
  820. // setTimeout(e=>{
  821. // uni.switchTab({
  822. // url: '/pages/course/video/living-app',
  823. // complete: () => {
  824. // this.getCreateAd()
  825. // }
  826. // });
  827. // },500);
  828. }
  829. this.scrollTopHall = this.old.scrollTopHall
  830. this.scrollTopStudy = this.old.scrollTopStudy
  831. this.scrollTopGoods = this.old.scrollTopGoods
  832. this.$nextTick(()=> {
  833. this.scrollTopHall = 0
  834. this.scrollTopStudy = 0
  835. this.scrollTopGoods = 0
  836. });
  837. },
  838. // 礼品弹窗
  839. getCreateAd() {
  840. // #ifdef APP-PLUS
  841. if(this.$isAgreePrivacy()) {
  842. if(plus.runtime.channel=="yyb" || plus.runtime.channel=="yybadv" || plus.runtime.channel=="yybadv1"){
  843. let guide = uni.getStorageSync("doctorHallGuide");
  844. let ele = "#guide3"
  845. if (guide && ele) {
  846. // 延迟执行,避免阻塞渲染
  847. setTimeout(() => {
  848. isCreateAd().then(res=>{
  849. if(res.code == 200 && res.isCreate) {
  850. this.$nextTick(()=>{
  851. if (this.$refs.giftPopup) {
  852. this.$refs.giftPopup.openPop();
  853. }
  854. })
  855. } else {
  856. this.$nextTick(()=>{
  857. if (this.$refs.giftPopup) {
  858. this.$refs.giftPopup.closePop();
  859. }
  860. })
  861. }
  862. }).catch(err => {
  863. console.warn('获取广告状态失败:', err);
  864. });
  865. }, 500);
  866. }
  867. }
  868. }
  869. // #endif
  870. },
  871. // scrolltolower(){
  872. // this.$refs.integralGoods&&this.$refs.integralGoods.scrolltolower()
  873. // },
  874. handleRefresher() {
  875. this.triggered = true;
  876. this.$nextTick(()=>{
  877. if (this.activeTab == 0) {
  878. this.$refs.doctorHall.initFun()
  879. } else if (this.activeTab == 1) {
  880. this.$refs['studyCenter'].initShow()
  881. }
  882. })
  883. setTimeout(() => {
  884. this.triggered = false;
  885. }, 500);
  886. },
  887. }
  888. }
  889. </script>
  890. <style scoped lang="scss">
  891. .back-top {
  892. border-radius: 50%;
  893. overflow: hidden;
  894. background-color: transparent;
  895. width: 40px;
  896. height: 40px;
  897. position: fixed;
  898. right: 24rpx;
  899. bottom: 100rpx;
  900. image {
  901. width: 40px;
  902. height: 40px;
  903. }
  904. }
  905. @mixin u-flex($flexD, $alignI, $justifyC) {
  906. display: flex;
  907. flex-direction: $flexD;
  908. align-items: $alignI;
  909. justify-content: $justifyC;
  910. }
  911. .guidebox {
  912. position: fixed;
  913. left: 0;
  914. top: 0;
  915. width: 100%;
  916. height: 100%;
  917. z-index: 1000;
  918. .guide {
  919. position: absolute;
  920. z-index: 10001;
  921. box-shadow: rgba(33, 33, 33,0.8) 0px 0px 0px 0px, rgba(33, 33, 33, 0.5) 0px 0px 0px 5000px;
  922. }
  923. .guide-step-tips {
  924. position: absolute;
  925. top: 0;
  926. left: 0;
  927. z-index: 10001;
  928. padding: 18rpx 18rpx 18rpx 90rpx;
  929. box-sizing: border-box;
  930. border-radius: 24rpx;
  931. font-family: PingFang SC, PingFang SC;
  932. font-weight: 400;
  933. font-size: 26rpx;
  934. color: #FFFFFF;
  935. line-height: 40rpx;
  936. background: linear-gradient(90deg, #FCAC34, #F9622F);
  937. }
  938. .Frame2612 {
  939. height: 158rpx;
  940. width: 158rpx;
  941. position: absolute;
  942. left: -66rpx;
  943. top: -102rpx;
  944. }
  945. .guide3-step-tips2 {
  946. display: flex;
  947. flex-direction: column;
  948. align-items: center;
  949. justify-content: center;
  950. position: absolute;
  951. }
  952. .guide3-step-tips {
  953. width: 100vw;
  954. display: flex;
  955. flex-direction: column;
  956. align-items: center;
  957. justify-content: center;
  958. height: 100vh;
  959. position: absolute;
  960. }
  961. .guide3-step-tipsbox {
  962. display: flex;
  963. flex-direction: column;
  964. align-items: flex-end;
  965. }
  966. .guide3-btn{
  967. width: 272rpx;
  968. height: 84rpx;
  969. margin: 0 auto;
  970. background: #FF5C03;
  971. border-radius: 42rpx 42rpx 42rpx 42rpx;
  972. font-family: PingFang SC, PingFang SC;
  973. font-weight: 500;
  974. font-size: 32rpx;
  975. color: #FFFFFF;
  976. line-height: 84rpx;
  977. text-align: center;
  978. }
  979. .guide3-toptip {
  980. width: 640rpx;
  981. height: 160rpx;
  982. padding: 26rpx;
  983. box-sizing: border-box;
  984. position: relative;
  985. font-family: PingFang SC, PingFang SC;
  986. font-weight: 400;
  987. font-size: 26rpx;
  988. color: #FFFFFF;
  989. line-height: 30rpx;
  990. }
  991. .guide3-toptip-head {
  992. // position: relative;
  993. margin-bottom: 8rpx;
  994. font-family: PingFang SC, PingFang SC;
  995. font-weight: 600;
  996. font-size: 34rpx;
  997. color: #FFFFFF;
  998. line-height: 40rpx;
  999. }
  1000. .guide3-toptip-headbg {
  1001. width: 640rpx;
  1002. height: 160rpx;
  1003. position: absolute;
  1004. top: 0;
  1005. left: 0;
  1006. z-index: -1;
  1007. }
  1008. .Frame2611 {
  1009. width: 188rpx;
  1010. height: 184rpx;
  1011. position: absolute;
  1012. top: -90rpx;
  1013. right: 0;
  1014. }
  1015. .Frame2291 {
  1016. width: 702rpx;
  1017. // height: 684rpx;
  1018. margin: 24rpx 0 40rpx 0;
  1019. }
  1020. }
  1021. .container {
  1022. font-family: PingFang SC, PingFang SC;
  1023. padding-top: var(--status-bar-height);
  1024. position: relative;
  1025. z-index: 2;
  1026. }
  1027. .home_top_bg {
  1028. width: 100%;
  1029. height: auto;
  1030. position: absolute;
  1031. top: 0;
  1032. left: 0;
  1033. z-index: -1;
  1034. }
  1035. .tabbox {
  1036. position: relative;
  1037. margin-bottom: 22rpx;
  1038. position: relative;
  1039. .tabbar {
  1040. height: 88rpx;
  1041. @include u-flex(row,center,center);
  1042. font-weight: 600;
  1043. font-size: 32rpx;
  1044. color: #222222;
  1045. line-height: 88rpx;
  1046. position: relative;
  1047. .tabbar-item {
  1048. margin: 0 24rpx;
  1049. }
  1050. .active {
  1051. font-weight: 600;
  1052. font-size: 40rpx;
  1053. color: #FF5C03;
  1054. position: relative;
  1055. }
  1056. }
  1057. .tabbar-tabline-image {
  1058. width: 36rpx;
  1059. height: 12rpx;
  1060. }
  1061. .tabbar-tabline {
  1062. position: absolute;
  1063. bottom: 0;
  1064. width: 0;
  1065. height: 12rpx;
  1066. display: flex;
  1067. align-items: center;
  1068. justify-content: center;
  1069. }
  1070. .tabbar-tabline-animation {
  1071. transition-duration: 0.2s;
  1072. transition-property: left;
  1073. }
  1074. }
  1075. .activityPop{
  1076. position: relative;
  1077. z-index: 1002;
  1078. }
  1079. .page-loading {
  1080. position: fixed;
  1081. top: 0;
  1082. left: 0;
  1083. right: 0;
  1084. bottom: 0;
  1085. background-color: #fff;
  1086. z-index: 9999;
  1087. display: flex;
  1088. align-items: center;
  1089. justify-content: center;
  1090. .loading-content {
  1091. display: flex;
  1092. flex-direction: column;
  1093. align-items: center;
  1094. justify-content: center;
  1095. }
  1096. .loading-spinner {
  1097. width: 60rpx;
  1098. height: 60rpx;
  1099. border: 4rpx solid #f3f3f3;
  1100. border-top: 4rpx solid #FF5C03;
  1101. border-radius: 50%;
  1102. animation: spin 1s linear infinite;
  1103. }
  1104. .loading-text {
  1105. margin-top: 20rpx;
  1106. font-size: 28rpx;
  1107. color: #999;
  1108. }
  1109. }
  1110. @keyframes spin {
  1111. 0% { transform: rotate(0deg); }
  1112. 100% { transform: rotate(360deg); }
  1113. }
  1114. </style>