App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <script>
  2. import { User } from '@/config/api.js'
  3. export default {
  4. onLaunch: function() {
  5. !this.$db.get('access_token') && this.getOpenid();
  6. // #ifdef MP
  7. this.checkVersion();
  8. // #endif
  9. },
  10. onShow: function() {
  11. },
  12. onHide: function() {
  13. },
  14. globalData:{
  15. isLogin:false,
  16. isAuth:null,//是否需要授权 uniid
  17. isBind:null,// 是否需要绑定手机号/邮箱
  18. userInfo:null,//用户信息
  19. access_token:'',
  20. loadOver:''
  21. },
  22. // onError: function(err) {
  23. // // 这里只能捕获方法内的异常,不能捕获生命周期中的逻辑异常
  24. // //console.log('方法内异常');
  25. // var json = JSON.stringify(err);
  26. // var arr = json.split("\\n");
  27. // var log = {
  28. // message : arr[1],
  29. // stack: err
  30. // }
  31. // this.$throw(log)
  32. // },
  33. methods:{
  34. /* 微信code换临时token */
  35. getOpenid() {
  36. uni.login({
  37. success: result=> {
  38. User.wechatLog({
  39. Code:result.code
  40. }).then(res => {
  41. try {
  42. let token = res.Data.Authorization;
  43. this.$db.set('access_token',token)
  44. // this.$isResolve()
  45. }catch (e){
  46. }
  47. //由于这里是网络请求,可能会在 Page.onLoad 之后才返回
  48. // 所以此处加入 callback 以防止这种情况
  49. // this.globalData.loadOver = true
  50. // if (this.loadCallback) {
  51. // this.loadCallback(true);
  52. // }
  53. })
  54. }
  55. });
  56. },
  57. checkVersion() {
  58. const updateManager = uni.getUpdateManager();
  59. updateManager.onCheckForUpdate(function (res) {
  60. // 请求完新版本信息的回调
  61. // console.log(res.hasUpdate);
  62. });
  63. updateManager.onUpdateReady(function (res) {
  64. uni.showModal({
  65. title: '更新提示',
  66. content: '新版本已经准备好,是否重启应用?',
  67. success(res) {
  68. if (res.confirm) {
  69. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  70. updateManager.applyUpdate();
  71. }
  72. }
  73. });
  74. });
  75. updateManager.onUpdateFailed(function (res) {
  76. // 新的版本下载失败
  77. });
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. @import "uview-ui/index.scss";
  84. /*每个页面公共css */
  85. * {
  86. margin: 0;padding: 0;
  87. box-sizing: border-box;
  88. }
  89. ::-webkit-scrollbar {
  90. display:none;
  91. width:0;
  92. height:0;
  93. color:transparent;
  94. }
  95. view,text {
  96. box-sizing: border-box;
  97. }
  98. input {
  99. box-sizing: border-box;
  100. }
  101. button {
  102. margin: 0;padding: 0;
  103. }
  104. button::after {
  105. border:none;
  106. }
  107. .container {
  108. width: 100%;
  109. min-height: 100vh;
  110. font-size: 28rpx;
  111. }
  112. text {
  113. display: block;
  114. }
  115. button {
  116. text-align: center;
  117. border-radius: 8rpx;
  118. }
  119. /* border 1px样式 */
  120. .border_bottom, .border_top, .border_all {
  121. position: relative;
  122. }
  123. .border_top::after {
  124. position: absolute;
  125. content: '';
  126. width: 100%;
  127. left: 0;
  128. top: 0;
  129. height: 1px;
  130. padding: 0 32rpx;
  131. box-sizing: border-box;
  132. background-color: #E5E5E5;
  133. -webkit-transform: scale(1, 0.5);
  134. transform: scale(1, 0.5);
  135. -webkit-transform-origin: center bottom;
  136. transform-origin: center bottom;
  137. }
  138. .border_bottom::after {
  139. position: absolute;
  140. content: '';
  141. width: 100%;
  142. left: 0;
  143. bottom: 0;
  144. height: 1px;
  145. padding: 0 32rpx;
  146. box-sizing: border-box;
  147. background-color: #E5E5E5;
  148. -webkit-transform: scale(1, 0.5);
  149. transform: scale(1, 0.5);
  150. -webkit-transform-origin: center bottom;
  151. transform-origin: center bottom;
  152. }
  153. .border_all::before {
  154. content: '';
  155. display: block;
  156. position: absolute;
  157. width: 200%;
  158. height: 200%;
  159. border: 1px solid #d9d9d9;
  160. border-radius: 10rpx;
  161. transform-origin: 0 0;
  162. transform: scale(0.5, 0.5);
  163. -webkit-transform: scale(0.5, 0.5);
  164. box-sizing: border-box;
  165. }
  166. //全屏蒙版
  167. .mask-diaog {
  168. position: fixed;
  169. left: 0;
  170. top: 0;
  171. bottom: 0;
  172. right: 0;
  173. overflow: hidden;
  174. background-color: rgba(0, 0, 0, 0.5);
  175. z-index: 1000;
  176. color: #fff;
  177. }
  178. // 底部确认按钮
  179. .bot-btn-cont {
  180. width: 100%;
  181. position: fixed;
  182. left:0;
  183. bottom: 122rpx;
  184. z-index: 9;
  185. .bot-btn {
  186. margin: 0 auto;
  187. width: 694rpx;
  188. height: 88rpx;
  189. line-height: 88rpx;
  190. text-align:center;
  191. font-size: 36rpx;
  192. color: #fff;
  193. background-color: #3385FF;
  194. }
  195. }
  196. // 无数据
  197. .nodata {
  198. text-align: center;
  199. display: block;
  200. color: #D8D8D8;
  201. padding: 200rpx 0;
  202. margin: 0 auto;
  203. .nodata_ico {
  204. width: 150rpx;
  205. height: 162rpx;
  206. margin-bottom: 50rpx;
  207. }
  208. }
  209. .nodata2 {
  210. margin-top: 300rpx;
  211. }
  212. // 单行省略
  213. .text_oneLine {
  214. overflow: hidden;
  215. text-overflow:ellipsis;
  216. white-space: nowrap;
  217. }
  218. /* 2行省略 */
  219. .text_twoLine {
  220. text-overflow: -o-ellipsis-lastline;
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. display: -webkit-box;
  224. -webkit-line-clamp: 2;
  225. line-clamp: 2;
  226. -webkit-box-orient: vertical;
  227. }
  228. /* 按钮空心样式 */
  229. .plain-style {
  230. background-color: #F2F2F2 !important;
  231. color: #07C160 !important;
  232. }
  233. </style>