index.vue 12 KB

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