App.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import { mapMutations } from "vuex";
  6. // #ifdef H5
  7. import { weixindata, setRouter } from "./utils/wxAuthorized";
  8. // #endif
  9. // #ifdef APP-PLUS
  10. import { getUpApp } from "./utils/upApp.js";
  11. // #endif
  12. export default {
  13. data() {
  14. return {
  15. /* 保存微信信息 */
  16. appData: {},
  17. };
  18. },
  19. methods: {
  20. ...mapMutations("user", ["setUserInfo", "login", "hasLogin",'logout']),
  21. },
  22. onExit(){
  23. },
  24. onLaunch: function (urlObj) {
  25. let obj = this;
  26. // 加载缓存中的用户信息
  27. let userInfo = uni.getStorageSync("userInfo") || "";
  28. // 判断是否拥有用户信息
  29. if (userInfo.uid) {
  30. //更新登陆状态
  31. uni.getStorage({
  32. key: "userInfo",
  33. success: res => {
  34. obj.setUserInfo(res.data);
  35. obj.login(res.data);
  36. },
  37. });
  38. }
  39. // ethereum.request({
  40. // method: 'eth_requestAccounts'
  41. // }).then((account) => {
  42. // if(account!=userInfo.account){
  43. // obj.logout();
  44. // }
  45. // });
  46. // #ifdef H5
  47. // 保存路由对象
  48. setRouter(this.$router);
  49. //判断是否已经缓存浏览器
  50. let bool = uni.getStorageSync("weichatBrowser") || "";
  51. if (bool === "") {
  52. //判断是否为微信浏览
  53. bool =
  54. navigator.userAgent
  55. .toLowerCase()
  56. .match(/MicroMessenger/i) == "micromessenger";
  57. // 保存当前是否为微信内核浏览器
  58. uni.setStorageSync("weichatBrowser", bool);
  59. }
  60. if (bool) {
  61. // 加载微信信息
  62. weixindata();
  63. }
  64. // #endif
  65. // #ifdef APP-PLUS
  66. // 判断是否升级
  67. getUpApp();
  68. // 获取当前运行系统
  69. let system = uni.getStorageSync("platform") || "";
  70. if (!system) {
  71. uni.setStorage({
  72. key: "platform",
  73. data: uni.getSystemInfoSync().platform,
  74. });
  75. }
  76. // #endif
  77. },
  78. onShow: function () {
  79. // 加载拦截
  80. // console.log('App Show');
  81. },
  82. onHide: function () {
  83. // console.log('App Hide');
  84. },
  85. };
  86. </script>
  87. <style lang="scss">
  88. /*全局公共样式和字体图标*/
  89. @import "@/uni_modules/uview-ui/index.scss";
  90. @import "/static/css/cmy.css";
  91. view,
  92. scroll-view,
  93. swiper,
  94. swiper-item,
  95. cover-view,
  96. cover-image,
  97. icon,
  98. text,
  99. rich-text,
  100. progress,
  101. button,
  102. checkbox,
  103. form,
  104. input,
  105. label,
  106. radio,
  107. slider,
  108. switch,
  109. textarea,
  110. navigator,
  111. audio,
  112. camera,
  113. image,
  114. video {
  115. box-sizing: border-box;
  116. }
  117. /* 骨架屏替代方案 */
  118. .Skeleton {
  119. background: #f3f3f3;
  120. padding: 20rpx 0;
  121. border-radius: 8rpx;
  122. }
  123. /* 图片载入替代方案 */
  124. .image-wrapper {
  125. font-size: 0;
  126. background: #f3f3f3;
  127. border-radius: 4px;
  128. image {
  129. width: 100%;
  130. height: 100%;
  131. transition: 0.6s;
  132. opacity: 0;
  133. &.loaded {
  134. opacity: 1;
  135. }
  136. }
  137. }
  138. // 设置富文本中图片最大宽度
  139. uni-rich-text img {
  140. max-width: 100% !important;
  141. }
  142. /*边框*/
  143. .b-b:after,
  144. .b-t:after {
  145. position: absolute;
  146. z-index: 3;
  147. left: 0;
  148. right: 0;
  149. height: 0;
  150. content: "";
  151. transform: scaleY(0.5);
  152. border-bottom: 1px solid $border-color-base;
  153. }
  154. .b-b:after {
  155. bottom: 0;
  156. }
  157. .b-t:after {
  158. top: 0;
  159. }
  160. /* button样式改写 */
  161. uni-button,
  162. button {
  163. height: 80rpx;
  164. line-height: 80rpx;
  165. font-size: $font-lg + 2rpx;
  166. font-weight: normal;
  167. &.no-border:before,
  168. &.no-border:after {
  169. border: 0;
  170. }
  171. }
  172. uni-button[type="default"],
  173. button[type="default"] {
  174. color: $font-color-dark;
  175. }
  176. /* input 样式 */
  177. .input-placeholder {
  178. color: #999999;
  179. }
  180. .placeholder {
  181. color: #999999;
  182. }
  183. // 边距样式
  184. @for $i from 1 to 4 {
  185. .margin-l-#{$i * 10} {
  186. margin-left: $i * 10rpx !important;
  187. }
  188. .margin-r-#{$i * 10} {
  189. margin-right: $i * 10rpx !important;
  190. }
  191. .margin-t-#{$i * 10} {
  192. margin-top: $i * 10rpx !important;
  193. }
  194. .margin-b-#{$i * 10} {
  195. margin-bottom: $i * 10rpx !important;
  196. }
  197. .margin-#{$i * 10} {
  198. margin: $i * 10rpx !important;
  199. }
  200. .margin-v-#{$i * 10} {
  201. margin-top: $i * 10rpx !important;
  202. margin-bottom: $i * 10rpx !important;
  203. }
  204. .margin-c-#{$i * 10} {
  205. margin-left: $i * 10rpx !important;
  206. margin-right: $i * 10rpx !important;
  207. }
  208. .padding-l-#{$i * 10} {
  209. padding-left: $i * 10rpx !important;
  210. }
  211. .padding-r-#{$i * 10} {
  212. padding-right: $i * 10rpx !important;
  213. }
  214. .padding-t-#{$i * 10} {
  215. padding-top: $i * 10rpx !important;
  216. }
  217. .padding-b-#{$i * 10} {
  218. padding-bottom: $i * 10rpx !important;
  219. }
  220. .padding-#{$i * 10} {
  221. padding: $i * 10rpx !important;
  222. }
  223. .padding-v-#{$i * 10} {
  224. padding-top: $i * 10rpx !important;
  225. padding-bottom: $i * 10rpx !important;
  226. }
  227. .padding-c-#{$i * 10} {
  228. padding-left: $i * 10rpx !important;
  229. padding-right: $i * 10rpx !important;
  230. }
  231. }
  232. // 字体大小
  233. .font-size-sm {
  234. font-size: $font-sm;
  235. }
  236. .font-size-base {
  237. font-size: $font-base;
  238. }
  239. .font-size-lg {
  240. font-size: $font-lg;
  241. }
  242. // 字体颜色
  243. .font-color-yellow {
  244. color: $color-yellow;
  245. }
  246. .font-color-gray {
  247. color: $color-gray;
  248. }
  249. .font-color-red {
  250. color: $color-red;
  251. }
  252. // 边框颜色
  253. .border-color-yellow {
  254. border: 1rpx solid $color-yellow;
  255. }
  256. page {
  257. background-color: $page-color-base;
  258. // 设置默认字体
  259. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial,
  260. sans-serif, Droid Sans Fallback;
  261. }
  262. /*边框*/
  263. .b-b:after,
  264. .b-t:after {
  265. position: absolute;
  266. z-index: 3;
  267. left: 0;
  268. right: 0;
  269. height: 0;
  270. content: "";
  271. transform: scaleY(0.5);
  272. border-bottom: 1px solid $border-color-base;
  273. }
  274. .b-b:after {
  275. bottom: 0;
  276. }
  277. </style>