index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  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. const activeTabCourse = uni.getStorageSync('activeTabCourse')
  290. if(activeTabCourse){
  291. this.activeTab = 0
  292. uni.removeStorageSync('activeTabCourse')
  293. }
  294. // #ifdef APP-PLUS
  295. if (this.$isAgreePrivacy()) {
  296. if (plus.runtime.channel == 'baidu') {
  297. let bdCmdType = uni.getStorageSync('bdCmdType');
  298. if (this.$isEmpty(bdCmdType)) {
  299. this.$registerIdCode('activate', 0, 0);
  300. }
  301. }
  302. }
  303. // #endif
  304. if(!this.$isLogin()){
  305. uni.navigateTo({
  306. url: '/pages/auth/loginIndex'
  307. })
  308. return;
  309. }
  310. // 非阻塞操作,延迟执行
  311. this.$updateMsgDot()
  312. this.swiperAutoplay=true;
  313. // 延迟执行非关键操作,避免阻塞渲染
  314. this.$nextTick(() => {
  315. this.$refs.uTabs && this.$refs.uTabs.resize();
  316. // 只初始化当前可见的tab,其他tab延迟加载
  317. this.initCurrentTab();
  318. // 延迟执行非关键操作
  319. setTimeout(() => {
  320. this.getCreateAd();
  321. }, 300);
  322. });
  323. },
  324. onHide() {
  325. this.swiperAutoplay=false;
  326. },
  327. onLoad(options){
  328. if(options.activeTab){
  329. this.activeTab = options.activeTab
  330. }
  331. // 同步获取系统信息,避免延迟
  332. try {
  333. const systemInfo = uni.getSystemInfoSync();
  334. this.statusBarHeight = systemInfo.statusBarHeight;
  335. // 提前设置 clientHeight,避免布局闪烁
  336. this.clientHeight = systemInfo.windowHeight - uni.upx2px(120) - systemInfo.statusBarHeight;
  337. this.isXiaomi=plus.runtime.channel == 'xiaomi';
  338. //this.isXiaomi=true;
  339. if(!this.isXiaomi){
  340. this.tabList.push({
  341. id: "tab04",
  342. name: '健康管理',
  343. });
  344. }
  345. } catch (e) {
  346. this.statusBarHeight = 0;
  347. }
  348. this.guideIndex=uni.getStorageSync("doctorHallGuide");
  349. // 延迟执行非关键操作,优先渲染页面
  350. if(this.$isLogin()){
  351. // 延迟获取签到信息,避免阻塞首屏渲染
  352. setTimeout(() => {
  353. this.getUserSign();
  354. }, 200);
  355. }else{
  356. 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天\"}]";
  357. this.userSign={"signNum":0,"isDaySign":0,"integral":0,"sign":JSON.parse(signStr)};
  358. // 延迟显示弹窗,避免阻塞渲染
  359. this.$nextTick(()=>{
  360. if(this.source!='course' && this.$refs.signPop){
  361. setTimeout(() => {
  362. this.$refs.signPop.open();
  363. }, 500);
  364. }
  365. });
  366. }
  367. // #ifdef APP-PLUS
  368. if(this.$isAgreePrivacy()) {
  369. if(plus.runtime.channel=="baidu"){ //获取渠道标识
  370. let bdCmdType=uni.getStorageSync("bdCmdType");
  371. console.log("qxj bdCmdType:"+bdCmdType);
  372. if(this.$isEmpty(bdCmdType)){
  373. this.$registerIdCode("activate",0,0);
  374. }
  375. }
  376. }
  377. // #endif
  378. uni.$on('loginOut', function() {
  379. let IMUserID = uni.getStorageSync('IMUserID');
  380. //Igexin.unbindAlias(IMUserID);
  381. uni.removeStorage({key: "IMUserID"});
  382. uni.setStorageSync("AppToken",null);
  383. uni.removeStorage({ key: 'IMToken' });
  384. uni.removeStorageSync("onLaunch",null)
  385. uni.removeStorageSync("imUnread",null);
  386. uni.removeStorageSync("companyUser");
  387. uni.removeStorageSync("CompanyUserToken");
  388. uni.$emit("refreshUserInfo");
  389. let pages = getCurrentPages();
  390. let url = pages[ pages.length - 1]; //当前页页面实例
  391. //如果登录界面已打开,自动关闭
  392. if(url!=undefined&&url.route=="pages/auth/loginIndex"){
  393. return;
  394. }
  395. uni.navigateTo({
  396. url: '/pages/auth/loginIndex'
  397. });
  398. });
  399. },
  400. mounted() {
  401. try {
  402. const system = uni.getSystemInfoSync();
  403. let itemWid=(system.windowWidth-40-32)*0.5*0.95;
  404. let tempHei=itemWid*0.5;
  405. tempHei=uni.upx2px(tempHei)+30;
  406. this.famousItemHei=tempHei;
  407. } catch (e) {
  408. }
  409. // 延迟执行活动弹窗检查,避免阻塞首屏
  410. setTimeout(() => {
  411. this.activityFun();
  412. }, 500);
  413. },
  414. methods: {
  415. getUserSign(){
  416. getUserSign().then(res => {
  417. if(res.code==200){
  418. this.userSign={"signNum":res.signNum,"isDaySign":res.isDaySign,"integral":res.integral,"sign":JSON.parse(res.sign)};
  419. // 延迟显示弹窗,避免阻塞渲染
  420. this.$nextTick(()=>{
  421. if(!res.isDaySign && this.$refs.signPop){
  422. setTimeout(() => {
  423. this.$refs.signPop.open();
  424. }, 500);
  425. }
  426. });
  427. }
  428. },
  429. rej => {}
  430. );
  431. },
  432. activityFun(){
  433. // 防抖处理,避免重复请求
  434. if (this._activityTimer) {
  435. clearTimeout(this._activityTimer);
  436. }
  437. this._activityTimer = setTimeout(() => {
  438. getUserActiveWindow().then(res=>{
  439. if(res.code == 200){
  440. if (res.isOpen && this.$refs.activityPop) {
  441. // 延迟显示弹窗,避免阻塞渲染
  442. setTimeout(() => {
  443. this.$refs.activityPop.open();
  444. }, 800);
  445. }
  446. }else{
  447. // 静默失败,不显示错误提示
  448. console.warn('获取活动窗口失败:', res.msg);
  449. }
  450. }).catch(err => {
  451. console.warn('获取活动窗口异常:', err);
  452. });
  453. }, 300);
  454. },
  455. goTop() {
  456. setTimeout(()=>{
  457. this.old.scrollTopGoods = 0
  458. this.scrollTopGoods = 0
  459. })
  460. },
  461. scroll(e,type) {
  462. this.old[type] = e.detail.scrollTop
  463. this.scrollTopGoods = this.old[type]
  464. },
  465. handleTab(e) {
  466. this.activeTab = e.index
  467. // if(this.haveFamousCourse) {
  468. // // 防止在没有名医讲堂数据的时候有指引弹窗
  469. // this.changeGuide(this.activeTab);
  470. // console.log("=handleTab=")
  471. // }
  472. // this.$nextTick(()=>{
  473. // this.selectorQuery()
  474. // })
  475. },
  476. loadFamousCourse(val){
  477. this.haveFamousCourse = true
  478. // this.changeGuide(val);
  479. },
  480. updateIndicator(left, width) {
  481. this.indicatorLineLeft = left;
  482. this.indicatorLineWidth = width;
  483. },
  484. selectorQuery() {
  485. uni.createSelectorQuery().in(this).selectAll('.tabbar-item').boundingClientRect((rects) => {
  486. rects.forEach((rect) => {
  487. this.tabListSize[rect.id] = rect;
  488. })
  489. this.updateIndicator(this.tabListSize[this.activeTab].left, this.tabListSize[this.activeTab].width);
  490. }).exec();
  491. },
  492. // swiper划动
  493. onSwiperChange(e){
  494. this.changeIdx(e.detail.current);
  495. },
  496. // 更新当前页
  497. changeIdx(index){
  498. if(this.activeTab === index) return;
  499. this.activeTab = index;
  500. this.scrollViewId = 'scrollView'+this.activeTab;
  501. // 初始化当前tab(懒加载)
  502. this.initCurrentTab();
  503. },
  504. // 初始化当前tab(懒加载优化)
  505. initCurrentTab() {
  506. if (this.initializedTabs.has(this.activeTab)) {
  507. return; // 已初始化,跳过
  508. }
  509. this.$nextTick(() => {
  510. if(this.activeTab == 0) {
  511. // tab 0 由 doctorHall 组件自己处理
  512. this.initializedTabs.add(0);
  513. } else if(this.activeTab == 1) {
  514. if(this.$refs['studyCenter']) {
  515. this.$refs['studyCenter'].initShow();
  516. this.initializedTabs.add(1);
  517. }
  518. } else if(this.activeTab == 2) {
  519. if(this.$refs.homeIndex) {
  520. this.$refs.homeIndex.initShow();
  521. this.initializedTabs.add(2);
  522. }
  523. } else if(this.activeTab == 3) {
  524. if(this.$refs.watchIndex) {
  525. this.$refs.watchIndex.initShow();
  526. this.initializedTabs.add(3);
  527. }
  528. }
  529. });
  530. },
  531. /*下拉刷新的回调 */
  532. downCallback() {
  533. this.mescroll.resetUpScroll(true);
  534. var that=this;
  535. this.requestData();
  536. },
  537. /*上拉加载的回调*/
  538. upCallback(page) {
  539. this.mescroll.endByPage(1, 1);
  540. },
  541. requestData(){
  542. //this.getCourseCate();
  543. },
  544. getCourseCate:function(){
  545. let that=this;
  546. getCourseCate().then(res => {
  547. if(res.code==200){
  548. this.mtabs=res.data;
  549. let findIdx=this.mtabs.findIndex(item=>item.dictLabel=='精选');
  550. // console.log("qxj findIdx:"+findIdx);
  551. if(findIdx==-1){
  552. let dictItem={"dictValue":0,"dictLabel": "精选"};
  553. this.mtabs.unshift(dictItem);
  554. }
  555. this.isBest=true;
  556. if(this.mtabs.length>0){
  557. this.cateId=this.mtabs[0].dictValue;
  558. for (let i = 0; i < this.mtabs.length; i++) {
  559. if(i<=4){
  560. this.tabChange(i);
  561. }
  562. }
  563. //this.tabIndex=0;
  564. //this.dataItem=this.dataList[this.tabIndex.toString()]
  565. this.tabChange(0);
  566. }
  567. }
  568. },
  569. rej => {}
  570. );
  571. },
  572. getFamousCourseList(index){
  573. let that=this;
  574. let params={};
  575. if(this.isBest){
  576. params={"isBest":1};
  577. }else{
  578. params={"cateId":this.cateId};
  579. }
  580. if(this.dataList.hasOwnProperty(index+"")){
  581. this.updateSwiperHeight(index);
  582. return;
  583. }
  584. getCourseList(params,1,6).then(res => {
  585. if(res.code==200){
  586. this.dataList[index+""]=res.data.list;
  587. //this.$nextTick(() => {
  588. this.updateSwiperHeight(index);
  589. //});
  590. }
  591. },
  592. rej => {}
  593. );
  594. },
  595. getRecommendList:function(){
  596. let that=this;
  597. const params={"isTui":1};
  598. getCourseList(params,1,10).then(res => {
  599. if(res.code==200){
  600. this.recommendList=res.data.list;
  601. }
  602. },
  603. rej => {}
  604. );
  605. },
  606. swiperChange(e){
  607. // console.log("qxj swiperChange");
  608. this.tabIndex = e.detail.current;
  609. this.tabChange(this.tabIndex);
  610. },
  611. tabChange(index){
  612. console.log("qxj tabChange index:",index);
  613. this.tabIndex=index;
  614. const item=this.mtabs[index];
  615. if(item){
  616. if(item.dictLabel=='精选'){
  617. this.isBest=true;
  618. }else{
  619. this.isBest=false;
  620. }
  621. this.cateId=item.dictValue;
  622. this.getFamousCourseList(index);
  623. }
  624. },
  625. onTransition(){
  626. },
  627. animationfinish(){
  628. this.updateSwiperHeight();
  629. },
  630. onSwiperResize() {
  631. //console.log("qxj onSwiperResize");
  632. },
  633. updateSwiperHeight() {
  634. let dataArr=this.dataList[this.tabIndex.toString()];
  635. if(dataArr==undefined || dataArr.length==0){
  636. this.swHeight=150;
  637. }else{
  638. uni.createSelectorQuery().in(this).select('#swiper-content').boundingClientRect(rect => {
  639. //console.log("qxj swHeight:"+this.swHeight);
  640. if(rect!=null){
  641. this.swHeight = rect.height+20;
  642. }
  643. if(this.swHeight<=100){
  644. //所以(total + pagesize -1) / pagesize就得到总页数
  645. // console.log("qxj famousItemHei:"+this.famousItemHei);
  646. this.swHeight=(dataArr.length+1)/2*this.famousItemHei;
  647. return;
  648. }
  649. }).exec();
  650. }
  651. },
  652. getAdvList() {
  653. //联网加载数据
  654. var that = this;
  655. var data = { advType:12,status:1}
  656. getAdvList(data).then(res => {
  657. if(res.code==200){
  658. that.imageList=[];
  659. that.advs=[];
  660. res.data.forEach(function(element) {
  661. if(element.imageUrl!=null&&element.imageUrl!=""){
  662. that.advs.push(element);
  663. that.imageList.push(element.imageUrl);
  664. }
  665. });
  666. }else{
  667. uni.showToast({icon:'none',title: "请求失败"});
  668. }
  669. });
  670. },
  671. goToMsg(){
  672. if(!this.$isLogin()){
  673. this.$showLoginPage();
  674. return;
  675. }else{
  676. let registrationID=uni.getStorageSync("registrationID");
  677. let token = uni.getStorageSync('AppToken');
  678. }
  679. },
  680. // 页面跳转
  681. navTo(url) {
  682. console.log("qxj url:"+url);
  683. uni.navigateTo({
  684. url: url
  685. });
  686. },
  687. loginNavTo(url){
  688. if(!this.$isLogin()){
  689. this.$showLoginPage();
  690. return;
  691. }
  692. this.$navTo(url);
  693. },
  694. changeImg(){
  695. },
  696. handleAdvClick(index){
  697. var ad=this.advs[index];
  698. if(ad.showType==1){
  699. uni.setStorageSync('url',ad.appAdvUrl);
  700. uni.navigateTo({
  701. url:"h5"
  702. });
  703. }
  704. else if(ad.showType==2){
  705. // console.log(ad.appAdvUrl);
  706. uni.navigateTo({
  707. url:ad.appAdvUrl
  708. });
  709. }
  710. else if(ad.showType==3){
  711. uni.setStorageSync('content',ad.content);
  712. uni.navigateTo({url:"content"});
  713. }
  714. },
  715. changeGuide(val){
  716. if(this.activeTab==0||this.activeTab==1){
  717. let guide = ''
  718. let ele = ""
  719. if(this.activeTab == 1) {
  720. // guide = uni.getStorageSync("studyCenterGuide");
  721. // ele = "#guide4"
  722. }
  723. else if(this.activeTab == 0){
  724. guide = uni.getStorageSync("doctorHallGuide");
  725. ele = "#guide3"
  726. }
  727. if ((guide!=undefined && !guide) &&ele) {
  728. setTimeout(e=>{
  729. if(this.showGuide||this.activeTab==1) return
  730. this.showGuide = true;
  731. this.getGuideInfo(ele,1);
  732. },val==0?1000:500);
  733. } else {
  734. this.showGuide = false;
  735. }
  736. }
  737. },
  738. getGuideInfo(el,type) {
  739. const refname = this.activeTab == 1 ? 'studyCenter' : this.activeTab == 0 ? 'doctorHall': ''
  740. if(!refname) return
  741. const query = uni.createSelectorQuery().in(this.$refs[refname]);
  742. this.$nextTick(function() {
  743. query.select(el).boundingClientRect()
  744. let _this = this;
  745. query.exec(function(res) {
  746. if(!res) return
  747. const {
  748. width,
  749. height,
  750. left,
  751. top,
  752. style = 'border-radius: 12rpx;margin: 0'
  753. } = res[0]
  754. if(el == '#guide3') {
  755. // 滑动至顶部(减去导航栏高度)
  756. _this.scrollTopHall = top - uni.upx2px(220) - 44 - _this.statusBarHeight
  757. _this.getGuide3item(res[0],_this.scrollTopHall)
  758. } else {
  759. _this.scrollTopStudy = _this.old.scrollTopStudy
  760. _this.scrollTopGoods = _this.old.scrollTopGoods
  761. _this.$nextTick(()=> {
  762. _this.scrollTopStudy = 0
  763. _this.scrollTopGoods = 0
  764. });
  765. // 减去我的评价宽度
  766. const relwidth = width
  767. let newstyle = "width:" + relwidth + "px;";
  768. newstyle += "height:" + height + "px;";
  769. newstyle += "left:" + uni.upx2px(24) + "px;";
  770. newstyle += "top:" + top + "px;";
  771. newstyle += style;
  772. _this.guideStyle = newstyle
  773. let tipsTop = height + uni.upx2px(20);
  774. _this.tipPosition = "top:" + tipsTop + 'px;left:' + uni.upx2px(88) + "px;";
  775. }
  776. })
  777. });
  778. },
  779. getGuide3item(res,scrollTopHall) {
  780. const {
  781. width,
  782. height,
  783. left,
  784. top,
  785. style = 'border-radius: 12rpx;margin: 0'
  786. } = res
  787. const refname = this.activeTab == 1 ? 'studyCenter' : this.activeTab == 0 ? 'doctorHall': ''
  788. if(!refname) return
  789. const query = uni.createSelectorQuery().in(this.$refs[refname]);
  790. let _this = this;
  791. query.select(".guide3item").boundingClientRect((data) => {
  792. if(!data) return
  793. if(data.height<80) data.height = uni.upx2px(538)
  794. const relwidth = width + uni.upx2px(24)
  795. const relheight = height + data.height + uni.upx2px(30)
  796. // console.log("qxj getGuide3item top:"+top+" scrollTopHall:"+ _this.scrollTopHall);
  797. // const reltop = top;
  798. const reltop = top - _this.scrollTopHall
  799. let newstyle = "width:" + relwidth + "px;";
  800. newstyle += "height:" + relheight + "px;";
  801. newstyle += "left:" + uni.upx2px(14) + "px;";
  802. newstyle += "top:" + reltop + "px;";
  803. newstyle += style;
  804. // console.log("qxj guide3Style:"+JSON.stringify(newstyle));
  805. _this.guideStyle = newstyle
  806. const tipsCenter = relheight + uni.upx2px(50)
  807. _this.tipsCenter = "height:" + tipsCenter +"px";
  808. let tipsTop = - uni.upx2px(180);
  809. _this.tipPosition = "top:" + tipsTop + 'px;left:' + uni.upx2px(66) + "px;";
  810. }).exec();
  811. },
  812. closeGuide(type) {
  813. if(type == 'mask' && this.activeTab==0) {
  814. return
  815. }
  816. this.showGuide = false;
  817. if(this.activeTab == 1) {
  818. uni.setStorageSync("studyCenterGuide", true);
  819. // setTimeout(e=>{
  820. // uni.switchTab({url: '/pages/course/video/living-app' });
  821. // },500);
  822. }else if(this.activeTab == 0) {
  823. uni.setStorageSync("doctorHallGuide", true);
  824. // this.handleTab(1);
  825. // setTimeout(e=>{
  826. // uni.switchTab({
  827. // url: '/pages/course/video/living-app',
  828. // complete: () => {
  829. // this.getCreateAd()
  830. // }
  831. // });
  832. // },500);
  833. }
  834. this.scrollTopHall = this.old.scrollTopHall
  835. this.scrollTopStudy = this.old.scrollTopStudy
  836. this.scrollTopGoods = this.old.scrollTopGoods
  837. this.$nextTick(()=> {
  838. this.scrollTopHall = 0
  839. this.scrollTopStudy = 0
  840. this.scrollTopGoods = 0
  841. });
  842. },
  843. // 礼品弹窗
  844. getCreateAd() {
  845. // #ifdef APP-PLUS
  846. if(this.$isAgreePrivacy()) {
  847. if(plus.runtime.channel=="yyb" || plus.runtime.channel=="yybadv" || plus.runtime.channel=="yybadv1"){
  848. let guide = uni.getStorageSync("doctorHallGuide");
  849. let ele = "#guide3"
  850. if (guide && ele) {
  851. // 延迟执行,避免阻塞渲染
  852. setTimeout(() => {
  853. isCreateAd().then(res=>{
  854. if(res.code == 200 && res.isCreate) {
  855. this.$nextTick(()=>{
  856. if (this.$refs.giftPopup) {
  857. this.$refs.giftPopup.openPop();
  858. }
  859. })
  860. } else {
  861. this.$nextTick(()=>{
  862. if (this.$refs.giftPopup) {
  863. this.$refs.giftPopup.closePop();
  864. }
  865. })
  866. }
  867. }).catch(err => {
  868. console.warn('获取广告状态失败:', err);
  869. });
  870. }, 500);
  871. }
  872. }
  873. }
  874. // #endif
  875. },
  876. // scrolltolower(){
  877. // this.$refs.integralGoods&&this.$refs.integralGoods.scrolltolower()
  878. // },
  879. handleRefresher() {
  880. this.triggered = true;
  881. this.$nextTick(()=>{
  882. if (this.activeTab == 0) {
  883. this.$refs.doctorHall.initFun()
  884. } else if (this.activeTab == 1) {
  885. this.$refs['studyCenter'].initShow()
  886. }
  887. })
  888. setTimeout(() => {
  889. this.triggered = false;
  890. }, 500);
  891. },
  892. }
  893. }
  894. </script>
  895. <style scoped lang="scss">
  896. .back-top {
  897. border-radius: 50%;
  898. overflow: hidden;
  899. background-color: transparent;
  900. width: 40px;
  901. height: 40px;
  902. position: fixed;
  903. right: 24rpx;
  904. bottom: 100rpx;
  905. image {
  906. width: 40px;
  907. height: 40px;
  908. }
  909. }
  910. @mixin u-flex($flexD, $alignI, $justifyC) {
  911. display: flex;
  912. flex-direction: $flexD;
  913. align-items: $alignI;
  914. justify-content: $justifyC;
  915. }
  916. .guidebox {
  917. position: fixed;
  918. left: 0;
  919. top: 0;
  920. width: 100%;
  921. height: 100%;
  922. z-index: 1000;
  923. .guide {
  924. position: absolute;
  925. z-index: 10001;
  926. box-shadow: rgba(33, 33, 33,0.8) 0px 0px 0px 0px, rgba(33, 33, 33, 0.5) 0px 0px 0px 5000px;
  927. }
  928. .guide-step-tips {
  929. position: absolute;
  930. top: 0;
  931. left: 0;
  932. z-index: 10001;
  933. padding: 18rpx 18rpx 18rpx 90rpx;
  934. box-sizing: border-box;
  935. border-radius: 24rpx;
  936. font-family: PingFang SC, PingFang SC;
  937. font-weight: 400;
  938. font-size: 26rpx;
  939. color: #FFFFFF;
  940. line-height: 40rpx;
  941. background: linear-gradient(90deg, #FCAC34, #F9622F);
  942. }
  943. .Frame2612 {
  944. height: 158rpx;
  945. width: 158rpx;
  946. position: absolute;
  947. left: -66rpx;
  948. top: -102rpx;
  949. }
  950. .guide3-step-tips2 {
  951. display: flex;
  952. flex-direction: column;
  953. align-items: center;
  954. justify-content: center;
  955. position: absolute;
  956. }
  957. .guide3-step-tips {
  958. width: 100vw;
  959. display: flex;
  960. flex-direction: column;
  961. align-items: center;
  962. justify-content: center;
  963. height: 100vh;
  964. position: absolute;
  965. }
  966. .guide3-step-tipsbox {
  967. display: flex;
  968. flex-direction: column;
  969. align-items: flex-end;
  970. }
  971. .guide3-btn{
  972. width: 272rpx;
  973. height: 84rpx;
  974. margin: 0 auto;
  975. background: #FF5C03;
  976. border-radius: 42rpx 42rpx 42rpx 42rpx;
  977. font-family: PingFang SC, PingFang SC;
  978. font-weight: 500;
  979. font-size: 32rpx;
  980. color: #FFFFFF;
  981. line-height: 84rpx;
  982. text-align: center;
  983. }
  984. .guide3-toptip {
  985. width: 640rpx;
  986. height: 160rpx;
  987. padding: 26rpx;
  988. box-sizing: border-box;
  989. position: relative;
  990. font-family: PingFang SC, PingFang SC;
  991. font-weight: 400;
  992. font-size: 26rpx;
  993. color: #FFFFFF;
  994. line-height: 30rpx;
  995. }
  996. .guide3-toptip-head {
  997. // position: relative;
  998. margin-bottom: 8rpx;
  999. font-family: PingFang SC, PingFang SC;
  1000. font-weight: 600;
  1001. font-size: 34rpx;
  1002. color: #FFFFFF;
  1003. line-height: 40rpx;
  1004. }
  1005. .guide3-toptip-headbg {
  1006. width: 640rpx;
  1007. height: 160rpx;
  1008. position: absolute;
  1009. top: 0;
  1010. left: 0;
  1011. z-index: -1;
  1012. }
  1013. .Frame2611 {
  1014. width: 188rpx;
  1015. height: 184rpx;
  1016. position: absolute;
  1017. top: -90rpx;
  1018. right: 0;
  1019. }
  1020. .Frame2291 {
  1021. width: 702rpx;
  1022. // height: 684rpx;
  1023. margin: 24rpx 0 40rpx 0;
  1024. }
  1025. }
  1026. .container {
  1027. font-family: PingFang SC, PingFang SC;
  1028. padding-top: var(--status-bar-height);
  1029. position: relative;
  1030. z-index: 2;
  1031. }
  1032. .home_top_bg {
  1033. width: 100%;
  1034. height: auto;
  1035. position: absolute;
  1036. top: 0;
  1037. left: 0;
  1038. z-index: -1;
  1039. }
  1040. .tabbox {
  1041. position: relative;
  1042. margin-bottom: 22rpx;
  1043. position: relative;
  1044. .tabbar {
  1045. height: 88rpx;
  1046. @include u-flex(row,center,center);
  1047. font-weight: 600;
  1048. font-size: 32rpx;
  1049. color: #222222;
  1050. line-height: 88rpx;
  1051. position: relative;
  1052. .tabbar-item {
  1053. margin: 0 24rpx;
  1054. }
  1055. .active {
  1056. font-weight: 600;
  1057. font-size: 40rpx;
  1058. color: #FF5C03;
  1059. position: relative;
  1060. }
  1061. }
  1062. .tabbar-tabline-image {
  1063. width: 36rpx;
  1064. height: 12rpx;
  1065. }
  1066. .tabbar-tabline {
  1067. position: absolute;
  1068. bottom: 0;
  1069. width: 0;
  1070. height: 12rpx;
  1071. display: flex;
  1072. align-items: center;
  1073. justify-content: center;
  1074. }
  1075. .tabbar-tabline-animation {
  1076. transition-duration: 0.2s;
  1077. transition-property: left;
  1078. }
  1079. }
  1080. .activityPop{
  1081. position: relative;
  1082. z-index: 1002;
  1083. }
  1084. .page-loading {
  1085. position: fixed;
  1086. top: 0;
  1087. left: 0;
  1088. right: 0;
  1089. bottom: 0;
  1090. background-color: #fff;
  1091. z-index: 9999;
  1092. display: flex;
  1093. align-items: center;
  1094. justify-content: center;
  1095. .loading-content {
  1096. display: flex;
  1097. flex-direction: column;
  1098. align-items: center;
  1099. justify-content: center;
  1100. }
  1101. .loading-spinner {
  1102. width: 60rpx;
  1103. height: 60rpx;
  1104. border: 4rpx solid #f3f3f3;
  1105. border-top: 4rpx solid #FF5C03;
  1106. border-radius: 50%;
  1107. animation: spin 1s linear infinite;
  1108. }
  1109. .loading-text {
  1110. margin-top: 20rpx;
  1111. font-size: 28rpx;
  1112. color: #999;
  1113. }
  1114. }
  1115. @keyframes spin {
  1116. 0% { transform: rotate(0deg); }
  1117. 100% { transform: rotate(360deg); }
  1118. }
  1119. </style>