index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <u-navbar :autoBack="false" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color" @rightClick="rightButtonClick()">
  3. <template #left>
  4. <view class="u-nav-slot">
  5. <!-- <u-icon name="arrow-left" size="19" color="#fff" style="display: none"></u-icon> -->
  6. <view class="u-navbar__content__title" style="color: #fff">应用中心</view>
  7. </view>
  8. </template>
  9. <template #center>
  10. <view class="u-nav-slot"> </view>
  11. </template>
  12. <template #right>
  13. <view class="u-nav-slot">
  14. <u-icon name="plus" size="19" color="#fff"></u-icon>
  15. </view>
  16. </template>
  17. </u-navbar>
  18. <!-- <pagesHarder></pagesHarder> -->
  19. <oa-scroll
  20. customClass="scroll-height"
  21. :customStyle="{ height: `calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}))` }"
  22. :refresherLoad="false"
  23. :refresherEnabled="true"
  24. :refresherDefaultStyle="'none'"
  25. :refresherThreshold="44"
  26. :refresherBackground="'#f5f6f7'"
  27. @refresh="refresh"
  28. >
  29. <template #default>
  30. <view class="home-container">
  31. <!-- 下拉列表 开始 -->
  32. <u-transition :show="dialogFlag" :duration="200" mode="fade">
  33. <view class="transition" @click="rightButtonClick()">
  34. <view class="transition-section" :style="{ top: proxy.$settingStore.barHightTop }">
  35. <view class="transition-section-content" @click="scanCode()">
  36. <text class="transition-section-content-icon iconfont ucicon-saoyisao"></text>
  37. <view class="transition-section-content-text"> 扫一扫 </view>
  38. </view>
  39. <!-- <div class="transition-section-divider"></div>
  40. <view class="transition-section-content">
  41. <text class="transition-section-content-icon iconfont ucicon-saoyisao"></text>
  42. <view class="transition-section-content-text">发起群聊 </view>
  43. </view> -->
  44. </view>
  45. </view>
  46. </u-transition>
  47. <!-- 下拉列表 结束 -->
  48. <!-- 轮播图 开始 -->
  49. <u-swiper v-if="swiperBool" :list="swiperList" :interval="swiperTime" indicatorMode="line" radius="0" height="160" indicator circular keyName="url" @click="swiperClick" @change="swiperChange">
  50. </u-swiper>
  51. <image v-if="!swiperBool" style="width: 100%; height: 160px" src="@/static/images/index/banner1.png"></image>
  52. <!-- <view class="app-info-notice bg-white radius shadow-default margin-lr-sm margin-bottom-sm">
  53. <view class="flex">
  54. <view class="info-title text-df">综合智慧云</view>
  55. <view class="info-time text-sm">07-25 19:23</view>
  56. </view>
  57. <view class="info-content text-sm">综合智慧云app,助力企业数字化转型升级,超多业务功能,全新部署上线,操作简单流畅...</view>
  58. </view> -->
  59. <!-- 轮播图 结束 -->
  60. <!-- 宫格列表 -->
  61. <view class="section2 section bg-white margin-bottom-sm" v-if="recentlyUsed.length > 0">
  62. <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">最近使用</view>
  63. <view class="cu-list grid col-5 no-border">
  64. <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in recentlyUsed.slice(0, 5)" :key="index">
  65. <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
  66. <!-- <view class="cu-tag badge" v-if="item.badge != 0">
  67. <block v-if="item.badge != 0">{{ item.badge > 99 ? "99+" : item.badge }}</block>
  68. </view> -->
  69. <text style="font-size: 12px">{{ item.meta.title }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 宫格列表 end -->
  74. <!-- 宫格列表 -->
  75. <view class="section2 section bg-white">
  76. <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">常用功能</view>
  77. <view class="cu-list grid col-5 no-border">
  78. <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in cuIconList" :key="index">
  79. <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
  80. <!-- <view class="cu-tag badge" v-if="item.badge != 0">
  81. <block v-if="item.badge != 0">{{ item.badge > 99 ? "99+" : item.badge }}</block>
  82. </view> -->
  83. <text style="font-size: 12px">{{ item.meta.title }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 宫格列表 end -->
  88. </view>
  89. </template>
  90. </oa-scroll>
  91. <oa-tabbar :tabbarValue="0"></oa-tabbar>
  92. </template>
  93. <script setup>
  94. import searchSelect from "@/components/searchSelect/searchSelect.vue";
  95. import * as jwx from "@/utils/jssdk.js"; //引入js sdk的封装
  96. import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  97. import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
  98. import { getToken } from "@/utils/auth";
  99. import { useStores, publicStores } from "@/store/modules/index";
  100. import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouters, qrCodeSend, getMobileBanner } from "@/api/index";
  101. const useStore = useStores();
  102. const publicStore = publicStores(); //全局公共Store
  103. const BASE_URL = inject("$BASE_URL");
  104. const { proxy } = getCurrentInstance();
  105. const arrayList = reactive({
  106. dialogFlag: false,
  107. swiperBool: false,
  108. swiperIndex: 0,
  109. swiperTime: 5000,
  110. swiperList: [],
  111. cuIconList: [],
  112. recentlyUsed: [],
  113. });
  114. const { dialogFlag, swiperBool, swiperIndex, swiperTime, swiperList, cuIconList, recentlyUsed } = toRefs(arrayList);
  115. /**
  116. * @获取轮播图下标
  117. * @change事件
  118. */
  119. function swiperChange(e) {
  120. swiperIndex.value = e.current;
  121. }
  122. /**
  123. * @轮播图点击事件
  124. */
  125. function swiperClick(list) {
  126. if (typeof list == "object") {
  127. let linkType = swiperList.value[swiperIndex.value].linkType;
  128. let url = swiperList.value[swiperIndex.value].link;
  129. if (url) {
  130. if (linkType == 1) {
  131. uni.navigateTo({
  132. url: url,
  133. });
  134. } else {
  135. uni.navigateTo({
  136. url: "/pages/common/webview/index?url=" + url,
  137. });
  138. }
  139. }
  140. }
  141. }
  142. onLoad((option) => {
  143. uni.hideTabBar(); //隐藏自带tabbar
  144. if (uni.getStorageSync(useStore.$state.name + useStore.$state.tenantId)) {
  145. recentlyUsed.value = uni.getStorageSync(useStore.$state.name + useStore.$state.tenantId);
  146. }
  147. getAppRoutersData(); //调用路由信息接口
  148. getMobileBannerApi(); //调用banner图接口
  149. });
  150. /**
  151. * @scrollView刷新数据
  152. */
  153. function refresh() {
  154. getAppRoutersData(); //调用路由信息接口
  155. getMobileBannerApi(); //调用banner图接口
  156. }
  157. /**
  158. * @扫码功能
  159. */
  160. function scanCode() {
  161. //#ifdef H5 || MP-WEIXIN
  162. jwx.configWeiXin((jweixin) => {
  163. console.log(2);
  164. jweixin.scanQRCode({
  165. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  166. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  167. success: function (res) {
  168. setTimeout(function () {
  169. scan_push({ ercode: res.resultStr }).then((res) => {
  170. if (res.data.flag) {
  171. uni.showToast({
  172. title: "扫码成功",
  173. icon: "none",
  174. });
  175. }
  176. });
  177. }, 1000);
  178. },
  179. });
  180. });
  181. //#endif
  182. //#ifdef APP-PLUS
  183. uni.scanCode({
  184. scanType: ["qrCode"],
  185. success: (res) => {
  186. let list = JSON.parse(res.result);
  187. uni.showToast({
  188. title: "扫码成功",
  189. icon: "none",
  190. });
  191. qrCodeSend({
  192. qrCode: list.uid,
  193. tenantId: useStore.$state.tenantId,
  194. userName: useStore.$state.name,
  195. }).then((res) => {});
  196. },
  197. fail: (err) => {
  198. console.log("扫码失败", err);
  199. },
  200. complete: () => {
  201. console.log("扫码结束");
  202. },
  203. });
  204. //#endif
  205. }
  206. /**
  207. * @获取地理位置
  208. */
  209. function getLocation() {
  210. jwx.configWeiXin((jweixin) => {
  211. // 微信公众号获取位置
  212. jweixin.getLocation({
  213. type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  214. success: function (res) {
  215. alert(res.longitude);
  216. },
  217. });
  218. });
  219. }
  220. /**
  221. * @九宫格页面跳转
  222. */
  223. function navItemClick(item) {
  224. if (item.path) {
  225. item.sort = 0;
  226. recentlyUsed.value.push(item);
  227. if (recentlyUsed.value.length > 0) {
  228. recentlyUsed.value = recentlyUsed.value.filter((currentValue, currentIndex, selfArr) => {
  229. return selfArr.findIndex((x) => x.path === currentValue.path) === currentIndex;
  230. });
  231. recentlyUsed.value.filter((el) => {
  232. if (el.path === item.path) {
  233. el.sort++;
  234. }
  235. });
  236. }
  237. recentlyUsed.value = publicStore.sortEvent(recentlyUsed.value, 1);
  238. uni.setStorageSync(useStore.$state.name + useStore.$state.tenantId, recentlyUsed.value);
  239. if (item.path.indexOf("http") != -1) {
  240. uni.navigateTo({
  241. url: "/pages/common/webview/index?url=" + item.path,
  242. });
  243. } else {
  244. uni.navigateTo({
  245. url: item.path,
  246. });
  247. }
  248. } else {
  249. uni.showModal({
  250. title: "Tips",
  251. content: "此模块开发中~",
  252. showCancel: false,
  253. success: function (res) {
  254. if (res.confirm) {
  255. } else if (res.cancel) {
  256. }
  257. },
  258. });
  259. }
  260. }
  261. /**
  262. * @右侧按钮点击事件
  263. */
  264. function rightButtonClick() {
  265. dialogFlag.value = !dialogFlag.value;
  266. }
  267. /**
  268. * @轮播图
  269. * @api接口请求
  270. */
  271. function getMobileBannerApi() {
  272. getMobileBanner({
  273. tenantId: useStore.$state.tenantId,
  274. }).then((res) => {
  275. if (res.data.length > 0) {
  276. swiperList.value = [];
  277. swiperBool.value = res.data[0].openNot == 1 ? true : false;
  278. swiperTime.value = res.data[0].carouselTime * 1000;
  279. for (let i = 1; i <= 5; i++) {
  280. if (res.data[0]["bannerPath" + i]) {
  281. swiperList.value.push({
  282. url: res.data[0]["bannerPath" + i],
  283. link: res.data[0]["linkUrl" + i],
  284. linkType: res.data[0]["linkType" + i],
  285. type: "image",
  286. });
  287. }
  288. }
  289. }
  290. });
  291. }
  292. /**
  293. * @获取路由信息
  294. * @api接口请求
  295. */
  296. function getAppRoutersData() {
  297. getAppRouters({
  298. // domain: window.location.host.indexOf("localhost") != -1 ? "localhost:81" : window.location.host,
  299. // platformType: "MOB",
  300. // domain :'172.16.120.165:13201'
  301. // domain :'172.16.120.165:13203'
  302. }).then((res) => {
  303. res.data.forEach((el) => {
  304. el.meta.icon = `/static/icons/index/${el.meta.icon}.png`;
  305. });
  306. cuIconList.value = res.data;
  307. });
  308. }
  309. onShow(() => {});
  310. // 自定义导航事件
  311. onNavigationBarButtonTap((e) => {
  312. if (e.float == "right") {
  313. // alert("你点击了扫一扫");
  314. scanCode();
  315. } else {
  316. rightButtonClick();
  317. }
  318. });
  319. </script>
  320. <style lang="scss" scoped>
  321. .home-container {
  322. // #ifdef H5
  323. // padding-bottom: 50px;
  324. // #endif
  325. .transition {
  326. position: fixed;
  327. top: 0;
  328. left: 0;
  329. right: 0;
  330. bottom: 0;
  331. z-index: 1100;
  332. .transition-section {
  333. position: absolute;
  334. top: 10px;
  335. right: 15px;
  336. background-color: #fff;
  337. border-radius: 10px;
  338. box-shadow: 0px 0px 15px 0 rgba(0, 0, 0, 0.2);
  339. .transition-section-divider {
  340. border-bottom: 0.5px rgba(0, 0, 0, 0.1) solid;
  341. margin: 0 20px;
  342. }
  343. .transition-section-content {
  344. display: flex;
  345. padding: 15px 20px;
  346. .transition-section-content-icon {
  347. font-size: 18px;
  348. color: #000;
  349. }
  350. .transition-section-content-text {
  351. margin: 0 20px;
  352. }
  353. }
  354. .transition-section-content:first-child {
  355. padding-top: 15px;
  356. border-radius: 10px 10px 0 0;
  357. }
  358. .transition-section-content:last-child {
  359. padding-bottom: 15px;
  360. border-radius: 0 0 10px 10px;
  361. }
  362. .transition-section-content:hover {
  363. // transform: 3s;
  364. // transition: all 600ms cubic-bezier(0.3, 1, 0.2, 1);
  365. transition: all 3s cubic-bezier(0.7, -0.5, 0.2, 2);
  366. background-color: rgba(0, 0, 0, 0.1);
  367. }
  368. }
  369. }
  370. }
  371. </style>