12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <script>
- import { User } from "@/config/api.js";
- export default {
- onLaunch: function () {
- let result = wx.getLaunchOptionsSync();
- this.$store.commit("getSceneNumber", result.scene);
- if (result.scene != 1154) {
- !this.$db.get("access_token") && this.getOpenid();
- const ENV = uni.getAccountInfoSync().miniProgram;
- // #ifdef MP
- this.checkVersion();
- // #endif
- }
- },
- onHide: function () {},
- globalData: {
- isLogin: false,
- isAuth: null, //是否需要授权 uniid
- isBind: null, // 是否需要绑定手机号/邮箱
- userInfo: null, //用户信息
- access_token: "",
- loadOver: "",
- },
- methods: {
- /* 微信code换临时token */
- getOpenid() {
- uni.login({
- success: (result) => {
- User.wechatLog({
- Code: result.code,
- }).then((res) => {
- try {
- let token = res.Data.Authorization;
- this.$db.set("access_token", token);
- // this.$isResolve()
- } catch (e) {}
- });
- },
- });
- },
- checkVersion() {
- const updateManager = uni.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- });
- updateManager.onUpdateReady(function (res) {
- uni.showModal({
- title: "更新提示",
- content: "新版本已经准备好,是否重启应用?",
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- },
- });
- });
- updateManager.onUpdateFailed(function (res) {
- // 新的版本下载失败
- });
- },
- },
- };
- </script>
- <style lang="scss">
- @import "uview-ui/index.scss";
- /* 页面公共样式 */
- @import "./style/common.scss";
- </style>
|