<template>
    <!--<div style="height: 100vh">
        <el-scrollbar style="width: 100%;height: 100%;">
            <headerNav :title="title" :iccid="iccid" :openid="openid"></headerNav>
            <footerNav></footerNav>

            <van-form @submit="onSubmit">
                <van-field
                        v-model="Ordpassword"
                        name="原始支付密码"
                        label="原始支付密码"
                        placeholder="原始支付密码"
                        :rules="[{ required: true, message: '请填写原始支付密码' }]"
                />
                <van-field
                        v-model="password"
                        type="password"
                        name="新的支付密码"
                        label="新的支付密码"
                        placeholder="新的支付密码"
                        maxlength="6"
                        :rules="[{ required: true, message: '请填写新的支付密码' }]"
                />
                <van-field
                        v-model="Newpassword"
                        type="password"
                        name="再次确认密码"
                        label="再次确认密码"
                        maxlength="6"
                        placeholder="再次确认密码"
                        :rules="[{ required: true, message: '请填写再次确认密码' }]"
                />
                <div style="margin: 16px;">
                    <van-button round block type="info" native-type="submit">提交</van-button>
                </div>
            </van-form>


            <div style="height: 3rem"></div>
        </el-scrollbar>
        <rightBottom></rightBottom>
    </div>
-->
</template>

<script>
    import headerNav from "../../../components/headerNav";
    import footerNav from "../../../components/footerNav";
    import rightBottom from "../../../components/rightBottom";
    /*import Vue from 'vue';
    import { Form } from 'vant';*/
    export default {
        name: "updpwd",
        components:{
            "headerNav":headerNav,
            "footerNav":footerNav,
            "rightBottom":rightBottom
        },
        data() {
            return {
                title:'修改密码',
                activeName: ['index'],
                iccid:'',
                openid:'',
                Ordpassword: '',
                password: '',
                Newpassword:'',
                /*contents:[{"title":"无信息"}],*/
                contents:{},
            };
        },
        mounted() {
            let _this=this;
            _this.iccid=_this.$route.params.iccid;
            if(_this.$check.checkIsNull(_this.iccid)){
                _this.iccid =_this.$store.state.iccid;
            }
            _this.openid=_this.$route.params.openid;
            if(_this.$check.checkIsNull(_this.openid)){
                _this.openid=_this.$store.state.openid;
            }
            _this.Ordpassword=_this.$route.params.Ordpassword;

            _this.appId =_this.$store.state.appid;
            //_this.$toast.fail(_this.iccid)

        },
        methods:{
            onSubmit(values){
                let _this=this;
                if(_this.Newpassword.length==6 && _this.password.length==6){

                    if(_this.Newpassword.trim().length==6 && _this.password.trim().length==6) {
                        if (_this.Newpassword == _this.password) {
                            _this.updPwd();
                        } else {
                            _this.$toast.fail("两次输入的密码不一致！");
                        }
                    }else{
                        _this.$toast.fail("支付密码长度为六位,且不包含空格！");
                    }
                }else{
                    _this.$toast.fail("支付密码长度为六位！");
                }


            },
            updPwd(){
                let _this=this;
                _this.$ajax.post(process.env.VUE_APP_SERVER+"/web/md-p-sign",{"iccid":_this.iccid,
                    "Ordpassword":_this.Ordpassword,"password":_this.password,"Newpassword":_this.Newpassword}).then(res=>{
                    if(res.data.code==="0"){
                        _this.$toast.success(res.data.data);
                        _this.Ordpassword = '';
                        _this.password = '';
                        _this.Newpassword = '';
                    }else{
                        _this.$toast.success(res.data.msg)
                    }
                }).catch(err=>{
                    _this.$toast.success("网络连接失败，请稍后重试")
                })
            }


        }
    }
</script>

<style scoped>

</style>