<script>
import { User } from "@/config/api.js";
export default {
  onLaunch: function () {
    !this.$db.get("access_token") && this.getOpenid();
    const ENV = uni.getAccountInfoSync().miniProgram;
    // #ifdef MP
    this.checkVersion();
    // #endif
    //打开调试
    if (ENV.envVersion !== "release") {
      // wx.setEnableDebug({
      //   enableDebug: true,
      // });
    }
  },
  onShow: function (optios) {
    uni.getSystemInfo({
      success: function (res) {
        if (res.windowWidth > 700) {
          uni.reLaunch({
            url: "/pages/pcWebViev/pcWebViev?path=" + optios.path + "&query=" + JSON.stringify(optios.query),
          });
        }
      },
    });
  },
  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";
/*每个页面公共css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  color: transparent;
}
view,
text {
  box-sizing: border-box;
}
input {
  box-sizing: border-box;
}
button {
  margin: 0;
  padding: 0;
}
button::after {
  border: none;
}
.container {
  width: 100%;
  min-height: 100vh;
  font-size: 28rpx;
}
text {
  display: block;
}
button {
  text-align: center;
  border-radius: 8rpx;
}
/* border 1px样式 */
.border_bottom,
.border_top,
.border_all {
  position: relative;
}

.border_top::after {
  position: absolute;
  content: "";
  width: 100%;
  left: 0;
  top: 0;
  height: 1px;
  padding: 0 32rpx;
  box-sizing: border-box;
  background-color: #e5e5e5;
  -webkit-transform: scale(1, 0.5);
  transform: scale(1, 0.5);
  -webkit-transform-origin: center bottom;
  transform-origin: center bottom;
}

.border_bottom::after {
  position: absolute;
  content: "";
  width: 100%;
  left: 0;
  bottom: 0;
  height: 1px;
  padding: 0 32rpx;
  box-sizing: border-box;
  background-color: #e5e5e5;
  -webkit-transform: scale(1, 0.5);
  transform: scale(1, 0.5);
  -webkit-transform-origin: center bottom;
  transform-origin: center bottom;
}

.border_all::before {
  content: "";
  display: block;
  position: absolute;
  width: 200%;
  height: 200%;
  border: 1px solid #d9d9d9;
  border-radius: 10rpx;
  transform-origin: 0 0;
  transform: scale(0.5, 0.5);
  -webkit-transform: scale(0.5, 0.5);
  box-sizing: border-box;
}
//全屏蒙版
.mask-diaog {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  color: #fff;
}
// 底部确认按钮
.bot-btn-cont {
  width: 100%;
  position: fixed;
  left: 0;
  bottom: 122rpx;
  z-index: 9;
  .bot-btn {
    margin: 0 auto;
    width: 694rpx;
    height: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 36rpx;
    color: #fff;
    background-color: #3385ff;
  }
}
// 无数据
.nodata {
  text-align: center;
  display: block;
  color: #666666;
  padding: 200rpx 0;
  margin: 0 auto;
  .nodata_ico {
    width: 374rpx;
    height: 288rpx;
    margin-bottom: 30rpx;
  }
  .nodata_img {
    width: 374rpx;
    height: 288rpx;
    margin-bottom: 50rpx;
  }
}
.nodata2 {
  margin-top: 300rpx;
}
// 单行省略
.text_oneLine {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 2行省略 */
.text_twoLine {
  text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
/* 按钮空心样式 */
.plain-style {
  background-color: #f2f2f2 !important;
  color: #07c160 !important;
}

.select-box {
  width: 100%;
  .box {
    height: 95prx;
    line-height: 95rpx;
    text-align: center;
    font-size: 32rpx;
    border-bottom: 1rpx solid #ebebeb;
  }

  .box-bottom {
    border-bottom: none !important;
  }
}
.slot-content {
  width: 100%;
  padding: 50rpx;
  text-align: center;
  font-size: 32rpx;
  color: #0f1826;
  line-height: 48rpx;
}
.forbid-copy {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.cancel-attention {
  flex-shrink: 0;
  padding: 5rpx 28rpx;
  border-radius: 37rpx 37rpx 37rpx 37rpx;
  font-weight: 400;
  font-size: 24rpx;
  background-color: #f0f0f0;
  color: #999999;
}
.free-charge {
  position: fixed;
  display: flex;
  align-items: center;
  bottom: 320rpx;
  right: 41rpx;
  height: 156rpx;
  z-index: 888;
}
.footer-free-charge {
  z-index: 99999;
}
</style>
