index.vue 12 KB

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