<!-- 修改密码 -->
<template>
  <view class="changepassword">
    <!-- <view class="goback" @tap="toBack"
      ><image src="../../../static/images/backicon.png" class="backicon"></image
    ></view> -->
    <view class="title">修改密码</view>
    <view class="input-item cellphone">
      <input type="password" v-model="oldPwd" placeholder="请输入旧密码" />
    </view>
    <view class="input-item imgcode">
      <input type="password" class="inputcode" v-model="newPwd" placeholder="请输入新密码" />
    </view>
    <view class="input-item sellcode">
      <input type="password" class="inputcode" v-model="reNewPwd" placeholder="再次输入新密码" />
    </view>
    <view class="btn-warp">
      <view class="btn" @tap="next">确认</view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'changepassword',
  data() {
    //这里存放数据
    return {
      oldPwd:'',
      newPwd:'',
      reNewPwd:''
    };
  },
  onLoad() {},
  //方法集合
  methods: {
    // 返回上一页
    toBack() {
      uni.navigateTo({url:'/pages/setting/setting'})
    },
    async next() {
      if(this.oldPwd){
				if(this.newPwd){
					if(this.reNewPwd){
            if(this.newPwd == this.reNewPwd){
              await this.$http.post('/WxApplet/updatePwd', {
                pwd:this.oldPwd,
                newPwd:this.newPwd
              }).then(async res => {
                console.log(res);	
                if(res.code == 200){
                  this.$mRouter.push({ route: '/pages/public/login' });
                }else{
                  uni.showToast({
                    title: res.msg,
                    icon: 'none'
                  });
                }							
              });
            }else{
              uni.showToast({
                title: '两次密码不一致',
                icon: 'none'
              });
            }
						
					}else{
						uni.showToast({
							title: '请再次输入新密码',
							icon: 'none'
						});
					}
				}else{
					uni.showToast({
						title: '请输入新密码',
						icon: 'none'
					});
				}
			}else{
				uni.showToast({
					title: '请输入旧密码',
					icon: 'none'
				});
			}
    },
  },
};
</script>
<style lang='scss' scoped>
.changepassword {
  padding: 20upx 50upx;
  background: #fff;
  .goback {
    padding-top: 100upx;
    .backicon {
      width: 24upx;
      height: 43upx;
    }
  }
  .title {
    font-size: 48upx;
    color: $titleColor;
    background: url('../../../static/images/passworddown.png') no-repeat left
      82%;
    background-size: 192upx 14upx;
    margin-top: 65upx;
  }
  .input-item {
    height: 95upx;
    border-bottom: 1px solid #e7e7e7;
    margin-top: 50upx;
    position: relative;
    input {
      width: 100%;
      height: 100%;
      font-size: 32upx;
    }
  }
  .cellphone {
    margin-top: 100upx;
  }
  .btn-warp {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 170upx;
    .btn {
      width: 586upx;
      height: 98upx;
      border-radius: 35upx;
      background-color: $barColor;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 36upx;
      font-weight: 700;
      color: $titleColor;
      letter-spacing: 5upx;
    }
  }
}
</style>
