initConfig.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. const common_vendor = require("./common/vendor.js");
  3. function checkNew() {
  4. const updateManager = common_vendor.index.getUpdateManager();
  5. updateManager.onCheckForUpdate(function(res) {
  6. });
  7. updateManager.onUpdateReady(function() {
  8. common_vendor.index.showModal({
  9. title: "更新提示",
  10. content: "新版本已经准备好,立即重启应用?",
  11. showCancel: false,
  12. success: function(res) {
  13. if (res.confirm) {
  14. updateManager.applyUpdate();
  15. }
  16. }
  17. });
  18. });
  19. updateManager.onUpdateFailed(function() {
  20. common_vendor.index.showModal({ title: "温馨提示", content: "新版本下载失败,请卸载小程序再重试", showCancel: false });
  21. });
  22. }
  23. function init() {
  24. common_vendor.index.getNetworkType({
  25. success: (res) => {
  26. const { networkType } = res;
  27. if (!["none"].includes(networkType)) {
  28. checkNew();
  29. } else {
  30. common_vendor.index.showToast({
  31. title: "当前无网络访问,请开启网络",
  32. icon: "none"
  33. });
  34. }
  35. },
  36. fail: () => {
  37. common_vendor.index.showToast({
  38. title: "获取网络失败,网络不稳定",
  39. icon: "none"
  40. });
  41. }
  42. });
  43. }
  44. exports.init = init;
  45. //# sourceMappingURL=../.sourcemap/mp-weixin/initConfig.js.map