<template>
    <el-dialog center title="赠送" :visible.sync="show" width="680px">
        <div class="page" v-loading="loading">
            <div class="top-tips">通过手机号码检索用户信息，<span>赠送后该加密作品将会被转移</span></div>
            <div class="user">
                <el-input
                    v-model="phone"
                    placeholder="请输入手机号码进行检索"
                    suffix-icon="el-icon-search"
                    size="small"
                    clearable
                    type="tel"
                    @change="getUser"
                ></el-input>

                <div class="user-content">
                    <div class="empty" v-if="info.length === 0">检索用户区域</div>
                    <div v-if="info.length != 0" class="content">
                        <img class="img" :src="info.avatar" alt="" />
                        <div class="init">
                            <div>
                                <div class="text1">{{ info.realName || '保密' }}</div>
                                <div class="text2">
                                    手机号码 <span>{{ info.phone }}</span>
                                </div>
                            </div>
                            <el-checkbox size="124px" v-model="checked"></el-checkbox>
                        </div>
                    </div>
                </div>
            </div>
            <div class="info">
                <div class="price">
                    <span class="text1">应付金额</span>
                    <img src="../assets/icon_jiage.png" alt="" />
                    <span class="text2">{{ orderInfo.price }}</span>
                </div>
                <div class="flex1"></div>
                <div class="order">
                    <span class="text1">订单编号</span>
                    <span class="text2">{{ orderInfo.id }}</span>
                    <el-button type="info" @click="copy" size="mini" plain>复制</el-button>
                </div>
            </div>

            <div class="payMethods">
                <div class="title">选择支付方式</div>
                <div class="pay-list">
                    <div class="pay-info">
                        <el-radio-group v-model="payMethods">
                            <el-radio v-for="item in payList" border :label="item.type" :key="item.type">
                                <img :src="item.icon" alt="" />
                                <span> {{ item.name }}</span>
                            </el-radio>
                        </el-radio-group>
                    </div>
                </div>
            </div>

            <div class="tips">
                <div class="text1">购买须知</div>
                <div class="text2">
                    1.数字盲盒按照随机概率进行抽取<br />
                    2.数字盲盒及其数字内容为虚拟商品<span style="color: #ff4f50">支付完成后，不可退换</span><br />
                    3.数字盲盒及其数字内容仅作为消费娱乐（或其他约定场景）使用<br />
                    4.切勿当成投资和投机品进行盲目消费
                </div>
            </div>
        </div>

        <span slot="footer" class="dialog-footer">
            <el-button type="primary" class="pay" @click="submit">立即支付</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    data() {
        return {
            payMethods: 'ALIPAY',
            show: false,
            info: [],
            checked: true,
            payList: [
                {
                    icon: require('../assets/alipay.png'),
                    name: '支付宝',
                    type: 'ALIPAY'
                },
                {
                    icon: require('../assets/weixin.png'),
                    name: '微信',
                    type: 'WEIXIN'
                }
                // {
                //     icon: require('../assets/dcep.png'),
                //     name: 'DCEP支付',
                //     type: 'DCEP'
                // }
            ],
            loading: false,
            orderInfo: {},
            phone: ''
        };
    },
    // mounted() {
    //     this.init();
    // },
    methods: {
        submit() {
            if (this.payMethods === 'DCEP') {
                this.wait();
            }
        },
        init(info) {
            this.checkLogin()
                .then(() => {
                    this.show = true;
                    this.loading = true;
                    console.log(this.$route.query.id);
                    // return this.$http.get('/order/get/' + this.$route.query.id);
                    // return this.$http.post('/order/create?collectionId=' + info.id + '&qty=1');
                })
                .then(res => {
                    this.orderInfo = res;
                    this.loading = false;
                })
                .catch(e => {
                    if (e) {
                        this.$message.warning(e.error);
                    }
                });
        },
        copy() {
            this.$copyText(this.orderInfo.id).then(
                e => {
                    this.$message.success('复制成功');
                },
                e => {
                    this.$message.warning('复制失败');
                }
            );
        },
        getUser() {
            this.$http
                .post('/user/searchByPhone', {
                    phone: this.phone
                })
                .then(res => {
                    this.info = res;
                    if (this.info.length === 0) {
                        this.empty = true;
                    }
                })
                .catch(e => {
                    if (e) {
                        this.$toast(e.error);
                    }
                });
        }
    }
};
</script>

<style lang="less" scoped>
/deep/ .el-checkbox__inner {
    // width: 24px;
    // height: 24px;
    border-radius: 50%;
    // background-image: linear-gradient(135deg, #fdfb60 20%, #ff8f3e 100%);
}
/deep/ .el-checkbox__label {
    margin-right: 20px;
}
.info {
    .flex();
    height: 94px;
    .price {
        .flex();
        align-items: flex-end;
        .text1 {
            font-size: 16px;
            color: #000000;
            line-height: 24px;
        }
        img {
            width: 10px;
            display: block;
            margin: 0 0 4px 10px;
        }
        .text2 {
            font-size: 40px;
            font-family: OSP;
            font-weight: normal;
            color: #ff4f50;
            line-height: 36px;
        }
    }

    .order {
        .text1 {
            font-size: 13px;
            color: #939599;
            line-height: 24px;
        }

        .text2 {
            font-size: 13px;
            color: #0e0e0e;
            line-height: 22px;
            padding: 0 6px 0 30px;
        }
        .el-button {
            height: 20px;
            line-height: 20px;
            padding: 0 10px;
        }
    }
}
/deep/.el-loading-mask {
    background-color: #ffffffee;
}

/deep/.el-radio {
    .flex();
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    width: 190px;
    height: 42px;
    color: #939599;
    padding: 0;
    box-sizing: border-box;
    .el-radio__label {
        .flex();
        img {
            width: 24px;
            height: 24px;
        }
        span {
            font-size: 16px;
            font-weight: bold;
            padding: 0 10px;
        }
        margin-left: 24px;
    }
    .el-radio__input {
        margin-right: 24px;
        width: 20px;
        flex-shrink: 0;

        .el-radio__inner {
            width: 20px;
            height: 20px;
            &::after {
                content: '\e6da';
                font-family: 'element-icons';
                width: 14px;
                height: 14px;
                font-size: 14px;
                color: #fff;
                font-weight: bold;
                background-color: transparent;
            }
        }

        &.is-checked {
            .el-radio__inner {
                background-image: linear-gradient(135deg, @prim 20%, @warn 100%);
                border-width: 0;
            }
        }
    }
    &.is-checked {
        .line(@bg:#E0FFF8,@radius:4px);
        border-width: 0;
        .el-radio__label {
            color: #000;
        }
    }
}
.payMethods {
    padding: 30px 0;
    .title {
        font-size: 16px;
        color: #000000;
        line-height: 24px;
        padding-bottom: 20px;
    }
}
/deep/.el-radio.is-bordered + .el-radio.is-bordered {
    margin-left: 0;
}

.tips {
    padding-top: 20px;
    .text1 {
        font-size: 16px;
        color: #939599;
        line-height: 24px;
    }
    .text2 {
        font-size: 14px;
        color: #939599;
        line-height: 28px;
        margin-top: 10px;
    }
}
.pay {
    background-image: linear-gradient(135deg, @prim, @warn);
    border-width: 0;
    width: 200px;
    color: #000;
    &:hover {
        background-image: linear-gradient(135deg, darken(@prim, 20), darken(@warn, 20));
    }
}

.top-tips {
    text-align: center;
    font-size: 14px;
    color: #939599;
    line-height: 28px;
    span {
        color: #ff4f50;
    }
}

.user {
    padding: 20px 0;

    .el-input {
        border-radius: 8px;
    }

    .user-content {
        background: #f5f7fa;
        border-radius: 8px;
        height: 142px;
        margin-top: 10px;
        position: relative;

        .empty {
            font-size: 14px;
            color: rgba(147, 149, 153, 0.5);
            line-height: 24px;
            text-align: center;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        .content {
            // padding: 0px 16px;
            display: flex;
            align-items: center;
            padding-top: 40px;
            border-radius: 12px;
            .img {
                width: 70px;
                height: 70px;
                border-radius: 50%;
                margin: 0 12px 0 20px;
            }
            .init {
                display: flex;
                align-items: center;
                justify-content: space-between;
                width: 100%;
                .text1 {
                    font-size: 16px;
                    font-weight: bold;
                    color: #000;
                    line-height: 24px;
                }
                .text2 {
                    font-size: 14px;
                    font-weight: 400;
                    color: #939599;
                    line-height: 24px;
                }
                span {
                    color: #000;
                }
                .btn {
                    width: 70px;
                    height: 26px;
                    border-radius: 16px;
                    border: 1px solid;
                    // border-image: linear-gradient(135deg, rgba(253, 251, 96, 1), rgba(255, 143, 62, 1)) 1 1;
                    line-height: 26px;
                    font-size: 14px;
                    color: #fdfb60;
                    text-align: center;
                }
            }
        }
    }
}
</style>
