|
@@ -11,8 +11,7 @@
|
|
|
<view class="search-container-history" v-if="!isShowWrapper">
|
|
|
<view :class="'s-' + themeClass" v-if="serachRecordList.length>0">
|
|
|
<view class="header">
|
|
|
- 搜索历史
|
|
|
- <text class="iconfont icon-shanchu" @click="confirmDetele"></text>
|
|
|
+ 搜索历史<text class="iconfont icon-shanchu" @click="confirmDetele"></text>
|
|
|
</view>
|
|
|
<view class="list">
|
|
|
<view v-for="(item,index) in serachRecordList" :key="index" @click="keywordsClick(item.searchWord)">{{item.searchWord}}</view>
|
|
@@ -25,7 +24,7 @@
|
|
|
<view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.pid)">
|
|
|
<image mode='widthFix' :src="item.image" class="list-img" alt="list-img"></image>
|
|
|
<view class="list-details-info">
|
|
|
- <text class="list-details-title">{{item.name}}</text>
|
|
|
+ <view class="list-details-title">{{isInterceptHtmlFn(item.name)}}</view>
|
|
|
<text class="list-details-specs">规格:{{item.unit}}</text>
|
|
|
<view class="list-details-specs" v-if="item.productcode!=''&&item.productCode!=null">
|
|
|
<view>商品编码:{{item.productCode}}</view>
|
|
@@ -76,7 +75,6 @@
|
|
|
</view>
|
|
|
<!-- 透明模态层 -->
|
|
|
<modal-layer v-if='isModallayer'></modal-layer>
|
|
|
-
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -90,6 +88,7 @@
|
|
|
queryNewSearchProduct ,
|
|
|
querySearchHistory,
|
|
|
clearSearchHistory,
|
|
|
+ searchHistoryAdd,
|
|
|
querySearchProductPrice
|
|
|
} from "@/api/product.js"
|
|
|
|
|
@@ -102,9 +101,10 @@
|
|
|
data() {
|
|
|
return {
|
|
|
userID:'',
|
|
|
- userIdentity:'',
|
|
|
themeClass: 'block',
|
|
|
searchInputVal:'', //搜索关键词
|
|
|
+ userIdentity:'',
|
|
|
+ identity:2,
|
|
|
isShowClose:false, //是否显示清空输入框图标
|
|
|
isSearchHistory:false,//是都显示搜索历史
|
|
|
serachRecordList:[],//历史搜索记录
|
|
@@ -137,6 +137,11 @@
|
|
|
this.$api.getStorage().then((resolve) =>{
|
|
|
this.userID = resolve.userID ? resolve.userID : '';
|
|
|
this.userIdentity = resolve.userIdentity ? resolve.userIdentity : '';
|
|
|
+ if(this.userIdentity == 1){
|
|
|
+ this.identity = 1
|
|
|
+ }else{
|
|
|
+ this.identity = 2
|
|
|
+ }
|
|
|
querySearchHistory({userId:this.userID}).then(response =>{
|
|
|
if(response.code == 0){
|
|
|
this.serachRecordList = response.data
|
|
@@ -149,6 +154,7 @@
|
|
|
this.$util.msg('请输入商品关键词',2000);
|
|
|
}else{
|
|
|
this.listData =[]
|
|
|
+ this.setSearchHistoryAdd()
|
|
|
this.getListFromServer(false)
|
|
|
}
|
|
|
},
|
|
@@ -165,12 +171,12 @@
|
|
|
if(loadMore) {
|
|
|
this.pageNum += 1;
|
|
|
}
|
|
|
- let params = {keyword:this.searchInputVal,pageNum:this.pageNum,pageSize:this.pageSize,sortField:'',sortType:''}
|
|
|
+ let params = {identity:this.identity,keyword:this.searchInputVal,pageNum:this.pageNum,pageSize:this.pageSize,sortField:'',sortType:''}
|
|
|
queryNewSearchProduct(params).then(response =>{
|
|
|
- console.log(JSON.parse(response.data))
|
|
|
this.isShowWrapper = true
|
|
|
const resData = JSON.parse(response.data);
|
|
|
const resList = resData.items;
|
|
|
+ console.log(resData)
|
|
|
if(resList && resList.length > 0){
|
|
|
this.totalPage = resData.total;
|
|
|
this.showEmpty = false;
|
|
@@ -183,9 +189,7 @@
|
|
|
}
|
|
|
// 防上拉暴滑
|
|
|
this.pullFlag = false;
|
|
|
- setTimeout(()=>{
|
|
|
- this.pullFlag = true;
|
|
|
- },500)
|
|
|
+ setTimeout(()=>{ this.pullFlag = true; },500)
|
|
|
// 底部提示文案
|
|
|
if(this.totalPage>this.pageNum) {
|
|
|
this.loadingText = '上拉加载更多';
|
|
@@ -202,24 +206,37 @@
|
|
|
this.$util.msg(error.msg,2000);
|
|
|
})
|
|
|
},
|
|
|
+ setSearchHistoryAdd(){//添加搜索记录
|
|
|
+ if (!this.hasLogin) {return false;}
|
|
|
+ searchHistoryAdd({userId: this.userID,keyword:this.searchInputVal}).then(response =>{
|
|
|
+ //此为每次搜索同时添加用户的搜索记录
|
|
|
+ }).catch(error =>{
|
|
|
+ this.$util.msg(error.msg,2000);
|
|
|
+ })
|
|
|
+ },
|
|
|
setProductPrice(){//获取价格
|
|
|
- if (!this.userID) {return false;}
|
|
|
+ if (!this.hasLogin) {return false;}
|
|
|
let productIdArr = [];
|
|
|
this.listData.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
|
|
|
- if (item.priceflag != 1){
|
|
|
- productIdArr.push(item.pid)
|
|
|
- }
|
|
|
+ productIdArr.push(item.pid)
|
|
|
})
|
|
|
this.productIds = productIdArr.join(",");
|
|
|
querySearchProductPrice({userId: this.userID,productIds:this.productIds}).then(response =>{
|
|
|
if (response.data) {
|
|
|
- let ids = Object.keys(response.data.prices);
|
|
|
+ let priceList = response.data
|
|
|
this.listData.map(item=>{
|
|
|
- for (let i = 0; i < ids.length; i++) {
|
|
|
- let id = ids[i];
|
|
|
- let price = response.data.prices[id];
|
|
|
- if (item.priceflag != 1 && item.pid == id){
|
|
|
- item.price = Number(price).toFixed(2);
|
|
|
+ for (let i = 0; i < priceList.length; i++) {
|
|
|
+ let priceObj ={
|
|
|
+ actStatus:priceList[i].actStatus,
|
|
|
+ costCheckFlag:priceList[i].costCheckFlag,
|
|
|
+ costPrice:priceList[i].costPrice,
|
|
|
+ costProportional:priceList[i].costProportional,
|
|
|
+ ladderPriceFlag:priceList[i].ladderPriceFlag,
|
|
|
+ price:Number(priceList[i].price).toFixed(2),
|
|
|
+ minBuyNumber:priceList[i].minBuyNumber
|
|
|
+ }
|
|
|
+ if( item.pid == priceList[i].productId ){
|
|
|
+ Object.assign(item,priceObj)
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -266,6 +283,10 @@
|
|
|
this.isShowClose = false
|
|
|
}
|
|
|
},
|
|
|
+ isInterceptHtmlFn(text){
|
|
|
+ let name = this.$reg.interceptHtmlFn(text)
|
|
|
+ return name
|
|
|
+ },
|
|
|
navToDetailPage(id) {
|
|
|
this.isModallayer = true;
|
|
|
this.$api.navigateTo(`/pages/goods/product?id=${id}`);
|