App.vue 2.4 KB

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