File: /var/www/dk/wp-content/themes/food/page-create_competition_legal.php
<?php
/* Template Name: create_competition_legal */
get_header('competition');
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();
}
$current_user = wp_get_current_user();
// 获取当前用户的ID
$user_id = $current_user->ID;
// 获取当前用户的用户名
$user_login = $current_user->user_login;
// 获取当前用户的邮箱
$user_email = $current_user->user_email;
// 获取当前用户的显示名称
$display_name = $current_user->display_name;
//电话
$phone = get_user_meta($user_id, 'phone', true);
//年龄
$age = get_user_meta($user_id, 'age', true);
$wpuseravatarID = get_user_meta($user_id, 'wp_user_avatar_id', true); //用户头像id
$wpuseravatar = wp_get_attachment_url($wpuseravatarID);
$wp_user_avatar_url = get_user_meta($user_id, 'wp_user_avatar_url', true); //用户头像id
if ($wp_user_avatar_url == '') {
$wp_user_avatar_url = get_template_directory_uri() . '/food-app/img/mmc/img_cover.png';
}
$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/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-top: 20px;
margin-bottom: 20px;
height: 24px;
font-size: 24px;
font-family: Source Han Sans CN;
font-weight: 500;
line-height: 41px;
color: #333333;
}
</style>
<script>
function setAutoSize() {
var htmlDom = document.getElementsByTagName('html')[0]
var temp_w = document.body.clientWidth
if (document.body.clientWidth >= 1280) {
htmlDom.style.fontSize = '80px'
} else if (document.body.clientWidth >= 768) {
htmlDom.style.fontSize = '50px'
} else {
nowSize = (temp_w / 750) * 100
htmlDom.style.fontSize = nowSize + 'px'
}
}
window.onresize = setAutoSize
setAutoSize()
</script>
</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=" w-full mx-auto">
<div class="flex flex-col text-left w-full title_div pb-1">
<h1 class="text-[0.26rem] font-medium title-font mb-4 text-gray-900 form_section_title">
用户信息</h1>
</div>
<div class="flex flex-wrap ">
<!-- <div class="mt-[0.1rem] p-[0.1rem] w-full md:w-2/3">-->
<!-- <div class="relative">-->
<!-- <label for="img_url"-->
<!-- class="text-[0.16rem] font-bold text-gray-600">头像:JPG、JPEG、PNG格式圖片需≤10M</label>-->
<!---->
<!-- <img alt="img_url" class=" mt-1" style="width: 350px" :src="img_url"/>-->
<!-- <div style="height: 10px"></div>-->
<!-- <div>-->
<!-- <a-upload :file-list="fileList" :remove="handleRemove"-->
<!-- :before-upload="beforeUpload">-->
<!-- <a-button style="width:200px;">-->
<!-- Select Image-->
<!-- <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 ? 'Uploading' : 'Start Upload' }}-->
<!-- </a-button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="flex ml-1 items-center text-[0.26rem]">-->
<!-- <span class="mr-1">Size</span>-->
<!-- <div class="relative">-->
<!-- <select class="rounded-sm border appearance-none border-gray-300 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-200 focus:border-indigo-500 pl-1 pr-1">-->
<!-- <option>SM</option>-->
<!-- <option>M</option>-->
<!-- <option>L</option>-->
<!-- <option>XL</option>-->
<!-- </select>-->
<!-- <span class="absolute right-0 top-0 h-full w-10 text-center text-gray-600 pointer-events-none flex items-center justify-center">-->
<!-- <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"-->
<!-- class="w-4 h-4" viewBox="0 0 24 24">-->
<!-- <path d="M6 9l6 6 6-6"></path>-->
<!-- </svg>-->
<!-- </span>-->
<!-- </div>-->
<!-- </div>-->
<div class="p-[0.1rem] w-full lg:w-1/2 text-[0.26rem]">
<div class="relative">
<label for="user_id" class=" text-gray-600 ml-1">ID</label>
<input type="text" v-model="current_info.id" disabled
class="mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">
</div>
</div>
<div class=" w-full lg:w-1/2 mt-[0.3rem] text-[0.26rem] flex items-center ">
<span class="mx-1">類型:</span>
<div class="relative">
<select style="width: 90px;"
class="rounded-sm border appearance-none border-gray-300 py-[0.2rem] focus:outline-none focus:ring-1 focus:ring-indigo-200 focus:border-indigo-500 pl-[0.2rem] pr-[0.2rem] w-[0.9rem]">
<option value="0">比賽</option>
<option value="1">MMC</option>
<!-- <option>L</option>-->
<!-- <option>XL</option>-->
</select>
<span class="absolute right-0 top-0 h-full w-[0.5rem] text-center text-gray-600 pointer-events-none flex items-center justify-center">
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
class="w-1 h-1" viewBox="0 0 24 24">
<path d="M6 9l6 6 6-6"></path>
</svg>
</div>
</div>
<!-- <div class="p-[0.1rem] w-1/2 text-[0.26rem]">-->
<!-- <div class="relative">-->
<!-- <label for="name" class=" text-gray-600 ml-1">登錄賬號:</label>-->
<!-- <input type="text" v-model="user_login" disabled-->
<!-- class="mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">-->
<!-- </div>-->
<!-- </div>-->
<!---->
<!-- <div class="p-[0.1rem] w-full text-[0.26rem]">-->
<!-- <div class="relative">-->
<!-- <label for="name" class=" text-gray-600 ml-1">郵箱:</label>-->
<!-- <input type="text" v-model="user_email" disabled-->
<!-- class=" mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">-->
<!-- </div>-->
<!-- </div>-->
<div class="p-[0.1rem] w-full lg:w-1/2 text-[0.26rem]">
<div class="relative">
<label for="name" class="ml-1 text-gray-600">顯示名稱:</label>
<input type="text" v-model="current_info.title"
class="mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">
</div>
</div>
<div class="p-[0.1rem] w-full lg:w-1/2 text-[0.26rem]">
<div class="relative">
<label for="name" class="ml-1 text-gray-600">列表名稱:</label>
<input type="text" v-model="current_info.list_title"
class="mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">
</div>
</div>
<div class="p-[0.1rem] w-full lg:w-1/2 text-[0.26rem]">
<label for="name" class="ml-1 text-gray-600">排列順序:</label>
<input type="number" v-model="current_info.order_num"
class="mt-[0.1rem] 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-1 px-1 transition-colors duration-200 ease-in-out">
</div>
<div class="p-[0.1rem] text-[0.2rem] mt-[0.3rem] w-full">
<div class="relative">
<label for="content" class="ml-1 text-gray-600">簡介:</label>
<textarea style="height: 200px" v-model="current_info.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 h-64 outline-none text-gray-700 py-[0.1rem] px-1 resize-none leading-1 transition-colors duration-200 ease-in-out"></textarea>
</div>
</div>
<div class="p-[0.1rem] w-1/2 mt-[0.3rem] text-[0.2rem]">
<div class="relative">
<label for="radioValue" class=" 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="p-2 w-full">-->
<!-- <div class="relative">-->
<!-- <label for="content" class="leading-7 text-sm text-gray-600">简介:</label>-->
<!-- <textarea style="height: 200px" v-model="content" :disabled="textFieldDisabled"-->
<!-- class="w-full bg-gray-100 bg-opacity-50 rounded border border-gray-300 focus:border-indigo-500 focus:bg-white focus:ring-2 focus:ring-indigo-200 h-64 text-base outline-none text-gray-700 py-1 px-3 resize-none leading-6 transition-colors duration-200 ease-in-out"></textarea>-->
<!-- </div>-->
<!-- </div>-->
<div class="p-[0.1rem] w-full text-[0.26rem] mt-[0.3rem]">
<!-- <button @click="submitForm" style="padding-left: 10px;padding-right: 10px;"-->
<!-- class=" inline-flex text-white bg-main-color border-0 py-1 px-1 focus:outline-none hover:bg-indigo-600 rounded-sm w-[1.5rem] ">-->
<!-- 提交-->
<!-- </button>-->
<a-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" 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: '',
radioValue: 0,
action: 'update',
id: '0',
name: "",
content: "",
start_date: "0000-00-00 00:00:00",
end_date: "0000-00-00 00:00:00",
score: "0",
status: "1",
user_id: "<?php echo $user_id; ?>",
user_login: "<?php echo $user_login; ?>",
user_email: "<?php echo $user_email; ?>",
display_name: "<?php echo $display_name; ?>",
phone: "<?php echo $phone; ?>",
age: "<?php echo $age; ?>",
img_id: "<?php echo $wpuseravatarID; ?>",
img_url: "<?php echo $wp_user_avatar_url; ?>",
img_id_has_uploaded: false,
fileList: [],
videoFileList: [],
uploading: false,
//page
submit_info: {
price_pre: '0',
price_next: '0',
order_name: '日期',
search_text: ''
},
current_info: {
id: '0',
type: 0,
order_num: 0,
title: '',
list_title: '',
content: '',
status: 0,
},
}
},
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);
// 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;
},
onChange(e) {
console.log('radio checked', e.target.value);
},
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': 'user',
'action': 'index',
'a': 'updateWpUser',
'func_action': 'competition_user_info',
'user_id': this.user_id,
'display_name': this.display_name,
'phone': this.phone,
'age': this.age,
'wp_user_avatar_id': up_img_id,
'wp_user_avatar_url': this.img_url,
// 'status': this.status,
// 'debugmod': 1,
}
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
console.log('submitForm', 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',
});
// 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("post_data => ", data.data[0]);
// var post_data = data.data[0];
//
// this.id = post_data.id;
// this.name = post_data.name;
// this.content = post_data.content;
// // 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;
//
// 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);
// });
// },
getQueryString(name) {
let reg = `(^|&)${name}=([^&]*)(&|$)`
let r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
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!');
}
const isLt8M = file.size / 1024 / 1024 < 10;
if (!isLt8M) {
this.$message.error('Image must smaller than 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;
},
//图片上传文件
uploadHandleChangeImg() {
this.uploadHandleChange(false);
},
uploadHandleChange(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];
// }
/* 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;
antd.notification.success({
message: 'upload successfully.',
});
} else {
antd.notification.error({
message: 'upload failed.',
});
}
})
.catch(error => {
console.log(error)
antd.notification.error({
message: 'upload failed.',
});
})
}
,
///page
searchSubmit() {
this.page_num = 1
this.get_product()
},
hdSearch(e) {
this.submit_info.search_text = e
this.searchSubmit()
},
},
}
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>
</body>
</html>
<?php get_footer('food'); ?>