App.vue 5.6 KB

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