App.vue 5.4 KB

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