App.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. const that = this;
  5. that.forceUpdate();
  6. },
  7. onShow: function() {
  8. const that = this;
  9. that.search();
  10. },
  11. onHide: function() {
  12. console.log('App Hide')
  13. },
  14. methods: {
  15. search() {
  16. const that = this;
  17. uni.login({
  18. success: function(res) {
  19. if (res.code) {
  20. uni.getStorage({
  21. key: 'openid',
  22. success: function(res) {},
  23. fail: async function(err) {
  24. const aee = await that.$api('/tool/app', 'GET', {
  25. js_code: res.code,
  26. config: that.$config.wx_projectkey
  27. })
  28. if (aee.errcode == '0') {
  29. uni.setStorage({
  30. key: "openid",
  31. data: aee.data.openid
  32. })
  33. } else {
  34. uni.showToast({
  35. title: aee.errmsg,
  36. icon: 'none'
  37. })
  38. }
  39. }
  40. })
  41. } else {
  42. uni.showToast({
  43. title: res.errMsg,
  44. icon: 'none'
  45. })
  46. }
  47. }
  48. });
  49. },
  50. // 强制更新
  51. forceUpdate() {
  52. const that = this;
  53. let system = uni.getSystemInfoSync();
  54. if (system.uniPlatform == 'mp-weixin') {
  55. const updateManager = uni.getUpdateManager();
  56. updateManager.onCheckForUpdate(function(res) {
  57. // 请求完新版本信息的回调
  58. console.log(res.hasUpdate);
  59. });
  60. updateManager.onUpdateReady(function(res) {
  61. uni.showModal({
  62. title: '更新提示',
  63. content: '新版本已经准备好,是否重启应用?',
  64. success(res) {
  65. if (res.confirm) {
  66. uni.clearStorage();
  67. updateManager.applyUpdate();
  68. }
  69. }
  70. });
  71. });
  72. updateManager.onUpdateFailed(function(res) {
  73. console.log(res);
  74. console.log('更新失败');
  75. });
  76. }
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. /*每个页面公共css */
  83. @import '@/uni_modules/uni-scss/index.scss';
  84. @import '@/common/css/font-icon.css';
  85. /* 公用 */
  86. .container {
  87. display: flex;
  88. flex-direction: column;
  89. box-sizing: border-box;
  90. width: 100vw;
  91. height: 100vh;
  92. }
  93. .textOne {
  94. overflow: hidden;
  95. white-space: nowrap;
  96. text-overflow: ellipsis;
  97. -o-text-overflow: ellipsis;
  98. }
  99. .textOver {
  100. overflow: hidden;
  101. text-overflow: ellipsis;
  102. word-break: break-all;
  103. display: -webkit-box;
  104. -webkit-box-orient: vertical;
  105. -webkit-line-clamp: 2;
  106. }
  107. // 弹框公共样式
  108. .uni-dialog-content {
  109. padding: 2vw !important;
  110. max-height: 40vh;
  111. overflow-y: auto;
  112. align-items: normal !important;
  113. box-sizing: border-box;
  114. }
  115. // 轮播图样式
  116. wx-swiper .wx-swiper-dot {
  117. width: 20rpx;
  118. height: 4rpx;
  119. border-radius: 10rpx;
  120. }
  121. wx-swiper .wx-swiper-dot-active {
  122. width: 40rpx;
  123. border-radius: 10rpx;
  124. }
  125. /* 设置整个项目的公用样式*/
  126. page {
  127. // font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  128. /* 窗口可用高度 */
  129. /* 有头有底 */
  130. --oneHeight: 100vh;
  131. /* 有头无底 */
  132. --twoHeight: 92vh;
  133. /* 可用窗口背景颜色 */
  134. --mainColor: #ffffff;
  135. /* 底部菜单背景颜色 */
  136. --footColor: #f1f1f1;
  137. /* 字体大小 */
  138. --font20Size: 20px;
  139. --font19Size: 19px;
  140. --font18Size: 18px;
  141. --font17Size: 17px;
  142. --font16Size: 16px;
  143. --font15Size: 15px;
  144. --font14Size: 14px;
  145. --font13Size: 13px;
  146. --font12Size: 12px;
  147. /* 颜色 */
  148. --f1Color: #f1f1f1;
  149. --f2Color: #f2f2f2;
  150. --f3Color: #f3f3f3;
  151. --f4Color: #f4f4f4;
  152. --f5Color: #f5f5f5;
  153. --f6Color: #f6f6f6;
  154. --f7Color: #f7f7f7;
  155. --f8Color: #f8f8f8;
  156. --f9Color: #f9f9f9;
  157. --f99Color: #999999;
  158. --f85Color: #858585;
  159. --f69Color: #696969;
  160. --f80Color: #808080;
  161. --fFB1Color: #7A7E83;
  162. --fDCColor: #DCDCDC;
  163. --fcColor: #cccccc;
  164. --f00Color: #000000;
  165. --fffColor: #ffffff;
  166. --f3CColor: #007AFF;
  167. --fF0Color: #FF0000;
  168. --f08Color: #008000;
  169. --f35BColor: #35BD7B;
  170. }
  171. </style>