App.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 "/static/css/cmy.css";
  90. view,
  91. scroll-view,
  92. swiper,
  93. swiper-item,
  94. cover-view,
  95. cover-image,
  96. icon,
  97. text,
  98. rich-text,
  99. progress,
  100. button,
  101. checkbox,
  102. form,
  103. input,
  104. label,
  105. radio,
  106. slider,
  107. switch,
  108. textarea,
  109. navigator,
  110. audio,
  111. camera,
  112. image,
  113. video {
  114. box-sizing: border-box;
  115. }
  116. /* 骨架屏替代方案 */
  117. .Skeleton {
  118. background: #f3f3f3;
  119. padding: 20rpx 0;
  120. border-radius: 8rpx;
  121. }
  122. /* 图片载入替代方案 */
  123. .image-wrapper {
  124. font-size: 0;
  125. background: #f3f3f3;
  126. border-radius: 4px;
  127. image {
  128. width: 100%;
  129. height: 100%;
  130. transition: 0.6s;
  131. opacity: 0;
  132. &.loaded {
  133. opacity: 1;
  134. }
  135. }
  136. }
  137. // 设置富文本中图片最大宽度
  138. uni-rich-text img {
  139. max-width: 100% !important;
  140. }
  141. /*边框*/
  142. .b-b:after,
  143. .b-t:after {
  144. position: absolute;
  145. z-index: 3;
  146. left: 0;
  147. right: 0;
  148. height: 0;
  149. content: "";
  150. transform: scaleY(0.5);
  151. border-bottom: 1px solid $border-color-base;
  152. }
  153. .b-b:after {
  154. bottom: 0;
  155. }
  156. .b-t:after {
  157. top: 0;
  158. }
  159. /* button样式改写 */
  160. uni-button,
  161. button {
  162. height: 80rpx;
  163. line-height: 80rpx;
  164. font-size: $font-lg + 2rpx;
  165. font-weight: normal;
  166. &.no-border:before,
  167. &.no-border:after {
  168. border: 0;
  169. }
  170. }
  171. uni-button[type="default"],
  172. button[type="default"] {
  173. color: $font-color-dark;
  174. }
  175. /* input 样式 */
  176. .input-placeholder {
  177. color: #999999;
  178. }
  179. .placeholder {
  180. color: #999999;
  181. }
  182. // 边距样式
  183. @for $i from 1 to 4 {
  184. .margin-l-#{$i * 10} {
  185. margin-left: $i * 10rpx !important;
  186. }
  187. .margin-r-#{$i * 10} {
  188. margin-right: $i * 10rpx !important;
  189. }
  190. .margin-t-#{$i * 10} {
  191. margin-top: $i * 10rpx !important;
  192. }
  193. .margin-b-#{$i * 10} {
  194. margin-bottom: $i * 10rpx !important;
  195. }
  196. .margin-#{$i * 10} {
  197. margin: $i * 10rpx !important;
  198. }
  199. .margin-v-#{$i * 10} {
  200. margin-top: $i * 10rpx !important;
  201. margin-bottom: $i * 10rpx !important;
  202. }
  203. .margin-c-#{$i * 10} {
  204. margin-left: $i * 10rpx !important;
  205. margin-right: $i * 10rpx !important;
  206. }
  207. .padding-l-#{$i * 10} {
  208. padding-left: $i * 10rpx !important;
  209. }
  210. .padding-r-#{$i * 10} {
  211. padding-right: $i * 10rpx !important;
  212. }
  213. .padding-t-#{$i * 10} {
  214. padding-top: $i * 10rpx !important;
  215. }
  216. .padding-b-#{$i * 10} {
  217. padding-bottom: $i * 10rpx !important;
  218. }
  219. .padding-#{$i * 10} {
  220. padding: $i * 10rpx !important;
  221. }
  222. .padding-v-#{$i * 10} {
  223. padding-top: $i * 10rpx !important;
  224. padding-bottom: $i * 10rpx !important;
  225. }
  226. .padding-c-#{$i * 10} {
  227. padding-left: $i * 10rpx !important;
  228. padding-right: $i * 10rpx !important;
  229. }
  230. }
  231. // 字体大小
  232. .font-size-sm {
  233. font-size: $font-sm;
  234. }
  235. .font-size-base {
  236. font-size: $font-base;
  237. }
  238. .font-size-lg {
  239. font-size: $font-lg;
  240. }
  241. // 字体颜色
  242. .font-color-yellow {
  243. color: $color-yellow;
  244. }
  245. .font-color-gray {
  246. color: $color-gray;
  247. }
  248. .font-color-red {
  249. color: $color-red;
  250. }
  251. // 边框颜色
  252. .border-color-yellow {
  253. border: 1rpx solid $color-yellow;
  254. }
  255. page {
  256. background-color: $page-color-base;
  257. // 设置默认字体
  258. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial,
  259. sans-serif, Droid Sans Fallback;
  260. }
  261. /*边框*/
  262. .b-b:after,
  263. .b-t:after {
  264. position: absolute;
  265. z-index: 3;
  266. left: 0;
  267. right: 0;
  268. height: 0;
  269. content: "";
  270. transform: scaleY(0.5);
  271. border-bottom: 1px solid $border-color-base;
  272. }
  273. .b-b:after {
  274. bottom: 0;
  275. }
  276. </style>