Commit 4db924a7 by 李嘉林

商品列表一个接口

parent 2bc21767
import { requestPOST, requestGET } from "@/utils/request.js";
export default {
queryProductInfo(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_product_info`, data);
},
queryBriefProductInfo(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_brief_product_info`, data);
},
queryMoreProductInfo(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_more_product_info`, data);
}
};
......@@ -2,6 +2,8 @@ import Vue from 'vue'
import App from './App'
import Store from './store/index'
import "../static/nicon/iconfont.css"
import goodsApi from "./api/goods"
import { DFSImg } from "@/utils/index";
Vue.config.productionTip = false
App.mpType = 'app'
......@@ -31,3 +33,5 @@ mpApp.shopCallBack=function() {}
mpApp.pageCallBack=function() {}
// 底部栏
mpApp.footerCallBack=function() {}
mpApp.goodsApi = goodsApi;
mpApp.DFSImg = DFSImg;
<template>
<div class="domain">
<div v-for="item in pageData" :key="item.id">
<!-- <goods-list id="goodsList"></goods-list> -->
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner'">
<banner :datas="item"></banner>
1
</div>
<div v-else-if="item.componentCode=='goods-list'">
<goods-list :datas="item"></goods-list>
</div>
<image
</div>
<!-- <image
src="http://cdn.mayi888.com/public/jpg/33ff0efc-96b5-4044-a65a-07799dfe98e1.jpg?x-oss-process=image/resize,limit_1,w_750"
></image>
<van-button type="primary">按钮</van-button>
<view class="ant-bofang">1</view>
----瀑布流开始----
<waterfall-flow id="waterfallFlow"></waterfall-flow>
----瀑布流结束----
<view class="ant-bofang">1</view> -->
<!-- ----瀑布流开始---- -->
<!-- <waterfall-flow id="waterfallFlow"></waterfall-flow> -->
<!-- ----瀑布流结束---- -->
<!-- <banner id="banner" :datas="componentsList[0]"></banner>
<div class="domain">abc
......@@ -31,10 +34,10 @@ export default {
};
},
onLoad() {
let that = this;
if (this.mpApp.globalData.pageList) {
that.init(this.mpApp.globalData.pageList);
} else {
let that = this;
this.mpApp.pageCallBack = function (params) {
that.init(params);
};
......
......@@ -5,7 +5,7 @@
<view class="merchantsEntrance flex" wx:if="{{datas.componentData['merchantsEntrance'] && datas.componentData['merchantsEntranceType'] == 0}}">
<view class="left flex" wx:if="{{items != null}}">
<view class="logo">
<image mode='widthFix' src="http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/ppefWK8BS6.png?x-oss-process=image/resize,limit_1,w_150,h_150" />
<image mode='widthFix' src="{{items.shopLogoUrl}}" />
</view>
<view class="name">{{items.orgName}}</view>
</view>
......@@ -30,14 +30,23 @@
style="width:{{datas.componentData.angleSignSize}}%;height:{{datas.componentData.angleSignSize}}%;"
wx:if="{{datas.componentData['angleSign'] && datas.componentData['angleSignImg']}}"
>
<image mode="widthFix" src="http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/ppefWK8BS6.png?x-oss-process=image/resize,limit_1,w_150,h_150" />
<image mode="widthFix" src="{{datas.componentData['angleSignImg']}}" />
</view>
<!-- 商品主图 -->
<image mode="widthFix" src="https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/yWDmitPPmD.jpg?x-oss-process=image/resize,limit_1,w_700" />
<image
mode="widthFix"
wx:if="{{datas.componentData.goodsImgType == 1}}"
src="{{items.productImgUrl}}"
/>
<image
mode="widthFix"
wx:else
src="{{items.coverImage}}"
/>
<!-- 售罄遮罩 -->
<view class="whiteBg" wx:if="{{items&&items.oversoldFlag==0&&items.totalQty-0<=0}}">
<view class="cover">
<image mode="widthFix" src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/f254fe62-6dda-46f6-a2f4-a7b2aa0474df.png" />
<image mode="aspectFit" src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/f254fe62-6dda-46f6-a2f4-a7b2aa0474df.png" />
</view>
</view>
</view>
......@@ -50,7 +59,7 @@
</view>
<view class="follower-wrap" wx:if="{{datas.componentData['followerShow']}}">
<view class="follower-num" style="color:{{datas.componentData['followerColor']?datas.componentData['followerColor']:'#ff9933'}};">
{{items!=null?Number(items['totalCollectionCount']) ? Number(items['totalCollectionCount']) : 0:0}}
{{items!=null? items['totalCollectionCount']:0}}
</view>
<view class="follower-text">关注人数</view>
</view>
......@@ -59,8 +68,8 @@
<view class="Sold">
<text wx:if="{{datas.componentData['alSaleShow']}}">已售{{items!=null ? items['totalSalesCount'] :0}}件</text>
<text wx:if="{{datas.componentData['alSaleShow'] && datas.componentData['collectShow']}}">/</text>
<text wx:if="{{datas.componentData['collectShow']}}">剩余{{items!=null && items['qty']!=undefined ? (Number(items['qty']) > 0 ? Number(items['qty'] ): items.oversoldFlag==1?'数量充足':'数量不足') : ''}}</text>
<text wx:if="{{items!=null && (Number(items['qty']) ? Number(items['qty']) >= 0 : Number(items['saleQty']) >= 0)}}">件</text>
<text wx:if="{{datas.componentData['collectShow']}}">剩余{{items!=null && items['qty']!=undefined ? (items['qty'] > 0 ? items['qty']: items.oversoldFlag==1?'数量充足':'数量不足') : ''}}</text>
<text wx:if="{{items!=null && (items['qty'] ? items['qty'] >= 0 : items['qty'] >= 0)}}">件</text>
</view>
<!-- 标签 -->
<view class="marketing flex" wx:if="{{datas.componentData['marketingTag']&&datas.componentData['marketingStyle']==0&&items.marketingTag}}">
......@@ -90,7 +99,7 @@
</view>
<view class="vipPrice2 flex">
<view class="left" wx:if="{{showVipPrice(index)==true}}">
¥{{Number(items['minPriceAfterRecommendedCardPriceTable']).toFixed(2)}}
¥{{items['minPriceAfterRecommendedCardPriceTable']}}
</view>
<view class="vipIcon line-clamp1" wx:if="{{showVipTag(index)==true}}">
{{items["recommendedCardMinPricePriceTableName"]}}
......@@ -102,7 +111,7 @@
<view class="showCommission" wx:if="{{datas.componentData.commissionStyle==0}}">
<view class="commission-box">
<text>收益</text>
<text>¥{{Number(items['minProductGoodsCommission']).toFixed(2)}}</text>
<text>¥{{items['minProductGoodsCommission']}}</text>
</view>
</view>
</block>
......@@ -144,7 +153,7 @@
<text class="iconfont-common common-iconfenxiang">
赚¥
<text style="font-size:32rpx;">
{{Number(items['minProductGoodsCommission']).toFixed(2)}}
{{items['minProductGoodsCommission']}}
</text>
</text>
</view>
......
const app = getApp();
const { goodsApi,DFSImg } = app;
const componentOptions = {
// 组件选项
options: {
multipleSlots: true
},
behaviors: [],
properties: {},
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
properties: {
datas: {
id: 7,
componentName: "商品列表",
componentCode: "goods-list",
componentType: 1,
queueNumber: 0,
componentInfo: {
visible: 1,
condition: "",
drawable: 0
},
componentData: {
goodsList: [
{
brandName: "",
bugRecommendedCardFlag: "false",
coverImage:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/yWDmitPPmD.jpg?x-oss-process=image/resize,limit_1,w_700",
defaultTags: ["freeShipping"],
extensionFieldJson: "",
goodsMaxPrice: "21.00",
goodsMinPrice: "21.00",
groupBuyFlag: "0",
haveGroupNum: "0",
maxPrice: "21.00",
minGoodsId: "99121",
minGoodsSuggestedRetailPrice: "100.00000",
minPrice: "21.00",
minProductGoodsId: "85531",
minProductGoodsMixid: "daadejqb50l7",
orgId: "1452",
orgName: "Air Jordan",
outerProductCode: "9fuMzUCl",
oversoldFlag: "1",
productGoodsMixId: "",
productId: "21724",
productImgUrl:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/yWDmitPPmD.jpg?x-oss-process=image/resize,limit_1,w_700",
productName: "热销 小白心里软",
productNature: "1",
productSaleType: "0",
productSecondName: "",
qty: "0",
recommendedCardMinPricePriceTableName: "",
saleTime: null,
saleWay: "1",
shopLogoUrl:
"/product/png/2d889aca-d9c7-41e3-9e08-76e3de2d50ba.png",
shopName: "Air Jordan",
stockSell: "0",
tagNames: "",
terminalProductId: "18785",
totalCollectionCount: "0",
totalQty: "0",
totalSalesCount: "0",
usedRecommendedCardFlag: "false",
marketingTag: [
{
key: "freeShipping",
label: "免邮"
}
]
},
{
brandName: "",
bugRecommendedCardFlag: "false",
coverImage:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/Ebs8TkSirK.png?x-oss-process=image/resize,limit_1,w_700",
defaultTags: [],
extensionFieldJson: "",
goodsMaxPrice: "800.00",
goodsMinPrice: "200.00",
groupBuyFlag: "0",
haveGroupNum: "0",
maxPrice: "800.00",
minGoodsId: "99344",
minGoodsSuggestedRetailPrice: "300.000000",
minPrice: "200.00",
minProductGoodsId: "92690",
minProductGoodsMixid: "emng64ho4rp3",
orgId: "1452",
orgName: "Air Jordan",
outerProductCode: "8vGrYIWZ",
oversoldFlag: "0",
productGoodsMixId: "",
productId: "21904",
productImgUrl:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/Ebs8TkSirK.png?x-oss-process=image/resize,limit_1,w_700",
productName: "测试刘==专用商品。。",
productNature: "1",
productSaleType: "0",
productSecondName: "",
qty: "400",
recommendedCardMinPricePriceTableName: "",
saleTime: null,
saleWay: "1",
shopLogoUrl:
"/product/png/2d889aca-d9c7-41e3-9e08-76e3de2d50ba.png",
shopName: "Air Jordan",
stockSell: "0",
tagNames: "",
terminalProductId: "22287",
totalCollectionCount: "0",
totalQty: "100",
totalSalesCount: "0",
usedRecommendedCardFlag: "false"
},
{
brandId: "65",
brandName: "三只松鼠",
bugRecommendedCardFlag: "false",
coverImage:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/GSjiWASDh3.jpg?x-oss-process=image/resize,limit_1,w_700",
defaultTags: [],
extensionFieldJson: "",
goodsMaxPrice: "10.00",
goodsMinPrice: "10.00",
groupBuyFlag: "0",
haveGroupNum: "0",
maxPrice: "10.00",
minGoodsId: "99537",
minGoodsSuggestedRetailPrice: "20.000000",
minPrice: "10.00",
minProductGoodsId: "92685",
minProductGoodsMixid: "lbsmteepkra4",
orgId: "1452",
orgName: "Air Jordan",
outerProductCode: "Z91MQdgf",
oversoldFlag: "1",
productGoodsMixId: "",
productId: "22077",
productImgUrl:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/SCdPMnX6wh.jpg?x-oss-process=image/resize,limit_1,w_700",
productName: "看图片",
productNature: "1",
productSaleType: "0",
productSecondName: "看图片",
qty: "0",
recommendedCardMinPricePriceTableName: "",
saleTime: null,
saleWay: "1",
shopLogoUrl:
"/product/png/2d889aca-d9c7-41e3-9e08-76e3de2d50ba.png",
shopName: "Air Jordan",
stockSell: "0",
tagNames: "",
terminalProductId: "22283",
totalCollectionCount: "0",
totalQty: "0",
totalSalesCount: "0",
usedRecommendedCardFlag: "false"
},
{
brandId: "65",
brandName: "三只松鼠",
bugRecommendedCardFlag: "false",
coverImage:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/hY7GyiXKf2.jpg?x-oss-process=image/resize,limit_1,w_700",
defaultTags: ["freeShipping"],
extensionFieldJson: "",
goodsMaxPrice: "10.00",
goodsMinPrice: "10.00",
groupBuyFlag: "0",
haveGroupNum: "0",
maxPrice: "10.00",
minGoodsId: "98888",
minGoodsSuggestedRetailPrice: "10.000000",
minPrice: "10.00",
minProductGoodsId: "85558",
minProductGoodsMixid: "na27hiltd3aa",
orgId: "1452",
orgName: "Air Jordan",
outerProductCode: "80x7V9Ud",
oversoldFlag: "1",
productGoodsMixId: "",
productId: "21509",
productImgUrl:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/hY7GyiXKf2.jpg?x-oss-process=image/resize,limit_1,w_700",
productName: "前端测试留言商品单规格",
productNature: "1",
productSaleType: "0",
productSecondName: "前端测试留言商品单规格",
qty: "0",
recommendedCardMinPricePriceTableName: "",
saleTime: null,
saleWay: "1",
shopLogoUrl:
"/product/png/2d889aca-d9c7-41e3-9e08-76e3de2d50ba.png",
shopName: "Air Jordan",
stockSell: "0",
tagNames: "",
terminalProductId: "18808",
totalCollectionCount: "1",
totalQty: "0",
totalSalesCount: "0",
usedRecommendedCardFlag: "false",
marketingTag: [
{
key: "freeShipping",
label: "免邮"
type: Object
}
]
},
{
brandName: "",
bugRecommendedCardFlag: "false",
coverImage:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/CcxsBCNci5.jpg?x-oss-process=image/resize,limit_1,w_700",
defaultTags: [],
extensionFieldJson: "",
goodsMinPrice: "0.00",
groupBuyFlag: "0",
haveGroupNum: "0",
minGoodsId: "106001",
minGoodsSuggestedRetailPrice: "11.000000",
minPrice: "0.00",
minProductGoodsId: "92646",
minProductGoodsMixid: "p87o5mt2gnh8",
orgId: "1452",
orgName: "Air Jordan",
outerProductCode: "YCRz5Rti",
oversoldFlag: "0",
productGoodsMixId: "",
productId: "25122",
productImgUrl:
"https://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/CcxsBCNci5.jpg?x-oss-process=image/resize,limit_1,w_700",
productName: "组合333",
productNature: "1",
productSaleType: "1",
productSecondName: "",
qty: "0",
recommendedCardMinPricePriceTableName: "",
saleTime: null,
saleWay: "1",
shopLogoUrl:
"/product/png/2d889aca-d9c7-41e3-9e08-76e3de2d50ba.png",
shopName: "Air Jordan",
stockSell: "0",
tagNames: "",
terminalProductId: "22272",
totalCollectionCount: "0",
totalQty: "0",
totalSalesCount: "0",
usedRecommendedCardFlag: "false"
}
],
categoryId: "",
categoryName: "",
initProductArr: [],
titles: "这是标题",
content:
"这里是内容 可以编写需要的内容 测试测试测试测试测试测试测试测试测试",
link: "https://www.baidu.com/",
fontColor: "#ed6a0c",
goodsSource: "assign",
goodsType: 0,
style: "list",
imgPadding: 20,
moreShow: true,
moreButtonSite: "top",
rowNum: 2,
columnNum: 2,
proGap: 5,
titleCardGap: 10,
heapBgColorShow: true,
heapBgColor: "",
backgroundColorShow: true,
backgroundColor: "#fff",
borderColorShow: true,
borderColor: "#e0e0e0",
nameShow: true,
nameFontSize: 1,
imgSize: "0%",
nameColor: "#333333",
describeShow: true,
describeFontSize: 1,
priceShow: true,
priceFontSize: 0.8,
priceColor: "#f23030",
angleShow: false,
colorLayoutShow: false,
colorLayoutSite: "top",
initcharAlign: "left",
borderRadius: 0.3,
cardBorderRadius: 0,
collectShow: true,
followerShow: true,
followerColor: "",
alSaleShow: true,
followerFontSize: 0.6,
paynow: true,
priceMarking: false,
goodsSort: 0,
whetherFindDistributionCommission: true,
commissionColor: "",
commissionBgColor: "",
commissionStyle: 0,
angleSign: true,
angleSignType: 0,
angleSignImg:
"http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/1f7d246e-966c-4f3e-b09f-264bfa579b02.png",
angleSignSize: 25,
marketingTag: true,
vipPrice: false,
marketingStyle: 0,
marketingTagList: [
{
key: "recommend",
label: "推荐"
},
{
key: "special",
label: "特价"
},
{
key: "freeShipping",
label: "免邮"
},
{
key: "newGoods",
label: "新品"
}
],
btnIcon: "",
btnType: 6,
btnColor: "",
btnTest: "立即购买",
titleIcon: "/product/ppefWK8BS6.png",
cardShadow: true,
cardShadowSize: 1,
goodsBrand: false,
merchantsEntrance: true,
merchantsEntranceType: 0,
paddingList: [
{
name: "上",
value: 0
},
{
name: "下",
value: 0
},
{
name: "左",
value: 0
},
{
name: "右",
value: 0
}
]
}
}
// 组件数据
data: {
isPageHidden: false, // 页面是否处于隐藏状态
titleIcon:"",
},
// 数据监听器
observers: {},
// 组件方法
methods: {
init() {},
},
// 组件生命周期
lifetimes: {
created() {},
attached() {
this.init();
},
ready() {},
moved() {},
detached() {}
},
attached() {
this.init();
},
definitionFilter() {},
// 页面生命周期
pageLifetimes: {
......@@ -403,7 +52,140 @@ const componentOptions = {
},
// 页面尺寸变化时
resize() {}
},
// 组件方法
methods: {
init() {
let {
goodsType,
goodsSource,
angleSignImg,
titleIcon
} = this.data.datas.componentData;
angleSignImg = DFSImg(angleSignImg, 700, null, 1);
titleIcon = DFSImg(titleIcon, 700, null, 1);
this.setData({
"data.datas.componentData.angleSignImg": angleSignImg,
titleIcon
});
console.log(
this.data.titleIcon,
"----------------------------68"
);
if (goodsType == 0) {
if (goodsSource == "classify") {
//商品分类
this.getProductList(1, 1);
} else {
//指定商品
this.getProductList(2);
}
} else if (goodsType == 1) {
if (goodsSource == "classify") {
//商品分类
this.getInterList(1);
} else {
//指定商品
this.getInterList(2);
}
}
},
getProductList(code, type) {
let { goodsList, goodsSort } = this.data.datas.componentData;
// type 1初始化 2滚动加载
//分类查
if (code == 1) {
goodsApi.queryProductInfo().then(res => {});
} else {
// 商品产品详情
let terminalProductIds = goodsList.map(element => {
return element.terminalProductId;
});
if (terminalProductIds.length == 0) {
return;
}
let briefQuery = {
sortColumn: goodsSort,
sortType: goodsSort != 2 ? 1 : 0,
page: 1,
rows: terminalProductIds.length,
terminalProductIds: terminalProductIds,
whetherShowSoldOutGoods: this.whetherShowSoldOutGoods
}; // 当前页 // 一页多少条
this.briefProduct(briefQuery);
}
},
async briefProduct(query) {
await goodsApi.queryBriefProductInfo(query).then(res => {
if (res.data.code == 200) {
let data = res.data.data.list;
let ids = data.map(element => {
return element.terminalProductId;
});
this.moreProduct(ids);
}
});
},
async moreProduct(terminalProductIds) {
let {
vipPrice,
marketingTag,
whetherFindDistributionCommission,
goodsList,
marketingTagList
} = this.data.datas.componentData;
let moreQuery = {
terminalProductIds,
whetherQueryCollectCount: true, //查询收藏数
whetherUseVirtualSalesQty: true, //是否使用虚拟销售数量
whetherUseVirtualCollectCount: true, //是否使用虚拟收藏人数
whetherFindDistributionCommission: whetherFindDistributionCommission, //是否查询商品佣金(0:不查询,1:展示,为空不查佣金)
whetherFindRecommendedCardFlag: vipPrice ? 1 : 0, //是否查询会员价 1是 0否
whetherShowGoodsDefaultTagFlag: marketingTag ? 1 : 0, //是否展示营销标签 1是 0否
whetherFindMultiShopFlag: 1, //是否查询多商户 //商城使用
whetherFindMultiSonShopFlag: 1 //是否查询多商户 //多主题使用
};
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
goodsList = res.data.data;
goodsList.forEach(item => {
item.marketingTag = item.defaultTags
? this.filtermark(item.defaultTags, marketingTagList)
: [];
item.shopLogoUrl = DFSImg(item.shopLogoUrl, 700, null, 1);
item.coverImage = DFSImg(item.coverImage, 700, null, 1);
item.productImgUrl = DFSImg(item.productImgUrl, 700, null, 1);
item.minPrice = Number(item.minPrice).toFixed(2);
item.qty = Number(item.qty)||0;
item.totalCollectionCount = Number(item.totalCollectionCount) || 0;
item.totalCollectionCount = Number(item.totalCollectionCount) || 0;
item.minPriceAfterRecommendedCardPriceTable = Number(item.minPriceAfterRecommendedCardPriceTable).toFixed(2) || 0;
item.minProductGoodsCommission = Number(item.minProductGoodsCommission).toFixed(2) || 0;
item.minGoodsSuggestedRetailPrice = Number(
item.minGoodsSuggestedRetailPrice
).toFixed(2);
});
this.setData({
"datas.componentData.goodsList": goodsList
});
}
});
},
filtermark(newlist, marketingTagList) {
let list = [];
if (newlist.length <= 0) return;
if (marketingTagList.length > 0) {
marketingTagList.forEach((item, index) => {
newlist.forEach((item1, index1) => {
if (item1 == item.key) {
list.push(item);
}
});
});
}
return list;
}
}
};
Component(componentOptions)
Component(componentOptions);
......@@ -4,8 +4,8 @@
<!-- 头部 -->
<view class="tops flex" style="padding:{{(datas.componentData['titleIcon'] || (datas.componentData['moreShow'] && datas.componentData.moreButtonSite=='top')) ?'0rpx 0rpx 0rpx 10rpx' : ''}};margin-bottom:{{datas.componentData['titleCardGap']*2}}rpx">
<view class="left flex">
<view class="img" wx:if="{{datas.componentData['titleIcon']}}">
<image mode="widthFix" src="http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/ppefWK8BS6.png?x-oss-process=image/resize,limit_1,w_150,h_150" />
<view class="img" wx:if="{{titleIcon}}">
<image mode="widthFix" src="{{titleIcon}}" />
</view>
<view class="title">{{datas.componentData['titles']}}</view>
</view>
......
{
"components":true
"component":true
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment