发布正式版

This commit is contained in:
ivo 2023-02-21 22:40:56 +08:00
parent 56016a9a88
commit fabc1861d2
389 changed files with 705 additions and 30145 deletions

View File

@ -1,34 +1,6 @@
{ {
"pages": [ "pages": [
"pages/home/home", "pages/home/home",
"pages/usercenter/index",
"pages/usercenter/person-info/index",
"pages/usercenter/address/list/index",
"pages/usercenter/address/edit/index",
"pages/goods/list/index",
"pages/goods/details/index",
"pages/goods/category/index",
"pages/goods/search/index",
"pages/goods/result/index",
"pages/cart/index",
"pages/order/order-confirm/index",
"pages/order/receipt/index",
"pages/order/pay-result/index",
"pages/order/order-list/index",
"pages/order/order-detail/index",
"pages/goods/comments/index",
"pages/order/apply-service/index",
"pages/order/after-service-list/index",
"pages/order/after-service-detail/index",
"pages/goods/comments/create/index",
"pages/coupon/coupon-list/index",
"pages/coupon/coupon-detail/index",
"pages/coupon/coupon-activity-goods/index",
"pages/promotion-detail/index",
"pages/order/fill-tracking-no/index",
"pages/order/delivery-detail/index",
"pages/order/invoice/index",
"pages/usercenter/name-edit/index",
"pages/home/session/session", "pages/home/session/session",
"pages/home/additive/additive", "pages/home/additive/additive",
"pages/home/chemical/chemical", "pages/home/chemical/chemical",
@ -36,7 +8,8 @@
"pages/standard/list/index", "pages/standard/list/index",
"pages/user/index", "pages/user/index",
"pages/user/session-list/index", "pages/user/session-list/index",
"pages/user/edit/index" "pages/user/edit/index",
"pages/info/content-page/index"
], ],
"tabBar": { "tabBar": {
"custom": true, "custom": true,

View File

@ -1,141 +0,0 @@
Component({
options: {
addGlobalClass: true,
},
properties: {
id: {
type: String,
value: '',
observer(id) {
this.genIndependentID(id);
if (this.properties.thresholds?.length) {
this.createIntersectionObserverHandle();
}
},
},
data: {
type: Object,
observer(data) {
if (!data) {
return;
}
let isValidityLinePrice = true;
if (data.originPrice && data.price && data.originPrice < data.price) {
isValidityLinePrice = false;
}
this.setData({ goods: data, isValidityLinePrice });
},
},
currency: {
type: String,
value: '¥',
},
thresholds: {
type: Array,
value: [],
observer(thresholds) {
if (thresholds && thresholds.length) {
this.createIntersectionObserverHandle();
} else {
this.clearIntersectionObserverHandle();
}
},
},
},
data: {
independentID: '',
goods: { id: '' },
isValidityLinePrice: false,
},
lifetimes: {
ready() {
this.init();
},
detached() {
this.clear();
},
},
pageLifeTimes: {},
methods: {
clickHandle() {
this.triggerEvent('click', { goods: this.data.goods });
},
clickThumbHandle() {
this.triggerEvent('thumb', { goods: this.data.goods });
},
addCartHandle(e) {
const { id } = e.currentTarget;
const { id: cardID } = e.currentTarget.dataset;
this.triggerEvent('add-cart', {
...e.detail,
id,
cardID,
goods: this.data.goods,
});
},
genIndependentID(id) {
let independentID;
if (id) {
independentID = id;
} else {
independentID = `goods-card-${~~(Math.random() * 10 ** 8)}`;
}
this.setData({ independentID });
},
init() {
const { thresholds, id } = this.properties;
this.genIndependentID(id);
if (thresholds && thresholds.length) {
this.createIntersectionObserverHandle();
}
},
clear() {
this.clearIntersectionObserverHandle();
},
intersectionObserverContext: null,
createIntersectionObserverHandle() {
if (this.intersectionObserverContext || !this.data.independentID) {
return;
}
this.intersectionObserverContext = this.createIntersectionObserver({
thresholds: this.properties.thresholds,
}).relativeToViewport();
this.intersectionObserverContext.observe(
`#${this.data.independentID}`,
(res) => {
this.intersectionObserverCB(res);
},
);
},
intersectionObserverCB() {
this.triggerEvent('ob', {
goods: this.data.goods,
context: this.intersectionObserverContext,
});
},
clearIntersectionObserverHandle() {
if (this.intersectionObserverContext) {
try {
this.intersectionObserverContext.disconnect();
} catch (e) {}
this.intersectionObserverContext = null;
}
},
},
});

View File

@ -1,8 +0,0 @@
{
"component": true,
"usingComponents": {
"price": "/components/price/index",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-image": "/components/webp-image/index"
}
}

View File

@ -1,63 +0,0 @@
<view
id="{{independentID}}"
class="goods-card"
bind:tap="clickHandle"
data-goods="{{ goods }}"
>
<view class="goods-card__main">
<view class="goods-card__thumb" bind:tap="clickThumbHandle">
<t-image
wx:if="{{ !!goods.thumb }}"
t-class="goods-card__img"
src="{{ goods.thumb }}"
mode="aspectFill"
lazy-load
/>
</view>
<view class="goods-card__body">
<view class="goods-card__upper">
<view wx:if="{{ goods.title }}" class="goods-card__title">
{{ goods.title }}
</view>
<view wx:if="{{ goods.tags && !!goods.tags.length }}" class="goods-card__tags">
<view
wx:for="{{ goods.tags }}"
wx:key="index"
wx:for-item="tag"
class="goods-card__tag"
data-index="{{index}}"
>
{{tag}}
</view>
</view>
</view>
<view class="goods-card__down">
<price
wx:if="{{ goods.price }}"
wr-class="spec-for-price"
symbol-class="spec-for-symbol"
symbol="{{currency}}"
price="{{goods.price}}"
/>
<price
wx:if="{{ goods.originPrice && isValidityLinePrice }}"
wr-class="goods-card__origin-price"
symbol="{{currency}}"
price="{{goods.originPrice}}"
type="delthrough"
/>
<t-icon
class="goods-card__add-cart"
prefix="wr"
name="cartAdd"
id="{{independentID}}-cart"
data-id="{{independentID}}"
catchtap="addCartHandle"
size="48rpx"
color="#FA550F"
/>
</view>
</view>
</view>
</view>

View File

@ -1,133 +0,0 @@
.goods-card {
box-sizing: border-box;
font-size: 24rpx;
border-radius: 0 0 16rpx 16rpx;
border-bottom: none;
}
.goods-card__main {
position: relative;
display: flex;
line-height: 1;
padding: 0;
background: transparent;
width: 342rpx;
border-radius: 0 0 16rpx 16rpx;
align-items: center;
justify-content: center;
margin-bottom: 16rpx;
flex-direction: column;
}
.goods-card__thumb {
flex-shrink: 0;
position: relative;
width: 340rpx;
height: 340rpx;
}
.goods-card__thumb:empty {
display: none;
margin: 0;
}
.goods-card__img {
display: block;
width: 100%;
height: 100%;
border-radius: 16rpx 16rpx 0 0;
overflow: hidden;
}
.goods-card__body {
display: flex;
flex: 1 1 auto;
background: #fff;
border-radius: 0 0 16rpx 16rpx;
padding: 16rpx 24rpx 18rpx;
flex-direction: column;
}
.goods-card__upper {
display: flex;
flex-direction: column;
overflow: hidden;
flex: 1 1 auto;
}
.goods-card__title {
flex-shrink: 0;
font-size: 28rpx;
color: #333;
font-weight: 400;
display: -webkit-box;
height: 72rpx;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-word;
line-height: 36rpx;
}
.goods-card__tags {
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 8rpx 0 0 0;
}
.goods-card__tag {
color: #fa4126;
background: transparent;
font-size: 20rpx;
border: 1rpx solid #fa4126;
padding: 0 8rpx;
border-radius: 16rpx;
line-height: 30rpx;
margin: 0 8rpx 8rpx 0;
display: block;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.goods-card__down {
display: flex;
position: relative;
flex-direction: row;
justify-content: flex-start;
align-items: baseline;
line-height: 32rpx;
margin: 8rpx 0 0 0;
}
.goods-card__origin-price {
white-space: nowrap;
font-weight: 700;
order: 2;
color: #bbbbbb;
font-size: 24rpx;
margin: 0 0 0 8rpx;
}
.goods-card__add-cart {
order: 3;
margin: auto 0 0 auto;
position: absolute;
bottom: 0;
right: 0;
}
.spec-for-price {
font-size: 36rpx;
white-space: nowrap;
font-weight: 700;
order: 1;
color: #fa4126;
margin: 0;
}
.spec-for-symbol {
font-size: 24rpx;
}

View File

@ -1,62 +0,0 @@
Component({
externalClasses: ['wr-class'],
properties: {
goodsList: {
type: Array,
value: [],
},
id: {
type: String,
value: '',
observer: (id) => {
this.genIndependentID(id);
},
},
thresholds: {
type: Array,
value: [],
},
},
data: {
independentID: '',
},
lifetimes: {
ready() {
this.init();
},
},
methods: {
onClickGoods(e) {
const { index } = e.currentTarget.dataset;
this.triggerEvent('click', { ...e.detail, index });
},
onAddCart(e) {
const { index } = e.currentTarget.dataset;
this.triggerEvent('addcart', { ...e.detail, index });
},
onClickGoodsThumb(e) {
const { index } = e.currentTarget.dataset;
this.triggerEvent('thumb', { ...e.detail, index });
},
init() {
this.genIndependentID(this.id || '');
},
genIndependentID(id) {
if (id) {
this.setData({ independentID: id });
} else {
this.setData({
independentID: `goods-list-${~~(Math.random() * 10 ** 8)}`,
});
}
},
},
});

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"goods-card": "/components/goods-card/index"
}
}

View File

@ -1,16 +0,0 @@
<view class="goods-list-wrap wr-class" id="{{independentID}}">
<block wx:for="{{goodsList}}" wx:for-item="item" wx:key="index">
<goods-card
id="{{independentID}}-gd-{{index}}"
data="{{item}}"
currency="{{item.currency || '¥'}}"
thresholds="{{thresholds}}"
class="goods-card-inside"
data-index="{{index}}"
bind:thumb="onClickGoodsThumb"
bind:click="onClickGoods"
bind:add-cart="onAddCart"
/>
</block>
</view>

View File

@ -1,7 +0,0 @@
.goods-list-wrap {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
padding: 0;
background: #fff;
}

View File

@ -1,11 +1,5 @@
<view class="t-class loading-content {{position}}" style="{{(position === 'static' || noMask) ? 'visibility: hidden;' : ''}} background-color: {{backgroundColor}}"> <view class="t-class loading-content {{position}}" style="{{(position === 'static' || noMask) ? 'visibility: hidden;' : ''}}">
<t-loading <t-loading t-class="loading" theme="{{type}}" layout="{{vertical}}" size="{{size}}">
t-class="loading"
theme="{{type}}"
layout="{{vertical}}"
size="{{size}}"
>
<slot /> <slot />
</t-loading> </t-loading>
</view> </view>

View File

@ -1,71 +0,0 @@
Component({
externalClasses: ['wr-class', 'symbol-class', 'decimal-class'],
useStore: [],
properties: {
priceUnit: {
type: String,
value: 'fen',
}, // 价格单位,分 | 元, fenyuan
price: {
type: null,
value: '',
observer(price) {
this.format(price);
},
}, // 价格, 以分为单位
type: {
type: String,
value: '', //
}, // main 粗体, lighter 细体, mini 黑色, del 中划线, delthrough 中划线,包括货币符号
symbol: {
type: String,
value: '¥', // '¥',
}, // 货币符号,默认是人民币符号¥
fill: Boolean, // 是否自动补齐两位小数
decimalSmaller: Boolean, // 小数字号小一点
lineThroughWidth: {
type: null,
value: '0.12em',
}, // 划线价线条高度
},
data: {
pArr: [],
},
methods: {
format(price) {
price = parseFloat(`${price}`);
const pArr = [];
if (!isNaN(price)) {
const isMinus = price < 0;
if (isMinus) {
price = -price;
}
if (this.properties.priceUnit === 'yuan') {
const priceSplit = price.toString().split('.');
pArr[0] = priceSplit[0];
pArr[1] = !priceSplit[1]
? '00'
: priceSplit[1].length === 1
? `${priceSplit[1]}0`
: priceSplit[1];
} else {
price = Math.round(price * 10 ** 8) / 10 ** 8; // 恢复精度丢失
price = Math.ceil(price); // 向上取整
pArr[0] = price >= 100 ? `${price}`.slice(0, -2) : '0';
pArr[1] = `${price + 100}`.slice(-2);
}
if (!this.properties.fill) {
// 如果 fill 为 false 不显示小数末尾的0
if (pArr[1] === '00') pArr[1] = '';
else if (pArr[1][1] === '0') pArr[1] = pArr[1][0];
}
if (isMinus) {
pArr[0] = `-${pArr[0]}`;
}
}
this.setData({ pArr });
},
},
});

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,21 +0,0 @@
<wxs module="utils">
var REGEXP = getRegExp('^\d+(\.\d+)?$');
function addUnit(value) {
if (value == null) {
return '';
}
return REGEXP.test('' + value) ? value + 'rpx' : value;
}
module.exports = {
addUnit: addUnit
};
</wxs>
<view class="price {{type}} wr-class">
<view wx:if="{{type === 'delthrough'}}" class="line" style="height:{{utils.addUnit(lineThroughWidth)}};" />
<view class="symbol symbol-class">{{symbol}}</view>
<view class="pprice">
<view class="integer inline">{{pArr[0]}}</view>
<view wx:if="{{pArr[1]}}" class="decimal inline {{decimalSmaller ? 'smaller' : ''}} decimal-class">.{{pArr[1]}}</view>
</view>
</view>

View File

@ -1,66 +0,0 @@
:host {
display: inline-block;
display: inline-block;
font-weight: inherit;
}
.inline {
display: inline;
white-space: nowrap;
}
.price {
display: inline;
color: inherit;
font-size: inherit;
text-decoration: inherit;
}
.lighter {
font-weight: 400;
font-size: 32rpx;
}
.mini {
font-size: 24rpx;
color: #5d5d5d;
font-weight: 400;
}
.del .pprice {
font-size: 32rpx;
color: #9b9b9b;
text-decoration: line-through;
font-weight: 400;
}
.delthrough {
position: relative;
}
.delthrough .line {
position: absolute;
top: 50%;
left: 0;
right: 0;
transform: translateY(-50%);
margin: 0;
background-color: currentColor;
}
.symbol {
display: inline;
color: inherit;
font-size: inherit;
font-size: 0.8em;
}
.pprice {
display: inline;
margin: 0 0 0 4rpx;
}
.integer {
color: inherit;
font-size: inherit;
}
.decimal {
color: inherit;
font-size: inherit;
}
.decimal.smaller {
font-size: 0.8em;
vertical-align: baseline;
}

View File

@ -147,21 +147,7 @@
}; };
</wxs> </wxs>
<view <view class="wr-class wr-swipeout" data-key="cell" capture-bind:tap="onClick" bindtouchstart="{{disabled || swipe.startDrag}}" capture-bind:touchmove="{{disabled || swipe.onDrag}}" bindtouchend="{{disabled || swipe.endDrag}}" bindtouchcancel="{{disabled || swipe.endDrag}}" closed="{{closed}}" change:closed="{{swipe.onCloseChange}}" leftWidth="{{leftWidth}}" rightWidth="{{rightWidth}}" change:leftWidth="{{swipe.initLeftWidth}}" change:rightWidth="{{swipe.initRightWidth}}">
class="wr-class wr-swipeout"
data-key="cell"
capture-bind:tap="onClick"
bindtouchstart="{{disabled || swipe.startDrag}}"
capture-bind:touchmove="{{disabled || swipe.onDrag}}"
bindtouchend="{{disabled || swipe.endDrag}}"
bindtouchcancel="{{disabled || swipe.endDrag}}"
closed="{{closed}}"
change:closed="{{swipe.onCloseChange}}"
leftWidth="{{leftWidth}}"
rightWidth="{{rightWidth}}"
change:leftWidth="{{swipe.initLeftWidth}}"
change:rightWidth="{{swipe.initRightWidth}}"
>
<view id="wrapper"> <view id="wrapper">
<view wx:if="{{ leftWidth }}" class="wr-swipeout__left" data-key="left" catch:tap="onClick"> <view wx:if="{{ leftWidth }}" class="wr-swipeout__left" data-key="left" catch:tap="onClick">
<slot name="left" /> <slot name="left" />

View File

@ -0,0 +1,31 @@
// components/tox-icon/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
ghsLevel: {
type: Number,
value: 99,
observer(ghsLevel) {
this.setData({
ghsLevel,
});
},
},
},
/**
* 组件的初始数据
*/
data: {
iconUrl: 'https://webplus-cn-hangzhou-s-603871eef968dd14ced82ed5.oss-cn-hangzhou.aliyuncs.com/hextech/static/tox.svg',
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

@ -0,0 +1,2 @@
<!--components/tox-icon/index.wxml-->
<t-icon name="{{iconUrl}}" size="24" data-name="{{iconUrl}}" />

View File

@ -0,0 +1 @@
/* components/tox-icon/index.wxss */

View File

@ -0,0 +1,85 @@
// components/tox-tag/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
ghsLevel: {
type: Number,
value: 99,
observer(ghsLevel) {
this.setData({
ghsLevel,
levelName: this.data.ghsMap[ghsLevel].text,
levelTheme: this.data.ghsMap[ghsLevel].theme,
});
},
},
size: {
type: String,
value: 'medium',
observer(size) {
this.setData({
size,
});
},
},
variant: {
type: String,
value: 'dark',
observer(variant) {
this.setData({
variant,
});
},
},
},
/**
* 组件的初始数据
*/
data: {
size: '',
variant: '',
levelName: '',
ghsLevel: 99,
levelTheme: 'success',
ghsMap: {
0: {
theme: 'success',
text: '无毒',
},
5: {
theme: 'warning',
text: '可能有害',
},
4: {
theme: 'danger',
text: '有害',
},
3: {
theme: 'danger',
text: '有毒',
},
2: {
theme: 'danger',
text: '致命',
},
1: {
theme: 'danger',
text: '致命',
},
99: {
theme: 'success',
text: '',
},
},
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

@ -1,6 +1,6 @@
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"goods-card": "../goods-card/index" "t-tag": "tdesign-miniprogram/tag/tag"
} }
} }

View File

@ -0,0 +1,2 @@
<!--components/tox-tag/index.wxml-->
<t-tag wx:if="{{levelName != ''}}" theme="{{levelTheme}}" variant="{{variant}}" size="{{size}}">{{levelName}}</t-tag>

View File

@ -0,0 +1 @@
/* components/tox-tag/index.wxss */

View File

@ -1,86 +0,0 @@
/*
* @Author: rileycai
* @Date: 2022-03-14 14:21:26
* @LastEditTime: 2022-03-14 15:23:04
* @LastEditors: rileycai
* @Description: webp-image组件对t-image包裹了一层主要实现图片裁剪webp压缩功能
* @FilePath: /tdesign-miniprogram-starter/components/webp-image/index.js
*/
const systemInfo = wx.getSystemInfoSync();
Component({
externalClasses: ['t-class', 't-class-load'],
properties: {
loadFailed: {
type: String,
value: 'default',
},
loading: {
type: String,
value: 'default',
},
src: {
type: String,
value: '',
},
mode: {
type: String,
value: 'aspectFill',
},
webp: {
type: Boolean,
value: true,
},
lazyLoad: {
type: Boolean,
value: false,
},
showMenuByLongpress: {
type: Boolean,
value: false,
},
},
data: {
thumbHeight: 375,
thumbWidth: 375,
systemInfo,
},
lifetimes: {
ready() {
const { mode } = this.properties;
// 获取容器的真实宽高,设置图片的裁剪宽度
this.getRect('.J-image').then((res) => {
if (res) {
const { width, height } = res;
this.setData(
mode === 'heightFix'
? {
thumbHeight: this.px2rpx(height) || 375,
}
: {
thumbWidth: this.px2rpx(width) || 375,
},
);
}
});
},
},
methods: {
px2rpx(px) {
return (750 / (systemInfo.screenWidth || 375)) * px;
},
getRect(selector) {
return new Promise((resolve) => {
if (!this.selectorQuery) {
this.selectorQuery = this.createSelectorQuery();
}
this.selectorQuery.select(selector).boundingClientRect(resolve).exec();
});
},
onLoad(e) {
this.triggerEvent('load', e.detail);
},
onError(e) {
this.triggerEvent('error', e.detail);
},
},
});

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"t-image": "tdesign-miniprogram/image/image"
}
}

View File

@ -1,14 +0,0 @@
<wxs src="./utils.wxs" module="Utils" />
<t-image
class="J-image"
src="{{Utils.getSrc({src, thumbWidth: thumbWidth || 0, thumbHeight: thumbHeight || 0, systemInfo, webp, mode})}}"
t-class="t-class"
t-class-load="t-class-load"
mode="{{ mode }}"
lazy="{{ lazyLoad }}"
show-menu-by-longpress="{{showMenuByLongpress}}"
error="{{loadFailed}}"
loading="{{loading}}"
binderror="onError"
bindload="onLoad"
/>

View File

@ -1,140 +0,0 @@
var isString = function (value) {
return typeof value === 'string';
};
var isNumber = function (value) {
return typeof value === 'number';
};
var getFileExt = function (src) {
var fileUrl = src.split('?')[0];
var splitUlr = fileUrl.split('/');
var filepath = splitUlr[splitUlr.length - 1];
return filepath.split('.')[1] || 'jpg';
};
function isUrl(url) {
// NOCC:ToolNameCheck(非敏感词)
var urlReg = getRegExp(
'/[(http(s)?)://(www.)?a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/',
'ig',
);
return urlReg.test(url);
}
function rpx2px(rpx, screenWidth) {
// px / systemWidth = rpx / 750
var result = (rpx * (screenWidth || 375)) / 750;
return Math.round(result);
}
function imageMogr(url, options) {
if (!isString(url) || !url) return '';
if (
url.indexOf('qlogo.cn') !== -1 ||
url.indexOf('wxfile://') === 0 ||
url.indexOf('http://tmp/wx') === 0 ||
url.indexOf('imageMogr2') !== -1
) {
//qlogo.cn域名或者本地图片不做转换
return url;
} //强制转https
if (url.indexOf('http://') === 0) {
url = url.replace('http://', 'https://');
} else if (url.indexOf('//') === 0) {
url = 'https:' + url;
}
if (!options) return url;
var width = Math.ceil(options.width),
height = Math.ceil(options.height),
format = options.format,
_optionsQuality = options.quality,
quality = _optionsQuality === undefined ? 70 : _optionsQuality,
_optionsStrip = options.strip,
strip = _optionsStrip === undefined ? true : _optionsStrip,
crop = options.crop;
var isValidWidth = isNumber(width) && width > 0;
var isValidHeight = isNumber(height) && height > 0;
var imageMogrStr = '';
var size = '';
if (isValidWidth && isValidHeight) {
size = ''.concat(width, 'x').concat(height);
} else if (isValidWidth) {
size = ''.concat(width, 'x');
} else if (isValidHeight) {
size = 'x'.concat(height);
}
if (size) {
//缩放或者裁剪
imageMogrStr += '/'.concat(crop ? 'crop' : 'thumbnail', '/').concat(size);
if (crop) {
//裁剪目前需求只有以图片中心为基准
imageMogrStr += '/gravity/center';
}
}
if (isNumber(quality)) {
//质量变换
imageMogrStr += '/quality/'.concat(quality);
}
if (strip) {
//去除元信息
imageMogrStr += '/strip';
}
var ext = getFileExt(url);
// gif 图片不做格式转换,否则会损坏动图
if (ext === 'gif') {
imageMogrStr += '/cgif/1';
} else if (format) {
//格式转换
imageMogrStr += '/format/'.concat(format);
}
if (format === 'jpg' || (!format && (ext === 'jpg' || ext === 'jpeg'))) {
//渐进式 jpg 加载
imageMogrStr += '/interlace/1';
}
if (!imageMogrStr) return url;
return ''
.concat(url)
.concat(url.indexOf('?') !== -1 ? '&' : '?', 'imageMogr2')
.concat(imageMogrStr);
}
function getSrc(options) {
if (!options.src) return '';
if (options.thumbWidth || options.thumbHeight) {
return imageMogr(options.src, {
width:
options.mode !== 'heightFix'
? rpx2px(options.thumbWidth, options.systemInfo.screenWidth) *
options.systemInfo.pixelRatio
: null,
height:
options.mode !== 'widthFix'
? rpx2px(options.thumbHeight, options.systemInfo.screenWidth) *
options.systemInfo.pixelRatio
: null,
format: options.webp ? 'webp' : null,
});
}
return '';
}
module.exports = {
imageMogr: imageMogr,
getSrc: getSrc,
};

View File

@ -7,11 +7,12 @@ Component({
methods: { methods: {
onChange(event) { onChange(event) {
this.setData({ active: event.detail.value }); this.setData({
active: event.detail.value
});
wx.switchTab({ wx.switchTab({
url: this.data.list[event.detail.value].url.startsWith('/') url: this.data.list[event.detail.value].url.startsWith('/') ?
? this.data.list[event.detail.value].url this.data.list[event.detail.value].url : `/${this.data.list[event.detail.value].url}`,
: `/${this.data.list[event.detail.value].url}`,
}); });
}, },
@ -23,7 +24,9 @@ Component({
(item.url.startsWith('/') ? item.url.substr(1) : item.url) === (item.url.startsWith('/') ? item.url.substr(1) : item.url) ===
`${route}`, `${route}`,
); );
this.setData({ active }); this.setData({
active
});
}, },
}, },
}); });

View File

@ -2,7 +2,7 @@
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar", "t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
"t-tab-bar-item": "tdesign-miniprogram/tab-bar/tab-bar-item", "t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item",
"t-icon": "tdesign-miniprogram/icon/icon" "t-icon": "tdesign-miniprogram/icon/icon"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,7 +0,0 @@
import { getActivity } from './activity';
export function getActivityList(baseID = 0, length = 10) {
return new Array(length).fill(0).map((_, idx) => getActivity(idx + baseID));
}
export const activityList = getActivityList();

View File

@ -1,18 +0,0 @@
/**
* @param {string|number} key 唯一值
*/
export function getActivity(key) {
return {
promotionId: `${key}`,
title: `满减满折回归${key}`,
description: null,
promotionCode: 'MERCHANT',
promotionSubCode: key % 2 === 0 ? 'MYJ' : 'MYG',
tag: '满减',
timeType: 1,
startTime: '1588737710000',
endTime: '1601467070000',
teasingStartTime: null,
activityLadder: [{ label: '满100元减99.9元' }],
};
}

View File

@ -1,31 +0,0 @@
/** 地址 */
export function genAddress(id) {
return {
saasId: '88888888',
uid: `8888888820550${id}`,
authToken: null,
id: `${id}`,
addressId: `${id}`,
phone: '17612345678',
name: `测试用户${id}`,
countryName: '中国',
countryCode: 'chn',
provinceName: '甘肃省',
provinceCode: '620000',
cityName: '甘南藏族自治州',
cityCode: '623000',
districtName: '碌曲县',
districtCode: '623026',
detailAddress: `松日鼎盛大厦${id}${id}`,
isDefault: `${id}` === '0' ? 1 : 0,
addressTag: id === 0 ? '' : '公司',
latitude: '34.59103',
longitude: '102.48699',
storeId: null,
};
}
/** 地址列表 */
export function genAddressList(len = 10) {
return new Array(len).fill(0).map((_, idx) => genAddress(idx));
}

View File

@ -1,324 +0,0 @@
import { mockIp, mockReqId } from '../utils/mock';
export function genCartGroupData() {
const resp = {
data: {
isNotEmpty: true,
storeGoods: [
{
storeId: '1000',
storeName: '云Mall深圳旗舰店',
storeStatus: 1,
totalDiscountSalePrice: '9990',
promotionGoodsList: [
{
title: '满减满折回归',
promotionCode: 'MERCHANT',
promotionSubCode: 'MYJ',
promotionId: '159174555838121985',
tagText: ['满100元减99.9元'],
promotionStatus: 3,
tag: '满减',
description: '满100元减99.9元,已减99.9元',
doorSillRemain: null,
isNeedAddOnShop: 0,
goodsPromotionList: [
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '12',
skuId: '135691622',
isSelected: 1,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-3a.png',
title:
'腾讯极光盒子4智能网络电视机顶盒6K千兆网络机顶盒4K高分辨率',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-3a.png',
quantity: 1,
stockStatus: true,
stockQuantity: 3,
price: '9900',
originPrice: '16900',
tagPrice: null,
titlePrefixTags: [{ text: '新品' }, { text: '火爆' }],
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '经典白',
},
{
specTitle: '类型',
specValue: '经典套装',
},
],
joinCartTime: '2020-06-29T07:55:40.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '18',
skuId: '135681631',
isSelected: 1,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-09a.png',
title:
'白色短袖连衣裙荷叶边裙摆宽松韩版休闲纯白清爽优雅连衣裙',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-09a.png',
quantity: 1,
stockStatus: true,
stockQuantity: 177,
price: '29800',
originPrice: '40000',
tagPrice: null,
titlePrefixTags: null,
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '米色荷叶边',
},
{
specTitle: '尺码',
specValue: 'M',
},
],
joinCartTime: '2020-06-29T07:55:27.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '13',
skuId: '135698362',
isSelected: 1,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png',
title:
'带帽午休毯虎年款多功能加厚加大加绒简约多功能午休毯连帽披肩',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png',
quantity: 13,
stockStatus: true,
stockQuantity: 9,
price: '29900',
originPrice: '0',
tagPrice: null,
titlePrefixTags: [{ text: '火爆' }],
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '浅灰色',
},
{
specTitle: '尺码',
specValue: 'M',
},
],
joinCartTime: '2020-06-29T07:54:43.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '7',
skuId: '135681625',
isSelected: 1,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png',
title:
'不锈钢刀叉勺套装家用西餐餐具ins简约耐用不锈钢金色银色可选',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png',
quantity: 1,
stockStatus: true,
stockQuantity: 0,
price: '29900',
originPrice: '29900',
tagPrice: null,
titlePrefixTags: null,
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '奶黄色',
},
{
specTitle: '数量',
specValue: '六件套',
},
],
joinCartTime: '2020-06-29T07:55:00.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
],
lastJoinTime: '2020-06-29T07:55:40.000+0000',
},
{
title: null,
promotionCode: 'EMPTY_PROMOTION',
promotionSubCode: null,
promotionId: null,
tagText: null,
promotionStatus: null,
tag: null,
description: null,
doorSillRemain: null,
isNeedAddOnShop: 0,
goodsPromotionList: [
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '11',
skuId: '135691629',
isSelected: 0,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-17a.png',
title: '运动连帽拉链卫衣休闲开衫长袖多色运动细绒面料运动上衣',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-17a.png',
quantity: 1,
stockStatus: false,
stockQuantity: 0,
price: '25900',
originPrice: '39900',
tagPrice: null,
tagText: null,
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '军绿色',
},
{
specTitle: '尺码',
specValue: 'S',
},
],
joinCartTime: '2020-04-24T06:26:48.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '5',
skuId: '135691635',
isSelected: 0,
thumb:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-2a.png',
title:
'迷你便携高颜值蓝牙无线耳机立体声只能触控式操作简约立体声耳机',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-2a.png',
quantity: 1,
stockStatus: true,
stockQuantity: 96,
price: '29000',
originPrice: '29900',
tagPrice: null,
tagText: null,
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '黑色',
},
{
specTitle: '类型',
specValue: '简约款',
},
],
joinCartTime: '2020-06-29T07:55:17.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
],
lastJoinTime: null,
},
],
lastJoinTime: '2020-06-29T07:55:40.000+0000',
postageFreePromotionVo: {
title: null,
promotionCode: null,
promotionSubCode: null,
promotionId: null,
tagText: null,
promotionStatus: null,
tag: null,
description: null,
doorSillRemain: null,
isNeedAddOnShop: 0,
},
},
],
invalidGoodItems: [
{
uid: '88888888205468',
saasId: '88888888',
storeId: '1000',
spuId: '1',
skuId: '135691631',
isSelected: 1,
thumb: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
title: '纯色纯棉休闲圆领短袖T恤纯白亲肤厚柔软细腻面料纯白短袖套头T恤',
primaryImage:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
quantity: 8,
stockStatus: true,
stockQuantity: 177,
price: '26900',
originPrice: '31900',
tagPrice: null,
tagText: null,
roomId: null,
specInfo: [
{
specTitle: '颜色',
specValue: '白色',
},
{
specTitle: '尺码',
specValue: 'S',
},
],
joinCartTime: '2020-04-28T04:03:59.000+0000',
available: 1,
putOnSale: 1,
etitle: null,
},
],
isAllSelected: false,
selectedGoodsCount: 16,
totalAmount: '179997',
totalDiscountAmount: '110000',
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 269,
success: true,
};
return resp;
}

View File

@ -1,206 +0,0 @@
export function getCategoryList() {
return [
{
groupId: '24948',
name: '女装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249481',
name: '女装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249480',
name: '卫衣',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-1.png',
},
{
groupId: '249480',
name: '毛呢外套',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-2.png',
},
{
groupId: '249480',
name: '雪纺衫',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-3.png',
},
{
groupId: '249480',
name: '羽绒服',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-4.png',
},
{
groupId: '249480',
name: '毛衣',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-5.png',
},
{
groupId: '249480',
name: '棉衣',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-6.png',
},
{
groupId: '249480',
name: '西装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-7.png',
},
{
groupId: '249480',
name: '马甲',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-8.png',
},
{
groupId: '249480',
name: '连衣裙',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-9.png',
},
{
groupId: '249480',
name: '半身裙',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-10.png',
},
{
groupId: '249480',
name: '裤子',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-11.png',
},
],
},
],
},
{
groupId: '24948',
name: '男装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249481',
name: '男装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249480',
name: '卫衣',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-1.png',
},
{
groupId: '249480',
name: '裤子',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-11.png',
},
{
groupId: '249480',
name: '西装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-7.png',
},
{
groupId: '249480',
name: '羽绒服',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-4.png',
},
{
groupId: '249480',
name: '马甲',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-8.png',
},
],
},
],
},
{
groupId: '24948',
name: '儿童装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249481',
name: '儿童装',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249480',
name: '马甲',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-8.png',
},
{
groupId: '249480',
name: '裤子',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-11.png',
},
{
groupId: '249480',
name: '连衣裙',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/classify/img-9.png',
},
{
groupId: '249480',
name: '其他',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3b.png',
},
],
},
],
},
{
groupId: '24948',
name: '美妆',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249481',
name: '美妆',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/miniapp/category/category-default.png',
children: [
{
groupId: '249480',
name: '唇釉',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/mz-20a1.png',
},
{
groupId: '249480',
name: '美妆蛋',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/mz-11a1.png',
},
{
groupId: '249480',
name: '眼影',
thumbnail:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/mz-12b.png',
},
],
},
],
},
];
}

View File

@ -1,338 +0,0 @@
/**
* * @param {number} spuId
* @param {number} pageNum
* @param {number} pageSize
* @param {number} commentsLevel
* @param {boolean} hasImage
*/
export function getGoodsAllComments(params) {
const { hasImage } = params.queryParameter;
if (hasImage) {
return {
pageNum: 1,
pageSize: 10,
totalCount: '1',
pageList: [
{
spuId: '1722045',
skuId: '0',
specInfo: '',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentResources: [
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
type: 'image',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
],
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1591953561000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '0',
specInfo: '',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentResources: [
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
type: 'image',
},
],
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1591953561000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '0',
specInfo: '',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentResources: [
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
type: 'image',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
],
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1591953561000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '0',
specInfo: '',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentResources: [
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
type: 'image',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
{
src: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/comment-video.mp4',
type: 'video',
coverSrc:
'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
},
],
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1591953561000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
],
};
}
return {
pageNum: 1,
pageSize: 10,
totalCount: '47',
pageList: [
{
spuId: '1722045',
skuId: '1697694',
specInfo: '很不错',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 1,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592224320000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '1697693',
specInfo: '很适合',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 1,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592224320000',
isAutoComment: false,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: 'NICE',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592218074000',
isAutoComment: true,
sellerReply:
'亲,你好,我们会联系商家和厂商给您一个满意的答复请一定妥善保管好发票',
},
{
spuId: '1722045',
skuId: '0',
specInfo: '',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592218074000',
isAutoComment: false,
goodsDetailInfo: '颜色:纯净白 尺码:S码',
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: '测试dr超长:dr专用超长;bwtgg01:fff',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592217607000',
isAutoComment: false,
},
{
spuId: '1722045',
skuId: '1697693',
specInfo: '测试dr超长:超长测试超长测试1;bwtgg01:bbb',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592217607000',
isAutoComment: false,
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: '测试dr超长:dr专用超长;bwtgg01:fff',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592205599000',
isAutoComment: false,
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: '测试dr超长:dr专用超长;bwtgg01:fff',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1592188822000',
isAutoComment: false,
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: '测试dr超长:dr专用超长;bwtgg01:fff',
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentImageUrls: null,
commentScore: 5,
uid: '88881055835',
userName: 'Max',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1593792002000',
isAutoComment: true,
},
{
spuId: '1722045',
skuId: '1697694',
specInfo: '测试dr超长:dr专用超长;bwtgg01:fff',
commentContent: '',
commentImageUrls: null,
commentScore: 5,
uid: '88881055835',
userName: 'Max',
userHeadUrl:
'https://cdn-we-retail.ym.tencent.com/tsr/avatar/avatar1.png',
isAnonymity: false,
commentTime: '1593792001000',
isAutoComment: true,
},
],
};
}
export function getGoodsCommentsCount() {
return {
commentCount: '47',
badCount: '0',
middleCount: '2',
goodCount: '45',
hasImageCount: '1',
goodRate: 95.7,
uidCount: '0',
};
}

View File

@ -1,50 +0,0 @@
const queryDetail = {
commentInfos: [
{
id: '647984992708380600',
uid: '',
userName: 'Dean Cheng',
userHeadUrl:
'https://bizmid-material-qa-1302115263.cos.ap-guangzhou.myqcloud.com/comment/default_head.png',
commentId: '1937712',
commentIdName: '小鹿商品',
commentIdImageUrl:
'https://bizmid-material-qa-1302115263.file.myqcloud.com/persist/4bf2ded7-1759-4821-919c-cc4960e14120/1078823925183295617/100000114727/material/1/cdbeb389be64427b8c165627895ff0bc-1610425563793-%E5%A4%B4%E5%83%8F.png',
commentStage: 1,
commentCheckStatus: 2,
commentIdType: 1,
content: '',
commentInfo: {
score: null,
content: '',
medias: [],
commentTime: '1617872404000',
},
isAgainComment: 0,
commentHasAgainComment: 0,
isAnonymous: 0,
replyList: [],
specification: '颜色:白色 ',
specificationJson: '{"颜色":"白色"}',
commentExtendId: '1937713',
commentTime: '1617872404000',
score: 0,
goodsScore: null,
freightScore: null,
serviceScore: null,
medias: [],
againCommentList: null,
},
],
logisticsScore: null,
serviceScore: null,
};
/**
* @param {string} skuId
* @param {string} spuId
* @param {string} orderNo
*/
export function queryCommentDetail() {
return queryDetail;
}

View File

@ -1,39 +0,0 @@
/**
* 优惠券
*
* @typedef {'default'|'useless'|'disabled'} CouponCardStatus
* @typedef {'discount'|'price'} CouponCardType
*
* @param {number} [id]
* @param {CouponCardStatus} [status]
* @param {CouponCardType} [type]
*/
export function getCoupon(id = 0, status = 'default', type = (id % 2) + 1) {
return {
/** key */
key: `${id}`,
/** 优惠券状态 */
status,
/** 优惠券类型 */
type,
/** 折扣或者满减值 */
value: type === 2 ? 5.5 : 1800,
/** 标签 */
tag: '',
/** 描述 */
desc: parseInt(id) > 0 ? `${parseInt(id) * 100}元可用` : '无门槛使用',
/** 订单底价,满n元 */
base: 10000 * (parseInt(id) || 0),
/** 标题 */
title: type === 2 ? `生鲜折扣券 - ${id}` : `生鲜满减券 - ${id}`,
/** 有效时间限制 */
timeLimit: '2019.11.18-2023.12.18',
/** 货币符号 */
currency: '¥',
};
}
/** 优惠券列表 */
export function getCouponList(status = 'default', length = 10) {
return new Array(length).fill(0).map((_, idx) => getCoupon(idx, status));
}

View File

@ -1,30 +0,0 @@
export function getGoodsDetailsComments() {
return {
homePageComments: [
{
spuId: '1722045',
skuId: null,
specInfo: null,
commentContent:
'收到货了,第一时间试了一下,很漂亮特别喜欢,大爱大爱,颜色也很好看。棒棒!',
commentScore: 4,
uid: '88881048075',
userName: 'Dean',
userHeadUrl:
'https://wx.qlogo.cn/mmopen/vi_32/5mKrvn3ibyDNaDZSZics3aoKlz1cv0icqn4EruVm6gKjsK0xvZZhC2hkUkRWGxlIzOEc4600JkzKn9icOLE6zjgsxw/132',
},
],
};
}
export function getGoodsDetailsCommentsCount() {
return {
commentCount: '47',
badCount: '0',
middleCount: '2',
goodCount: '45',
hasImageCount: '1',
goodRate: 95.7,
uidCount: '0',
};
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
import { genGood } from './good';
export function getGoodsList(baseID = 0, length = 10) {
return new Array(length).fill(0).map((_, idx) => genGood(idx + baseID));
}
export const goodsList = getGoodsList();

View File

@ -1,295 +0,0 @@
import { mockIp, mockReqId } from '../../utils/mock';
const orderResps = [
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135691625',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName:
'迷你便携高颜值蓝牙无线耳机立体声只能触控式操作简约立体声耳机',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-2a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '黑色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: '简约款',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135676631',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '白色短袖连衣裙荷叶边裙摆宽松韩版休闲纯白清爽优雅连衣裙',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-09a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '米色荷叶边',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'S',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135691622',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '腾讯极光盒子4智能网络电视机顶盒6K千兆网络机顶盒4K高分辨率',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/dz-3a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '经典白',
},
{
specId: '50459',
specTitle: '类型',
specValue: '经典套装',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135676629',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '带帽午休毯虎年款多功能加厚加大加绒简约多功能午休毯连帽披肩',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '浅灰色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'S',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135686631',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '运动连帽拉链卫衣休闲开衫长袖多色运动细绒面料运动上衣',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-17a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '军绿色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'XS',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '19384938948343',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '130169571554503755',
goodsInfo: {
goodsName:
'纯色纯棉休闲圆领短袖T恤纯白亲肤厚柔软细腻面料纯白短袖套头T恤',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '军绿色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'XS',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
];
export function genRightsPreview(params) {
const { orderNo, skuId } = params;
const resp = orderResps.find(
(r) => r.data.orderNo === orderNo && r.data.skuId === skuId,
);
return resp;
}
export function genApplyReasonList(params) {
const resp = {
data: {
saasId: '70000001',
rightsReasonList: [
{ id: '1', desc: '实际商品与描述不符' },
{ id: '2', desc: '质量问题' },
{ id: '3', desc: '少件/漏发' },
{ id: '4', desc: '包装/商品/污迹/裂痕/变形' },
{ id: '5', desc: '发货太慢' },
{ id: '6', desc: '物流配送太慢' },
{ id: '7', desc: '商家发错货' },
{ id: '8', desc: '不喜欢' },
],
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 6,
success: true,
};
// 未收货对应的原因列表
if (params.rightsReasonType === 'REFUND_MONEY') {
resp.data.rightsReasonList = [
{ id: '9', desc: '空包裹' },
{ id: '10', desc: '快递/物流一直未送到' },
{ id: '11', desc: '货物破损已拒签' },
{ id: '12', desc: '不喜欢' },
];
}
return resp;
}
export function applyService() {
const resp = {
data: {
rightsNo: '123123423',
saasId: '70000001',
uid: '700000011070005',
storeId: '542',
result: null,
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 269,
success: true,
};
return resp;
}

View File

@ -1,147 +0,0 @@
import { mockIp, mockReqId } from '../../utils/mock';
export const transformGoodsDataToConfirmData = (goodsDataList) => {
const list = [];
goodsDataList.forEach((goodsData) => {
list.push({
storeId: goodsData.storeId,
spuId: goodsData.spuId,
skuId: goodsData.skuId,
goodsName: goodsData.title,
image: goodsData.primaryImage,
reminderStock: 119,
quantity: goodsData.quantity,
payPrice: goodsData.price,
totalSkuPrice: goodsData.price,
discountSettlePrice: goodsData.price,
realSettlePrice: goodsData.price,
settlePrice: goodsData.price,
oriPrice: goodsData.originPrice,
tagPrice: null,
tagText: null,
skuSpecLst: goodsData.specInfo,
promotionIds: null,
weight: 0.0,
unit: 'KG',
volume: null,
masterGoodsType: 0,
viceGoodsType: 0,
roomId: goodsData.roomId,
egoodsName: null,
});
});
return list;
};
/** 生成结算数据 */
export function genSettleDetail(params) {
const { userAddressReq, couponList, goodsRequestList } = params;
const resp = {
data: {
settleType: 0,
userAddress: null,
totalGoodsCount: 3,
packageCount: 1,
totalAmount: '289997',
totalPayAmount: '',
totalDiscountAmount: '110000',
totalPromotionAmount: '1100',
totalCouponAmount: '0',
totalSalePrice: '289997',
totalGoodsAmount: '289997',
totalDeliveryFee: '0',
invoiceRequest: null,
skuImages: null,
deliveryFeeList: null,
storeGoodsList: [
{
storeId: '1000',
storeName: '云Mall深圳旗舰店',
remark: null,
goodsCount: 1,
deliveryFee: '0',
deliveryWords: null,
storeTotalAmount: '0',
storeTotalPayAmount: '179997',
storeTotalDiscountAmount: '110000',
storeTotalCouponAmount: '0',
skuDetailVos: [],
couponList: [
{
couponId: 11,
storeId: '1000',
},
],
},
],
inValidGoodsList: null,
outOfStockGoodsList: null,
limitGoodsList: null,
abnormalDeliveryGoodsList: null,
invoiceSupport: 1,
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 244,
success: true,
};
const list = transformGoodsDataToConfirmData(goodsRequestList);
// 获取购物车传递的商品数据
resp.data.storeGoodsList[0].skuDetailVos = list;
// 判断是否携带优惠券数据
const discountPrice = [];
if (couponList && couponList.length > 0) {
couponList.forEach((coupon) => {
if (coupon.status === 'default') {
discountPrice.push({
type: coupon.type,
value: coupon.value,
});
}
});
}
// 模拟计算场景
// 计算总价
const totalPrice = list.reduce((pre, cur) => {
return pre + cur.quantity * Number(cur.settlePrice);
}, 0);
// 计算折扣
const totalDiscountPrice =
discountPrice.length > 0
? discountPrice.reduce((pre, cur) => {
if (cur.type === 1) {
return pre + cur.value;
}
if (cur.type === 2) {
return pre + (Number(totalPrice) * cur.value) / 10;
}
return pre + cur;
}, 0)
: 0;
resp.data.totalSalePrice = totalPrice;
resp.data.totalCouponAmount = totalDiscountPrice;
resp.data.totalPayAmount =
totalPrice - totalDiscountPrice - Number(resp.data.totalPromotionAmount);
if (userAddressReq) {
resp.data.settleType = 1;
resp.data.userAddress = userAddressReq;
}
return resp;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
import { getGoodsList } from './goods';
export function getPromotion(baseID = 0, length = 10) {
return {
list: getGoodsList(baseID, length).map((item) => {
return {
spuId: item.spuId,
thumb: item.primaryImage,
title: item.title,
price: item.minSalePrice,
originPrice: item.maxLinePrice,
tags: item.spuTagList.map((tag) => ({ title: tag.title })),
};
}),
banner:
'https://cdn-we-retail.ym.tencent.com/tsr/promotion/banner-promotion.png',
time: 1000 * 60 * 60 * 20,
showBannerDesc: true,
statusTag: 'running',
};
}

View File

@ -1,60 +0,0 @@
import { getGoodsList } from './goods';
/**
* @param {number} sort
* @param {number} pageNum
* @param {number} pageSize
* @param {number} minPrice
* @param {number} maxPrice
* @param {string} keyword
*/
export function getSearchHistory() {
return {
historyWords: [
'鸡',
'电脑',
'iPhone12',
'车载手机支架',
'自然堂',
'小米10',
'原浆古井贡酒',
'欧米伽',
'华为',
'针织半身裙',
'氢跑鞋',
'三盒处理器',
],
};
}
export function getSearchPopular() {
return {
popularWords: [
'鸡',
'电脑',
'iPhone12',
'车载手机支架',
'自然堂',
'小米10',
'原浆古井贡酒',
'欧米伽',
'华为',
'针织半身裙',
'氢跑鞋',
'三盒处理器',
],
};
}
export function getSearchResult() {
return {
saasId: null,
storeId: null,
pageNum: 1,
pageSize: 30,
totalCount: 1,
spuList: getGoodsList(7),
algId: 0,
};
}

View File

@ -1,58 +0,0 @@
export function getGoods() {
return {
goods: [
{
squid: '1',
checkItems: [
{
name: '匿名评价',
value: 'anonymous',
checked: false,
},
],
detail: {
image:
'https://wx.qlogo.cn/mmopen/vi_32/51VSMNuy1CyHiaAhAjLJ00kMZVqqnCqXeZduCLXHUBr52zFHRGxwL7kGia3fHj8GSNzFcqFDInQmRGM1eWjtQgqA/132',
title: '',
},
goodComment: {
/** 商品评价 */
rate: 0,
/** 评价内容 */
label: '123',
/** 上传图片 */
images: [],
},
},
{
squid: '2',
checkItems: [
{
name: '匿名评价',
value: 'anonymous',
checked: false,
},
],
detail: {
image:
'https://wx.qlogo.cn/mmopen/vi_32/51VSMNuy1CyHiaAhAjLJ00kMZVqqnCqXeZduCLXHUBr52zFHRGxwL7kGia3fHj8GSNzFcqFDInQmRGM1eWjtQgqA/132',
title: '评价内容 山姆智利进口',
},
goodComment: {
/** 商品评价 */
rate: 0,
/** 评价内容 */
label: '山姆智利进口',
/** 上传图片 */
images: [],
},
},
],
storeComment: {
/** 物流评价 */
logisticsRate: 0,
/** 服务评价 */
servicesRate: 0,
},
};
}

View File

@ -1,5 +1,5 @@
const images = [{ const images = [{
img: '/images/use_btn.jpg', img: 'https://webplus-cn-hangzhou-s-603871eef968dd14ced82ed5.oss-cn-hangzhou.aliyuncs.com/hextech/static/use_btn.jpg',
text: '1', text: '1',
}, },
{ {

View File

@ -1,52 +0,0 @@
const userInfo = {
avatarUrl:
'https://we-retail-static-1300977798.cos.ap-guangzhou.myqcloud.com/retail-ui/components-exp/avatar/avatar-1.jpg',
nickName: 'TDesign 🌟',
phoneNumber: '13438358888',
gender: 2,
};
const countsData = [
{
num: 2,
name: '积分',
type: 'point',
},
{
num: 10,
name: '优惠券',
type: 'coupon',
},
];
const orderTagInfos = [
{
orderNum: 1,
tabType: 5,
},
{
orderNum: 1,
tabType: 10,
},
{
orderNum: 1,
tabType: 40,
},
{
orderNum: 0,
tabType: 0,
},
];
const customerServiceInfo = {
servicePhone: '4006336868',
serviceTimeDuration: '每周三至周五 9:00-12:00 13:00-15:00',
};
export const genSimpleUserInfo = () => ({ ...userInfo });
export const genUsercenter = () => ({
userInfo,
countsData,
orderTagInfos,
customerServiceInfo,
});

View File

@ -1,59 +0,0 @@
Component({
options: {
addGlobalClass: true,
},
/**
* 组件的属性列表
*/
properties: {
isAllSelected: {
type: Boolean,
value: false,
},
totalAmount: {
type: Number,
value: 1,
},
totalGoodsNum: {
type: Number,
value: 0,
observer(num) {
const isDisabled = num == 0;
setTimeout(() => {
this.setData({
isDisabled,
});
});
},
},
totalDiscountAmount: {
type: Number,
value: 0,
},
bottomHeight: {
type: Number,
value: 100,
},
fixed: Boolean,
},
data: {
isDisabled: false,
},
methods: {
handleSelectAll() {
const { isAllSelected } = this.data;
this.setData({
isAllSelected: !isAllSelected,
});
this.triggerEvent('handleSelectAll', {
isAllSelected: isAllSelected,
});
},
handleToSettle() {
if (this.data.isDisabled) return;
this.triggerEvent('handleToSettle');
},
},
});

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"price": "/components/price/index",
"t-icon": "tdesign-miniprogram/icon/icon"
}
}

View File

@ -1,31 +0,0 @@
<view class="cart-bar__placeholder" wx:if="{{fixed}}" />
<view class="cart-bar {{fixed ? 'cart-bar--fixed' : ''}} flex flex-v-center" style="bottom: {{fixed ? 'calc(' + bottomHeight + 'rpx + env(safe-area-inset-bottom))' : ''}};">
<t-icon
size="40rpx"
color="{{isAllSelected ? '#FA4126' : '#BBBBBB'}}"
name="{{isAllSelected ? 'check-circle-filled' : 'circle'}}"
class="cart-bar__check"
catchtap="handleSelectAll"
/>
<text>全选</text>
<view class="cart-bar__total flex1">
<view>
<text class="cart-bar__total--bold text-padding-right">总计</text>
<price
price="{{totalAmount || '0'}}"
fill="{{false}}"
decimalSmaller
class="cart-bar__total--bold cart-bar__total--price"
/>
<text class="cart-bar__total--normal">(不含运费)</text>
</view>
<view wx:if="{{totalDiscountAmount}}">
<text class="cart-bar__total--normal text-padding-right">已优惠</text>
<price class="cart-bar__total--normal" price="{{totalDiscountAmount || '0'}}" fill="{{false}}" />
</view>
</view>
<view catchtap="handleToSettle" class="{{!isDisabled ? '' : 'disabled-btn'}} account-btn" hover-class="{{!isDisabled ? '' : 'hover-btn'}}">
去结算({{totalGoodsNum}})
</view>
</view>

View File

@ -1,80 +0,0 @@
.cart-bar__placeholder {
height: 100rpx;
}
.flex {
display: flex;
}
.flex-v-center {
align-items: center;
}
.flex1 {
flex: 1;
}
.algin-bottom {
text-align: end;
}
.cart-bar--fixed {
position: fixed;
left: 0;
right: 0;
z-index: 99;
bottom: calc(100rpx + env(safe-area-inset-bottom));
}
.cart-bar {
height: 112rpx;
background-color: #fff;
border-top: 1rpx solid #e5e5e5;
padding: 16rpx 32rpx;
box-sizing: border-box;
font-size: 24rpx;
line-height: 36rpx;
color: #333;
}
.cart-bar .cart-bar__check {
margin-right: 12rpx;
}
.cart-bar .cart-bar__total {
margin-left: 24rpx;
}
.cart-bar .account-btn {
width: 192rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #fa4126;
font-size: 28rpx;
font-weight: bold;
line-height: 80rpx;
color: #ffffff;
text-align: center;
}
.cart-bar .disabled-btn {
background-color: #cccccc !important;
}
.cart-bar .hover-btn {
opacity: 0.5;
}
.cart-bar__total .cart-bar__total--bold {
font-size: 28rpx;
line-height: 40rpx;
color: #333;
font-weight: bold;
}
.cart-bar__total .cart-bar__total--normal {
font-size: 24rpx;
line-height: 32rpx;
color: #999;
}
.cart-bar__total .cart-bar__total--price {
color: #fa4126;
font-weight: bold;
}
.text-padding-right {
padding-right: 4rpx;
}

View File

@ -1,23 +0,0 @@
Component({
properties: {
imgUrl: {
type: String,
value:
'https://cdn-we-retail.ym.tencent.com/miniapp/template/empty-cart.png',
},
tip: {
type: String,
value: '购物车是空的',
},
btnText: {
type: String,
value: '去首页',
},
},
data: {},
methods: {
handleClick() {
this.triggerEvent('handleClick');
},
},
});

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"t-image": "/components/webp-image/index"
}
}

View File

@ -1,6 +0,0 @@
<view class="cart-empty">
<t-image t-class="cart-img" src="{{imgUrl}}" />
<view class="tip">{{tip}}</view>
<view class="btn" bind:tap="handleClick">{{btnText}}</view>
</view>

View File

@ -1,33 +0,0 @@
.cart-empty {
padding: 64rpx 0rpx;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
height: calc(100vh - 100rpx);
background-color: #f5f5f5;
}
.cart-empty .cart-img {
width: 160rpx;
height: 160rpx;
margin-bottom: 24rpx;
}
.cart-empty .tip {
font-size: 28rpx;
line-height: 40rpx;
color: #999;
margin-bottom: 24rpx;
}
.cart-empty .btn {
width: 240rpx;
height: 72rpx;
border-radius: 36rpx;
text-align: center;
line-height: 72rpx;
border: 2rpx solid #fa4126;
color: #fa4126;
background-color: transparent;
font-size: 28rpx;
font-weight: bold;
}

View File

@ -1,166 +0,0 @@
import Toast from 'tdesign-miniprogram/toast/index';
const shortageImg =
'https://cdn-we-retail.ym.tencent.com/miniapp/cart/shortage.png';
Component({
isSpecsTap: false, // 标记本次点击事件是否因为点击specs触发由于底层goods-card组件没有catch specs点击事件只能在此处加状态来避免点击specs时触发跳转商品详情
externalClasses: ['wr-class'],
properties: {
storeGoods: {
type: Array,
observer(storeGoods) {
for (const store of storeGoods) {
for (const activity of store.promotionGoodsList) {
for (const goods of activity.goodsPromotionList) {
goods.specs = goods.specInfo.map((item) => item.specValue); // 目前仅展示商品已选规格的值
}
}
for (const goods of store.shortageGoodsList) {
goods.specs = goods.specInfo.map((item) => item.specValue); // 目前仅展示商品已选规格的值
}
}
this.setData({ _storeGoods: storeGoods });
},
},
invalidGoodItems: {
type: Array,
observer(invalidGoodItems) {
invalidGoodItems.forEach((goods) => {
goods.specs = goods.specInfo.map((item) => item.specValue); // 目前仅展示商品已选规格的值
});
this.setData({ _invalidGoodItems: invalidGoodItems });
},
},
thumbWidth: { type: null },
thumbHeight: { type: null },
},
data: {
shortageImg,
isShowSpecs: false,
currentGoods: {},
isShowToggle: false,
_storeGoods: [],
_invalidGoodItems: [],
},
methods: {
// 删除商品
deleteGoods(e) {
const { goods } = e.currentTarget.dataset;
this.triggerEvent('delete', { goods });
},
// 清空失效商品
clearInvalidGoods() {
this.triggerEvent('clearinvalidgoods');
},
// 选中商品
selectGoods(e) {
const { goods } = e.currentTarget.dataset;
this.triggerEvent('selectgoods', {
goods,
isSelected: !goods.isSelected,
});
},
changeQuantity(num, goods) {
this.triggerEvent('changequantity', {
goods,
quantity: num,
});
},
changeStepper(e) {
const { value } = e.detail;
const { goods } = e.currentTarget.dataset;
let num = value;
if (value > goods.stack) {
num = goods.stack;
}
this.changeQuantity(num, goods);
},
input(e) {
const { value } = e.detail;
const { goods } = e.currentTarget.dataset;
const num = value;
this.changeQuantity(num, goods);
},
overlimit(e) {
const text =
e.detail.type === 'minus'
? '该商品数量不能减少了哦'
: '同一商品最多购买999件';
Toast({
context: this,
selector: '#t-toast',
message: text,
});
},
// 去凑单/再逛逛
gotoBuyMore(e) {
const { promotion, storeId = '' } = e.currentTarget.dataset;
this.triggerEvent('gocollect', { promotion, storeId });
},
// 选中门店
selectStore(e) {
const { storeIndex } = e.currentTarget.dataset;
const store = this.data.storeGoods[storeIndex];
const isSelected = !store.isSelected;
if (store.storeStockShortage && isSelected) {
Toast({
context: this,
selector: '#t-toast',
message: '部分商品库存不足',
});
return;
}
this.triggerEvent('selectstore', {
store,
isSelected,
});
},
// 展开/收起切换
showToggle() {
this.setData({
isShowToggle: !this.data.isShowToggle,
});
},
// 展示规格popup
specsTap(e) {
this.isSpecsTap = true;
const { goods } = e.currentTarget.dataset;
this.setData({
isShowSpecs: true,
currentGoods: goods,
});
},
hideSpecsPopup() {
this.setData({
isShowSpecs: false,
});
},
goGoodsDetail(e) {
if (this.isSpecsTap) {
this.isSpecsTap = false;
return;
}
const { goods } = e.currentTarget.dataset;
this.triggerEvent('goodsclick', { goods });
},
gotoCoupons() {
wx.navigateTo({ url: '/pages/coupon/coupon-list/index' });
},
},
});

View File

@ -1,11 +0,0 @@
{
"component": true,
"usingComponents": {
"t-toast": "tdesign-miniprogram/toast/toast",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-stepper": "tdesign-miniprogram/stepper/stepper",
"swipeout": "/components/swipeout/index",
"goods-card": "../../components/goods-card/index",
"specs-popup": "../../components/specs-popup/index"
}
}

View File

@ -1,185 +0,0 @@
<wxs module="handlePromotion">
var hasPromotion = function (code) {
return code && code !== 'EMPTY_PROMOTION';
}
module.exports.hasPromotion = hasPromotion;
</wxs>
<wxs src="./utils.wxs" module="utils" />
<view class="cart-group">
<view
class="goods-wrap"
wx:for="{{_storeGoods}}"
wx:for-item="store"
wx:for-index="si"
wx:key="storeId"
>
<view class="cart-store">
<t-icon
size="40rpx"
color="{{store.isSelected ? '#FA4126' : '#BBBBBB'}}"
name="{{store.isSelected ? 'check-circle-filled' : 'circle'}}"
class="cart-store__check"
bindtap="selectStore"
data-store-index="{{si}}"
/>
<view class="cart-store__content">
<view class="store-title">
<t-icon
prefix="wr"
size="40rpx"
color="#333333"
name="store"
/>
<view class="store-name">{{store.storeName}}</view>
</view>
<view class="get-coupon" catch:tap="gotoCoupons">优惠券</view>
</view>
</view>
<block
wx:for="{{store.promotionGoodsList}}"
wx:for-item="promotion"
wx:for-index="promoindex"
wx:key="promoindex"
>
<view
class="promotion-wrap"
wx:if="{{handlePromotion.hasPromotion(promotion.promotionCode)}}"
bindtap="gotoBuyMore"
data-promotion="{{promotion}}"
data-store-id="{{store.storeId}}"
>
<view class="promotion-title">
<view class="promotion-icon">{{promotion.tag}}</view>
<view class="promotion-text">{{promotion.description}}</view>
</view>
<view class="promotion-action action-btn" hover-class="action-btn--active">
<view class="promotion-action-label">
{{promotion.isNeedAddOnShop == 1 ? '去凑单' : '再逛逛'}}
</view>
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
</view>
</view>
<view
class="goods-item"
wx:for="{{promotion.goodsPromotionList}}"
wx:for-item="goods"
wx:for-index="gi"
wx:key="extKey"
>
<swipeout right-width="{{ 72 }}">
<view class="goods-item-info">
<view class="check-wrap" catchtap="selectGoods" data-goods="{{goods}}">
<t-icon
size="40rpx"
color="{{goods.isSelected ? '#FA4126' : '#BBBBBB'}}"
name="{{goods.isSelected ? 'check-circle-filled' : 'circle'}}"
class="check"
/>
</view>
<view class="goods-sku-info">
<goods-card
layout="horizontal-wrap"
thumb-width="{{thumbWidth}}"
thumb-height="{{thumbHeight}}"
centered="{{true}}"
data="{{goods}}"
data-goods="{{goods}}"
catchspecs="specsTap"
catchclick="goGoodsDetail"
>
<view slot="thumb-cover" class="stock-mask" wx:if="{{goods.shortageStock || goods.stockQuantity <= 3}}">
仅剩{{goods.stockQuantity}}件
</view>
<view slot="append-body" class="goods-stepper">
<view class="stepper-tip" wx:if="{{goods.shortageStock}}">库存不足</view>
<t-stepper
classname="stepper-info"
value="{{goods.quantity}}"
min="{{1}}"
max="{{999}}"
data-goods="{{goods}}"
data-gi="{{gi}}"
data-si="{{si}}"
catchchange="changeStepper"
catchblur="input"
catchoverlimit="overlimit"
theme="grey"
/>
</view>
</goods-card>
</view>
</view>
<view
slot="right"
class="swiper-right-del"
bindtap="deleteGoods"
data-goods="{{goods}}"
>
删除
</view>
</swipeout>
</view>
<view class="promotion-line-wrap" wx:if="{{handlePromotion.hasPromotion(promotion.promotionCode) && promoindex != (store.promotionGoodsList.length - 2)}}">
<view class="promotion-line" />
</view>
</block>
<block wx:if="{{store.shortageGoodsList.length>0}}">
<view
class="goods-item"
wx:for="{{store.shortageGoodsList}}"
wx:for-item="goods"
wx:for-index="gi"
wx:key="extKey"
>
<swipeout right-width="{{ 72 }}">
<view class="goods-item-info">
<view class="check-wrap">
<view class="unCheck-icon" />
</view>
<view class="goods-sku-info">
<goods-card
layout="horizontal-wrap"
thumb-width="{{thumbWidth}}"
thumb-height="{{thumbHeight}}"
centered="{{true}}"
data="{{goods}}"
data-goods="{{goods}}"
catchspecs="specsTap"
catchclick="goGoodsDetail"
>
<view slot="thumb-cover" class="no-storage-mask" wx:if="{{goods.stockQuantity <=0}}">
<view class="no-storage-content">无货</view>
</view>
</goods-card>
</view>
</view>
<view
slot="right"
class="swiper-right-del"
bindtap="deleteGoods"
data-goods="{{goods}}"
>
删除
</view>
</swipeout>
</view>
<view class="promotion-line-wrap" wx:if="{{handlePromotion.hasPromotion(promotion.promotionCode) && promoindex != (store.promotionGoodsList.length - 2)}}">
<view class="promotion-line" />
</view>
</block>
</view>
</view>
<specs-popup
show="{{isShowSpecs}}"
title="{{currentGoods.title || ''}}"
price="{{currentGoods.price || ''}}"
thumb="{{utils.imgCut(currentGoods.thumb, 180, 180)}}"
specs="{{currentGoods.specs || []}}"
zIndex="{{999}}"
bindclose='hideSpecsPopup'
/>
<t-toast id="t-toast" />

View File

@ -1,335 +0,0 @@
.cart-group {
border-radius: 8rpx;
}
.cart-group .goods-wrap {
margin-top: 40rpx;
background-color: #fff;
border-radius: 8rpx;
overflow: hidden;
}
.cart-group .goods-wrap:first-of-type {
margin-top: 0;
}
.cart-group .cart-store {
height: 96rpx;
background-color: #fff;
box-sizing: border-box;
display: flex;
align-items: center;
padding: 0rpx 24rpx 0rpx 36rpx;
}
.cart-group .cart-store .cart-store__check {
padding: 28rpx 32rpx 28rpx 0rpx;
}
.cart-group .cart-store__content {
box-sizing: border-box;
flex: auto;
display: flex;
align-items: center;
justify-content: space-between;
}
.cart-group .cart-store__content .store-title {
flex: auto;
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
display: flex;
align-items: center;
font-weight: bold;
overflow: hidden;
}
.cart-group .cart-store__content .store-title .wr-store {
font-size: 32rpx;
}
.cart-group .cart-store__content .store-title .store-name {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-left: 12rpx;
}
.cart-group .cart-store__content .get-coupon {
width: 112rpx;
height: 40rpx;
border-radius: 20rpx;
background-color: #ffecf9;
line-height: 40rpx;
text-align: center;
font-size: 26rpx;
color: #fa4126;
}
.cart-group .promotion-wrap {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0rpx 24rpx 32rpx 36rpx;
background-color: #ffffff;
font-size: 24rpx;
line-height: 36rpx;
color: #222427;
}
.cart-group .promotion-wrap .promotion-title {
font-weight: bold;
flex: auto;
overflow: hidden;
margin-right: 20rpx;
display: flex;
align-items: center;
}
.cart-group .promotion-wrap .promotion-title .promotion-icon {
flex: none;
font-weight: normal;
display: inline-block;
padding: 0 8rpx;
color: #ffffff;
background: #fa4126;
font-size: 20rpx;
height: 32rpx;
line-height: 32rpx;
margin-right: 16rpx;
border-radius: 16rpx;
}
.cart-group .promotion-wrap .promotion-title .promotion-text {
flex: auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.cart-group .promotion-wrap .promotion-action {
flex: none;
color: #333333;
}
.cart-group .promotion-line-wrap {
background-color: #fff;
height: 2rpx;
display: flex;
justify-content: flex-end;
}
.cart-group .promotion-line-wrap .promotion-line {
width: 684rpx;
height: 2rpx;
background-color: #e6e6e6;
}
.cart-group .goods-item-info {
display: flex;
background-color: #fff;
align-items: flex-start;
}
.cart-group .goods-item-info .check-wrap {
margin-top: 56rpx;
padding: 20rpx 28rpx 20rpx 36rpx;
}
.cart-group .goods-item-info .check-wrap .unCheck-icon {
box-sizing: border-box;
width: 36rpx;
height: 36rpx;
border-radius: 20rpx;
background: #f5f5f5;
border: 2rpx solid #bbbbbb;
}
.cart-group .goods-item-info .goods-sku-info {
padding: 0rpx 32rpx 40rpx 0;
flex-grow: 1;
}
.cart-group .goods-item-info .goods-sku-info .stock-mask {
position: absolute;
color: #fff;
font-size: 24rpx;
bottom: 0rpx;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
height: 40rpx;
line-height: 40rpx;
text-align: center;
}
.cart-group .goods-item-info .goods-sku-info .goods-stepper {
position: absolute;
right: 0;
bottom: 8rpx;
}
.cart-group .goods-item-info .goods-sku-info .goods-stepper .stepper-tip {
position: absolute;
top: -36rpx;
right: 0;
height: 28rpx;
color: #ff2525;
font-size: 20rpx;
line-height: 28rpx;
}
.cart-group .shortage-line {
width: 662rpx;
height: 2rpx;
background-color: #e6e6e6;
margin: 0 auto;
}
.cart-group .shortage-goods-wrap {
background-color: #fff;
}
.cart-group .shortage-goods-wrap .shortage-tip-title {
height: 72rpx;
line-height: 72rpx;
padding-left: 28rpx;
font-size: 24rpx;
color: #999;
}
.stepper-info {
margin-left: auto;
}
.invalid-goods-wrap {
background-color: #fff;
border-radius: 8rpx;
margin-top: 40rpx;
}
.invalid-goods-wrap .invalid-head {
display: flex;
justify-content: space-between;
padding: 30rpx 20rpx;
font-size: 24rpx;
border-bottom: 2rpx solid #f6f6f6;
}
.invalid-goods-wrap .invalid-head .invalid-title {
color: #333;
font-size: 28rpx;
font-weight: 600;
}
.invalid-goods-wrap .invalid-head .invalid-clear {
color: #fa4126;
}
.invalid-goods-wrap .toggle {
display: flex;
height: 80rpx;
justify-content: center;
align-items: center;
font-size: 24rpx;
color: #fa4126;
}
.invalid-goods-wrap .toggle .m-r-6 {
margin-right: 6rpx;
}
.invalid-goods-wrap .toggle .top-icon {
display: inline-block;
width: 0;
height: 0;
border-left: 10rpx solid transparent;
border-right: 10rpx solid transparent;
border-bottom: 10rpx solid #fa4126;
}
.invalid-goods-wrap .toggle .down-icon {
display: inline-block;
width: 0;
height: 0;
border-left: 10rpx solid transparent;
border-right: 10rpx solid transparent;
border-top: 10rpx solid #fa4126;
}
.action-btn {
display: flex;
align-items: center;
}
.action-btn .action-btn-arrow {
font-size: 20rpx;
margin-left: 8rpx;
}
.action-btn--active {
opacity: 0.5;
}
.swiper-right-del {
height: calc(100% - 40rpx);
width: 144rpx;
background-color: #fa4126;
font-size: 28rpx;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.goods-stepper .stepper {
border: none;
border-radius: 0;
height: auto;
width: 168rpx;
overflow: visible;
}
.goods-stepper .stepper .stepper__minus,
.goods-stepper .stepper .stepper__plus {
width: 44rpx;
height: 44rpx;
background-color: #f5f5f5;
}
.goods-stepper .stepper .stepper__minus--hover,
.goods-stepper .stepper .stepper__plus--hover {
background-color: #f5f5f5;
}
.goods-stepper .stepper .stepper__minus .wr-icon,
.goods-stepper .stepper .stepper__plus .wr-icon {
font-size: 24rpx;
}
.goods-stepper .stepper .stepper__minus {
position: relative;
}
.goods-stepper .stepper .stepper__minus::after {
position: absolute;
display: block;
content: ' ';
left: -20rpx;
right: -5rpx;
top: -20rpx;
bottom: -20rpx;
background-color: transparent;
}
.goods-stepper .stepper .stepper__plus {
position: relative;
}
.goods-stepper .stepper .stepper__plus::after {
position: absolute;
display: block;
content: ' ';
left: -5rpx;
right: -20rpx;
top: -20rpx;
bottom: -20rpx;
background-color: transparent;
}
.goods-stepper .stepper .stepper__input {
width: 72rpx;
height: 44rpx;
background-color: #f5f5f5;
font-size: 24rpx;
color: #222427;
font-weight: 600;
border-left: none;
border-right: none;
min-height: 40rpx;
margin: 0 4rpx;
display: flex;
align-items: center;
}
.goods-sku-info .no-storage-mask {
position: absolute;
color: #fff;
bottom: 0rpx;
left: 0rpx;
background-color: rgba(0, 0, 0, 0.1);
height: 192rpx;
width: 192rpx;
border-radius: 8rpx;
display: flex;
justify-content: center;
align-items: center;
}
.no-storage-mask .no-storage-content {
width: 128rpx;
height: 128rpx;
border-radius: 64rpx;
background-color: rgba(0, 0, 0, 0.4);
text-align: center;
line-height: 128rpx;
font-size: 28rpx;
}

View File

@ -1,20 +0,0 @@
module.exports.slice = function(arr) {
return arr.slice(0, 2);
};
module.exports.imgCut = function(url, width, height) {
if (url && (url.slice(0, 5) === 'http:' || url.slice(0, 6) === 'https:' || url.slice(0, 2) === '//')) {
var argsStr = 'imageMogr2/thumbnail/!' + width + 'x' + height + 'r';
if (url.indexOf('?') > -1) {
url = url + '&' + argsStr;
} else {
url = url + '?' + argsStr;
}
if (url.slice(0, 5) === 'http:') {
url = 'https://' + url.slice(5)
}
if (url.slice(0, 2) === '//') {
url = 'https:' + url
}
}
return url;
};

View File

@ -1,243 +0,0 @@
Component({
options: {
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
addGlobalClass: true,
},
intersectionObserverContext: null,
externalClasses: [
'card-class',
'title-class',
'desc-class',
'num-class',
'thumb-class',
'specs-class',
'price-class',
'origin-price-class',
'price-prefix-class',
],
properties: {
hidden: {
// 设置为null代表不做类型转换
type: null,
value: false,
observer(hidden) {
// null就是代表没有设置没有设置的话不setData防止祖先组件触发的setHidden操作被覆盖
if (hidden !== null) {
this.setHidden(!!hidden);
}
},
},
id: {
type: String,
// `goods-card-88888888`
// 不能在这里写生成逻辑如果在这里写那么假设有多个goods-list时他们将共享这个值
value: '',
observer: (id) => {
this.genIndependentID(id);
if (this.properties.thresholds?.length) {
this.createIntersectionObserverHandle();
}
},
},
data: {
type: Object,
observer(goods) {
// 有ID的商品才渲染
if (!goods) {
return;
}
/** 划线价是否有效 */
let isValidityLinePrice = true;
// 判断一次划线价格是否合理
if (
goods.originPrice &&
goods.price &&
goods.originPrice < goods.price
) {
isValidityLinePrice = false;
}
// 敲定换行数量默认值
if (goods.lineClamp === undefined || goods.lineClamp <= 0) {
// tag数组长度 大于0 且 可见
// 指定换行为1行
if ((goods.tags?.length || 0) > 0 && !goods.hideKey?.tags) {
goods.lineClamp = 1;
} else {
goods.lineClamp = 2;
}
}
this.setData({ goods, isValidityLinePrice });
},
},
layout: {
type: String,
value: 'horizontal',
},
thumbMode: {
type: String,
value: 'aspectFill',
},
priceFill: {
type: Boolean,
value: true,
},
currency: {
type: String,
value: '¥',
},
lazyLoad: {
type: Boolean,
value: false,
},
centered: {
type: Boolean,
value: false,
},
pricePrefix: {
type: String,
value: '',
},
/** 元素可见监控阈值, 数组长度大于0就创建 */
thresholds: {
type: Array,
value: [],
observer(current) {
if (current && current.length) {
this.createIntersectionObserverHandle();
} else {
this.clearIntersectionObserverHandle();
}
},
},
specsIconClassPrefix: {
type: String,
value: 'wr',
},
specsIcon: {
type: String,
value: 'expand_more',
},
addCartIconClassPrefix: {
type: String,
value: 'wr',
},
addCartIcon: {
type: String,
value: 'cart',
},
},
data: {
hiddenInData: false,
independentID: '',
goods: { id: '' },
/** 保证划线价格不小于原价,否则不渲染划线价 */
isValidityLinePrice: false,
},
lifetimes: {
ready() {
this.init();
},
detached() {
this.clear();
},
},
methods: {
clickHandle() {
this.triggerEvent('click', { goods: this.data.goods });
},
clickThumbHandle() {
this.triggerEvent('thumb', { goods: this.data.goods });
},
clickSpecsHandle() {
this.triggerEvent('specs', { goods: this.data.goods });
},
clickTagHandle(evt) {
const { index } = evt.currentTarget.dataset;
this.triggerEvent('tag', { goods: this.data.goods, index });
},
// 加入购物车
addCartHandle(e) {
const { id } = e.currentTarget;
const { id: cardID } = e.currentTarget.dataset;
this.triggerEvent('add-cart', {
...e.detail,
id,
cardID,
goods: this.data.goods,
});
},
genIndependentID(id, cb) {
let independentID;
if (id) {
independentID = id;
} else {
independentID = `goods-card-${~~(Math.random() * 10 ** 8)}`;
}
this.setData({ independentID }, cb);
},
init() {
const { thresholds, id, hidden } = this.properties;
if (hidden !== null) {
this.setHidden(!!hidden);
}
this.genIndependentID(id || '', () => {
if (thresholds && thresholds.length) {
this.createIntersectionObserverHandle();
}
});
},
clear() {
this.clearIntersectionObserverHandle();
},
setHidden(hidden) {
this.setData({ hiddenInData: !!hidden });
},
createIntersectionObserverHandle() {
if (this.intersectionObserverContext || !this.data.independentID) {
return;
}
this.intersectionObserverContext = wx
.createIntersectionObserver(this, {
thresholds: this.properties.thresholds,
})
.relativeToViewport();
this.intersectionObserverContext.observe(
`#${this.data.independentID}`,
(res) => {
this.intersectionObserverCB(res);
},
);
},
intersectionObserverCB(ob) {
this.triggerEvent('ob', {
goods: this.data.goods,
context: this.intersectionObserverContext,
ob,
});
},
clearIntersectionObserverHandle() {
if (this.intersectionObserverContext) {
try {
this.intersectionObserverContext.disconnect();
} catch (e) {}
this.intersectionObserverContext = null;
}
},
},
});

View File

@ -1,9 +0,0 @@
{
"component": true,
"usingComponents": {
"price": "/components/price/index",
"t-tag": "tdesign-miniprogram/tag/tag",
"t-image": "/components/webp-image/index",
"t-icon": "tdesign-miniprogram/icon/icon"
}
}

View File

@ -1,75 +0,0 @@
<view
id="{{independentID}}"
class="wr-goods-card card-class {{ layout }} {{ centered ? 'center' : ''}}"
bind:tap="clickHandle"
data-goods="{{ goods }}"
hidden="{{hiddenInData}}"
>
<view class="wr-goods-card__main">
<view class="wr-goods-card__thumb thumb-class" bind:tap="clickThumbHandle">
<!-- data-src 是方便加购动画读取图片用的 -->
<t-image
t-class="wr-goods-card__thumb-com"
wx:if="{{ !!goods.thumb && !goods.hideKey.thumb }}"
src="{{ goods.thumb }}"
mode="{{ thumbMode }}"
lazy-load="{{ lazyLoad }}"
/>
<slot name="thumb-cover" />
</view>
<view class="wr-goods-card__body">
<view class="wr-goods-card__long_content">
<view wx:if="{{ goods.title && !goods.hideKey.title }}" class="wr-goods-card__title title-class" style="-webkit-line-clamp: {{ goods.lineClamp }};">
<slot name="before-title" />
{{ goods.title }}
</view>
<slot name="after-title" />
<view wx:if="{{ goods.desc && !goods.hideKey.desc }}" class="wr-goods-card__desc desc-class">{{ goods.desc }}</view>
<slot name="after-desc" />
<view wx:if="{{ goods.specs && goods.specs.length > 0 && !goods.hideKey.specs }}" class="wr-goods-card__specs__desc specs-class" bind:tap="clickSpecsHandle">
<view class="wr-goods-card__specs__desc-text">{{ goods.specs }}</view>
<t-icon name="chevron-down" size="32rpx" color="#999999" />
</view>
<view class="goods_tips" wx:if="{{goods.stockQuantity !== 0 && goods.quantity >= goods.stockQuantity}}">库存不足</view>
</view>
<view class="wr-goods-card__short_content">
<block wx:if="{{goods.stockQuantity !== 0}}">
<view wx:if="{{ pricePrefix }}" class="wr-goods-card__price__prefix price-prefix-class">{{ pricePrefix }}</view>
<slot name="price-prefix" />
<view wx:if="{{ goods.price && !goods.hideKey.price }}" class="wr-goods-card__price">
<price
wr-class="price-class"
symbol="{{currency}}"
price="{{goods.price}}"
fill="{{priceFill}}"
decimalSmaller
/>
</view>
<view wx:if="{{ goods.originPrice && !goods.hideKey.originPrice && isValidityLinePrice }}" class="wr-goods-card__origin-price">
<price
wr-class="origin-price-class"
symbol="{{currency}}"
price="{{goods.originPrice}}"
fill="{{priceFill}}"
/>
</view>
<slot name="origin-price" />
<view wx:if="{{goods.num && !goods.hideKey.num}}" class="wr-goods-card__num num-class">
<text class="wr-goods-card__num__prefix">x </text>
{{ goods.num }}
</view>
</block>
<block wx:else>
<view class="no_storage">
<view>请重新选择商品规格</view>
<view class="no_storage__right">重选</view>
</view>
</block>
</view>
<slot name="append-body" />
</view>
<slot name="footer" />
</view>
<slot name="append-card" />
</view>

View File

@ -1,260 +0,0 @@
.wr-goods-card {
box-sizing: border-box;
font-size: 24rpx;
}
/* */
.wr-goods-card__main {
position: relative;
display: flex;
padding: 0;
background: transparent;
}
.wr-goods-card.center .wr-goods-card__main {
align-items: flex-start;
justify-content: center;
}
.wr-goods-card__thumb {
flex-shrink: 0;
position: relative;
width: 140rpx;
height: 140rpx;
}
.wr-goods-card__thumb-com {
width: 192rpx;
height: 192rpx;
border-radius: 8rpx;
overflow: hidden;
}
.wr-goods-card__thumb:empty {
display: none;
margin: 0;
}
.wr-goods-card__body {
display: flex;
margin: 0 0 0 20rpx;
flex-direction: row;
flex: 1 1 auto;
min-height: 192rpx;
}
.wr-goods-card__long_content {
display: flex;
flex-direction: column;
overflow: hidden;
flex: 1 1 auto;
}
.wr-goods-card__long_content .goods_tips {
width: 100%;
margin-top: 16rpx;
text-align: right;
color: #fa4126;
font-size: 24rpx;
line-height: 32rpx;
font-weight: bold;
}
.wr-goods-card__title {
flex-shrink: 0;
font-size: 28rpx;
color: #333;
line-height: 40rpx;
font-weight: 400;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-word;
}
.wr-goods-card__title__prefix-tags {
display: inline-flex;
}
.wr-goods-card__title__prefix-tags .prefix-tag {
margin: 0 8rpx 0 0;
}
.wr-goods-card__desc {
font-size: 24rpx;
color: #f5f5f5;
line-height: 40rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.wr-goods-card__specs__desc,
.wr-goods-card__specs__text {
font-size: 24rpx;
height: 32rpx;
line-height: 32rpx;
color: #999999;
margin: 8rpx 0;
}
.wr-goods-card__specs__desc {
display: flex;
align-self: flex-start;
flex-direction: row;
background: #f5f5f5;
border-radius: 8rpx;
padding: 4rpx 8rpx;
}
.wr-goods-card__specs__desc-text {
height: 100%;
max-width: 380rpx;
word-break: break-all;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
}
.wr-goods-card__specs__desc-icon {
line-height: inherit;
margin-left: 8rpx;
font-size: 24rpx;
color: #bbb;
}
.wr-goods-card__specs__text {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
}
.wr-goods-card__tags {
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 16rpx 0 0 0;
}
.wr-goods-card__tag {
color: #fa550f;
background: transparent;
font-size: 20rpx;
border: 1rpx solid #fa550f;
padding: 0 8rpx;
height: 30rpx;
line-height: 30rpx;
margin: 0 8rpx 8rpx 0;
display: block;
overflow: hidden;
white-space: nowrap;
word-break: keep-all;
text-overflow: ellipsis;
}
.wr-goods-card__short_content {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-end;
margin: 0 0 0 46rpx;
}
.wr-goods-card__price__prefix {
order: 0;
color: #666;
margin: 0;
}
.wr-goods-card__price {
white-space: nowrap;
font-weight: bold;
order: 1;
color: #fa4126;
font-size: 36rpx;
margin: 0;
line-height: 48rpx;
}
.wr-goods-card__origin-price {
white-space: nowrap;
font-weight: normal;
order: 2;
color: #aaaaaa;
font-size: 24rpx;
margin: 0;
}
.wr-goods-card__num {
white-space: nowrap;
order: 4;
font-size: 24rpx;
color: #999;
margin: 20rpx 0 0 auto;
}
.wr-goods-card__num__prefix {
color: inherit;
}
.wr-goods-card__add-cart {
order: 3;
margin: auto 0 0 auto;
}
.wr-goods-card.horizontal-wrap .wr-goods-card__thumb {
width: 192rpx;
height: 192rpx;
border-radius: 8rpx;
overflow: hidden;
}
.wr-goods-card.horizontal-wrap .wr-goods-card__body {
flex-direction: column;
}
.wr-goods-card.horizontal-wrap .wr-goods-card__short_content {
flex-direction: row;
align-items: center;
margin: 16rpx 0 0 0;
}
.wr-goods-card.horizontal-wrap .wr-goods-card__num {
margin: 0 0 0 auto;
}
.wr-goods-card.vertical .wr-goods-card__main {
padding: 0 0 22rpx 0;
flex-direction: column;
}
.wr-goods-card.vertical .wr-goods-card__thumb {
width: 340rpx;
height: 340rpx;
}
.wr-goods-card.vertical .wr-goods-card__body {
margin: 20rpx 20rpx 0 20rpx;
flex-direction: column;
}
.wr-goods-card.vertical .wr-goods-card__long_content {
overflow: hidden;
}
.wr-goods-card.vertical .wr-goods-card__title {
line-height: 36rpx;
}
.wr-goods-card.vertical .wr-goods-card__short_content {
margin: 20rpx 0 0 0;
}
.wr-goods-card.vertical .wr-goods-card__price {
order: 2;
color: #fa4126;
margin: 20rpx 0 0 0;
}
.wr-goods-card.vertical .wr-goods-card__origin-price {
order: 1;
}
.wr-goods-card.vertical .wr-goods-card__add-cart {
position: absolute;
bottom: 20rpx;
right: 20rpx;
}
.wr-goods-card__short_content .no_storage {
display: flex;
align-items: center;
justify-content: space-between;
height: 40rpx;
color: #333;
font-size: 24rpx;
line-height: 32rpx;
width: 100%;
}
.no_storage .no_storage__right {
width: 80rpx;
height: 40rpx;
border-radius: 20rpx;
border: 2rpx solid #fa4126;
line-height: 40rpx;
text-align: center;
color: #fa4126;
}

View File

@ -1,72 +0,0 @@
Component({
options: {
addGlobalClass: true,
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
},
properties: {
show: {
type: Boolean,
value: false,
},
value: {
type: String,
value: '',
},
title: {
type: String,
observer(newVal) {
this.setData({ 'goods.title': newVal });
},
},
price: {
type: String,
value: '',
observer(newVal) {
this.setData({ 'goods.price': newVal });
},
},
thumb: {
type: String,
value: '',
observer(newVal) {
this.setData({ 'goods.thumb': newVal });
},
},
thumbMode: {
type: String,
value: 'aspectFit',
},
zIndex: {
type: Number,
value: 99,
},
specs: {
type: Array,
value: [],
},
},
data: {
goods: {
title: '',
thumb: '',
price: '',
hideKey: {
originPrice: true,
tags: true,
specs: true,
num: true,
},
},
},
methods: {
onClose() {
this.triggerEvent('close');
},
onCloseOver() {
this.triggerEvent('closeover');
},
},
});

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"t-popup": "tdesign-miniprogram/popup/popup",
"goods-card": "../../components/goods-card/index"
}
}

View File

@ -1,26 +0,0 @@
<t-popup
close-on-overlay-click="{{true}}"
visible="{{show}}"
placement="bottom"
z-index="{{zIndex}}"
>
<view class="specs-popup">
<view>
<goods-card data="{{goods}}" layout="horizontal-wrap" thumb-mode="{{thumbMode}}" />
<view class="section">
<view class="title">已选规格</view>
<view class="options">
<view
wx:for="{{specs}}"
wx:for-item="spec"
wx:key="spec"
class="option"
>{{spec}}
</view>
</view>
</view>
</view>
<view class="bottom-btn" hover-class="bottom-btn--active" bindtap="onClose">我知道了</view>
</view>
</t-popup>

View File

@ -1,68 +0,0 @@
.specs-popup {
width: 100vw;
box-sizing: border-box;
padding: 32rpx 32rpx calc(20rpx + env(safe-area-inset-bottom)) 32rpx;
max-height: 80vh;
display: flex;
flex-direction: column;
background-color: white;
border-radius: 20rpx 20rpx 0 0;
}
.specs-popup .section {
margin-top: 44rpx;
flex: auto;
overflow-y: scroll;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
.specs-popup .section .title {
font-size: 26rpx;
color: #4f5356;
}
.specs-popup .section .options {
color: #333333;
font-size: 24rpx;
margin-right: -26rpx;
}
.specs-popup .section .options .option {
display: inline-block;
margin-top: 24rpx;
height: 56rpx;
line-height: 56rpx;
padding: 0 16rpx;
border-radius: 8rpx;
background-color: #f5f5f5;
max-width: 100%;
box-sizing: border-box;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.specs-popup .section .options .option:not(:last-child) {
margin-right: 26rpx;
}
.specs-popup .bottom-btn {
margin-top: 42rpx;
position: relative;
height: 80rpx;
line-height: 80rpx;
text-align: center;
background-color: white;
color: #fa4126;
}
.specs-popup .bottom-btn--active {
opacity: 0.5;
}
.specs-popup .bottom-btn::after {
display: block;
content: ' ';
position: absolute;
left: 0;
top: 0;
width: 200%;
height: 200%;
border: 1px solid #fa4126;
border-radius: 80rpx;
transform: scale(0.5);
transform-origin: left top;
}

View File

@ -1,315 +0,0 @@
import Dialog from 'tdesign-miniprogram/dialog/index';
import Toast from 'tdesign-miniprogram/toast/index';
import { fetchCartGroupData } from '../../services/cart/cart';
Page({
data: {
cartGroupData: null,
},
// 调用自定义tabbar的init函数使页面与tabbar激活状态保持一致
onShow() {
this.getTabBar().init();
},
onLoad() {
this.refreshData();
},
refreshData() {
this.getCartGroupData().then((res) => {
let isEmpty = true;
const cartGroupData = res.data;
// 一些组件中需要的字段可能接口并没有返回,或者返回的数据结构与预期不一致,需要在此先对数据做一些处理
// 统计门店下加购的商品是否全选、是否存在缺货/无货
for (const store of cartGroupData.storeGoods) {
store.isSelected = true; // 该门店已加购商品是否全选
store.storeStockShortage = false; // 该门店已加购商品是否存在库存不足
if (!store.shortageGoodsList) {
store.shortageGoodsList = []; // 该门店已加购商品如果库存为0需单独分组
}
for (const activity of store.promotionGoodsList) {
activity.goodsPromotionList = activity.goodsPromotionList.filter(
(goods) => {
goods.originPrice = undefined;
// 统计是否有加购数大于库存数的商品
if (goods.quantity > goods.stockQuantity) {
store.storeStockShortage = true;
}
// 统计是否全选
if (!goods.isSelected) {
store.isSelected = false;
}
// 库存为0无货的商品单独分组
if (goods.stockQuantity > 0) {
return true;
}
store.shortageGoodsList.push(goods);
return false;
},
);
if (activity.goodsPromotionList.length > 0) {
isEmpty = false;
}
}
if (store.shortageGoodsList.length > 0) {
isEmpty = false;
}
}
cartGroupData.invalidGoodItems = cartGroupData.invalidGoodItems.map(
(goods) => {
goods.originPrice = undefined;
return goods;
},
);
cartGroupData.isNotEmpty = !isEmpty;
this.setData({ cartGroupData });
});
},
findGoods(spuId, skuId) {
let currentStore;
let currentActivity;
let currentGoods;
const { storeGoods } = this.data.cartGroupData;
for (const store of storeGoods) {
for (const activity of store.promotionGoodsList) {
for (const goods of activity.goodsPromotionList) {
if (goods.spuId === spuId && goods.skuId === skuId) {
currentStore = store;
currentActivity = currentActivity;
currentGoods = goods;
return {
currentStore,
currentActivity,
currentGoods,
};
}
}
}
}
return {
currentStore,
currentActivity,
currentGoods,
};
},
// 注:实际场景时应该调用接口获取购物车数据
getCartGroupData() {
const { cartGroupData } = this.data;
if (!cartGroupData) {
return fetchCartGroupData();
}
return Promise.resolve({ data: cartGroupData });
},
// 选择单个商品
// 注:实际场景时应该调用接口更改选中状态
selectGoodsService({ spuId, skuId, isSelected }) {
this.findGoods(spuId, skuId).currentGoods.isSelected = isSelected;
return Promise.resolve();
},
// 全选门店
// 注:实际场景时应该调用接口更改选中状态
selectStoreService({ storeId, isSelected }) {
const currentStore = this.data.cartGroupData.storeGoods.find(
(s) => s.storeId === storeId,
);
currentStore.isSelected = isSelected;
currentStore.promotionGoodsList.forEach((activity) => {
activity.goodsPromotionList.forEach((goods) => {
goods.isSelected = isSelected;
});
});
return Promise.resolve();
},
// 加购数量变更
// 注:实际场景时应该调用接口
changeQuantityService({ spuId, skuId, quantity }) {
this.findGoods(spuId, skuId).currentGoods.quantity = quantity;
return Promise.resolve();
},
// 删除加购商品
// 注:实际场景时应该调用接口
deleteGoodsService({ spuId, skuId }) {
function deleteGoods(group) {
for (const gindex in group) {
const goods = group[gindex];
if (goods.spuId === spuId && goods.skuId === skuId) {
group.splice(gindex, 1);
return gindex;
}
}
return -1;
}
const { storeGoods, invalidGoodItems } = this.data.cartGroupData;
for (const store of storeGoods) {
for (const activity of store.promotionGoodsList) {
if (deleteGoods(activity.goodsPromotionList) > -1) {
return Promise.resolve();
}
}
if (deleteGoods(store.shortageGoodsList) > -1) {
return Promise.resolve();
}
}
if (deleteGoods(invalidGoodItems) > -1) {
return Promise.resolve();
}
return Promise.reject();
},
// 清空失效商品
// 注:实际场景时应该调用接口
clearInvalidGoodsService() {
this.data.cartGroupData.invalidGoodItems = [];
return Promise.resolve();
},
onGoodsSelect(e) {
const {
goods: { spuId, skuId },
isSelected,
} = e.detail;
const { currentGoods } = this.findGoods(spuId, skuId);
Toast({
context: this,
selector: '#t-toast',
message: `${isSelected ? '选择' : '取消'}"${
currentGoods.title.length > 5
? `${currentGoods.title.slice(0, 5)}...`
: currentGoods.title
}"`,
icon: '',
});
this.selectGoodsService({ spuId, skuId, isSelected }).then(() =>
this.refreshData(),
);
},
onStoreSelect(e) {
const {
store: { storeId },
isSelected,
} = e.detail;
this.selectStoreService({ storeId, isSelected }).then(() =>
this.refreshData(),
);
},
onQuantityChange(e) {
const {
goods: { spuId, skuId },
quantity,
} = e.detail;
const { currentGoods } = this.findGoods(spuId, skuId);
const stockQuantity =
currentGoods.stockQuantity > 0 ? currentGoods.stockQuantity : 0; // 避免后端返回的是-1
// 加购数量超过库存数量
if (quantity > stockQuantity) {
// 加购数量等于库存数量的情况下继续加购
if (
currentGoods.quantity === stockQuantity &&
quantity - stockQuantity === 1
) {
Toast({
context: this,
selector: '#t-toast',
message: '当前商品库存不足',
});
return;
}
Dialog.confirm({
title: '商品库存不足',
content: `当前商品库存不足,最大可购买数量为${stockQuantity}`,
confirmBtn: '修改为最大可购买数量',
cancelBtn: '取消',
})
.then(() => {
this.changeQuantityService({
spuId,
skuId,
quantity: stockQuantity,
}).then(() => this.refreshData());
})
.catch(() => {});
return;
}
this.changeQuantityService({ spuId, skuId, quantity }).then(() =>
this.refreshData(),
);
},
goCollect() {
/** 活动肯定有一个活动ID用来获取活动banner活动商品列表等 */
const promotionID = '123';
wx.navigateTo({
url: `/pages/promotion-detail/index?promotion_id=${promotionID}`,
});
},
goGoodsDetail(e) {
const { spuId, storeId } = e.detail.goods;
wx.navigateTo({
url: `/pages/goods/details/index?spuId=${spuId}&storeId=${storeId}`,
});
},
clearInvalidGoods() {
// 实际场景时应该调用接口清空失效商品
this.clearInvalidGoodsService().then(() => this.refreshData());
},
onGoodsDelete(e) {
const {
goods: { spuId, skuId },
} = e.detail;
Dialog.confirm({
content: '确认删除该商品吗?',
confirmBtn: '确定',
cancelBtn: '取消',
}).then(() => {
this.deleteGoodsService({ spuId, skuId }).then(() => {
Toast({ context: this, selector: '#t-toast', message: '商品删除成功' });
this.refreshData();
});
});
},
onSelectAll(event) {
const { isAllSelected } = event?.detail ?? {};
Toast({
context: this,
selector: '#t-toast',
message: `${isAllSelected ? '取消' : '点击'}了全选按钮`,
});
// 调用接口改变全选
},
onToSettle() {
const goodsRequestList = [];
this.data.cartGroupData.storeGoods.forEach((store) => {
store.promotionGoodsList.forEach((promotion) => {
promotion.goodsPromotionList.forEach((m) => {
if (m.isSelected == 1) {
goodsRequestList.push(m);
}
});
});
});
wx.setStorageSync(
'order.goodsRequestList',
JSON.stringify(goodsRequestList),
);
wx.navigateTo({ url: '/pages/order/order-confirm/index?type=cart' });
},
onGotoHome() {
wx.switchTab({ url: '/pages/home/home' });
},
});

View File

@ -1,10 +0,0 @@
{
"navigationBarTitleText": "购物车",
"usingComponents": {
"cart-group": "./components/cart-group/index",
"cart-empty": "./components/cart-empty/index",
"cart-bar": "./components/cart-bar/index",
"t-toast": "tdesign-miniprogram/toast/toast",
"t-dialog": "tdesign-miniprogram/dialog/dialog"
}
}

View File

@ -1,31 +0,0 @@
<!-- 分层购物车 -->
<block wx:if="{{cartGroupData.isNotEmpty}}">
<cart-group
store-goods="{{ cartGroupData.storeGoods }}"
invalid-good-items="{{ cartGroupData.invalidGoodItems }}"
bindselectgoods="onGoodsSelect"
bindselectstore="onStoreSelect"
bindchangequantity="onQuantityChange"
bindgocollect="goCollect"
bindgoodsclick="goGoodsDetail"
bindclearinvalidgoods="clearInvalidGoods"
binddelete="onGoodsDelete"
/>
<view class="gap" />
<!-- 商品小计以及结算按钮 -->
<cart-bar
is-all-selected="{{cartGroupData.isAllSelected}}"
total-amount="{{cartGroupData.totalAmount}}"
total-goods-num="{{cartGroupData.selectedGoodsCount}}"
total-discount-amount="{{cartGroupData.totalDiscountAmount}}"
fixed="{{true}}"
bottomHeight="{{94}}"
bindhandleSelectAll="onSelectAll"
bindhandleToSettle="onToSettle"
/>
</block>
<!-- 购物车空态 -->
<cart-empty wx:else bindbtnclick="onBtnClick" />
<t-toast id="t-toast" />
<t-dialog id="t-dialog" t-class-confirm="add-notes__confirm" />

View File

@ -1,12 +0,0 @@
:host {
padding-bottom: 100rpx;
}
.gap {
height: 100rpx;
width: 100%;
}
.add-notes__confirm {
color: #fa4126 !important;
}

View File

@ -1,57 +0,0 @@
const statusMap = {
default: { text: '去使用', theme: 'primary' },
useless: { text: '已使用', theme: 'default' },
disabled: { text: '已过期', theme: 'default' },
};
Component({
options: {
addGlobalClass: true,
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
},
externalClasses: ['coupon-class'],
properties: {
couponDTO: {
type: Object,
value: {}, // 优惠券数据
},
},
data: {
btnText: '',
btnTheme: '',
},
observers: {
couponDTO: function (couponDTO) {
if (!couponDTO) {
return;
}
const statusInfo = statusMap[couponDTO.status];
this.setData({
btnText: statusInfo.text,
btnTheme: statusInfo.theme,
});
},
},
attached() {},
methods: {
// 跳转到详情页
gotoDetail() {
wx.navigateTo({
url: `/pages/coupon/coupon-detail/index?id=${this.data.couponDTO.key}`,
});
},
// 跳转到商品列表
gotoGoodsList() {
wx.navigateTo({
url: `/pages/coupon/coupon-activity-goods/index?id=${this.data.couponDTO.key}`,
});
},
},
});

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"ui-coupon-card": "../ui-coupon-card/index",
"t-button": "tdesign-miniprogram/button/button"
}
}

View File

@ -1,17 +0,0 @@
<ui-coupon-card
title="{{couponDTO.title || ''}}"
type="{{couponDTO.type || ''}}"
value="{{couponDTO.value || '0'}}"
tag="{{couponDTO.tag || ''}}"
desc="{{couponDTO.desc || ''}}"
currency="{{couponDTO.currency || ''}}"
timeLimit="{{couponDTO.timeLimit || ''}}"
status="{{couponDTO.status || ''}}"
bind:tap="gotoDetail"
>
<view slot="operator" class="coupon-btn-slot">
<t-button t-class="coupon-btn-{{btnTheme}}" theme="{{btnTheme}}" bind:tap="gotoGoodsList">{{btnText}}
</t-button>
</view>
</ui-coupon-card>

View File

@ -1,12 +0,0 @@
.coupon-btn-slot .coupon-btn-primary {
width: 136rpx;
height: 56rpx;
border-radius: 28rpx;
background-color: transparent;
border-color: #fa4126;
color: #fa4126;
}
.coupon-btn-default {
display: none;
}

View File

@ -1,17 +0,0 @@
Component({
data: { icon: 'cart' },
properties: {
count: {
type: Number,
},
},
methods: {
goToCart() {
wx.switchTab({
url: '/pages/cart/index',
});
},
},
});

View File

@ -1,14 +0,0 @@
<view class="floating-button" bind:tap="goToCart">
<view class="floating-inner-container">
<t-icon
prefix="wr"
name="{{icon}}"
size="42rpx"
color="#FFFFFF"
/>
</view>
<view class="floating-right-top">
{{count}}
</view>
</view>

View File

@ -1,30 +0,0 @@
.floating-button {
position: fixed;
right: 20rpx;
bottom: 108rpx;
}
.floating-button .floating-inner-container {
display: flex;
align-items: center;
justify-content: center;
height: 96rpx;
width: 96rpx;
background-color: rgba(0, 0, 0, 0.8);
opacity: 0.7;
border-radius: 48rpx;
}
.floating-button .floating-right-top {
position: absolute;
right: 0rpx;
top: 0rpx;
height: 28rpx;
background: #fa4126;
border-radius: 64rpx;
font-weight: bold;
font-size: 22rpx;
line-height: 28rpx;
color: #fff;
padding: 0 8rpx;
}

View File

@ -1,87 +0,0 @@
Component({
options: {
addGlobalClass: true,
multipleSlots: true,
},
externalClasses: ['coupon-class'],
properties: {
mask: {
type: Boolean,
value: false, // 是否添加遮罩
},
superposable: {
type: Boolean,
value: false, // 是否可叠加
},
type: {
type: String,
value: '', // 优惠券类型CouponType
},
value: {
type: String,
value: '', // 优惠金额
},
tag: {
type: String,
value: '', // 优惠标签优惠券名字标签img
},
desc: {
type: String,
value: '', // 优惠金额描述,金额下方
},
title: {
type: String, // 优惠券名称
value: '',
},
timeLimit: {
type: String, // 优惠券时限
value: '',
},
ruleDesc: {
type: String, // 优惠券适用规则描述
value: '',
},
currency: {
type: String,
value: '¥', // 优惠货币
},
status: {
type: String,
value: 'default',
},
image: {
type: String,
value: '',
},
},
data: {
CouponType: {
MJ_COUPON: 1,
ZK_COUPON: 2,
MJF_COUPON: 3,
GIFT_COUPON: 4,
},
theme: 'primary',
},
observers: {
status: function (value) {
let theme = 'primary';
// 已过期或已使用的券 颜色置灰
if (value === 'useless' || value === 'disabled') {
theme = 'weak';
}
this.setData({ theme });
},
},
attached() {
this.setData({
color: `color${this.properties.colorStyle}`,
});
},
});

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"t-image": "/components/webp-image/index"
}
}

View File

@ -1,54 +0,0 @@
<wxs module="tools">
function isBigValue(value) {
var values = (value + '').split('.');
if (values[1] && values[0].length >= 3) return true;
else return false
}
function getBigValues(value) {
return value.split('.');
}
module.exports = { isBigValue: isBigValue, getBigValues: getBigValues };
</wxs>
<view class="wr-coupon coupon-class theme-{{theme}}">
<view class="wr-coupon__left">
<view wx:if="{{type == CouponType.ZK_COUPON || type === CouponType.MERCHANT_ZK_COUPON}}">
<text class="wr-coupon__left--value">{{value}}</text>
<text class="wr-coupon__left--unit">折</text>
<view class="wr-coupon__left--desc">{{desc}}</view>
</view>
<view wx:if="{{type == CouponType.MJ_COUPON || type === CouponType.MERCHANT_MJ_COUPON}}">
<text class="wr-coupon__left--value" wx:if="{{tools.isBigValue(value)}}">
<text class="wr-coupon__left--value-int">{{tools.getBigValues(value)[0]}}</text>
<text class="wr-coupon__left--value-decimal">.{{tools.getBigValues(value)[1]}}</text>
</text>
<text class="wr-coupon__left--value" wx:else>{{value / 100}}</text>
<text class="wr-coupon__left--unit">元</text>
<view class="wr-coupon__left--desc">{{desc}}</view>
</view>
<view wx:if="{{type === CouponType.MJF_COUPON || type === CouponType.MYF_COUPON}}">
<text class="wr-coupon__left--value" style="font-family: PingFang SC;font-size: 44rpx">免邮</text>
<view class="wr-coupon__left--desc">{{desc}}</view>
</view>
<view wx:if="{{type == CouponType.GIFT_COUPON}}">
<t-image t-class="wr-coupon__left--image" src="{{image}}" mode="aspectFill" />
</view>
</view>
<view class="wr-coupon__right">
<view class="wr-coupon__right--title">
<text class="coupon-title">{{title}}</text>
<view class="coupon-time">{{timeLimit}}</view>
<view class="coupon-desc">
<view wx:if="{{ruleDesc}}">{{ruleDesc}}</view>
</view>
</view>
<view class="wr-coupon__right--oper">
<slot name="operator" />
</view>
</view>
<view wx:if="{{status === 'useless' || status === 'disabled'}}" class="wr-coupon__seal seal-{{status}}}" />
<view wx:if="{{mask}}" class="wr-coupon__mask" />
<view wx:if="{{superposable}}" class="wr-coupon__tag">可叠加</view>
</view>

View File

@ -1,147 +0,0 @@
.wr-coupon {
display: flex;
background-image: url('https://cdn-we-retail.ym.tencent.com/miniapp/coupon/coupon-bg-nocorners.png');
background-size: 100% 100%;
background-repeat: no-repeat;
position: relative;
margin-bottom: 24rpx;
overflow: hidden;
}
.theme-weak.wr-coupon {
background-image: url('https://cdn-we-retail.ym.tencent.com/miniapp/coupon/coupon-bg-grey2.png');
}
.wr-coupon__left {
width: 200rpx;
height: 180rpx;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
color: #fa4126;
overflow: hidden;
position: relative;
}
.theme-weak .wr-coupon__left {
color: #333;
}
.wr-coupon__left--value {
font-size: 64rpx;
line-height: 88rpx;
font-weight: bold;
font-family: 'DIN Alternate', cursive;
}
.wr-coupon__left--value-int {
font-size: 48rpx;
line-height: 88rpx;
}
.wr-coupon__left--value-decimal {
font-size: 36rpx;
line-height: 48rpx;
}
.wr-coupon__left--image {
width: 128rpx;
height: 128rpx;
border-radius: 8px;
margin-top: 30rpx;
}
.wr-coupon__left--unit {
font-size: 24rpx;
line-height: 32rpx;
}
.wr-coupon__left--desc {
font-size: 24rpx;
line-height: 32rpx;
color: #fa4126;
}
.theme-weak .wr-coupon__left--desc {
color: #333;
}
.wr-coupon__right {
flex-grow: 1;
padding: 0 20rpx;
height: 180rpx;
box-sizing: border-box;
overflow: hidden;
display: flex;
align-items: center;
}
.wr-coupon__right--title {
display: flex;
-webkit-display: flex;
flex-direction: column;
align-items: flex-start;
color: #999999;
font-size: 24rpx;
flex: 1;
}
.wr-coupon__right--title .coupon-title {
max-width: 320rpx;
color: #333333;
font-size: 28rpx;
line-height: 40rpx;
font-weight: bold;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
white-space: normal;
}
.wr-coupon__right--title .coupon-time {
margin-top: 16rpx;
/* // letter-spacing: -0.05em; */
}
.wr-coupon__right--title .coupon-desc {
margin-top: 8rpx;
}
.wr-coupon__right--title .coupon-arrow {
font-size: 22rpx;
}
.wr-coupon__right--oper {
display: flex;
justify-content: center;
align-items: center;
}
.wr-coupon__mask {
width: 702rpx;
height: 182rpx;
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
opacity: 0.5;
}
.wr-coupon__tag {
position: absolute;
top: 8px;
right: -24rpx;
text-align: center;
width: 106rpx;
height: 28rpx;
opacity: 0.9;
font-size: 20rpx;
line-height: 28rpx;
color: #fa4126;
border: 0.5px solid #fa4126;
box-sizing: border-box;
transform: rotate(45deg);
}
.wr-coupon__seal {
width: 128rpx;
height: 128rpx;
position: absolute;
top: 0;
right: 0;
background-size: 100% 100%;
}
.wr-coupon__seal.seal-useless {
background-image: url('https://cdn-we-retail.ym.tencent.com/miniapp/coupon/seal-used.png');
}
.wr-coupon__seal.seal-disabled {
background-image: url('https://cdn-we-retail.ym.tencent.com/miniapp/coupon/coupon-expired.png');
}

View File

@ -1,78 +0,0 @@
import { fetchCouponDetail } from '../../../services/coupon/index';
import { fetchGoodsList } from '../../../services/good/fetchGoods';
import Toast from 'tdesign-miniprogram/toast/index';
Page({
data: {
goods: [],
detail: {},
couponTypeDesc: '',
showStoreInfoList: false,
cartNum: 2,
},
id: '',
onLoad(query) {
const id = parseInt(query.id);
this.id = id;
this.getCouponDetail(id);
this.getGoodsList(id);
},
getCouponDetail(id) {
fetchCouponDetail(id).then(({ detail }) => {
this.setData({ detail });
if (detail.type === 2) {
if (detail.base > 0) {
this.setData({
couponTypeDesc: `${detail.base / 100}${detail.value}`,
});
} else {
this.setData({ couponTypeDesc: `${detail.value}` });
}
} else if (detail.type === 1) {
if (detail.base > 0) {
this.setData({
couponTypeDesc: `${detail.base / 100}元减${detail.value / 100}`,
});
} else {
this.setData({ couponTypeDesc: `${detail.value / 100}` });
}
}
});
},
getGoodsList(id) {
fetchGoodsList(id).then((goods) => {
this.setData({ goods });
});
},
openStoreList() {
this.setData({
showStoreInfoList: true,
});
},
closeStoreList() {
this.setData({
showStoreInfoList: false,
});
},
goodClickHandle(e) {
const { index } = e.detail;
const { spuId } = this.data.goods[index];
wx.navigateTo({ url: `/pages/goods/details/index?spuId=${spuId}` });
},
cartClickHandle() {
Toast({
context: this,
selector: '#t-toast',
message: '点击加入购物车',
});
},
});

View File

@ -1,10 +0,0 @@
{
"navigationBarTitleText": "活动商品",
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"t-popup": "tdesign-miniprogram/popup/popup",
"t-toast": "tdesign-miniprogram/toast/toast",
"goods-list": "/components/goods-list/index",
"floating-button": "../components/floating-button/index"
}
}

Some files were not shown because too many files have changed in this diff Show More