SettingBox.vue 5.01 KB
<template>
  <uni-popup ref="popup" border-radius="20px">
    <view class="setting-box">
      <view class="close flex" @click="close">
        <uni-icons type="closeempty" :size="18" color="#1A1A1A"></uni-icons>
      </view>
      <view class="app-info flex">
        <view class="sprite-icon icon-logo"></view>
        展业助手
        <view class="version">版本号:V{{ version }}</view>
        <view class="check-box" @click="handleCheck">检查更新</view>
      </view>
      <view class="btn-box">
        <view class="btn flex" @click="changeAccount">切换账号</view>
        <view class="btn flex logout" @click="logout">退出</view>
      </view>
      <view class="a" @click="jump('agreement')">《用户隐私协议》</view>
      <view class="icp flex" @click="jump('icp')">
        ICP备案号:苏ICP备18023686号-2A
        <view class="sprite-icon icon-arrow-right"></view>
      </view>
      <view class="app-code flex">
        APP编码:{{ deviceId }}
        <view class="sprite-icon icon-clone" @click="copyText"></view>
      </view>
    </view>
  </uni-popup>
</template>

<script type="text/ecmascript-6">
import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js";
export default {
  name: 'SettingBox',
  data () {
    return {
      version: '',
      deviceId:''
    }
  },
  mounted () {
    this.version = plus?.runtime?.version || '1.0.0'
    const {deviceId} = uni.getDeviceInfo()
    this.deviceId = deviceId
  },
  methods: {
    copyText() {
      uni.setClipboardData({
        data: this.deviceId,
        success: function() {
          uni.showToast({
            title: '复制成功',
            icon: 'success'
          });
        }
      });
    },
    handleCheck() {
      checkUpdate()
    },
    open () {
      this.$refs.popup.open("center");
    },
    close () {
      this.$refs.popup.close()
    },
    changeAccount () {
      uni.reLaunch({
        url: '/pages/common/accountItems'
      })
    },
    // 退出
    logout () {
      let _this = this
      uni.showModal({
        title: '温馨提示',
        content: '是否退出当前账号?',
        confirmColor: '#347BFF',
        async success (res) {
          if (res.confirm) {
            _this.$emit('stopAudio')
            try {
              uni.showLoading({
                mask: true
              })
              const { code, message } = await uni.$api.userApi.logout(),
                userInfo = uni.$storage.get("userInfo")
              console.log(code)
              if (code == 0) {
                uni.$storage.rm("userInfo");
                uni.$storage.rm("sessionId");
                uni.$storage.rm("noSignInUuid");
                setTimeout(() => {
                  uni.hideLoading()
                  uni.reLaunch({
                    url: `/pages/common/login?mobile=${userInfo.phone}`,
                  });
                }, 500)
              } else throw message
            } catch (error) {
              console.log(error)
              uni.hideLoading()
              uni.showToast({
                title: error,
                icon: "none",
              });
            }
          }
        }
      })
    },
    jump (type) {
      let url = type == 'icp' ? 'https://beian.miit.gov.cn/' : 'https://img01.glsx.com.cn/weapp/resource/saas/app/privacy.html'
      uni.navigateTo({
        url: `/pages/common/webview?url=${url}`
      })
    }
  }
}
</script>

<style scoped lang="scss">
.setting-box {
  position: relative;
  width: 720rpx;
  height: 880rpx;
  background: #ffffff;
  border-radius: 40rpx;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  .close {
    position: absolute;
    width: 120rpx;
    height: 120rpx;
    top: 0;
    right: 0;
    justify-content: center;
  }
  .app-info {
    flex-direction: column;
    font-size: 32rpx;
    color: #333333;
    .sprite-icon {
      margin-bottom: 12rpx;
      box-shadow: 0 0 24rpx 0 #3682ef33;
      border-radius: 40rpx;
    }
    .version {
      margin-top: 8rpx;
      font-size: 24rpx;
      color: #999999;
    }
    .check-box {
      width: 120rpx;
      padding: 10rpx 0rpx 4rpx;
      background: #f2f2f2;
      border-radius: 6rpx;
      font-size: 22rpx;
      color: #999999;
      text-align: center;
      margin-top: 16rpx;
      box-sizing: border-box;
    }
  }
  .btn-box {
    margin-top: 120rpx;
    .btn {
      width: 384rpx;
      height: 64rpx;
      background: #3b73ff1a;
      border: 2rpx solid transparent;
      border-radius: 32rpx;
      justify-content: center;
      font-size: 28rpx;
      color: #3b73ff;
      margin-bottom: 16rpx;
    }
    .logout {
      background: #ffffff;
      color: #333333;
      border: 2rpx solid #e8e8e8;
    }
  }
  .a {
    font-size: 24rpx;
    color: #2c66f7;
    margin: 48rpx 0 16rpx;
  }
  .icp {
    font-size: 24rpx;
    color: #999999;
  }
  .app-code {
    font-size: 24rpx;
    color: #999999;
    line-height: 40rpx;
    .icon-clone {
      width: 24rpx;
      height: 24rpx;
    }
  }
}
</style>