App.vue 4.9 KB

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