s-layout.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="page-app" :class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]">
  3. <view class="page-main" :style="[bgMain]">
  4. <!-- 默认通用顶部导航栏 -->
  5. <su-navbar v-if="navbar === 'normal'" :title="title" statusBar :color="color" :tools="tools"
  6. :opacityBgUi="opacityBgUi" @search="(e) => emits('search', e)" :defaultSearch="defaultSearch" />
  7. <!-- 装修组件导航栏-普通 -->
  8. <s-custom-navbar v-else-if="navbar === 'custom' && navbarMode === 'normal'" :data="navbarStyle"
  9. :showLeftButton="showLeftButton" />
  10. <view class="page-body" :style="[bgBody]">
  11. <!-- 沉浸式头部 -->
  12. <su-inner-navbar v-if="navbar === 'inner'" :title="title" />
  13. <view v-if="navbar === 'inner'" :style="[{ paddingTop: sheep.$platform.navbar + 'px' }]"></view>
  14. <!-- 装修组件导航栏-沉浸式 -->
  15. <!-- <s-custom-navbar v-if="navbar === 'custom' && navbarMode === 'inner'" :data="navbarStyle" :showLeftButton="showLeftButton" /> -->
  16. <!-- 页面内容插槽 -->
  17. <slot />
  18. <!-- 底部导航 -->
  19. <s-tabbar v-if="tabbar !== ''" :path="tabbar" />
  20. </view>
  21. </view>
  22. <view class="page-modal">
  23. <!-- 全局获得佣金提示弹窗 -->
  24. <s-wallet-modal />
  25. <!-- 全局自动签到弹窗 -->
  26. <s-signup-modal />
  27. <!-- 全局关注公众号弹窗 -->
  28. <s-follow-modal />
  29. <!-- 全局授权弹窗 -->
  30. <s-auth-modal />
  31. <!-- 全局分享弹窗 -->
  32. <s-share-modal :shareInfo="shareInfo" />
  33. <!-- 全局快捷入口 -->
  34. <s-menu-tools />
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. /**
  40. * 模板组件 - 提供页面公共组件,属性,方法
  41. */
  42. import {
  43. computed,
  44. reactive,
  45. ref
  46. } from 'vue';
  47. import sheep from '@/sheep';
  48. import {
  49. isEmpty
  50. } from 'lodash';
  51. import {
  52. onShow
  53. } from '@dcloudio/uni-app';
  54. // #ifdef MP-WEIXIN
  55. import {
  56. onShareAppMessage
  57. } from '@dcloudio/uni-app';
  58. // #endif
  59. const props = defineProps({
  60. title: {
  61. type: String,
  62. default: '',
  63. },
  64. navbar: {
  65. type: String,
  66. default: 'normal',
  67. },
  68. opacityBgUi: {
  69. type: String,
  70. default: 'bg-white',
  71. },
  72. color: {
  73. type: String,
  74. default: '',
  75. },
  76. tools: {
  77. type: String,
  78. default: 'title',
  79. },
  80. keyword: {
  81. type: String,
  82. default: '',
  83. },
  84. navbarStyle: {
  85. type: Object,
  86. default: () => ({
  87. mode: '',
  88. type: '',
  89. color: '',
  90. src: '',
  91. list: [],
  92. alwaysShow: 0,
  93. }),
  94. },
  95. bgStyle: {
  96. type: Object,
  97. default: () => ({
  98. src: '',
  99. color: 'var(--ui-BG-1)',
  100. }),
  101. },
  102. tabbar: {
  103. type: [String, Boolean],
  104. default: '',
  105. },
  106. onShareAppMessage: {
  107. type: [Boolean, Object],
  108. default: true,
  109. },
  110. leftWidth: {
  111. type: [Number, String],
  112. default: 100,
  113. },
  114. rightWidth: {
  115. type: [Number, String],
  116. default: 100,
  117. },
  118. defaultSearch: {
  119. type: String,
  120. default: '',
  121. },
  122. //展示返回按钮
  123. showLeftButton: {
  124. type: Boolean,
  125. default: false,
  126. },
  127. });
  128. const emits = defineEmits(['search']);
  129. const sysStore = sheep.$store('sys');
  130. const userStore = sheep.$store('user');
  131. const appStore = sheep.$store('app');
  132. const modalStore = sheep.$store('modal');
  133. const sys = computed(() => sysStore);
  134. // 导航栏模式(因为有自定义导航栏 需要计算)
  135. const navbarMode = computed(() => {
  136. if (props.navbar === 'normal' || props.navbarStyle.mode === 'normal') {
  137. return 'normal';
  138. }
  139. return 'inner';
  140. });
  141. // 背景1
  142. const bgMain = computed(() => {
  143. if (navbarMode.value === 'inner') {
  144. return {
  145. background: `${props.bgStyle.backgroundColor} url(${sheep.$url.cdn(
  146. props.bgStyle.backgroundImage,
  147. )}) no-repeat top center / 100% auto`,
  148. };
  149. }
  150. return {};
  151. });
  152. // 背景2
  153. const bgBody = computed(() => {
  154. if (navbarMode.value === 'normal') {
  155. return {
  156. background: `${props.bgStyle.backgroundColor} url(${sheep.$url.cdn(
  157. props.bgStyle.backgroundImage,
  158. )}) no-repeat top center / 100% auto`,
  159. };
  160. }
  161. return {};
  162. });
  163. // 分享信息
  164. const shareInfo = computed(() => {
  165. if (props.onShareAppMessage === true) {
  166. return sheep.$platform.share.getShareInfo();
  167. } else {
  168. if (!isEmpty(props.onShareAppMessage)) {
  169. sheep.$platform.share.updateShareInfo(props.onShareAppMessage);
  170. return props.onShareAppMessage;
  171. }
  172. }
  173. return {};
  174. });
  175. // #ifdef MP-WEIXIN
  176. // 微信小程序分享
  177. onShareAppMessage(() => {
  178. return {
  179. title: shareInfo.value.title,
  180. path: shareInfo.value.path,
  181. imageUrl: shareInfo.value.image,
  182. };
  183. });
  184. // #endif
  185. onShow(() => {
  186. if (!isEmpty(shareInfo.value)) {
  187. sheep.$platform.share.updateShareInfo(shareInfo.value);
  188. }
  189. });
  190. </script>
  191. <style lang="scss" scoped>
  192. .page-app {
  193. position: relative;
  194. color: var(--ui-TC);
  195. background-color: var(--ui-BG-1) !important;
  196. z-index: 2;
  197. display: flex;
  198. width: 100%;
  199. height: 100vh;
  200. .page-main {
  201. position: absolute;
  202. z-index: 1;
  203. width: 100%;
  204. min-height: 100%;
  205. display: flex;
  206. flex-direction: column;
  207. background-color: var(--ui-BG-1) !important;
  208. .page-body {
  209. width: 100%;
  210. position: relative;
  211. z-index: 1;
  212. flex: 1;
  213. }
  214. .page-img {
  215. width: 100vw;
  216. height: 100vh;
  217. position: absolute;
  218. top: 0;
  219. left: 0;
  220. z-index: 0;
  221. }
  222. }
  223. }
  224. </style>