<template>
  <view class="page" style="height: 100%">
    <!-- <view class="content">
			<image class="logo" src="/static/img/xslogo.png" />
		</view> -->
    <view style="height: 2%; width: 100%; background-color: #f5f7f5"></view>
    <view style="padding: 20px 0 0 5px; height: 100%; background-color: #fff">
      <!-- <view style="padding-bottom: 15px;" @click="navito('https://work.weixin.qq.com/kfid/kfcd81d6fcf1eb5e2f0')">
				<image class="img-size" src="/static/img/people.png">
					<span class="text">在线客服</span>
					<image class="img-size" style="float: right;margin-right: 45px;" src="/static/img/goOn.png">
			</view>
			<view style="padding-bottom: 15px;" @click="navito('https://weixin.qq.com/f/MKLhYh2xXYc2vphJ_LOBGRo')">
				<image class="img-size" src="/static/img/study.png">
					<span class="text">在线课堂</span>
					<image class="img-size" style="float: right;margin-right: 45px;" src="/static/img/goOn.png">
			</view> -->
      <view @click="changePassword">
        <image class="img-size" src="/static/img/mark.png" />
        <span class="text">修改密码</span>
        <image
          class="img-size"
          style="float: right; margin-right: 45px"
          src="/static/img/goOn.png"
        />
      </view>
    </view>
    <view
      class="fixBottom"
      style="position: fixed; bottom: 250upx; padding: 0; background: #fff"
    >
      <view class="uni-flex uni-row">
        <view style="-webkit-flex: 1; flex: 1">
          <button type="primary" style="width: 90%" @click="loginOut()">
            退出登录
          </button>
        </view>
      </view>
    </view>
    <uni-popup ref="dialogInput" type="dialog">
      <uni-popup-dialog
        @confirm="dialogInputConfirm"
        :title="title"
      ></uni-popup-dialog>
    </uni-popup>
  </view>
</template>

<script>
import uniPopupDialog from "../../components/uni-popup/uni-popup-dialog.vue";
export default {
  components: {
    uniPopupDialog,
  },
  data() {
    return {
      title: "修改密码",
    };
  },
  methods: {
    loginOut() {
      var admin_info = uni.getStorageSync("admin_info");
      uni.clearStorage();
      if (admin_info) {
        uni.setStorage({
          key: "admin_info",
          data: admin_info,
          success: function () {
            uni.reLaunch({
              url: "../login/login",
            });
          },
        });
      } else {
        uni.reLaunch({
          url: "../login/login",
        });
      }
    },
    navito(e) {
      window.location.href = e;
    },
    changePassword() {
      this.$refs.dialogInput.open();
    },
    dialogInputConfirm(val) {
      this.$http
        .request({
          url: "/apis/user/resetPwd",
          data: { pwdNew: val },
        })
        .then((res) => {
          if (res.data.code == 0) {
            uni.showToast({
              icon: "success",
              title: "修改成功",
            });
          } else {
            uni.showToast({
              icon: "none",
              title: res.data.msg,
            });
          }
        });
      this.$refs.dialogInput.close();
    },
  },
};
</script>

<style scoped>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 120px;
  width: 120px;
  margin-top: 50px;
  margin-left: auto;
  margin-right: auto;
}

.img-size {
  display: inline-block;
  width: 30px;
  height: 30px;
}

.text {
  display: inline-block;
  height: 30px;
  margin-left: 10px;
  vertical-align: bottom;
}
</style>
