index.vue 9.8 KB

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