version.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import Config from "../../model/config";
  2. import Api from "../../model/api";
  3. import { toast } from "../../utils/utils";
  4. import updateManager from "../../model/update-manager";
  5. Page({
  6. data: {
  7. info: {},
  8. miniProgram: {},
  9. version: '0',
  10. url:Config.BASE_URL,
  11. isProd:false,
  12. },
  13. async onLoad(options) {
  14. const res = await Api.getHelpInfo(Config.APP_ID, true)
  15. const accountInfo = wx.getAccountInfoSync();
  16. this.setData({
  17. info: res.data,
  18. miniProgram: accountInfo.miniProgram,
  19. version: Config.VERSION_CODE,
  20. isProd:__wxConfig.envVersion == 'release' //trial体验版 release线上版 develop开发版
  21. })
  22. },
  23. handleUpgrade(){
  24. let oldVersion = this.data.version || this.data.miniProgram.version || '';
  25. let newVersion = this.data.info.appVersion || '';
  26. if(oldVersion.trim() === newVersion.trim()) {
  27. toast('已是最新版本!');
  28. return;
  29. }
  30. updateManager.update({loading: true, hasUpdate: true});
  31. }
  32. })