App.vue 6.6 KB

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