<template>
  <view class="page" :style="themeColor">
    <view class="flex benben-position-layout flex flex-wrap align-center forgotPassword_flex_0"
      :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
      <view class='flex flex-wrap align-center justify-between flex-sub forgotPassword_fd0_0'>
        <view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
          <text class='fu-iconfont2  forgotPassword_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">&#xE794;</text>
        </view>
        <view class='flex flex-wrap align-stretch justify-center flex-sub'>
          <text class='forgotPassword_fd0_0_c1_c0'>忘记密码</text>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd0_0_c2'>
        </view>
      </view>

    </view>
    <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
    <!---flex布局flex布局开始-->
    <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout forgotPassword_flex_1">
      <view class='flex flex-wrap align-center forgotPassword_fd1_0'>
        <text class='forgotPassword_fd1_0_c0'>欢迎来到萬家商超</text>
      </view>
      <view class='flex flex-direction flex-wrap align-stretch forgotPassword_fd1_1'>
        <text class='forgotPassword_fd1_1_c0'>账号</text>
        <view class='flex flex-wrap align-center justify-between'>
          <input type="number" placeholder="请输入手机号" confirm-type="done" :maxlength="11"
            placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
        </view>
      </view>
      <view class='flex flex-direction flex-wrap align-stretch forgotPassword_fd1_2'>
        <text class='forgotPassword_fd1_2_c0'>验证码</text>
        <view class='flex flex-wrap align-center justify-between'>
          <input type="number" class="flex-sub" placeholder="请输入验证码" confirm-type="done" :maxlength="4"
            placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="code" />
          <benben-send-verification-code class='flex  forgotPassword_fd1_2_c1_c1' after-text='后重新获取' before-text='获取验证码'
            type='2' :phone="mobile"></benben-send-verification-code>
        </view>
      </view>
      <view class='flex flex-direction flex-wrap align-stretch forgotPassword_fd1_3'>
        <text class='forgotPassword_fd1_3_c0'>密码</text>
        <view class='flex flex-wrap align-center justify-between'>
          <benben-flex-password-diy v-model="password" class-name="flex flex align-center forgotPassword_fd1_3_c1_c0"
            :placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
            placeholder-style="color:#999;font-size:32rpx">
            <template #show>
              <text class='fu-iconfont2  forgotPassword_fd1_3_c1_c0_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  forgotPassword_fd1_3_c1_c0_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
      </view>
      <view class='flex flex-wrap align-center forgotPassword_fd1_4'>
        <button class='flex-sub forgotPassword_fd1_4_c0' @tap.stop="logetLoginFunc()">确定</button>
      </view>
    </view>

    <!---flex布局flex布局结束-->


  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "mobile": "",
        "code": "",
        "password": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //忘记密码
      logetLoginFunc() {
        if (!validate(this.mobile, 'require')) {
          this.$message.info('手机号不能为空');
          return false;
        }
        if (!validate(this.mobile, 'phone')) {
          this.$message.info('请输入正确的手机号');
          return false;
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (!validate(this.password, 'require')) {
          this.$message.info('密码不能为空');
          return false;
        }
        if (!validate(this.password, 'password')) {
          this.$message.info('请输入6~12位字母+数字的密码');
          return false;
        }
        this.$api.post(global.apiUrls.postForgotPass, {
            account: this.mobile,
            password: this.password,
            code:this.code,
            type: 2
          })
          .then(res => {
            console.log(res.data.data.userinfo);
            this.$message.info(res.data.msg)
            if(res.data.code == 1){
              // this.$store.commit("updateUserInfo", res.data.data.userinfo);
              // global.token=res.data.data.userinfo.user_token
              // global.userInfo=res.data.data.userinfo
              // uni.setStorageSync('USER_INFO', res.data.data.userinfo)
              // uni.setStorageSync('USER_TOKEN', res.data.data.userinfo.user_token)
              setTimeout(() => {
                uni.navigateBack({
                  delta: 1
                })
              }, 1000)
              
              // uni.reLaunch({
              //   url:'/pages/tabBar/guide/index'
              // })
            }
          });
        this.$urouter.switchTab(`/pages/tabBar/passwordLogin/passwordLogin`);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(https://lvtai-files.oss-cn-beijing.aliyuncs.com/mini/117.png) no-repeat, rgba(255, 255, 255, 1);
    background-size: 100% auto !important;
  }

  .forgotPassword_flex_0 {
    background: transparent;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .forgotPassword_fd0_0_c2 {
    width: 32rpx;
    height: 32rpx;
  }

  .forgotPassword_fd0_0_c1_c0 {
    color: #333333;
    font-size: 36rpx;
    font-weight: 500;
    line-height: 36rpx;
  }

  .forgotPassword_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
    line-height: 88rpx;
  }

  .forgotPassword_fd0_0 {
    margin: 0rpx 32rpx 0rpx 32rpx;
  }

  .forgotPassword_flex_1 {
    padding: 88rpx 75rpx 0rpx 75rpx;
  }

  .forgotPassword_fd1_4_c0 {
    background: rgba(255, 147, 0, 1);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    font-size: 32rpx;
    color: #fff;
    height: 80rpx;
    line-height: 80rpx;
  }

  .forgotPassword_fd1_4 {
    padding: 88rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_3_c1_c0_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .forgotPassword_fd1_3_c1_c0_icon1 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  ::v-deep .forgotPassword_fd1_3_c1_c0 {
    width: 600rpx;
    font-size: 32rpx;
    height: 50rpx;
  }

  .forgotPassword_fd1_3_c0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
    color: #333333;
    font-size: 30rpx;
    font-weight: 600;
    line-height: 32rpx;
  }

  .forgotPassword_fd1_3 {
    border-bottom: 1px solid #eee;
    padding: 40rpx 0rpx 20rpx 0rpx;
  }

  .forgotPassword_fd1_2_c1_c1 {
    min-width: 120rpx;
    line-height: 32rpx;
    text-align: center;
    font-size: 24rpx;
    color: #FF7F1E;
    font-weight: 400;
  }

  .forgotPassword_fd1_2_c0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
    color: #333333;
    font-size: 30rpx;
    font-weight: 600;
    line-height: 32rpx;
  }

  .forgotPassword_fd1_2 {
    border-bottom: 1px solid #eee;
    padding: 40rpx 0rpx 20rpx 0rpx;
  }

  .forgotPassword_fd1_1_c0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
    color: #333333;
    font-size: 30rpx;
    font-weight: 600;
    line-height: 32rpx;
  }

  .forgotPassword_fd1_1 {
    border-bottom: 1px solid #eee;
    padding: 40rpx 0rpx 20rpx 0rpx;
  }

  .forgotPassword_fd1_0_c0 {
    color: #333333;
    font-size: 50rpx;
    font-weight: 600;
    line-height: 50rpx;
  }

  .forgotPassword_fd1_0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
  }
</style>
