App.vue 2.9 KB

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