Home.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view>
  3. <modeBaseHome v-if="modeType == 'base'" ref="modeBaseHome" class="modeBaseHome"></modeBaseHome>
  4. <modeCareHome v-if="modeType == 'care'" ref="modeCareHome" class="modeCareHome"></modeCareHome>
  5. <!-- 通知公告弹窗 -->
  6. <view class="popMask" v-if="isPopShow">
  7. <view class="popContent">
  8. <view class="popTips" :class="modeType == 'care' ? 'careFont44' : ''">公告</view>
  9. <view class="popBody">
  10. <rich-text :nodes="renewNoticeData.content" :class="modeType == 'care' ? 'careFont36' : ''"></rich-text>
  11. </view>
  12. <view class="popBtn" @tap="onCancelTo" :class="modeType == 'care' ? 'careFont36' : ''">知道了</view>
  13. </view>
  14. </view>
  15. <!-- 悬浮球 -->
  16. <DragButton exceedBorderLength=15>
  17. <view class="modeBtn" :class="modeType == 'care' ? 'careFont36' : ''" @tap="OnChangeMode">{{modeType == 'base' ? '关怀模式' : '标准模式'}}</view>
  18. </DragButton>
  19. </view>
  20. </template>
  21. <script>
  22. import modeBaseHome from '@/pages/BaseTabBar/Home.vue'
  23. import modeCareHome from '@/pages/CareTabBar/Home.vue'
  24. import DragButton from "@/components/dragon-dragButton/index.vue";
  25. var that;
  26. export default {
  27. data() {
  28. return {
  29. modeType: '', // base: 标准版 care: 关怀版
  30. isPopShow: false,
  31. renewNoticeTimeout: null,
  32. renewNoticeData: [],
  33. }
  34. },
  35. components:{
  36. modeBaseHome,
  37. modeCareHome,
  38. DragButton
  39. },
  40. onLoad(options) {
  41. that = this;
  42. that.modeType = uni.getStorageSync('modeType') || 'base';
  43. that.$nextTick(function() {
  44. if (that.modeType == 'base'){
  45. that.$refs.modeBaseHome.getData();
  46. }else if (that.modeType == 'care'){
  47. that.$refs.modeCareHome.getData();
  48. }
  49. })
  50. that.onGetRenewNotice(function() {
  51. // 弹出更新公告
  52. if (that.renewNoticeData && that.renewNoticeData.content) {
  53. that.isPopShow = true;
  54. let time = that.modeType == 'care' ? 30000 : 10000;
  55. that.renewNoticeTimeout = setTimeout(function() {
  56. that.isPopShow = false;
  57. }, time);
  58. }
  59. });
  60. },
  61. onShow(){
  62. that.$nextTick(function() {
  63. if (that.modeType == 'base'){
  64. that.$refs.modeBaseHome.updateData();
  65. }else if (that.modeType == 'care'){
  66. that.$refs.modeCareHome.updateData();
  67. }
  68. })
  69. },
  70. onShareAppMessage() {
  71. return {
  72. title: '群众随时拍,部门马上办',
  73. path: '/pages/Index/Home',
  74. imageUrl: '/static/img/home/share.jpg'
  75. }
  76. },
  77. onShareTimeline(){
  78. return {
  79. title: '群众随时拍,部门马上办',
  80. imageUrl: '/static/img/home/share.jpg'
  81. }
  82. },
  83. methods: {
  84. // 更新公告
  85. onGetRenewNotice(fun) {
  86. that.$admin.reqDirect({
  87. method: 'GET',
  88. url: '/api/v1/Snapshot/bulletions/popup'
  89. }).then(res => {
  90. that.renewNoticeData = res;
  91. typeof fun === 'function' && fun();
  92. })
  93. },
  94. onCancelTo() {
  95. that.isPopShow = false;
  96. that.renewNoticeTimeout = null;
  97. },
  98. // 切换体验版
  99. OnChangeMode(){
  100. if (that.modeType == 'base'){
  101. uni.setStorageSync('modeType', "care");
  102. }else if (that.modeType == 'care'){
  103. uni.setStorageSync('modeType', "base");
  104. }
  105. uni.reLaunch({
  106. url: "/pages/Index/Home"
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="less">
  113. /* 自定提示弹窗 */
  114. .popMask {
  115. position: fixed;
  116. left: 0;
  117. top: 0;
  118. right: 0;
  119. bottom: 0;
  120. /* #ifndef APP-NVUE */
  121. display: flex;
  122. /* #endif */
  123. justify-content: center;
  124. align-items: center;
  125. background-color: rgba(0, 0, 0, 0.2);
  126. line-height: 1 !important;
  127. z-index: 99;
  128. }
  129. .popContent {
  130. width: 80%;
  131. line-height: 1 !important;
  132. }
  133. .popTips {
  134. width: 100%;
  135. font-size: 36rpx;
  136. color: #333;
  137. font-weight: bold;
  138. text-align: center;
  139. padding: 30rpx 0 10rpx;
  140. line-height: 1 !important;
  141. background-color: #fff;
  142. border-radius: 30rpx 30rpx 0 0;
  143. }
  144. .popBody {
  145. width: calc(100% - 40rpx);
  146. padding: 20rpx;
  147. font-size: 24rpx;
  148. color: #333;
  149. line-height: 1.5 !important;
  150. background-color: #fff;
  151. max-height: 600rpx;
  152. overflow-y: auto;
  153. word-break: break-all;
  154. }
  155. .popBtn {
  156. width: 100%;
  157. padding: 30rpx 0;
  158. text-align: center;
  159. font-size: 30rpx;
  160. letter-spacing: 2rpx;
  161. line-height: 1 !important;
  162. background-color: #fff;
  163. color: #3e6ffd;
  164. border-top: 2rpx #ebebeb solid;
  165. border-radius: 0 0 30rpx 30rpx;
  166. }
  167. </style>