s-layout.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. <!-- 全局支付密码弹窗 -->
  36. <s-pay-password />
  37. </view>
  38. </view>
  39. </template>
  40. <script setup>
  41. /**
  42. * 模板组件 - 提供页面公共组件,属性,方法
  43. */
  44. import {
  45. computed,
  46. reactive,
  47. ref
  48. } from 'vue';
  49. import sheep from '@/sheep';
  50. import {
  51. isEmpty
  52. } from 'lodash';
  53. import {
  54. onShow
  55. } from '@dcloudio/uni-app';
  56. // #ifdef MP-WEIXIN
  57. import {
  58. onShareAppMessage
  59. } from '@dcloudio/uni-app';
  60. // #endif
  61. const props = defineProps({
  62. title: {
  63. type: String,
  64. default: '',
  65. },
  66. navbar: {
  67. type: String,
  68. default: 'normal',
  69. },
  70. opacityBgUi: {
  71. type: String,
  72. default: 'bg-white',
  73. },
  74. color: {
  75. type: String,
  76. default: '',
  77. },
  78. tools: {
  79. type: String,
  80. default: 'title',
  81. },
  82. keyword: {
  83. type: String,
  84. default: '',
  85. },
  86. navbarStyle: {
  87. type: Object,
  88. default: () => ({
  89. mode: '',
  90. type: '',
  91. color: '',
  92. src: '',
  93. list: [],
  94. alwaysShow: 0,
  95. }),
  96. },
  97. bgStyle: {
  98. type: Object,
  99. default: () => ({
  100. src: '',
  101. color: 'var(--ui-BG-1)',
  102. }),
  103. },
  104. tabbar: {
  105. type: [String, Boolean],
  106. default: '',
  107. },
  108. onShareAppMessage: {
  109. type: [Boolean, Object],
  110. default: true,
  111. },
  112. leftWidth: {
  113. type: [Number, String],
  114. default: 100,
  115. },
  116. rightWidth: {
  117. type: [Number, String],
  118. default: 100,
  119. },
  120. defaultSearch: {
  121. type: String,
  122. default: '',
  123. },
  124. //展示返回按钮
  125. showLeftButton: {
  126. type: Boolean,
  127. default: false,
  128. },
  129. });
  130. const emits = defineEmits(['search']);
  131. const sysStore = sheep.$store('sys');
  132. const userStore = sheep.$store('user');
  133. const appStore = sheep.$store('app');
  134. const modalStore = sheep.$store('modal');
  135. const sys = computed(() => sysStore);
  136. // 导航栏模式(因为有自定义导航栏 需要计算)
  137. const navbarMode = computed(() => {
  138. if (props.navbar === 'normal' || props.navbarStyle.mode === 'normal') {
  139. return 'normal';
  140. }
  141. return 'inner';
  142. });
  143. // 背景1
  144. const bgMain = computed(() => {
  145. if (navbarMode.value === 'inner') {
  146. return {
  147. background: `${props.bgStyle.backgroundColor} url(${sheep.$url.cdn(
  148. props.bgStyle.backgroundImage,
  149. )}) no-repeat top center / 100% auto`,
  150. };
  151. }
  152. return {};
  153. });
  154. // 背景2
  155. const bgBody = computed(() => {
  156. if (navbarMode.value === 'normal') {
  157. return {
  158. background: `${props.bgStyle.backgroundColor} url(${sheep.$url.cdn(
  159. props.bgStyle.backgroundImage,
  160. )}) no-repeat top center / 100% auto`,
  161. };
  162. }
  163. return {};
  164. });
  165. // 分享信息
  166. const shareInfo = computed(() => {
  167. if (props.onShareAppMessage === true) {
  168. return sheep.$platform.share.getShareInfo();
  169. } else {
  170. if (!isEmpty(props.onShareAppMessage)) {
  171. sheep.$platform.share.updateShareInfo(props.onShareAppMessage);
  172. return props.onShareAppMessage;
  173. }
  174. }
  175. return {};
  176. });
  177. // #ifdef MP-WEIXIN
  178. // 微信小程序分享
  179. onShareAppMessage(() => {
  180. return {
  181. title: shareInfo.value.title,
  182. path: shareInfo.value.path,
  183. imageUrl: shareInfo.value.image,
  184. };
  185. });
  186. // #endif
  187. onShow(() => {
  188. if (!isEmpty(shareInfo.value)) {
  189. sheep.$platform.share.updateShareInfo(shareInfo.value);
  190. }
  191. });
  192. </script>
  193. <style lang="scss" scoped>
  194. .page-app {
  195. position: relative;
  196. color: var(--ui-TC);
  197. background-color: var(--ui-BG-1) !important;
  198. z-index: 2;
  199. display: flex;
  200. width: 100%;
  201. height: 100vh;
  202. .page-main {
  203. position: absolute;
  204. z-index: 1;
  205. width: 100%;
  206. min-height: 100%;
  207. display: flex;
  208. flex-direction: column;
  209. background-color: var(--ui-BG-1) !important;
  210. .page-body {
  211. width: 100%;
  212. position: relative;
  213. z-index: 1;
  214. flex: 1;
  215. }
  216. .page-img {
  217. width: 100vw;
  218. height: 100vh;
  219. position: absolute;
  220. top: 0;
  221. left: 0;
  222. z-index: 0;
  223. }
  224. }
  225. }
  226. </style>