App.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <script>
  2. import dd from '@/static/dd.js'
  3. import {
  4. mapMutations
  5. } from 'vuex'
  6. import {
  7. version
  8. } from './package.json'
  9. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
  10. import {
  11. list
  12. } from '@/utils/router.js'
  13. import {
  14. editDDtitle
  15. } from '@/utils/DateUtils.js'
  16. import Util from "@/common/js/util.js"
  17. export default {
  18. onLaunch: function() {
  19. // #ifdef H5
  20. // console.log(
  21. // `%c hello uniapp %c v${version} `,
  22. // 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
  23. // 'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
  24. // )
  25. // #endif
  26. // 线上示例使用
  27. // console.log('%c uni-app官方团队诚邀优秀前端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
  28. // console.log('App Launch');
  29. // #ifdef APP-PLUS
  30. // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542
  31. if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid
  32. checkUpdate()
  33. }
  34. // 一键登录预登陆,可以显著提高登录速度
  35. uni.preLogin({
  36. provider: 'univerify',
  37. success: (res) => {
  38. // 成功
  39. this.setUniverifyErrorMsg();
  40. console.log("preLogin success: ", res);
  41. },
  42. fail: (res) => {
  43. this.setUniverifyLogin(false);
  44. this.setUniverifyErrorMsg(res.errMsg);
  45. // 失败
  46. console.log("preLogin fail res: ", res);
  47. }
  48. })
  49. uni.getSetting({
  50. success: (res) => {
  51. if (!res.authSetting['scope.writePhotosAlbum']) {
  52. uni.authorize({
  53. scope: 'scope.writePhotosAlbum',
  54. success: () => {
  55. console.log('用户已授权')
  56. },
  57. fail: () => {
  58. console.log('用户拒绝授权')
  59. }
  60. })
  61. }
  62. }
  63. })
  64. // #endif
  65. },
  66. onShow: function() {},
  67. onHide: function() {
  68. },
  69. globalData: {
  70. test: ''
  71. },
  72. methods: {
  73. ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
  74. },
  75. mounted() {
  76. // list.filter(item => {
  77. // if (item.path == this.$route.meta.pagePath) {
  78. // editDDtitle(item.title)
  79. // }
  80. // })
  81. // if (dd.env.platform !== "notInDingTalk") {
  82. // dd.biz.navigation.hideBar({
  83. // hidden: true, // true:隐藏,false:显示
  84. // onSuccess: function(result) {},
  85. // onFail: function(err) {}
  86. // })
  87. // }
  88. list.filter(item => {
  89. if (item.path == this.$route.meta.pagePath) {
  90. editDDtitle(item.title)
  91. }
  92. })
  93. },
  94. created() {
  95. if (sessionStorage.getItem('store')) {
  96. // this.$store.replaceState(
  97. // Object.assign({},
  98. // this.$store.state,
  99. // JSON.parse(sessionStorage.getItem('store'))
  100. // )
  101. // )
  102. this.$store.replaceState(Util.deepClone(JSON.parse(sessionStorage.getItem('store'))))
  103. }
  104. // 在页面刷新时将vuex里的信息保存到sessionStorage里
  105. // beforeunload事件在页面刷新时先触发
  106. window.addEventListener('beforeunload', () => {
  107. sessionStorage.setItem('store', JSON.stringify(this.$store.state))
  108. })
  109. },
  110. watch: {
  111. $route() {
  112. list.filter(item => {
  113. if (item.path == this.$route.meta.pagePath) {
  114. editDDtitle(item.title)
  115. }
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. @import "uview-ui/index.scss";
  123. @import '@/common/plus.css';
  124. @import "./uni_modules/uni-scss/index.scss";
  125. uni-modal {
  126. z-index: 999999 !important;
  127. }
  128. /deep/.popup-content {
  129. border-top-left-radius: 10px;
  130. background-color: #fff;
  131. border-top-right-radius: 10px;
  132. }
  133. @font-face {
  134. font-family: "PingFang";
  135. src: url("@/static/PingFang.ttf");
  136. font-weight: normal;
  137. font-style: normal;
  138. }
  139. .contianer {
  140. height: 100vh;
  141. font-family: "PingFang";
  142. }
  143. uni-page-head {
  144. display: none !important;
  145. }
  146. @import '@/uni_modules/uni-scss/index.scss';
  147. /* #ifndef APP-PLUS-NVUE */
  148. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  149. @import './common/uni.css';
  150. @import '@/static/customicons.css';
  151. /* H5 兼容 pc 所需 */
  152. /* #ifdef H5 */
  153. @media screen and (min-width: 768px) {
  154. body {
  155. overflow-y: scroll;
  156. }
  157. }
  158. /* 顶栏通栏样式 */
  159. /* .uni-top-window {
  160. left: 0;
  161. right: 0;
  162. } */
  163. uni-page-body {
  164. min-height: 100% !important;
  165. height: auto !important;
  166. height: 100vh;
  167. }
  168. .uni-top-window uni-tabbar .uni-tabbar {
  169. background-color: #fff !important;
  170. }
  171. .uni-app--showleftwindow .hideOnPc {
  172. display: none !important;
  173. }
  174. /* #endif */
  175. /* 以下样式用于 hello uni-app 演示所需 */
  176. page {
  177. background-color: rgba(242, 242, 242, 1);
  178. height: 100%;
  179. font-size: 28rpx;
  180. /* line-height: 1.8; */
  181. font-family: 'PingFang';
  182. }
  183. .fix-pc-padding {
  184. padding: 0 50px;
  185. }
  186. .uni-header-logo {
  187. padding: 30rpx;
  188. flex-direction: column;
  189. justify-content: center;
  190. align-items: center;
  191. margin-top: 10rpx;
  192. }
  193. .uni-header-image {
  194. width: 100px;
  195. height: 100px;
  196. }
  197. .uni-hello-text {
  198. color: #7A7E83;
  199. }
  200. .uni-hello-addfile {
  201. text-align: center;
  202. line-height: 300rpx;
  203. background: #FFF;
  204. padding: 50rpx;
  205. margin-top: 10px;
  206. font-size: 38rpx;
  207. color: #808080;
  208. }
  209. .contianer::after {
  210. content: "";
  211. position: absolute;
  212. left: 0;
  213. top: 0;
  214. /* 将阴影位置设置在导航栏下方 */
  215. width: 100%;
  216. height: 1px;
  217. box-shadow: 0 0 10px #ccc;
  218. z-index: 1;
  219. /* 使阴影在内容之上 */
  220. }
  221. /* #endif*/
  222. </style>