SettingBox.vue 4.25 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>
      <view class="btn-box">
        <!-- v-if="accountLength" -->
        <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>
  </uni-popup>

</template>

<script type='text/ecmascript-6'>
export default {
  name: 'SettingBox',
  data () {
    return {
      accountLength: uni.$storage.get('accountLength'),
      version: '',
    }
  },
  mounted () {
    this.version = plus?.runtime?.version || '1.0.0'
  },
  methods: {
    open () {
      this.$refs.popup.open("center");
    },
    close () {
      this.$refs.popup.close()
    },
    changeAccount () {
      uni.redirectTo({
        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;
    }
  }
  .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;
  }
}
</style>