|
@@ -1,19 +1,35 @@
|
|
|
var supplierHome = new Vue({
|
|
|
el: "#supplierHome",
|
|
|
data: {
|
|
|
+ requestFlag: true,
|
|
|
userId: 0,
|
|
|
- supplierId: 0,
|
|
|
+ supplierInfo:{},
|
|
|
supplierBanner: [],
|
|
|
mainProducts:[],
|
|
|
+ params: {
|
|
|
+ size: 12,
|
|
|
+ num: 1,
|
|
|
+ id: 0,
|
|
|
+ keyword: ''
|
|
|
+ },
|
|
|
+ listRecord:0,
|
|
|
productLists:[]
|
|
|
},
|
|
|
computed: {
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ getShopInfo: function(){
|
|
|
+ var _self = this;
|
|
|
+ $.getJSON(spiServer + "/supplier/home/detail",{supplierId: this.params.id}).done(function (r) {
|
|
|
+ if (r.code === 0 && r.data) {
|
|
|
+ _self.supplierInfo = r.data;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
getBanners: function(){
|
|
|
var _self = this;
|
|
|
- $.getJSON("/supplier/images",{supplierId: this.supplierId}).done(function (r) {
|
|
|
+ $.getJSON(spiServer + "/supplier/home/images",{supplierId: this.params.id}).done(function (r) {
|
|
|
if (r.code === 0 && r.data) {
|
|
|
_self.supplierBanner = r.data;
|
|
|
setTimeout(function(){
|
|
@@ -52,7 +68,7 @@ var supplierHome = new Vue({
|
|
|
},
|
|
|
getMainProducts: function(){
|
|
|
var _self = this;
|
|
|
- $.getJSON("/supplier/products",{supplierId: this.supplierId}).done(function (r) {
|
|
|
+ $.getJSON(spiServer + "/supplier/home/products",{supplierId: this.params.id}).done(function (r) {
|
|
|
if (r.code === 0 && r.data) {
|
|
|
if(_self.userId && _self.userId>0){
|
|
|
var productIdArr = [];
|
|
@@ -70,35 +86,93 @@ var supplierHome = new Vue({
|
|
|
},
|
|
|
getProductLists: function(){
|
|
|
var _self = this;
|
|
|
- $.getJSON(spiServer+"/search/query/product/supplier",{
|
|
|
- id: this.supplierId,
|
|
|
- pageSize: 12,
|
|
|
- pageNum: 1
|
|
|
- }, function (r) {
|
|
|
+ $.getJSON(spiServer + "/search/query/product/supplier",this.params, function (r) {
|
|
|
if (r.code === 0 && r.data) {
|
|
|
var result = JSON.parse(r.data);
|
|
|
_self.listRecord = result.total;
|
|
|
- var resultData = setSearchProductList(result.items, _self.userId);
|
|
|
+ var resultData = setSearchProductList(result.items, _self.userId,2);
|
|
|
_self.productLists = _self.productLists.concat(resultData);
|
|
|
}
|
|
|
+ _self.requestFlag = true;
|
|
|
})
|
|
|
+ },
|
|
|
+ keyupSearch: function(event) {
|
|
|
+ // 搜索输入框 按回车键搜索
|
|
|
+ var keyCode = event.keyCode || event.which;
|
|
|
+ if(keyCode === 13){
|
|
|
+ this.supplierSearch();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ supplierSearch: function(){
|
|
|
+ if (this.params.keyword.length < 2) {
|
|
|
+ $.confirm({
|
|
|
+ useBootstrap: false,
|
|
|
+ boxWidth: (isPC?'300px':'70%'),
|
|
|
+ title:'提示',
|
|
|
+ content:'请至少输入两个关键字!',
|
|
|
+ closeIcon: true,
|
|
|
+ animation: 'opacity',
|
|
|
+ closeAnimation: 'opacity',
|
|
|
+ animateFromElement: false,
|
|
|
+ buttons: {
|
|
|
+ close: {
|
|
|
+ text: '确定',
|
|
|
+ btnClass: 'btn-confirm'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.productLists = [];
|
|
|
+ this.getProductLists();
|
|
|
+ var floorScroll = $('#supProduct').offset().top;
|
|
|
+ $('html,body').animate({scrollTop: floorScroll},600);
|
|
|
+ },
|
|
|
+ upgrade: function () {
|
|
|
+ location.href='/upgrade.html';
|
|
|
}
|
|
|
},
|
|
|
created: function () {
|
|
|
- this.supplierId = getUrlParam("id") ? getUrlParam("id") * 1 : 0;
|
|
|
- if(this.supplierId !== 0) {
|
|
|
+ this.params.id = getUrlParam("id") ? getUrlParam("id") * 1 : 0;
|
|
|
+ if(this.params.id !== 0) {
|
|
|
+ this.getShopInfo();
|
|
|
this.getBanners();
|
|
|
- this.getMainProducts();
|
|
|
- this.getProductLists();
|
|
|
}
|
|
|
},
|
|
|
mounted: function () {
|
|
|
+ if(this.params.id !== 0) {
|
|
|
+ this.getMainProducts();
|
|
|
+ this.getProductLists();
|
|
|
+ }
|
|
|
+ var userInfo = localStorage.getItem('userInfo');
|
|
|
+ if(userInfo){
|
|
|
+ this.userId = JSON.parse(userInfo).userID;
|
|
|
+ }
|
|
|
var _self = this;
|
|
|
$('.supplierInfo').slide({
|
|
|
mainCell:".tabCon"
|
|
|
,titCell:".tabTit span"
|
|
|
,trigger: "click"
|
|
|
});
|
|
|
+ //上垃加载更多
|
|
|
+ $(window).on('scroll', function(){
|
|
|
+ var scrollTop = $(this).scrollTop();
|
|
|
+ var scrollHeight = $(document).height();
|
|
|
+ var windowHeight = window.innerHeight+$(".new-footer").height();
|
|
|
+ if (scrollTop + windowHeight >= scrollHeight) {
|
|
|
+ //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
|
|
|
+ var totalPage = Math.ceil(_self.listRecord / _self.params.size)?Math.ceil(_self.listRecord / _self.params.size):1;
|
|
|
+ var next = _self.params.num+1;
|
|
|
+ if(next <= totalPage){
|
|
|
+ if (_self.requestFlag){
|
|
|
+ _self.params.num = next;
|
|
|
+ // 获取列表数据
|
|
|
+ _self.getProductLists();
|
|
|
+ }
|
|
|
+ _self.requestFlag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
$('body').on("click", '.showSearch', function(){
|
|
|
$('.supplierTit .search').show();
|
|
|
})
|