File: /var/www/dk/wp-content/themes/food/food-app/page-ranking_search.php
<?php
/* Template Name: ranking_search */
get_header('food');
//get_header('MedicalMediaChannel');
//get_header('BizRoadShow');
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => 0
);
$productCat = array();
//$productTabs = get_terms('product_cat', $args);
//$term_taxonomy_id = 39;
//foreach ($productTabs as $key => $value) {
//// if ($value->name != 'Uncategorized' && $value->name != '未分類') {
//// array_push($productCat, $value->name);
//// }
//
// if ($value->name == 'Medical Media Channel') {
//// array_push($productCat, $value->name);
// $term_taxonomy_id = $value->term_taxonomy_id;
// }
//
// if ($value->parent == $term_taxonomy_id) {
// array_push($productCat, $value->name);
// }
//
//}
$initCate = empty($_GET['cat']) ? '' : '"' . htmlspecialchars($_GET['cat']) . '"'; // '"電子產品專區"';
$vueVersion = time();
$user = wp_get_current_user();
$user_id = $user->ID;
//print_r($user);
$username = '';
if ($user_id == 0) {
// $username = $user->data->display_name;
if (isset($user->data->user_nicename)) {
$username = $user->data->user_nicename;
}
}
//echo '$username -> '.$username;
?>
<style>
.search-list {
background-color: white;
}
/*#topBanner {*/
/* width: 100%;*/
/* height: 400px;*/
/* background: linear-gradient(315deg, #00839B 0%, #1ABFBA 100%);*/
/* opacity: 1;*/
/*}*/
.list_item {
/*width: 500px;*/
/*height: 740px;*/
background: rgba(255, 255, 255, 0.39);
box-shadow: 0 0 20px rgba(0, 155, 150, 0.2);
opacity: 1;
}
/*banner横幅start*/
.banner{
width: 100%;
height: 400px;
background: url(<?php showFoodAppPath('/ranking/images/banner_bg.webp') ?>) no-repeat right center,linear-gradient(315deg, #00839B 0%, #1ABFBA 100%);
padding: 20px;
/*//#1b9ffc;*/
}
.banner .banner_content{
height: 100%;
width: 1400px;
margin: 0 auto;
position: relative;
float: left;
}
.banner .banner_content .banner_title{
color:white;
float: left;
text-indent: 6px;
width: 160px;
height: 36px;
font-size: 36px;
font-family: Source Han Sans CN;
font-weight: 500;
opacity: 1;
}
.banner .banner_content .banner_text{
color: white;
/*float: left;*/
width: 130px;
text-indent: 6px;
margin-top: 70px;
/*height: 32px;*/
background: rgba(255,255,255,0.39);
font-size: 18px;
/*font-family: Source Han Sans CN;*/
font-weight: 400;
}
.banner .banner_content .banner_line{
height: 4px;
width: 505px;
float: left;
background: white;
margin: 28px 0 0 3px;
}
.banner .banner_content .banner_bottom_title{
font-size:18px;
line-height: 18px;
height: 18px;
color: white;
float: left;
width: 100%;
font-weight: 500;
text-indent: 6px;
margin-top: 30px;
}
.banner .banner_content .banner_bottom_text{
font-size:16px;
color: white;
line-height: 32px;
width: 745px;
float: left;
margin-left: 6px;
margin-top: 10px;
}
.banner .banner_content .banner_btn_outNode{
width: 100%;
float: left;
height: 70px;
margin-top: 35px;
margin-left: 4px;
}
.banner .banner_content .banner_btn_outNode .banner_btn{
/*width: 213px;*/
height: 100%;
float: left;
/*border-radius: 107px;*/
/*background: url(img/btn_bg.png) repeat-y;*/
font-size: 23px;
line-height: 70px;
text-align: center;
cursor: pointer;
margin-right: 27px;
width: 180px;
color: #009B96;
background: rgba(255,255,255,1);
box-shadow: 0 10px 10px rgba(255,255,255,0.2);
opacity: 1;
border-radius: 20px;
}
.banner .banner_content .banner_btn_outNode .btn_one{
margin-left: 4px;
}
.banner .banner_content .banner_lists{
width: 100%;
float: left;
height:27px;
margin-top: 69px;
text-indent: -1px;
}
.banner .banner_content .banner_lists li{
float: left;
height: 20px;
line-height: 20px;
font-size: 20px;
color: white;
margin-right: 43px;
cursor: pointer;
position: relative;
top: 4px;
}
.banner .banner_content .banner_lists .active{
font-size: 27px;
line-height: 27px;
color: #fdc235;
height: 27px;
top: 0;
}
.banner .banner_content .banner_position{
width: 80px;
height: 10px;
position: absolute;
left: 50%;
bottom: 29px;
margin-left: -40px;
}
.banner .banner_content .banner_position li{
width: 10px;
height: 10px;
float: left;
background: #f0f0f0;
border-radius: 50%;
margin-right: 13px;
cursor: pointer;
}
.banner .banner_content .banner_position li.active{
background: #fe672d;
}
.banner .banner_content .banner_position .end{
margin-right: 0;
}
/*banner横幅end*/
</style>
<app id="app">
<yq-header :search_text="submit_info.search_text" @search="hdSearch"></yq-header>
<main class=" pb-[0.2rem] md:w-[768px] md:mx-auto xl:w-[1280px]" style="background: white">
<!-- <div id="topBanner" class="container mx-auto"></div>-->
<!-- 輪播 -->
<!-- <div v-if="a_banner.length > 0" class=" relative w-100 px-[0.3rem] mb-[0.2rem]">-->
<!-- <div @click="toBannerLink()" class=" w-full h-[2.3rem] md:h-[6.6rem]">-->
<!-- <div @click="toBannerLink()" class=" w-full " id="banner">-->
<!-- <img v-for="(item, key) in a_banner" :key="'bannerimg'+item.id" v-show="banner_current == key"-->
<!-- :class="banner_show?' opacity-100':' opacity-0'"-->
<!-- class=" transition-opacity duration-700 cursor-pointer rounded-[0.2rem] w-full h-full bg-main"-->
<!-- :src="item.banner_url">-->
<!-- </div>-->
<!---->
<!-- 指示點 -->
<!-- <div class=" absolute bottom-[0.1rem] left-1/2 -translate-x-1/2 flex justify-center">-->
<!-- <div v-for="(item, key) in a_banner" :key="'banner'+item.id"-->
<!-- :class="banner_current==key?'bg-white':'bg-sub-white'"-->
<!-- class=" ml-[0.2rem] first:ml-0 w-[0.33rem] h-[0.04rem]"></div>-->
<!-- </div>-->
<!---->
<!-- <img @click="preBanner()"-->
<!-- class=" cursor-pointer w-[0.66rem] h-[0.66rem] md:w-[1rem] md:h-[1rem] absolute left-[-0.04rem] md:left-[-0.16rem] top-1/2 -translate-y-1/2"-->
<!-- src="--><?php //showFoodAppPath('img/scroll-left.png') ?><!--">-->
<!-- <img @click="nextBanner()"-->
<!-- class=" cursor-pointer w-[0.66rem] h-[0.66rem] md:w-[1rem] md:h-[1rem] absolute right-[-0.04rem] md:right-[-0.16rem] top-1/2 -translate-y-1/2"-->
<!-- src="--><?php //showFoodAppPath('img/scroll-right.png') ?><!--">-->
<!-- </div>-->
<!-- banner 横幅模块start-->
<div class='banner pc_banner'>
<div class='banner_content'>
<div class='banner_title'>
比賽標題
</div>
<div class='banner_text '>
公平·公正·公開
</div>
<!-- <div class='banner_line'></div>-->
<div class='banner_bottom_title'>
規則:
</div>
<div class='banner_bottom_text'>
平台內容以相關醫療科技資訊、香港與大灣區相關醫療護理康養政策討論及醫療器材及藥物和周邊產品為主目的打造 一個醫療相關的產品銷售及內容資訊為主的平台,該平台可形成一個Transmedia的環境 ,以第三方角度讓蓮和醫療得到媒體支持 、讓集团相關產品及服務找到支持點 。
</div>
<div class='banner_btn_outNode'>
<div class='banner_btn btn_one' @click="creatingActivity">
創建新比賽
<img src="<?php showFoodAppPath('/ranking/images/ranking_banner__btn_right.webp') ?>" style="float: right;margin-top: 23px;margin-right: 10px">
</div>
<!-- <div class='banner_btn'>-->
<!-- 申请合作-->
<!-- </div>-->
</div>
</div>
</div>
<!-- banner 横幅模块end-->
<div class=" xl:hidden flex mx-[0.3rem] px-[0.3rem] items-center h-[0.6rem] bg-f5 rounded-full">
<input v-model="submit_info.search_text" @keydown.enter="searchSubmit()" placeholder="你想要的商品"
class=" text-[0.24rem] leading-[0.2rem] outline-none w-full h-full bg-f5" type="text">
<div @click="searchSubmit()"
class=" cursor-pointer ml-[0.1rem] text-main font-medium text-[0.24rem] leading-[0.2rem] flex-shrink-0">
搜尋
</div>
</div>
<div class=" mt-[0.2rem] mx-[0.3rem] bg-f5 rounded-[0.2rem] pt-[0.2rem] px-[0.3rem] pb-[0.2rem] mb-[0.2rem]">
<div class=" w-full flex items-center">
<div class=" text-main text-[0.24rem] leading-[0.2rem] flex-shrink-0">篩選</div>
<div @click="searchSubmit"
class=" ml-auto w-[1.2rem] h-[0.4rem] cursor-pointer flex items-center justify-center bg-main rounded-[0.04rem]">
<div class=" text-[0.2rem] leading-[0.24rem] text-white">確認</div>
</div>
<div @click="clearFilter"
class=" ml-[0.2rem] w-[1.2rem] h-[0.4rem] cursor-pointer flex items-center justify-center bg-white border-[0.02rem] border-main rounded-[0.04rem]">
<div class=" text-[0.2rem] leading-[0.24rem] text-main">清空</div>
</div>
<div @click="creatingActivity"
class=" ml-[0.2rem] w-[1.2rem] h-[0.4rem] cursor-pointer flex items-center justify-center bg-white border-[0.02rem] border-main rounded-[0.04rem]">
<div class=" text-[0.2rem] leading-[0.24rem] text-main">創建新比賽</div>
</div>
<!-- <div @click="creatingActivityPlayer"-->
<!-- class=" ml-[0.2rem] w-[1.2rem] h-[0.4rem] cursor-pointer flex items-center justify-center bg-white border-[0.02rem] border-main rounded-[0.04rem]">-->
<!-- <div class=" text-[0.2rem] leading-[0.24rem] text-main">創建新比賽項目</div>-->
<!-- </div>-->
</div>
<div class=" w-full mt-[0.4rem] flex items-center">
<div class=" text-[0.2rem] leading-[0.24rem] text-333">價錢:</div>
<a-input-number
class=" ml-[0.1rem]"
size="small"
v-model="submit_info.price_pre"
:formatter="value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
:parser="value => value.replace(/\$\s?|(,*)/g, '')"
></a-input-number>
<div class=" ml-[0.1rem]">-</div>
<a-input-number
class=" ml-[0.1rem]"
size="small"
v-model="submit_info.price_next"
:formatter="value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
:parser="value => value.replace(/\$\s?|(,*)/g, '')"
/>
</a-input-number>
</div>
<div class=" w-full mt-[0.2rem] flex items-center">
<div class=" text-[0.2rem] leading-[0.24rem] text-333">排序:</div>
<a-select v-model="submit_info.order_name" size="small" style="margin-left: 0.1rem;width:3rem">
<a-select-option value="日期">
日期
</a-select-option>
<!-- <a-select-option value="銷量">
銷量
</a-select-option> -->
<a-select-option value="價格升序">
價格升序
</a-select-option>
<a-select-option value="價格降序">
價格降序
</a-select-option>
</a-select>
</div>
<div class=" mt-[0.2rem] bg-e6 w-full h-[0.02rem]"></div>
<div v-if="submit_info.filter_cate.length > 0" class=" mt-[0.2rem] flex flex-wrap">
<a-tag v-for="(item, key) in submit_info.filter_cate" :key="item" closable
@close="() => tagClose(key)" class=" text-main mb-[0.1rem] flex items-center border-main">
{{item}}
</a-tag>
</div>
<div class=" mt-[0.2rem] text-[0.2rem] leading-[0.2rem] text-333 flex flex-col">
<div v-for="(item, id) in filter_arr" :key="id" class=" w-full flex flex-row">
<div class=" w-[1.2rem] flex-shrink-0">
{{item.title}}
</div>
<div class=" flex-1 flex flex-wrap">
<div v-for="item2 in item.value" :key="item2" :class="item2=='全部'?'text-main':'text-999'"
@click="selectTag(item.title, item2)" class=" cursor-pointer mr-[0.3rem] mb-[0.3rem]">
{{item2}}
</div>
</div>
</div>
</div>
</div>
<!-- <yq-products-list-search :list="product_list" class=" mt-[0.4rem]"></yq-products-list-search>-->
<yq-ranking-search-list class="search-list" :list="product_list" class=" mt-[0.4rem]" :user_id="<?php echo $user_id; ?>"></yq-ranking-search-list>
</main>
<yq-footer></yq-footer>
</app>
<script>
const local_url = '<?php echo $local_url ?>'
const domain = '<?php echo esc_url(home_url('/')); ?>'
const product_cat = JSON.parse('<?php echo json_encode($productCat) ?>')
new Vue({
el: "#app",
components: {
'yq-header': httpVueLoader('<?php showFoodAppPath('components/yq-header-MMC.vue?v=' . $vueVersion) ?>'),
'yq-footer': httpVueLoader('<?php showFoodAppPath('components/yq-footer-MMC.vue?v=' . $vueVersion) ?>'),
//'yq-food-list-search': httpVueLoader('<?php //showFoodAppPath('components/yq-food-list-search.vue?v=1') ?>//'),
//'yq-products-list-search': httpVueLoader('<?php //showFoodAppPath('components/yq-products-list-search.vue?v=' . $vueVersion) ?>//'),
'yq-ranking-search-list': httpVueLoader('<?php showFoodAppPath('components/ranking/yq-ranking-search-list.vue?v=' . $vueVersion) ?>'),
},
data: {
product_list: [],
submit_info: {
price_pre: '0',
price_next: '0',
order_name: '日期',
filter_cate: [<?php echo $initCate; ?>],
search_text: ''
},
filter_arr: [
{
title: "分類:",
value: [
"全部", ...product_cat
]
}
],
page_num: 1,
is_end: false,
banner_show: true,
product_list_one: [],
product_list_two: [],
a_banner: [],
banner_current: 0,
a_cate: [],
a_cate_product: [],
current_cate: 0,
scrollFlag: true,
bannerObj: null
},
created() {
// this.get_banner()
// this.linkBanner()
if (sessionStorage.search_text) {
this.submit_info.search_text = sessionStorage.search_text
sessionStorage.search_text = ''
}
this.get_product()
},
mounted() {
window.addEventListener('scroll', this.handleScroll)
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 = '<?php echo $user_id; ?>'; // this.user_id;
localStorage.user_name = '<?php echo $username; ?>';
console.log('user_id => ' + localStorage.user_id + ' username => ' + localStorage.username);
// window.open(domain + '/creating_activity_page?id=0&action=add', '_blank')
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
moment,
clearFilter() {
this.submit_info = {
price_pre: '0',
price_next: '0',
order_name: '日期',
filter_cate: [],
search_text: ''
};
this.searchSubmit()
},
creatingActivity() {
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 = '<?php echo $user_id; ?>'; // this.user_id;
localStorage.user_name = '<?php echo $username; ?>';
console.log('user_id => ' + localStorage.user_id + ' username => ' + localStorage.username);
window.open(domain + '/creating_activity_page?id=0&action=add', '_blank')
},
creatingActivityPlayer() {
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 = '<?php echo $user_id; ?>'; // this.user_id;
localStorage.user_name = '<?php echo $username; ?>';
console.log('user_id => ' + localStorage.user_id + ' username => ' + localStorage.username);
window.open(domain + '/creating_activity_player_page?aid=1&id=0&action=add', '_blank')
},
handleScroll() {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop
let windowHeight = document.documentElement.clientHeight || document.body.clientHeight
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
if (scrollTop + windowHeight == scrollHeight && !this.is_end) {
this.page_num = this.page_num + 1
this.get_product()
}
},
searchSubmit() {
this.page_num = 1
this.get_product()
},
hdSearch(e) {
this.submit_info.search_text = e
this.searchSubmit()
},
async get_product() {
const hide = antd.message.loading('加載中...');
// let res = await axios({
// method: 'post',
// url: '/api/',
// data: Qs.stringify({
// module: 'product',
// action: 'get_product_by_search',
// web_type: 'MedicalMediaChannel',
// limit: 24,
// page_num: this.page_num,
// ...this.submit_info
// })
// });
let res = await axios({
method: 'post',
url: '/api/',
data: Qs.stringify({
module: 'ranking',
action: 'index',
a: 'getActivityListInfoByPage',
limit: 24,
pageNum: this.page_num,
...this.submit_info
})
});
hide();
if (res.status == 200) {
let data = res.data;
if (data.rc == 0) {
// console.log(data.data)
if (data.data.length > 0) {
if (this.page_num == 1) {
this.product_list = data.data
} else {
this.product_list = this.product_list.concat(data.data)
}
console.log(this.product_list)
} else {
// antd.message.info('已顯示所有產品');
this.is_end = true
}
}
}
},
tagClose(key) {
this.submit_info.filter_cate.splice(key, 1)
},
selectTag(title, value) {
if (value == "全部") {
this.submit_info.filter_cate = []
} else {
this.submit_info.filter_cate.push(value)
}
},
// async get_banner() {
// let res = await axios({
// method: 'post',
// url: '/api/',
// data: Qs.stringify({
// module: 'banner',
// action: 'get_banner',
// banner_type: 5
// })
// });
//
// if (res.status == 200) {
// let data = res.data;
// if (data.rc == 0) {
// this.a_banner = data.res
// }
// }
// },
//
// linkBanner() {
// this.bannerObj = setInterval(() => {
// this.nextBanner()
// }, 8000);
// },
// toBannerLink() {
// if (this.a_banner[this.banner_current].banner_link) {
// window.open(this.a_banner[this.banner_current].banner_link, '_blank')
// }
// },
// preBanner() {
// clearInterval(this.bannerObj)
// this.bannerObj = null
//
// this.banner_show = false
//
// setTimeout(() => {
// let temp = this.banner_current - 1
// this.banner_current = temp < 0 ? this.a_banner.length - 1 : temp
//
// this.banner_show = true
//
// this.linkBanner()
// }, 700);
//
// },
// nextBanner() {
// clearInterval(this.bannerObj)
// this.bannerObj = null
//
// this.banner_show = false
//
// setTimeout(() => {
// let temp = this.banner_current + 1
// this.banner_current = temp > this.a_banner.length - 1 ? 0 : temp
//
// this.banner_show = true
//
// this.linkBanner()
// }, 700);
// },
}
})
</script>
<?php get_footer('food'); ?>