App.vue 4.6 KB

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