App.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. getOn:true,
  6. globalData:{
  7. shareList:[],
  8. }
  9. }
  10. },
  11. onLaunch: function(param) {
  12. },
  13. onShow: function() {
  14. // #ifdef MP
  15. // 检查是否升级
  16. this.checkForUpdate();
  17. // #endif
  18. // 进入小程序,如果需要推送客服,请求客户信息,获取最新的微伴ID
  19. if( this.$checkAccess.getFollowQrcode() ){
  20. if( !this.getOn ) return ;
  21. this.getOn = false;
  22. // 判断数据
  23. this.$http.request('api/custom/get_info').then((callback)=>{
  24. this.getOn = true;
  25. if( callback.code == 'success' ){
  26. if( !callback.data.userpic ) callback.data.userpic = "../../static/icon/doctor.png";
  27. // 赋值
  28. this.userInfo = callback.data;
  29. // 存储登录标识
  30. uni.setStorageSync('userInfo',callback.data);
  31. }
  32. });
  33. }
  34. // 判断数据
  35. this.$http.request('/api/share_message/get_list').then((callback)=>{
  36. if( callback.code == 'success' ){
  37. // 赋值
  38. getApp().globalData.shareList = callback.data;
  39. }
  40. });
  41. },
  42. onHide: function() {
  43. console.log('App Hide');
  44. },
  45. methods:{
  46. // 检查是否升级
  47. checkForUpdate(){
  48. const _this = this;
  49. // 获取升级管理实例
  50. const updateManager = uni.getUpdateManager();
  51. // 请求版本回调
  52. updateManager.onCheckForUpdate(function(res){
  53. console.log(res);
  54. // 如果有版本升级
  55. if( res && res.hasUpdate ){
  56. uni.showModal({
  57. title:"更新提示",
  58. content:"检测到新版,点击确认升级程序",
  59. showCancel:false,
  60. success(res){
  61. if(res.confirm){
  62. uni.showLoading({title:"程序更新中"});
  63. // 判断是否准备好升级
  64. updateManager.onUpdateReady(function(res){
  65. // 关闭加载
  66. uni.hideLoading();
  67. // 当新版本下载完成,调用该方法会强制当前uni-app应用上新版本并重启
  68. updateManager.applyUpdate();
  69. })
  70. updateManager.onUpdateFailed(function(err){
  71. // 关闭加载
  72. uni.hideLoading();
  73. })
  74. }
  75. }
  76. })
  77. }
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="less">
  84. /*每个页面公共css */
  85. page{
  86. font-family: Arial, Helvetica, sans-serif;
  87. background: #F5F5F5;
  88. }
  89. // 到底了
  90. .to_bottom{
  91. height: 40rpx;
  92. color: #999999;
  93. display: block;
  94. font-size: 20rpx;
  95. margin-top: 20rpx;
  96. line-height: 40rpx;
  97. text-align: center;
  98. padding-bottom: 160rpx;
  99. }
  100. </style>