result = result.map((item) => {
return {
values: {
shopImg: item.returnRequestEntryDTOList[0].picUrl,
},
...item,
};
});
<wxs src="./index.wxs" module="computed" />
<view class="card-main content-class" wx:if="{{useMain}}">
<view class="card-left">
<view class="card-img-box">
<image
catch:tap="handleClickImg"
lazy-load="{{true}}"
class="card-img"
src="{{computed.getters('shopImg',values,valueMap,useMap)}}"
data-url="{{computed.getters('shopImg',values,valueMap,useMap)}}"
data-imgs="{{computed.getters('imgs',values,valueMap,useMap)}}"
mode="widthFix"
/>
<view class="content-class-explosion" wx:if="{{explosionText}}">{{explosionText}}</view>
</view>
<view class="card-name-box">
<slot name="info" wx:if="{{useInfoSlotMain}}"></slot>
<view class="card-name" wx:else>{{computed.getters("shopName",values,valueMap,useMap)}}</view>
<slot name="code" wx:if="{{useCodeSlotMain}}"></slot>
<block wx:else>
<view class="card-number">{{mainTitle}}{{computed.getters("shopCode",values,valueMap,useMap)}}</view>
<view class="card-number">{{purchaseAgent}}{{computed.getters("purchaser",values,valueMap,useMap)}}</view>
<view class="card-number">{{purchaseAccount}}{{computed.getters("purchaseNumber",values,valueMap,useMap)}}</view>
</block>
</view>
</view>
<view class="card-right content-price-class">
<view class="card-price">{{computed.getters("shopPrice",values,valueMap,useMap)}}</view>
<view class="card-num">{{computed.getters("shopNum",values,valueMap,useMap)}}</view>
</view>
</view>
function getters(key, values, map, flag) {
return !flag ? values[key] : values[map[key]];
}
module.exports = {
getters: getters,
};
base-card-shop的js
useMap: {
type: Boolean,
value: true,
},
valueMap: {
type: Object,
value: {
titleVal: "code",
time: "time",
footTitle: "total",
footVal: "value",
stateInfo: "name",
stateVal: "state",
shopName: "shopName",
shopCode: "shopCode",
shopImg: "shopImg",
shopPrice: "shopPrice",
shopNum: "shopNum",
imgs: [],
purchaser: "purchaser",
purchaseNumber: "purchaseNumber",
},
},