2018-08-26 10:59:32 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="marketplace-page"
|
|
|
|
:data-page-name="page_name"
|
2018-08-26 12:36:25 +00:00
|
|
|
v-if="init || profile"
|
2018-08-26 10:59:32 +00:00
|
|
|
>
|
2018-08-26 12:36:25 +00:00
|
|
|
<detail-view
|
2018-08-26 10:59:32 +00:00
|
|
|
:title="title"
|
|
|
|
:image="image"
|
|
|
|
:sections="sections"
|
2018-08-26 12:36:25 +00:00
|
|
|
:show_skeleton="init"
|
2018-08-26 10:59:32 +00:00
|
|
|
>
|
2018-08-27 05:19:42 +00:00
|
|
|
<detail-header-item slot="detail-header-item"
|
|
|
|
:value="country"
|
|
|
|
></detail-header-item>
|
|
|
|
<detail-header-item slot="detail-header-item"
|
|
|
|
:value="site_name"
|
|
|
|
></detail-header-item>
|
|
|
|
<detail-header-item slot="detail-header-item"
|
|
|
|
:value="joined_when"
|
|
|
|
></detail-header-item>
|
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
</detail-view>
|
|
|
|
|
2019-02-08 12:21:01 +00:00
|
|
|
<div v-if="items.length">
|
|
|
|
<h5>
|
|
|
|
{{ item_container_heading }}
|
|
|
|
<small v-if="is_user_registered() && is_own_company">
|
|
|
|
<a class="pull-right" href="#marketplace/featured-items">Customize your Featured Items</a>
|
|
|
|
</small>
|
|
|
|
</h5>
|
|
|
|
<item-cards-container
|
|
|
|
:container_name="item_container_heading"
|
|
|
|
:items="items"
|
|
|
|
:item_id_fieldname="item_id_fieldname"
|
|
|
|
:on_click="go_to_item_details_page"
|
|
|
|
>
|
|
|
|
</item-cards-container>
|
|
|
|
<a class="pull-right" @click="go_to_seller_items_page(seller_company)">Show all items</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="recent_seller_reviews.length">
|
|
|
|
<h5>Customer Reviews</h5>
|
|
|
|
<div class="container" v-for="review in recent_seller_reviews" :key="review.name">
|
|
|
|
<br>
|
|
|
|
<span class="text-muted">
|
|
|
|
<rating :rating="review.rating" :max_rating="5"></rating>
|
|
|
|
</span>
|
|
|
|
<i class="octicon octicon-quote hidden-xs fa-fw"></i>
|
|
|
|
<span class="bold">{{ review.subject }}</span>
|
|
|
|
<i class="octicon octicon-quote hidden-xs fa-fw fa-rotate-180"></i>
|
|
|
|
<div class="container">
|
|
|
|
by {{ review.username }}
|
|
|
|
<a class="text-muted">
|
|
|
|
<span class="text-muted hidden-xs">–</span>
|
|
|
|
<span class="hidden-xs" v-html="comment_when(review.timestamp)"></span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="seller_product_view_stats.length">
|
|
|
|
<h5>Stats</h5>
|
|
|
|
<div id="seller_traffic_chart"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-02-08 12:21:01 +00:00
|
|
|
import Rating from '../components/Rating.vue';
|
|
|
|
|
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
export default {
|
|
|
|
name: 'seller-page',
|
2019-02-08 12:21:01 +00:00
|
|
|
components: {
|
|
|
|
Rating
|
|
|
|
},
|
2018-08-26 10:59:32 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
page_name: frappe.get_route()[1],
|
|
|
|
seller_company: frappe.get_route()[2],
|
2019-02-08 12:21:01 +00:00
|
|
|
hub_seller: null,
|
2018-08-26 10:59:32 +00:00
|
|
|
|
2018-08-26 12:36:25 +00:00
|
|
|
init: true,
|
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
profile: null,
|
|
|
|
items:[],
|
2019-02-08 12:21:01 +00:00
|
|
|
recent_seller_reviews: [],
|
|
|
|
seller_product_view_stats: [],
|
|
|
|
seller_traffic_chart: null,
|
2018-08-27 08:41:48 +00:00
|
|
|
item_id_fieldname: 'name',
|
2019-02-08 12:21:01 +00:00
|
|
|
item_container_heading: 'Items',
|
2018-08-26 10:59:32 +00:00
|
|
|
|
|
|
|
title: null,
|
|
|
|
image: null,
|
|
|
|
sections: [],
|
2018-08-27 05:19:42 +00:00
|
|
|
|
|
|
|
country: '',
|
|
|
|
site_name: '',
|
|
|
|
joined_when: '',
|
2018-08-26 10:59:32 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.get_seller_profile_and_items();
|
|
|
|
},
|
|
|
|
computed: {
|
2019-02-08 12:21:01 +00:00
|
|
|
is_own_company() {
|
|
|
|
let is_own_company = false;
|
|
|
|
if(this.hub_seller) {
|
|
|
|
if(this.hub_seller === hub.settings.hub_seller_name) {
|
|
|
|
is_own_company = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return is_own_company;
|
|
|
|
},
|
2018-08-26 10:59:32 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2019-02-08 12:21:01 +00:00
|
|
|
comment_when(timestamp){
|
|
|
|
return comment_when(timestamp)
|
|
|
|
},
|
|
|
|
is_user_registered(){
|
|
|
|
return hub.is_user_registered()
|
|
|
|
},
|
2018-08-26 10:59:32 +00:00
|
|
|
get_seller_profile_and_items() {
|
2019-02-12 09:39:41 +00:00
|
|
|
let post_data = {company: this.seller_company}
|
2019-02-08 12:21:01 +00:00
|
|
|
if (this.page_name == 'profile'){
|
|
|
|
this.seller_company = null;
|
|
|
|
this.hub_seller = hub.settings.hub_seller_name
|
2019-02-12 09:39:41 +00:00
|
|
|
post_data = {hub_seller: this.hub_seller}
|
2019-02-08 12:21:01 +00:00
|
|
|
}
|
2019-02-12 09:39:41 +00:00
|
|
|
hub.call('get_hub_seller_page_info', post_data)
|
|
|
|
.then(data => {
|
2018-08-26 12:36:25 +00:00
|
|
|
this.init = false;
|
2018-08-26 10:59:32 +00:00
|
|
|
this.profile = data.profile;
|
|
|
|
this.items = data.items;
|
2020-11-25 03:41:51 +00:00
|
|
|
this.item_container_heading = data.is_featured_item ? __('Featured Items') : __('Popular Items');
|
2019-02-08 12:21:01 +00:00
|
|
|
this.hub_seller = this.items[0].hub_seller;
|
|
|
|
this.recent_seller_reviews = data.recent_seller_reviews;
|
|
|
|
this.seller_product_view_stats = data.seller_product_view_stats;
|
2018-08-26 10:59:32 +00:00
|
|
|
|
|
|
|
const profile = this.profile;
|
|
|
|
|
|
|
|
this.title = profile.company;
|
2018-08-27 05:19:42 +00:00
|
|
|
|
|
|
|
this.country = __(profile.country);
|
|
|
|
this.site_name = __(profile.site_name);
|
2020-11-25 03:41:51 +00:00
|
|
|
this.joined_when = __('Joined {0}', [comment_when(profile.creation)]);
|
2018-08-27 05:19:42 +00:00
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
this.image = profile.logo;
|
|
|
|
this.sections = [
|
|
|
|
{
|
|
|
|
title: __('About the Company'),
|
|
|
|
content: profile.company_description
|
|
|
|
? __(profile.company_description)
|
|
|
|
: __('No description')
|
|
|
|
}
|
|
|
|
];
|
2019-02-08 12:21:01 +00:00
|
|
|
|
|
|
|
setTimeout(() => this.init_seller_traffic_chart(), 1);
|
|
|
|
|
2018-08-26 10:59:32 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-08-27 08:41:48 +00:00
|
|
|
go_to_item_details_page(hub_item_name) {
|
|
|
|
frappe.set_route(`marketplace/item/${hub_item_name}`);
|
2019-02-08 12:21:01 +00:00
|
|
|
},
|
|
|
|
go_to_seller_items_page(hub_seller) {
|
|
|
|
frappe.set_route(`marketplace/seller/${hub_seller}/items`);
|
|
|
|
},
|
|
|
|
init_seller_traffic_chart() {
|
|
|
|
let lables = []
|
|
|
|
let tooltip_lables = {}
|
|
|
|
let datasets = [{name:"Product Views",chartType: 'line',values: []}]
|
|
|
|
this.seller_product_view_stats.map((stat) => {
|
|
|
|
lables.push(stat.date.substring(5));
|
|
|
|
tooltip_lables[stat.date.substring(5)] = new Date(stat.date).toDateString();
|
|
|
|
datasets[0].values.push(stat.view_count);
|
|
|
|
});
|
|
|
|
let data = {labels: lables, datasets:datasets, tooltip_lables:tooltip_lables}
|
|
|
|
this.seller_traffic_chart = new Chart( "#seller_traffic_chart", { // or DOM element
|
|
|
|
data: data,
|
|
|
|
|
|
|
|
title: "Daily Product Views",
|
|
|
|
type: 'axis-mixed', // or 'bar', 'line', 'pie', 'percentage'
|
|
|
|
height: 300,
|
|
|
|
colors: ['purple', '#ffa3ef', 'light-blue'],
|
|
|
|
|
|
|
|
tooltipOptions: {
|
|
|
|
formatTooltipX: d => this.seller_traffic_chart.data.tooltip_lables[d],
|
|
|
|
formatTooltipY: d => d + ' Views',
|
|
|
|
}
|
|
|
|
});
|
2018-08-26 10:59:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|