HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/dk/wp-content/themes/food/page-creating_competition_page.php
<?php
/* Template Name: creating_competition_page  */
//$tangDomain = "https://app.tangchinese.org/wp-content/themes/classapp/";

get_header('competition');

//if( !is_page('about') && !is_user_logged_in() && !is_category( '7' ) && !in_category( '7' ) ){
if (!is_user_logged_in()) {
    //auth_redirect(); //跳转到登录页面
//    $HOMEURL =  esc_url(home_url('login')) ;
    $HOMEURL = esc_url(home_url('/'));
    echo "<script>setTimeout(window.location='" . $HOMEURL . "',50)</script>";
    exit();
}

$user = wp_get_current_user();
//print_r($user);
$user_id = $user->ID;

$username = '';
if ($user_id != 0) {
    // 获取当前用户的显示名称
    $display_name = $user->display_name;
//    echo '$display_name '. $display_name;

    $user_nicename = $user->user_nicename;
//    echo 'user_nicename '. $user_nicename;

    if ($display_name != '') {
        $username = $display_name;
    } elseif ($user_nicename != '') {
        $username = $user_nicename;
    }

}

$vueVersion = time();
?>

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>創建比賽</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">

        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/vue.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/vue.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/axios.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/qs.js"></script>
        <link href="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/antd.min.css"
              rel="stylesheet">
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/moment.min.js"></script>

        <style>
            img {
                max-width: 100%;
                height: auto;
            }

            .form_section {
                border: 1px solid #E6E6E6;
                border-radius: 2px;
            }

            .title_div {
                border-bottom: 1px solid #E6E6E6;
                margin-bottom: 20px;
            }

            .form_section .form_section_title {
                margin-bottom: 10px;
                color: #333333;
            }

            .ant-upload-list {
                display: none;
            }

            .ant-btn-primary {
                color: #fff;
                background-color: #009B96;
                border-color: #009B96;
            }

            .ant-upload.ant-upload-drag p.ant-upload-hint {
                font-size: 12px;
            }

            .ant_img_upload_div_had {
                width: 150px;
                height: 150px;
                margin-bottom: 5px;
            }

            .ant_img_upload_div_none {
                width: 350px;
                height: 150px;
                margin-bottom: 5px;
            }
        </style>
    </head>
    <body>
    <div id="app">
        <yq-header :search_text="submit_info.search_text" @search="hdSearch"></yq-header>

        <section class="text-gray-600 body-font relative ">
            <div class="container px-1 pb-1 mx-auto form_section">


                <div class=" md:w-2/3 mx-auto">
                    <button v-on:click="goBackPage()" class="mt-[0.1rem]"><img style="width: 32px;"
                                                                               src="<?php showFoodAppPath('/img/arrow.png') ?>"/>
                    </button>

                    <div class="flex flex-col text-center w-full title_div">
                        <span class="text-[0.3rem] font-bold form_section_title">
                            比賽</span>
                        <!--                    <p class="lg:w-2/3 mx-auto leading-relaxed text-base">Whatever cardigan tote bag tumblr hexagon brooklyn asymmetrical gentrify.</p>-->
                    </div>
                    <div class="flex flex-wrap ">
                        <!--                        <div class="p-2 w-2/3">-->
                        <!--                            <div class="relative">-->
                        <!--                                <label for="name" class="leading-7 text-sm text-gray-600">支持wmv、avi、mpg、mp4、rmvb、mov、mkv、vob格式文件-->
                        <!--                                    建議上傳mp4格式文件,轉碼速度會更快 需≤200M</label>-->
                        <!--                                <div style="height: 10px"></div>-->
                        <!---->
                        <!--                                <video width="320" height="240" controls  v-if="this.video_url != ''">-->
                        <!--                                    <source :src="video_url" type="video/mp4">-->
                        <!--                                    您的浏览器不支持 HTML5 video 标签。-->
                        <!--                                </video>-->
                        <!--                                <div>-->
                        <!--                                    <a-upload :file-list="videoFileList" :remove="handleRemoveVideo"-->
                        <!--                                              :before-upload="beforeUploadVideo">-->
                        <!--                                        <img v-if="this.video_url == ''" style="width: 320px"-->
                        <!--                                             src="-->
                        <?php //echo get_template_directory_uri(); ?><!--/food-app/img/mmc/video_upload.png"/>-->
                        <!--                                        <a-button style="width:200px;">-->
                        <!--                                            Select Image-->
                        <!--                                            <a-icon type="upload"/>-->
                        <!--                                        </a-button>-->
                        <!--                                    </a-upload>-->
                        <!--                                    <a-button-->
                        <!--                                            type="danger"-->
                        <!--                                            :disabled="videoFileList.length === 0"-->
                        <!--                                            :loading="uploading"-->
                        <!--                                            style="margin-top: 16px"-->
                        <!--                                            @click="uploadHandleChangeVideo"-->
                        <!--                                    >-->
                        <!--                                        {{ uploading ? 'Uploading' : 'Start Upload' }}-->
                        <!--                                    </a-button>-->
                        <!--                                </div>-->
                        <!--                            </div>-->
                        <!--                        </div>-->

                        <div class=" w-2/3">
                            <div class="relative">
                                <label for="img_url"
                                       class="text-[0.2rem] font-bold text-gray-600">封面:</label>

                                <img class="mt-[0.1rem]" alt="img_url" style="width: 350px" v-if="this.img_url != ''"
                                     :src="img_url"/>
                                <div v-if="this.img_url == ''" class="text-[0.2rem] font-bold ">圖片未上傳</div>
                                <div style="height: 10px"></div>
                                <div>
                                    <!--                                    <a-upload :file-list="fileList" :remove="handleRemove"-->
                                    <!--                                              :before-upload="beforeUpload">-->
                                    <!--                                        <a-button style="width:200px;">-->
                                    <!--                                            選擇圖片-->
                                    <!--                                            <a-icon type="upload"/>-->
                                    <!--                                        </a-button>-->
                                    <!--                                    </a-upload>-->
                                    <!--                                    <a-button-->
                                    <!--                                            type="primary"-->
                                    <!--                                            :disabled="fileList.length === 0"-->
                                    <!--                                            :loading="uploading"-->
                                    <!--                                            style="margin-top: 16px"-->
                                    <!--                                            @click="uploadHandleChangeImg"-->
                                    <!--                                    >-->
                                    <!--                                        {{ uploading ? '上傳中...' : '開始上傳' }}-->
                                    <!--                                    </a-button>-->

                                    <div :class="{ 'ant_img_upload_div_had' : isHadImgUrl, 'ant_img_upload_div_none' : !isHadImgUrl }">
                                        <a-upload-dragger
                                                :remove="handleRemove"
                                                :before-upload="beforeUpload"
                                                name="images"
                                                :multiple="false"
                                                @change="handleChange"
                                                :default-file-list=[]
                                        >
                                            <p class="ant-upload-drag-icon">
                                                <!--                                                <a-icon type="inbox"/>-->
                                                <a-icon type="picture" theme="twoTone"/>
                                                <!--                                                <img alt="img_url" style="width: 50px" :src="img_url"/>-->
                                            </p>
                                            <p v-if="isHadImgUrl" class="ant-upload-text">更改影片</p>
                                            <p v-if="!isHadImgUrl" class="ant-upload-text">點擊或將圖片拖至此處上載</p>
                                            <p class="ant-upload-hint">
                                                JPG、JPEG、PNG格式圖片需≤10M
                                            </p>
                                        </a-upload-dragger>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <!--                        <div class=" w-1/2 text-[0.2rem] mt-[0.3rem]">-->
                        <!--                            <div class="relative">-->
                        <!--                                <label for="id" class="text-[0.2rem] font-bold  text-gray-600">ID:</label>-->
                        <!--                                <input type="text" name="id" v-model="id" disabled-->
                        <!--                                       class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">-->
                        <!--                            </div>-->
                        <!--                        </div>-->
                        <!--                        <div class=" w-1/2 "></div>-->
                        <!--                        <div class=" w-1/2 text-[0.2rem] mt-[0.3rem] ">-->
                        <!--                            <label for="score" class="text-[0.2rem] font-bold text-gray-600">Score:</label>-->
                        <!--                            <input type="number" name="score" v-model="score"-->
                        <!--                                   class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">-->
                        <!--                        </div>-->
                        <!--                        <div class=" w-1/2 text-[0.2rem] mt-[0.3rem] ">-->
                        <!--                            <div style="padding-left: 20px">-->
                        <!--                                <label for="share_num" class="text-[0.2rem] font-bold text-gray-600">Share:</label>-->
                        <!--                                <input type="number" name="share_num" v-model="share_num"-->
                        <!--                                       class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">-->
                        <!--                            </div>-->
                        <!--                        </div>-->

                        <div class="w-full mt-[0.3rem] text-[0.2rem]">
                            <div class="relative">
                                <label for="name" class="text-[0.2rem] font-bold  text-gray-600">標題:</label>
                                <input type="text" v-model="name"
                                       class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">
                            </div>
                        </div>
                        <div class="w-1/2 mt-[0.3rem] text-[0.2rem]">
                            <div class="relative">
                                <label for="start_date" class=" font-bold  text-gray-600">開始時間:</label>
                                <input type="datetime-local" v-model="start_date"
                                       class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">
                            </div>
                        </div>
                        <div class="w-1/2 mt-[0.3rem] text-[0.2rem]" style="padding-left: 20px">
                            <div class="relative">
                                <label for="end_date" class="text-[0.2rem] font-bold text-gray-600">結束時間:</label>
                                <input type="datetime-local" v-model="end_date"
                                       class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 transition-colors duration-200 ease-in-out">
                            </div>
                        </div>
                        <div class=" w-full mt-[0.3rem]">
                            <div class="relative">
                                <label for="content" class="text-[0.2rem] font-bold text-gray-600">簡介:</label>
                                <textarea style="height: 200px" v-model="content"
                                          class="w-full bg-gray-100 bg-opacity-50 rounded-sm border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 outline-none text-gray-700 py-[0.1rem] px-1 resize-none transition-colors duration-200 ease-in-out"></textarea>
                            </div>
                        </div>

                        <div class=" w-1/2 mt-[0.3rem] text-[0.2rem]">
                            <div class="relative">
                                <label for="email" class=" font-bold text-gray-600">狀態:</label>
                                <a-radio-group class="form-radio" v-model="radioValue" @change="onChange"
                                >
                                    <a-radio :value="0">
                                        下架
                                    </a-radio>
                                    <a-radio :value="1">
                                        上架
                                    </a-radio>
                                </a-radio-group>
                            </div>
                        </div>

                        <div class=" w-full text-[0.2rem] mt-[0.3rem]">
                            <!--                            <button @click="submitForm" style="padding-left: 10px;padding-right: 10px;width:150px;text-align: center;"-->
                            <!--                                    class="w-[2rem] inline-flex text-white bg-main-color border-0 py-1 px-1 focus:outline-none hover:bg-indigo-600 rounded-sm text-center">-->
                            <!--                                提交-->
                            <!--                            </button>-->
                            <a-button @click="submitForm"
                                      style="padding-left: 10px;padding-right: 10px;width:150px;text-align: center;"
                                      :disabled="uploading"
                                      class="w-[2rem] inline-flex text-white bg-main-color border-0 py-1 px-1 focus:outline-none hover:bg-indigo-600 rounded-sm text-center"
                                      type="primary">
                                提交
                            </a-button>
                        </div>

                    </div>
                </div>
            </div>
        </section>
        <div style="height: 80px"></div>
        <yq-footer :year_text="year_text"></yq-footer>
    </div>

    <script>
        const local_url = '<?php echo $local_url ?>'
        const domain = '<?php echo esc_url(home_url('/')); ?>'

        const app = {
            el: "#app",
            components: {
                'yq-header': httpVueLoader('<?php showFoodAppPath('components/yq-header-competition.vue?v=' . $vueVersion) ?>'),
                'yq-footer': httpVueLoader('<?php showFoodAppPath('components/yq-footer-competition.vue?v=' . $vueVersion) ?>'),
            },
            data() {
                return {
                    year_text: <?php echo date("Y") ?>,
                    token: '',

                    action: 'update',
                    aid: '0',
                    id: '0',

                    name: "",
                    content: "",
                    start_date: "0000-00-00 00:00:00",
                    end_date: "0000-00-00 00:00:00",

                    score: "0",
                    share_num: "0",

                    status: "1",

                    user_id: '<?php echo $user_id; ?>',
                    user_name: '<?php echo $username; ?>',


                    img_id: '0',
                    // img_url: local_url + '/img/mmc/img_cover.png',
                    img_url: '',
                    img_id_has_uploaded: false,

                    video_file_id: '0',
                    // video_url: local_url + '/img/mmc/video_upload.png',
                    video_url: '',
                    video_file_id_has_uploaded: false,

                    radioValue: 0,

                    has_customize: false,
                    textFieldDisabled: false,
                    isHadImgUrl: false,


                    fileList: [],
                    videoFileList: [],
                    uploading: false,

                    //page
                    submit_info: {
                        price_pre: '0',
                        price_next: '0',
                        order_name: '日期',
                        //filter_cate: [<?php //echo $initCate; ?>//],
                        search_text: ''
                    },
                }
            },
            computed: {
                //自定义请求头
                headers() {
                    return {
                        'Authorization': 'Bearer ' + this.token,
                    }
                }
            },

            mounted() {
                // let id = this.$route.query.id;
                // this.type = this.getQueryString("type"); //参数名1
                this.id = this.getQueryString("id"); //参数名1
                console.log("id => ", this.id);

                this.aid = this.getQueryString("aid"); //参数名1
                console.log("aid => ", this.aid);

                // if (window.localStorage) {
                //     console.log("This browser supports localStorage");
                //     // alert('This browser supports localStorage');
                // } else {
                //     alert('This browser does NOT support localStorage');
                // }
                //
                // // localStorage.user_id = 3; // this.user_id;
                // this.user_id = localStorage.user_id;
                // // this.user_id = this.getQueryString("user_id");
                // console.log('user_id => ' + this.user_id);
                // this.user_name = localStorage.user_name;
                // console.log('user_name => ' + this.user_name);

                // this.token = this.getQueryString("token");
                // console.log('token => ' + this.token);

                this.action = this.getQueryString("action");
                console.log('action => ' + this.action);

                if (this.action === 'update') {
                    this.initForm();
                }
            },
            methods: {
                changeFormState() {
                    this.textFieldDisabled = !this.textFieldDisabled;
                },
                submitForm() {
                    this.status = this.radioValue
                    const up_img_id = this.img_id_has_uploaded ? this.img_id : null;
                    // const up_video_id = this.video_file_id_has_uploaded ? this.video_file_id : null;

                    // var stringTime = this.start_date; //'2012-10-12 22:37:33';
                    // var timestamp = Date.parse(new Date(stringTime));
                    // var live_timestamp = timestamp / 1000;
                    // // console.log(timestamp + '就是' + stringTime + '时间戳 ' + live_timestamp);
                    // console.log(stringTime + ' 时间戳 => ' + live_timestamp);

                    // console.log(this.start_date + ' 处理前 => ' + this.end_date);
                    this.start_date = this.date2Db(this.start_date)
                    this.end_date = this.date2Db(this.end_date)
                    console.log(this.start_date + ' 处理后 => ' + this.end_date);

                    // console.log('video_file_id_has_uploaded => ' + this.video_file_id_has_uploaded + ', up_video_id => ' + up_video_id + ', video_file_id => ' + this.video_file_id + ' video_url => ' + this.video_url);

                    let formData = {
                        'module': 'ranking',
                        'action': 'index',
                        'a': 'setActivity',

                        'func_action': this.action,

                        'id': this.id,

                        'type': '0',

                        'score': this.score,
                        'share_num': this.share_num,

                        'form_name': this.name,
                        'content': this.content,

                        'start_date': this.start_date,
                        'end_date': this.end_date,

                        'img_id': up_img_id,
                        'img_url': this.img_url,

                        // 'video_file_id': up_video_id,
                        // 'video_url': this.video_url,

                        'status': this.status,

                        // 'debugmod': 1,
                    }

                    if (this.action === 'add') {
                        formData['user_id'] = this.user_id
                        formData['user_name'] = this.user_name
                    }

                    console.log(' formData => ');
                    console.log(formData);

                    axios({
                        method: 'post',
                        // headers: {
                        //     'Authorization': 'Bearer ' + this.token,
                        // },
                        url: '/api/',
                        data: Qs.stringify(formData)
                    })
                        .then((response) => {
                            // console.log(response);
                            let data = response.data
                            if (data.rc === 0) {

                                if (this.action === 'add') {
                                    // let backData = data.data;
                                    this.id = data.id;

                                    console.log('add done id =>' + this.id);
                                }

                                this.action = 'update';

                                antd.notification.success({
                                    // message: 'Submit Success',
                                    message: '提交成功',
                                });

                                setTimeout(() => this.goBackPage(), 3000)

                                this.initForm()
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                },

                initForm() {
                    axios({
                        method: 'post',
                        // url: '//dk.smart1space.site/api',
                        url: '/api',
                        data: Qs.stringify({
                            'module': 'ranking',
                            'action': 'index',
                            'a': 'getActivityListInfoByPage',
                            id: this.id,

                            pageNum: 1,
                            pageSize: 1,
                        })
                        // , headers: {
                        //     'Authorization': 'Bearer ' + this.token,
                        // }
                    })
                        .then((response) => {
                            // console.log(response);
                            let data = response.data
                            // console.log(data);
                            // console.log("data.rc => ", data.rc);

                            if (data.rc === 0) {
                                // this.tag_id = data.data.main.tag_id;
                                // this.series_id = data.data.main.id;

                                console.log("Activity => ", data.data[0]);
                                var post_data = data.data[0];

                                this.id = post_data.id;
                                this.name = post_data.name;
                                this.content = post_data.content;

                                this.score = post_data.score;
                                this.share_num = post_data.share_num;
                                // console.log("post_content => ", this.post_content);

                                // var d = new Date(post_data.live_time * 1000);
                                // console.log("this.live_time date => ", d);
                                //
                                // let live_time = this.formatDate3(d, 'yyyy-mm-dd hh:ii:ss');
                                // console.log(live_time); // 2016-07-06 16:19

                                let start_date_db = post_data.start_date;
                                let start_date_arr = start_date_db.split(" ");
                                this.start_date = start_date_arr[0] + 'T' + start_date_arr[1]
                                // console.log("start_date => ", this.start_date);
                                // str="jpg|bmp|gif|ico|png";


                                //'2017-06-01T08:30:06'
                                this.end_date = this.date2Input(post_data.end_date);// post_data.end_date;
                                // console.log("end_date => ", this.end_date);

                                this.status = post_data.status;

                                this.radioValue = parseInt(this.status);
                                // console.log("status => ", this.status);


                                this.img_id = post_data.img_id;
                                this.img_url = post_data.img_url;

                                if (this.img_url == '' || this.img_url == null) {
                                    this.isHadImgUrl = false
                                } else {
                                    this.isHadImgUrl = true
                                }

                                this.video_file_id = post_data.video_file_id;
                                this.video_url = post_data.video_url;

                                // this.videoFileList = [this.video_file_id];

                                // var img_url = post_data.post.img1_url;
                                // if (img_url.startsWith('http')) {
                                //     console.log("字符串是以http开头的!");
                                //
                                //     this.img1_url = img_url.replace("http://", "https://")
                                // } else {
                                //     this.img1_url = img_url;
                                // }

                                this.has_customize = true;
                                this.textFieldDisabled = false;
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                },

                // 数据库格式日期 加T  2017-06-01 08:30:06 -> 2017-06-01T08:30:06
                date2Input(inDate) {
                    let start_date_arr = inDate.split(" ");
                    return start_date_arr[0] + 'T' + start_date_arr[1]
                },

                // input 转 数据库格式日期 去T  2017-06-01T08:30:06 -> 2017-06-01 08:30:06
                date2Db(inDate) {
                    let start_date_arr = inDate.split("T");
                    return start_date_arr[0] + ' ' + start_date_arr[1]
                },

                //相差日期
                selectTime() {
                    var beginTime = $("#inTime").val();
                    var endTime = $("#outTime").val();
                    var date1 = new Date(beginTime)
                    var date2 = new Date(endTime)
                    console.log(Math.ceil((date2 - date1) / (86400 * 1000)) + "天")
                },


                formatDate(date, cut) {
                    var date = new Date(date);
                    var YY = date.getFullYear() + cut;
                    var MM =
                        (date.getMonth() + 1 < 10
                            ? "0" + (date.getMonth() + 1)
                            : date.getMonth() + 1) + cut;
                    var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                    var hh =
                        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
                    var mm =
                        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
                        ":";
                    var ss = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
                    return YY + MM + DD + " " + hh + mm + ss;
                },


                getQueryString(name) {
                    let reg = `(^|&)${name}=([^&]*)(&|$)`
                    let r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]);
                    return null;
                }
                ,

                onChange(e) {
                    console.log('radio checked', e.target.value);
                },

                // beforeUploadVideo(file) {
                //     // console.log('beforeUpload', file);
                //     const isJpgOrPng = file.type === 'video/mp4';
                //     if (!isJpgOrPng) {
                //         // this.$message.error('You can only upload Mp4 file!');
                //         this.$message.error('只能上传mp4文件!');
                //     }
                //     const isLt8M = file.size / 1024 / 1024 < 250;
                //     if (!isLt8M) {
                //         // this.$message.error('Image must smaller than 250MB!');
                //         this.$message.error('視頻必須小於250MB!');
                //     }
                //     // return isJpgOrPng && isLt8M;
                //
                //     this.videoFileList = [file]; // [...this.videoFileList, file];
                //     // return false;
                //     return isJpgOrPng && isLt8M;
                // },
                // handleRemoveVideo(file) {
                //     const index = this.videoFileList.indexOf(file);
                //     const newFileList = this.videoFileList.slice();
                //     newFileList.splice(index, 1);
                //     this.videoFileList = newFileList;
                // },
                //
                // ///视频文件上传
                // uploadHandleChangeVideo() {
                //     this.uploadHandleChange(true);
                // },

                beforeUpload(file) {
                    // console.log('beforeUpload', file);
                    const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
                    if (!isJpgOrPng) {
                        // this.$message.error('You can only upload JPG/PNG file!');
                        this.$message.error('只能上传JPG/PNG格式圖片!');
                    }
                    const isLt8M = file.size / 1024 / 1024 < 10;
                    if (!isLt8M) {
                        // this.$message.error('Image must smaller than 10MB!');
                        this.$message.error('圖片大小不能超過10MB!');
                    }
                    // return isJpgOrPng && isLt8M;

                    this.fileList = [file]; // [...this.fileList, file];
                    // return false;
                    return isJpgOrPng && isLt8M;
                },

                handleRemove(file) {
                    const index = this.fileList.indexOf(file);
                    const newFileList = this.fileList.slice();
                    newFileList.splice(index, 1);
                    this.fileList = newFileList;
                },

                handleChange(info) {
                    const status = info.file.status;
                    if (status === 'uploading') {
                        this.uploading = true
                    }
                    if (status !== 'uploading') {
                        this.uploading = false
                        // console.log(info.file, info.fileList);
                    }
                    if (status === 'done') {
                        this.uploadHandleChangeImg(info)
                        // this.$message.success(`${info.file.name} file uploaded successfully.`);
                    } else if (status === 'error') {
                        this.$message.error(`${info.file.name} 上傳失敗.`);
                    }
                },
                //图片上传文件
                uploadHandleChangeImg(info) {
                    this.uploadHandleChange(info, false);
                },

                uploadHandleChange(info, isVideo = false) {
                    // const {fileList} = this;
                    // const formData = new FormData();
                    // fileList.forEach(file => {
                    //     formData.append('files[]', file);
                    // });
                    this.uploading = true;

                    // let file = e.target.files[0]
                    var file = this.fileList[0]
                    // if (isVideo) {
                    //     file = this.videoFileList[0];
                    // }

                    console.log('file =>', file)

                    /* eslint-disable no-undef */
                    let param = new FormData()  // 创建form对象
                    param.append('images', file)  // 通过append向form对象添加数据
                    param.append('user_id', this.user_id) // 添加form表单中其他数据
                    param.append('img_upload_verify', 'imgE5FCDG3HQA4B1NOPIJ2RSTUV67KL') // 添加form表单中其他数据

                    // console.log(param.get('tang_file')) // FormData私有类对象,访问不到,可以通过get判断值是否传进去
                    let config = {
                        headers: {'Authorization': 'Bearer ' + this.token}
                    }
                    // axios.post('https://app.tangchinese.org/api-app-data?module=upload&action=upload_app', param, config)
                    //axios.post('<?php //echo $domain_url; ?>//' + '/wp_upload_img', param, config)
                    axios.post(domain + '/wp_upload_img', param, config)
                        .then(response => {
                            // console.log(response)
                            console.log(response.data)

                            var model = response.data;

                            if (model.rc == 0) {
                                if (isVideo) {
                                    this.video_file_id = model.id;
                                    this.video_url = model.url;
                                    this.video_file_id_has_uploaded = true;
                                } else {
                                    this.img_id = model.id;
                                    this.img_url = model.url;
                                    this.img_id_has_uploaded = true;
                                }

                                this.uploading = false;

                                this.isHadImgUrl = true

                                // antd.notification.success({
                                //     message: '圖片上傳成功',
                                // });

                                this.$message.success(`${info.file.name} 上傳成功.`);
                            } else {
                                // antd.notification.error({
                                //     message: '圖片上傳失敗',
                                // });
                                this.$message.error(`${info.file.name} 上傳失敗.`);
                            }
                        })
                        .catch(error => {
                            console.log(error)
                            // antd.notification.error({
                            //     message: '圖片上傳失敗',
                            // });
                            this.$message.error(`${info.file.name} 上傳失敗.`);
                        })
                }
                ,

                ///page
                searchSubmit() {
                    this.page_num = 1
                    this.get_product()
                },
                hdSearch(e) {
                    this.submit_info.search_text = e
                    this.searchSubmit()
                },

                goBackPage() {
                    // console.log('goBackPage')
                    // history.back();
                    // window.open('/competition_index/?aid=' + this.id, '_self');

                    var fromType = this.getQueryString("fromType"); //参数名1
                    // console.log("fromType => ", fromType);

                    if (fromType === 'competition_user_info') {
                        window.open('/competition_user_info/ ', '_self');
                    } else {
                        window.open('/competition_index/?aid=' + this.id, '_self');
                    }
                }


            },
        }

        function init() {
            new Vue(app)
        }
    </script>
    <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/antd.min.js"
            onload="init()"></script>

    <!--<script crossorigin="anonymous" integrity="sha384-drFt50yMKg7m1EtWl1ZjDhAePoX+5g30w8Jkc8wnKfEx3GW1qZs2p5iAn03WbRIb" src="https://lib.baomitu.com/antd/1.11.6/antd.js" onload="init()"></script>-->
    </body>
    </html>

<?php get_footer('food'); ?>