index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="menhu-v">
  3. <uni-nav-bar class='nav' :fixed="true" :statusBar="true" :border="false">
  4. <view class="nav-left" @click="showSelectBox">
  5. <view class="nav-left-text">{{portalTitle}}</view>
  6. <uni-icons class='right-icons' type="down" color="#000000" size="14"
  7. v-if="portalList.length>1 &&userInfo.appPortalId" :class="{'select-right-icons':showSelect}" />
  8. </view>
  9. </uni-nav-bar>
  10. <view v-if="userInfo.appPortalId">
  11. <mescroll-body ref="mescrollRef" @down="downCallback" :down="downOption" :sticky="true" @up="upCallback"
  12. :up="upOption" :bottombar="false" style="min-height: 100%" @init="mescrollInit">
  13. <view class="portal-v" v-if="authConfig.type==0">
  14. <view v-if="formData.length">
  15. <view class="portal-box" v-for="(item,index) in formData" :key="index">
  16. <portalItem :item='item' ref="portalItem" :key="key" v-if="item.show" />
  17. </view>
  18. </view>
  19. <view v-else class="portal-v portal-nodata">
  20. <view class="u-flex-col" style="align-items: center;">
  21. <u-image width="280rpx" height="280rpx" :src="emptyImg1"></u-image>
  22. <text class="u-m-t-20" style="color: #909399;">{{$t('common.noData')}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view v-if="authConfig.type==1">
  27. <view v-if="authConfig.linkType==1" style="height:calc(100vh - 100px)">
  28. <web-view :src="authConfig.customUrl" v-if="showWebView"></web-view>
  29. </view>
  30. <view v-else class="portal-v portal-nodata">
  31. <view class="u-flex-col" style="align-items: center;">
  32. <u-image width="280rpx" height="280rpx" :src="emptyImg"></u-image>
  33. <text class="u-m-t-20" style="color: #909399;">当前内容无法在APP上显示,请前往PC门户查看~~</text>
  34. </view>
  35. </view>
  36. </view>
  37. </mescroll-body>
  38. </view>
  39. <view class="portal-v" v-else>
  40. <view class="portal-box">
  41. <defaultPortal></defaultPortal>
  42. </view>
  43. </view>
  44. <u-popup v-model="showSelect" mode="top" class="select-box" height="600rpx">
  45. <view :style="{'margin-top':statusBarHeight+88+'rpx'}"></view>
  46. <view v-for="(item,index) in portalList" :key="index" class="select-item" @click="selectItem(item,index)">
  47. <text class="u-m-r-12 u-font-40"
  48. :class="[item.icon,{'currentItem':item.id === userInfo.appPortalId}]" />
  49. <text class="item-text sysName">{{item.fullName}}</text>
  50. <u-icon name="checkbox-mark " class="currentItem" v-if="item.id === userInfo.appPortalId"></u-icon>
  51. </view>
  52. </u-popup>
  53. </view>
  54. </template>
  55. <script>
  56. var wv; //计划创建的webview
  57. import {
  58. PortalList,
  59. SetPortal,
  60. auth
  61. } from '@/api/portal/portal.js'
  62. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"
  63. import IndexMixin from '@/pages/index/mixin.js'
  64. import chat from '@/libs/chat.js'
  65. import portalItem from '@/pages/portal/components/index.vue'
  66. import defaultPortal from '@/pages/portal/components/defaultPortal.vue'
  67. import resources from '@/libs/resources.js'
  68. import emptyImg from '@/static/image/defPortal.png'
  69. import {
  70. useChatStore
  71. } from '@/store/modules/chat'
  72. import {
  73. useUserStore
  74. } from '@/store/modules/user'
  75. export default {
  76. mixins: [MescrollMixin, IndexMixin],
  77. components: {
  78. portalItem,
  79. defaultPortal
  80. },
  81. data() {
  82. return {
  83. showWebView: true,
  84. emptyImg: emptyImg,
  85. emptyImg1: resources.message.nodata,
  86. rightIcon: '',
  87. key: +new Date(),
  88. formData: [],
  89. portalTitle: '门户',
  90. statusBarHeight: '',
  91. showSelect: false,
  92. selectData: {
  93. name: '',
  94. id: ''
  95. },
  96. portalList: [],
  97. id: '',
  98. userInfo: {},
  99. downOption: {
  100. use: true,
  101. auto: true
  102. },
  103. upOption: {
  104. page: {
  105. num: 0,
  106. size: 50,
  107. time: null
  108. },
  109. empty: {
  110. use: false,
  111. },
  112. textNoMore: this.$t('app.apply.noMoreData'),
  113. },
  114. authConfig: {},
  115. token: ''
  116. };
  117. },
  118. onShow() {
  119. this.$forceUpdate()
  120. },
  121. onLoad(e) {
  122. uni.setStorageSync('token', e.token)
  123. this.getCurrentUser()
  124. const chatStore = useChatStore()
  125. if (!chatStore.getSocket) chat && chat.initSocket()
  126. uni.$on('refresh', () => {
  127. this.formData = [];
  128. this.mescroll.resetUpScroll();
  129. })
  130. },
  131. methods: {
  132. getCurrentUser() {
  133. const userStore = useUserStore()
  134. userStore.getCurrentUser().then(() => {
  135. this.userInfo = uni.getStorageSync('userInfo') || {}
  136. if (!this.userInfo.appPortalId) return
  137. this.getPortalList()
  138. })
  139. },
  140. upCallback(keyword) {
  141. auth(this.userInfo.appPortalId).then(res => {
  142. this.authConfig = res.data || {}
  143. let data = JSON.parse(res.data.formData) || {};
  144. this.formData = []
  145. this.formData = data.layout ? JSON.parse(JSON.stringify(data.layout)) : []
  146. this.handelFormData(data)
  147. if (data.refresh.autoRefresh) {
  148. setInterval(() => {
  149. uni.$emit('proRefresh')
  150. }, data.refresh.autoRefreshTime * 60000)
  151. }
  152. this.mescroll.endSuccess(this.formData.length);
  153. this.key = +new Date()
  154. }).catch(() => {
  155. this.mescroll.endSuccess(0);
  156. this.mescroll.endErr();
  157. this.key = +new Date()
  158. })
  159. },
  160. handelFormData(data) {
  161. const loop = (list) => {
  162. list.forEach(o => {
  163. o.allRefresh = data.refresh
  164. o.show = false
  165. o.platform = 'mp'
  166. if (o.visibility && o.visibility.length && o.visibility.includes('app')) o.show =
  167. true
  168. if (o.children && o.children.length) loop(o.children)
  169. })
  170. this.key = +new Date()
  171. }
  172. loop(this.formData)
  173. this.dataList = this.formData.filter(o => o.show)
  174. if (this.dataList.length < 1) {
  175. this.formData = this.dataList
  176. this.mescroll.endSuccess(this.dataList.length);
  177. }
  178. },
  179. getPortalList() {
  180. PortalList().then(res => {
  181. let list = res.data.list || [];
  182. list.map(o => {
  183. this.portalList.push(...o.children)
  184. this.portalList.forEach(o => {
  185. if (o.id === this.userInfo.appPortalId) {
  186. this.portalTitle = o.fullName
  187. }
  188. })
  189. })
  190. })
  191. },
  192. showSelectBox() {
  193. this.showSelect = !this.showSelect
  194. },
  195. getStatusBarHeight() {
  196. let that = this;
  197. wx.getSystemInfo({
  198. success: function(res) {
  199. that.statusBarHeight = res.statusBarHeight;
  200. },
  201. });
  202. },
  203. selectItem(item, index) {
  204. SetPortal(item.id).then(res => {
  205. this.portalTitle = this.portalList[index].fullName
  206. this.userInfo.appPortalId = item.id
  207. this.mescroll.resetUpScroll();
  208. this.showSelectBox()
  209. uni.setStorageSync('userInfo', this.userInfo)
  210. })
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. page {
  217. background-color: #f0f2f6;
  218. }
  219. .menhu-v {
  220. .nav {
  221. z-index: 99999;
  222. :deep(.uni-navbar__content) {
  223. z-index: 99999;
  224. }
  225. :deep(.uni-navbar__header-container) {
  226. justify-content: center;
  227. }
  228. .nav-left {
  229. max-width: 100%;
  230. display: flex;
  231. align-items: center;
  232. .nav-left-text {
  233. font-weight: 700;
  234. font-size: 32rpx;
  235. flex: 1;
  236. min-width: 0;
  237. white-space: nowrap;
  238. overflow: hidden;
  239. text-overflow: ellipsis;
  240. }
  241. .right-icons {
  242. font-weight: 700;
  243. margin-top: 2px;
  244. margin-left: 4px;
  245. transition-duration: 0.3s;
  246. }
  247. .select-right-icons {
  248. transform: rotate(-180deg);
  249. }
  250. }
  251. }
  252. .select-box {
  253. overflow-y: scroll;
  254. .currentItem {
  255. color: #2979FF;
  256. }
  257. .select-item {
  258. height: 100rpx;
  259. display: flex;
  260. align-items: center;
  261. padding: 0 20rpx;
  262. font-size: 30rpx;
  263. color: #303133;
  264. text-align: left;
  265. position: relative;
  266. &::after {
  267. content: " ";
  268. position: absolute;
  269. left: 2%;
  270. top: 0;
  271. box-sizing: border-box;
  272. width: 96%;
  273. height: 1px;
  274. transform: scale(1, .3);
  275. border: 0 solid #e4e7ed;
  276. z-index: 2;
  277. border-bottom-width: 1px;
  278. }
  279. .sysName {
  280. flex: 1;
  281. overflow: auto;
  282. min-width: 0;
  283. }
  284. }
  285. }
  286. }
  287. :deep(.portal-nodata) {
  288. position: absolute;
  289. top: 450rpx;
  290. width: 100%;
  291. text-align: center;
  292. z-index: 100;
  293. background-color: #f0f2f6;
  294. }
  295. </style>