App.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. let ver = plus.runtime.versionCode;
  34. console.log(obj.versionFu,ver)
  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. uni.navigateTo({
  64. url:"./pages/home/home"
  65. })
  66. let obj = this;
  67. //判断当前版本是否需要更新
  68. obj.banben();
  69. // 加载缓存中的用户信息
  70. let userInfo = uni.getStorageSync('userInfo') || '';
  71. // 判断是否拥有用户信息
  72. if (userInfo.uid) {
  73. //更新登陆状态
  74. uni.getStorage({
  75. key: 'userInfo',
  76. success: res => {
  77. obj.setUserInfo(res.data);
  78. obj.login(res.data);
  79. }
  80. });
  81. }
  82. },
  83. onShow: function() {},
  84. onHide: function() {}
  85. };
  86. </script>
  87. <style lang="scss">
  88. /*全局公共样式和字体图标*/
  89. @import '/static/css/public.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. // 修改默认背景颜色
  256. uni-page-wrapper {
  257. background-color: #ffffff;
  258. }
  259. page {
  260. background-color: #ffffff;
  261. // 设置默认字体
  262. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  263. }
  264. </style>