points.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="container">
  3. <image class="home_top_bg" src="@/static/image/hall/coin_points_mall_top_bg.png" mode="widthFix" :lazy-load="false"></image>
  4. <view class="tabbox">
  5. <u-tabs
  6. ref="uTabs"
  7. :list="tabList"
  8. :current="activeTab"
  9. :scrollable="false"
  10. :lineColor="`url(${lineBg}) 40rpx 12rpx`"
  11. lineWidth="40rpx"
  12. lineHeight="12rpx"
  13. :inactiveStyle="{
  14. fontWeight: 600,
  15. fontSize: '32rpx',
  16. color: '#f9f9f9',
  17. lineHeight: '88rpx',
  18. flexShrink: 0,
  19. }"
  20. :activeStyle="{
  21. fontWeight: 600,
  22. fontSize: '40rpx',
  23. color: '#ffffff',
  24. lineHeight: '88rpx',
  25. flexShrink: 0,
  26. }"
  27. itemStyle="margin: 10rpx 0"
  28. @change="handleTab"></u-tabs>
  29. </view>
  30. <swiper :current="activeTab" @change="onSwiperChange" :style="'height:' + (clientHeight || '100vh') + 'px;'">
  31. <swiper-item>
  32. <scroll-view
  33. scroll-y="true"
  34. :style="'height:' + clientHeight + 'px;'"
  35. :scroll-top="scrollTopGoods"
  36. @scrolltolower="scrolltolower"
  37. @scroll="scroll($event,'scrollTopGoods')"
  38. :refresher-enabled="true"
  39. :refresher-triggered="triggered"
  40. @refresherrefresh="handleRefresher">
  41. <pointsMall ref="integralGoods"></pointsMall>
  42. <view class="back-top" v-show="scrollTopGoods>clientHeight" @click="goTop">
  43. <image src="https://www.mescroll.com/img/mescroll-totop.png" mode="aspectFill"></image>
  44. </view>
  45. </scroll-view>
  46. </swiper-item>
  47. <swiper-item>
  48. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'" :scroll-top="scrollTopStudy" @scrolltolower="scrolltolowerStudy" @scroll="scroll($event,'scrollTopStudy')" :refresher-enabled="true"
  49. :refresher-triggered="triggered"
  50. @refresherrefresh="handleRefresher">
  51. <saveMoney ref="studyCenter"/>
  52. <view class="back-top" v-show="scrollTopStudy>clientHeight" @click="goTopStudy">
  53. <image src="https://www.mescroll.com/img/mescroll-totop.png" mode="aspectFill"></image>
  54. </view>
  55. </scroll-view>
  56. </swiper-item>
  57. <!-- <swiper-item>
  58. <scroll-view scroll-y="true" :style="'height:' + clientHeight + 'px;'">
  59. <makeMoney ref="homeIndex" source="course" />
  60. </scroll-view>
  61. </swiper-item> -->
  62. </swiper>
  63. </view>
  64. </template>
  65. <script>
  66. import pointsMall from "../course/components/integralGoods.vue"
  67. import saveMoney from './components/saveMoney.vue'
  68. import makeMoney from './components/makeMoney.vue'
  69. const lineBg = "/static/image/hall/tab_ellipse.png";
  70. export default {
  71. components:{
  72. pointsMall,
  73. saveMoney,
  74. makeMoney
  75. },
  76. data() {
  77. return {
  78. lineBg,
  79. clientHeight:0,
  80. scrollTopGoods: 0,
  81. scrollTopStudy: 0,
  82. old: {
  83. scrollTopStudy: 0,
  84. scrollTopHall: 0,
  85. scrollTopGoods: 0
  86. },
  87. triggered: false,
  88. activeTab:0,
  89. scrollViewId:'scrollView0',
  90. tabList: [
  91. {
  92. id: "tab01",
  93. name: '优选'
  94. }, {
  95. id: "tab02",
  96. name: '省钱'
  97. },
  98. // {
  99. // id: "tab03",
  100. // name: '赚钱'
  101. // }
  102. ],
  103. }
  104. },
  105. onPageScroll(e) {
  106. this.top=e.scrollTop;
  107. this.scrollTopGoods = e.scrollTop;
  108. },
  109. onReady() {
  110. // 同步获取系统信息,避免异步延迟
  111. try {
  112. const systemInfo = uni.getSystemInfoSync();
  113. this.clientHeight = systemInfo.windowHeight - uni.upx2px(120) - systemInfo.statusBarHeight;
  114. } catch (e) {
  115. // 降级到异步获取
  116. uni.getSystemInfo({
  117. success: (res) => {
  118. this.clientHeight = res.windowHeight - uni.upx2px(120) - res.statusBarHeight;
  119. }
  120. });
  121. }
  122. },
  123. onLoad() {
  124. // return uni.navigateTo({
  125. // url: '/pages/points/shopDetail?id=8541'
  126. // })
  127. // 同步获取系统信息,避免延迟
  128. try {
  129. const systemInfo = uni.getSystemInfoSync();
  130. this.statusBarHeight = systemInfo.statusBarHeight;
  131. // 提前设置 clientHeight,避免布局闪烁
  132. this.clientHeight = systemInfo.windowHeight - uni.upx2px(120) - systemInfo.statusBarHeight;
  133. this.isXiaomi=plus.runtime.channel == 'xiaomi';
  134. //this.isXiaomi=true;
  135. // if(!this.isXiaomi){
  136. // this.tabList.push({
  137. // id: "tab04",
  138. // name: '健康管理',
  139. // });
  140. // }
  141. } catch (e) {
  142. this.statusBarHeight = 0;
  143. }
  144. // 初始化当前默认tab(如果是直接进入的话)
  145. this.initCurrentTab();
  146. },
  147. methods: {
  148. handleTab(e) {
  149. this.activeTab = e.index
  150. // if(this.haveFamousCourse) {
  151. // // 防止在没有名医讲堂数据的时候有指引弹窗
  152. // this.changeGuide(this.activeTab);
  153. // console.log("=handleTab=")
  154. // }
  155. // this.$nextTick(()=>{
  156. // this.selectorQuery()
  157. // })
  158. },
  159. // swiper划动
  160. onSwiperChange(e){
  161. this.changeIdx(e.detail.current);
  162. },
  163. // 更新当前页
  164. changeIdx(index){
  165. if(this.activeTab === index) return;
  166. this.activeTab = index;
  167. this.scrollViewId = 'scrollView'+this.activeTab;
  168. // 初始化当前tab(懒加载)
  169. this.initCurrentTab();
  170. },
  171. // 初始化当前tab(懒加载优化)
  172. initCurrentTab() {
  173. if (this.initializedTabs && this.initializedTabs.has(this.activeTab)) {
  174. return; // 已初始化,跳过
  175. }
  176. if (!this.initializedTabs) {
  177. this.initializedTabs = new Set();
  178. }
  179. this.$nextTick(() => {
  180. if(this.activeTab == 0) {
  181. // tab 0 由 doctorHall 组件自己处理
  182. this.initializedTabs.add(0);
  183. } else if(this.activeTab == 1) {
  184. if(this.$refs['studyCenter']) {
  185. this.$refs['studyCenter'].initShow();
  186. this.initializedTabs.add(1);
  187. }
  188. } else if(this.activeTab == 2) {
  189. if(this.$refs.homeIndex) {
  190. this.$refs.homeIndex.initShow();
  191. this.initializedTabs.add(2);
  192. }
  193. }
  194. });
  195. },
  196. goTop() {
  197. setTimeout(()=>{
  198. this.old.scrollTopGoods = 0
  199. this.scrollTopGoods = 0
  200. })
  201. },
  202. scroll(e,type) {
  203. this.old[type] = e.detail.scrollTop
  204. if (type === 'scrollTopGoods') {
  205. this.scrollTopGoods = this.old[type]
  206. } else if (type === 'scrollTopStudy') {
  207. this.scrollTopStudy = this.old[type]
  208. }
  209. },
  210. scrolltolower(){
  211. this.$refs.integralGoods&&this.$refs.integralGoods.scrolltolower()
  212. },
  213. scrolltolowerStudy() {
  214. this.$refs.studyCenter&&this.$refs.studyCenter.scrolltolower()
  215. },
  216. goTopStudy() {
  217. setTimeout(()=>{
  218. this.old.scrollTopStudy = 0
  219. this.scrollTopStudy = 0
  220. })
  221. },
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. @mixin u-flex($flexD, $alignI, $justifyC) {
  227. display: flex;
  228. flex-direction: $flexD;
  229. align-items: $alignI;
  230. justify-content: $justifyC;
  231. }
  232. .back-top {
  233. border-radius: 50%;
  234. overflow: hidden;
  235. background-color: transparent;
  236. width: 40px;
  237. height: 40px;
  238. position: fixed;
  239. right: 24rpx;
  240. bottom: 100rpx;
  241. z-index: 99;
  242. image {
  243. width: 40px;
  244. height: 40px;
  245. }
  246. }
  247. .container {
  248. font-family: PingFang SC, PingFang SC;
  249. padding-top: var(--status-bar-height);
  250. position: relative;
  251. z-index: 2;
  252. }
  253. .home_top_bg {
  254. width: 100%;
  255. height: auto;
  256. position: absolute;
  257. top: 0;
  258. left: 0;
  259. z-index: -1;
  260. }
  261. .tabbox {
  262. position: relative;
  263. margin-bottom: 22rpx;
  264. position: relative;
  265. display: flex;
  266. justify-content: center;
  267. .tabbar {
  268. height: 88rpx;
  269. @include u-flex(row,center,center);
  270. font-weight: 600;
  271. font-size: 32rpx;
  272. color: #222222;
  273. line-height: 88rpx;
  274. position: relative;
  275. .tabbar-item {
  276. margin: 0 24rpx;
  277. }
  278. .active {
  279. font-weight: 600;
  280. font-size: 40rpx;
  281. color: #FF5C03;
  282. position: relative;
  283. }
  284. }
  285. .tabbar-tabline-image {
  286. width: 36rpx;
  287. height: 12rpx;
  288. }
  289. .tabbar-tabline {
  290. position: absolute;
  291. bottom: 0;
  292. width: 0;
  293. height: 12rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. }
  298. .tabbar-tabline-animation {
  299. transition-duration: 0.2s;
  300. transition-property: left;
  301. }
  302. }
  303. </style>