create-weapp-vite 2.0.31 → 2.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{chunk-FGMHC2DJ.js → chunk-IT75MAH3.js} +3 -2
- package/dist/cli.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/wevu-retail/.editorconfig +9 -0
- package/templates/wevu-retail/.vscode/settings.json +10 -0
- package/templates/wevu-retail/AGENTS.md +35 -0
- package/templates/wevu-retail/README.md +26 -0
- package/templates/wevu-retail/auto-import-components.json +1 -0
- package/templates/wevu-retail/gitignore +35 -0
- package/templates/wevu-retail/package.json +42 -0
- package/templates/wevu-retail/postcss.config.js +6 -0
- package/templates/wevu-retail/project.config.json +44 -0
- package/templates/wevu-retail/project.private.config.json +8 -0
- package/templates/wevu-retail/src/app.vue +104 -0
- package/templates/wevu-retail/src/common/updateManager.ts +29 -0
- package/templates/wevu-retail/src/components/filter/index.vue +134 -0
- package/templates/wevu-retail/src/components/filter-popup/index.vue +67 -0
- package/templates/wevu-retail/src/components/goods-card/index.vue +219 -0
- package/templates/wevu-retail/src/components/goods-list/index.vue +91 -0
- package/templates/wevu-retail/src/components/load-more/index.vue +99 -0
- package/templates/wevu-retail/src/components/loading-content/index.vue +48 -0
- package/templates/wevu-retail/src/components/price/index.vue +104 -0
- package/templates/wevu-retail/src/components/promotion/ui-coupon-card/index.vue +143 -0
- package/templates/wevu-retail/src/components/promotion/ui-coupon-card/tools.wxs +18 -0
- package/templates/wevu-retail/src/components/swipeout/index.vue +118 -0
- package/templates/wevu-retail/src/components/swipeout/swipe.wxs +151 -0
- package/templates/wevu-retail/src/components/webp-image/index.vue +105 -0
- package/templates/wevu-retail/src/components/webp-image/utils.wxs +140 -0
- package/templates/wevu-retail/src/config/index.ts +20437 -0
- package/templates/wevu-retail/src/custom-tab-bar/data.ts +22 -0
- package/templates/wevu-retail/src/custom-tab-bar/index.vue +62 -0
- package/templates/wevu-retail/src/model/activities.ts +7 -0
- package/templates/wevu-retail/src/model/activity.ts +18 -0
- package/templates/wevu-retail/src/model/address.ts +31 -0
- package/templates/wevu-retail/src/model/cart.ts +306 -0
- package/templates/wevu-retail/src/model/category.ts +175 -0
- package/templates/wevu-retail/src/model/comments/queryDetail.ts +50 -0
- package/templates/wevu-retail/src/model/comments.ts +298 -0
- package/templates/wevu-retail/src/model/coupon.ts +39 -0
- package/templates/wevu-retail/src/model/detailsComments.ts +30 -0
- package/templates/wevu-retail/src/model/good.ts +1904 -0
- package/templates/wevu-retail/src/model/goods.ts +7 -0
- package/templates/wevu-retail/src/model/order/applyService.ts +329 -0
- package/templates/wevu-retail/src/model/order/orderConfirm.ts +147 -0
- package/templates/wevu-retail/src/model/order/orderDetail.ts +1191 -0
- package/templates/wevu-retail/src/model/order/orderList.ts +1033 -0
- package/templates/wevu-retail/src/model/promotion.ts +20 -0
- package/templates/wevu-retail/src/model/search.ts +60 -0
- package/templates/wevu-retail/src/model/submitComment.ts +58 -0
- package/templates/wevu-retail/src/model/swiper.ts +39 -0
- package/templates/wevu-retail/src/model/usercenter.ts +52 -0
- package/templates/wevu-retail/src/pages/cart/components/cart-bar/index.vue +104 -0
- package/templates/wevu-retail/src/pages/cart/components/cart-empty/index.vue +41 -0
- package/templates/wevu-retail/src/pages/cart/components/cart-group/index.vue +333 -0
- package/templates/wevu-retail/src/pages/cart/components/cart-group/index.wxs +5 -0
- package/templates/wevu-retail/src/pages/cart/components/cart-group/utils.wxs +20 -0
- package/templates/wevu-retail/src/pages/cart/components/goods-card/index.vue +334 -0
- package/templates/wevu-retail/src/pages/cart/components/specs-popup/index.vue +100 -0
- package/templates/wevu-retail/src/pages/cart/index.vue +342 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/README.md +95 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/c-sidebar-item/index.vue +73 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/index.vue +121 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-tabbar/c-tabbar-more/index.vue +74 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-tabbar/index.vue +102 -0
- package/templates/wevu-retail/src/pages/category/components/goods-category/index.vue +137 -0
- package/templates/wevu-retail/src/pages/category/index.vue +50 -0
- package/templates/wevu-retail/src/pages/coupon/components/coupon-card/index.vue +95 -0
- package/templates/wevu-retail/src/pages/coupon/components/floating-button/index.vue +44 -0
- package/templates/wevu-retail/src/pages/coupon/coupon-activity-goods/index.vue +135 -0
- package/templates/wevu-retail/src/pages/coupon/coupon-detail/index.vue +94 -0
- package/templates/wevu-retail/src/pages/coupon/coupon-list/index.vue +136 -0
- package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/images-videos/assets/play.png +0 -0
- package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/images-videos/index.vue +65 -0
- package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/my-video/index.vue +92 -0
- package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/index.vue +93 -0
- package/templates/wevu-retail/src/pages/goods/comments/create/index.vue +196 -0
- package/templates/wevu-retail/src/pages/goods/comments/index.vue +293 -0
- package/templates/wevu-retail/src/pages/goods/details/components/buy-bar/index.vue +117 -0
- package/templates/wevu-retail/src/pages/goods/details/components/goods-specs-popup/index.vue +440 -0
- package/templates/wevu-retail/src/pages/goods/details/components/promotion-popup/index.vue +83 -0
- package/templates/wevu-retail/src/pages/goods/details/index.vue +598 -0
- package/templates/wevu-retail/src/pages/goods/list/index.vue +299 -0
- package/templates/wevu-retail/src/pages/goods/result/index.vue +350 -0
- package/templates/wevu-retail/src/pages/goods/search/index.vue +196 -0
- package/templates/wevu-retail/src/pages/home/home.vue +215 -0
- package/templates/wevu-retail/src/pages/home/readme +8 -0
- package/templates/wevu-retail/src/pages/order/after-service-detail/api.ts +34 -0
- package/templates/wevu-retail/src/pages/order/after-service-detail/index.vue +430 -0
- package/templates/wevu-retail/src/pages/order/after-service-list/api.ts +1262 -0
- package/templates/wevu-retail/src/pages/order/after-service-list/index.vue +299 -0
- package/templates/wevu-retail/src/pages/order/apply-service/index.vue +665 -0
- package/templates/wevu-retail/src/pages/order/components/after-service-button-bar/index.vue +142 -0
- package/templates/wevu-retail/src/pages/order/components/customer-service/index.vue +75 -0
- package/templates/wevu-retail/src/pages/order/components/goods-card/index.vue +356 -0
- package/templates/wevu-retail/src/pages/order/components/noGoods/noGood.wxs +17 -0
- package/templates/wevu-retail/src/pages/order/components/noGoods/noGoods.vue +125 -0
- package/templates/wevu-retail/src/pages/order/components/order-button-bar/index.vue +262 -0
- package/templates/wevu-retail/src/pages/order/components/order-card/index.vue +126 -0
- package/templates/wevu-retail/src/pages/order/components/order-goods-card/index.vue +86 -0
- package/templates/wevu-retail/src/pages/order/components/reason-sheet/index.vue +161 -0
- package/templates/wevu-retail/src/pages/order/components/reason-sheet/reasonSheet.ts +25 -0
- package/templates/wevu-retail/src/pages/order/components/selectCoupons/mock.ts +22 -0
- package/templates/wevu-retail/src/pages/order/components/selectCoupons/selectCoupon.wxs +16 -0
- package/templates/wevu-retail/src/pages/order/components/selectCoupons/selectCoupons.vue +207 -0
- package/templates/wevu-retail/src/pages/order/components/specs-goods-card/index.vue +185 -0
- package/templates/wevu-retail/src/pages/order/config.ts +94 -0
- package/templates/wevu-retail/src/pages/order/delivery-detail/index.vue +145 -0
- package/templates/wevu-retail/src/pages/order/delivery-detail/isUrl.wxs +7 -0
- package/templates/wevu-retail/src/pages/order/fill-tracking-no/api.ts +71 -0
- package/templates/wevu-retail/src/pages/order/fill-tracking-no/index.vue +267 -0
- package/templates/wevu-retail/src/pages/order/invoice/index.vue +94 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/components/address-card/index.vue +78 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/getNotes.wxs +11 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/handleInvoice.wxs +11 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/index.vue +707 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/order.wxs +8 -0
- package/templates/wevu-retail/src/pages/order/order-confirm/pay.ts +115 -0
- package/templates/wevu-retail/src/pages/order/order-detail/index.vue +456 -0
- package/templates/wevu-retail/src/pages/order/order-list/index.vue +288 -0
- package/templates/wevu-retail/src/pages/order/pay-result/index.vue +77 -0
- package/templates/wevu-retail/src/pages/order/receipt/index.vue +336 -0
- package/templates/wevu-retail/src/pages/promotion/promotion-detail/index.vue +145 -0
- package/templates/wevu-retail/src/pages/user/address/edit/index.vue +514 -0
- package/templates/wevu-retail/src/pages/user/address/list/index.vue +249 -0
- package/templates/wevu-retail/src/pages/user/components/t-location/index.vue +156 -0
- package/templates/wevu-retail/src/pages/user/components/ui-address-item/index.vue +92 -0
- package/templates/wevu-retail/src/pages/user/name-edit/index.vue +49 -0
- package/templates/wevu-retail/src/pages/user/person-info/index.vue +198 -0
- package/templates/wevu-retail/src/pages/usercenter/address/edit/util.ts +33 -0
- package/templates/wevu-retail/src/pages/usercenter/components/order-group/index.vue +90 -0
- package/templates/wevu-retail/src/pages/usercenter/components/ui-select-picker/index.vue +108 -0
- package/templates/wevu-retail/src/pages/usercenter/components/user-center-card/index.vue +82 -0
- package/templates/wevu-retail/src/pages/usercenter/index.vue +301 -0
- package/templates/wevu-retail/src/services/_utils/delay.ts +3 -0
- package/templates/wevu-retail/src/services/_utils/timeout.ts +3 -0
- package/templates/wevu-retail/src/services/activity/fetchActivity.ts +20 -0
- package/templates/wevu-retail/src/services/activity/fetchActivityList.ts +20 -0
- package/templates/wevu-retail/src/services/address/edit.ts +33 -0
- package/templates/wevu-retail/src/services/address/fetchAddress.ts +48 -0
- package/templates/wevu-retail/src/services/address/list.ts +31 -0
- package/templates/wevu-retail/src/services/cart/cart.ts +20 -0
- package/templates/wevu-retail/src/services/comments/fetchComments.ts +18 -0
- package/templates/wevu-retail/src/services/comments/fetchCommentsCount.ts +18 -0
- package/templates/wevu-retail/src/services/coupon/index.ts +65 -0
- package/templates/wevu-retail/src/services/good/comments/fetchCommentDetail.ts +20 -0
- package/templates/wevu-retail/src/services/good/fetchCategoryList.ts +18 -0
- package/templates/wevu-retail/src/services/good/fetchGood.ts +18 -0
- package/templates/wevu-retail/src/services/good/fetchGoods.ts +29 -0
- package/templates/wevu-retail/src/services/good/fetchGoodsDetailsComments.ts +37 -0
- package/templates/wevu-retail/src/services/good/fetchGoodsList.ts +39 -0
- package/templates/wevu-retail/src/services/good/fetchSearchHistory.ts +35 -0
- package/templates/wevu-retail/src/services/good/fetchSearchResult.ts +38 -0
- package/templates/wevu-retail/src/services/home/home.ts +53 -0
- package/templates/wevu-retail/src/services/order/applyService.ts +70 -0
- package/templates/wevu-retail/src/services/order/orderConfirm.ts +69 -0
- package/templates/wevu-retail/src/services/order/orderDetail.ts +39 -0
- package/templates/wevu-retail/src/services/order/orderList.ts +39 -0
- package/templates/wevu-retail/src/services/order/orderSubmitComment.ts +22 -0
- package/templates/wevu-retail/src/services/promotion/detail.ts +18 -0
- package/templates/wevu-retail/src/services/usercenter/fetchPerson.ts +28 -0
- package/templates/wevu-retail/src/services/usercenter/fetchUsercenter.ts +18 -0
- package/templates/wevu-retail/src/sitemap.json +7 -0
- package/templates/wevu-retail/src/utils/addressParse.ts +25 -0
- package/templates/wevu-retail/src/utils/getPermission.ts +45 -0
- package/templates/wevu-retail/src/utils/mock.ts +51 -0
- package/templates/wevu-retail/src/utils/util.ts +134 -0
- package/templates/wevu-retail/src/vite-env.d.ts +1 -0
- package/templates/wevu-retail/tailwind.config.ts +15 -0
- package/templates/wevu-retail/tsconfig.app.json +58 -0
- package/templates/wevu-retail/tsconfig.json +11 -0
- package/templates/wevu-retail/tsconfig.node.json +33 -0
- package/templates/wevu-retail/vite.config.ts +14 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
Component({
|
|
3
|
+
options: {
|
|
4
|
+
addGlobalClass: true,
|
|
5
|
+
multipleSlots: true,
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
externalClasses: ['coupon-class'],
|
|
9
|
+
|
|
10
|
+
properties: {
|
|
11
|
+
mask: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
value: false, // 是否添加遮罩
|
|
14
|
+
},
|
|
15
|
+
superposable: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
value: false, // 是否可叠加
|
|
18
|
+
},
|
|
19
|
+
type: {
|
|
20
|
+
type: String,
|
|
21
|
+
value: '', // 优惠券类型:CouponType
|
|
22
|
+
},
|
|
23
|
+
value: {
|
|
24
|
+
type: String,
|
|
25
|
+
value: '', // 优惠金额
|
|
26
|
+
},
|
|
27
|
+
tag: {
|
|
28
|
+
type: String,
|
|
29
|
+
value: '', // 优惠标签,优惠券名字标签,img
|
|
30
|
+
},
|
|
31
|
+
desc: {
|
|
32
|
+
type: String,
|
|
33
|
+
value: '', // 优惠金额描述,金额下方
|
|
34
|
+
},
|
|
35
|
+
title: {
|
|
36
|
+
type: String, // 优惠券名称
|
|
37
|
+
value: '',
|
|
38
|
+
},
|
|
39
|
+
timeLimit: {
|
|
40
|
+
type: String, // 优惠券时限
|
|
41
|
+
value: '',
|
|
42
|
+
},
|
|
43
|
+
ruleDesc: {
|
|
44
|
+
type: String, // 优惠券适用规则描述
|
|
45
|
+
value: '',
|
|
46
|
+
},
|
|
47
|
+
currency: {
|
|
48
|
+
type: String,
|
|
49
|
+
value: '¥', // 优惠货币
|
|
50
|
+
},
|
|
51
|
+
status: {
|
|
52
|
+
type: String,
|
|
53
|
+
value: 'default',
|
|
54
|
+
},
|
|
55
|
+
image: {
|
|
56
|
+
type: String,
|
|
57
|
+
value: '',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
data: {
|
|
62
|
+
CouponType: {
|
|
63
|
+
MJ_COUPON: 1,
|
|
64
|
+
ZK_COUPON: 2,
|
|
65
|
+
MJF_COUPON: 3,
|
|
66
|
+
GIFT_COUPON: 4,
|
|
67
|
+
},
|
|
68
|
+
theme: 'primary',
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
observers: {
|
|
72
|
+
status: function (value) {
|
|
73
|
+
let theme = 'primary';
|
|
74
|
+
// 已过期或已使用的券 颜色置灰
|
|
75
|
+
if (value === 'useless' || value === 'disabled') {
|
|
76
|
+
theme = 'weak';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this.setData({ theme });
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
attached() {
|
|
84
|
+
this.setData({
|
|
85
|
+
color: `color${this.properties.colorStyle}`,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<wxs src="./tools.wxs" module="tools"></wxs>
|
|
93
|
+
<view class="wr-coupon coupon-class theme-{{theme}} [display:flex] [background-image:url(https://tdesign.gtimg.com/miniprogram/template/retail/coupon/coupon-bg-nocorners.png)] [background-size:100%_100%] [background-repeat:no-repeat] [position:relative] [margin-bottom:24rpx] [overflow:hidden] [background-image:url('https://tdesign.gtimg.com/miniprogram/template/retail/coupon/coupon-bg-nocorners.png')]">
|
|
94
|
+
<view class="wr-coupon__left [width:200rpx] [height:180rpx] [display:flex] [flex-direction:column] [justify-content:center] [text-align:center] [color:#fa4126] [overflow:hidden] [position:relative]">
|
|
95
|
+
<view wx:if="{{type == CouponType.ZK_COUPON || type === CouponType.MERCHANT_ZK_COUPON}}">
|
|
96
|
+
<text class="wr-coupon__left--value [font-size:64rpx] [line-height:88rpx] [font-weight:bold] [font-family:\'DIN_Alternate\',_cursive] [font-family:'DIN_Alternate',_cursive]">{{value}}</text>
|
|
97
|
+
<text class="wr-coupon__left--unit [font-size:24rpx] [line-height:32rpx]">折</text>
|
|
98
|
+
<view class="wr-coupon__left--desc [font-size:24rpx] [line-height:32rpx] [color:#fa4126]">{{desc}}</view>
|
|
99
|
+
</view>
|
|
100
|
+
<view wx:if="{{type == CouponType.MJ_COUPON || type === CouponType.MERCHANT_MJ_COUPON}}">
|
|
101
|
+
<text class="wr-coupon__left--value [font-size:64rpx] [line-height:88rpx] [font-weight:bold] [font-family:\'DIN_Alternate\',_cursive] [font-family:'DIN_Alternate',_cursive]" wx:if="{{tools.isBigValue(value)}}">
|
|
102
|
+
<text class="wr-coupon__left--value-int [font-size:48rpx] [line-height:88rpx]">{{tools.getBigValues(value)[0]}}</text>
|
|
103
|
+
<text class="wr-coupon__left--value-decimal [font-size:36rpx] [line-height:48rpx]">.{{tools.getBigValues(value)[1]}}</text>
|
|
104
|
+
</text>
|
|
105
|
+
<text class="wr-coupon__left--value [font-size:64rpx] [line-height:88rpx] [font-weight:bold] [font-family:\'DIN_Alternate\',_cursive] [font-family:'DIN_Alternate',_cursive]" wx:else>{{value / 100}}</text>
|
|
106
|
+
<text class="wr-coupon__left--unit [font-size:24rpx] [line-height:32rpx]">元</text>
|
|
107
|
+
<view class="wr-coupon__left--desc [font-size:24rpx] [line-height:32rpx] [color:#fa4126]">{{desc}}</view>
|
|
108
|
+
</view>
|
|
109
|
+
<view wx:if="{{type === CouponType.MJF_COUPON || type === CouponType.MYF_COUPON}}">
|
|
110
|
+
<text class="wr-coupon__left--value [font-size:64rpx] [line-height:88rpx] [font-weight:bold] [font-family:\'DIN_Alternate\',_cursive] [font-family:'DIN_Alternate',_cursive]" style="font-family: PingFang SC; font-size: 44rpx">免邮</text>
|
|
111
|
+
<view class="wr-coupon__left--desc [font-size:24rpx] [line-height:32rpx] [color:#fa4126]">{{desc}}</view>
|
|
112
|
+
</view>
|
|
113
|
+
<view wx:if="{{type == CouponType.GIFT_COUPON}}">
|
|
114
|
+
<t-image t-class="wr-coupon__left--image [width:128rpx] [height:128rpx] [border-radius:8px] [margin-top:30rpx]" src="{{image}}" mode="aspectFill" />
|
|
115
|
+
</view>
|
|
116
|
+
</view>
|
|
117
|
+
<view class="wr-coupon__right [flex-grow:1] [padding:0_20rpx] [height:180rpx] [box-sizing:border-box] [overflow:hidden] [display:flex] [align-items:center]">
|
|
118
|
+
<view class="wr-coupon__right--title [display:flex] [-webkit-display:flex] [flex-direction:column] [align-items:flex-start] [color:#999999] [font-size:24rpx] [flex:1] [&_.coupon-title]:[max-width:320rpx] [&_.coupon-title]:[color:#333333] [&_.coupon-title]:[font-size:28rpx] [&_.coupon-title]:[line-height:40rpx] [&_.coupon-title]:[font-weight:bold] [&_.coupon-title]:[display:-webkit-box] [&_.coupon-title]:[-webkit-line-clamp:1] [&_.coupon-title]:[-webkit-box-orient:vertical] [&_.coupon-title]:[overflow:hidden] [&_.coupon-title]:[white-space:normal] [&_.coupon-time]:[margin-top:16rpx] [&_.coupon-desc]:[margin-top:8rpx] [&_.coupon-arrow]:[font-size:22rpx]">
|
|
119
|
+
<text class="coupon-title">{{title}}</text>
|
|
120
|
+
<view class="coupon-time">{{timeLimit}}</view>
|
|
121
|
+
<view class="coupon-desc">
|
|
122
|
+
<view wx:if="{{ruleDesc}}">{{ruleDesc}}</view>
|
|
123
|
+
</view>
|
|
124
|
+
</view>
|
|
125
|
+
<view class="wr-coupon__right--oper [display:flex] [justify-content:center] [align-items:center]">
|
|
126
|
+
<slot name="operator" />
|
|
127
|
+
</view>
|
|
128
|
+
</view>
|
|
129
|
+
<view wx:if="{{status === 'useless' || status === 'disabled'}}" class="wr-coupon__seal seal-{{status}}} [width:128rpx] [height:128rpx] [position:absolute] [top:0] [right:0] [background-size:100%_100%] [&_.seal-useless]:[background-image:url('https://tdesign.gtimg.com/miniprogram/template/retail/coupon/seal-used.png')] [&_.seal-disabled]:[background-image:url('https://tdesign.gtimg.com/miniprogram/template/retail/coupon/coupon-expired.png')]" />
|
|
130
|
+
<view wx:if="{{mask}}" class="wr-coupon__mask [width:702rpx] [height:182rpx] [position:absolute] [top:0] [left:0] [background-color:#ffffff] [opacity:0.5]" />
|
|
131
|
+
<view wx:if="{{superposable}}" class="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)]">可叠加</view>
|
|
132
|
+
</view>
|
|
133
|
+
</template>
|
|
134
|
+
|
|
135
|
+
<json>
|
|
136
|
+
{
|
|
137
|
+
"component": true,
|
|
138
|
+
"usingComponents": {
|
|
139
|
+
"t-icon": "tdesign-miniprogram/icon/icon",
|
|
140
|
+
"t-image": "/components/webp-image/index"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
</json>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function isBigValue(value) {
|
|
2
|
+
var values = (value + '').split('.');
|
|
3
|
+
if (values[1] && values[0].length >= 3) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getBigValues(value) {
|
|
12
|
+
return value.split('.');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
isBigValue: isBigValue,
|
|
17
|
+
getBigValues: getBigValues,
|
|
18
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let ARRAY = [];
|
|
3
|
+
Component({
|
|
4
|
+
externalClasses: ['wr-class'],
|
|
5
|
+
|
|
6
|
+
options: {
|
|
7
|
+
multipleSlots: true,
|
|
8
|
+
},
|
|
9
|
+
properties: {
|
|
10
|
+
disabled: Boolean,
|
|
11
|
+
leftWidth: {
|
|
12
|
+
type: Number,
|
|
13
|
+
value: 0,
|
|
14
|
+
},
|
|
15
|
+
rightWidth: {
|
|
16
|
+
type: Number,
|
|
17
|
+
value: 0,
|
|
18
|
+
},
|
|
19
|
+
asyncClose: Boolean,
|
|
20
|
+
},
|
|
21
|
+
attached() {
|
|
22
|
+
ARRAY.push(this);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
detached() {
|
|
26
|
+
ARRAY = ARRAY.filter((item) => item !== this);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Component initial data
|
|
31
|
+
*/
|
|
32
|
+
data: {
|
|
33
|
+
wrapperStyle: '',
|
|
34
|
+
asyncClose: false,
|
|
35
|
+
closed: true,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Component methods
|
|
40
|
+
*/
|
|
41
|
+
methods: {
|
|
42
|
+
open(position) {
|
|
43
|
+
this.setData({ closed: false });
|
|
44
|
+
this.triggerEvent('close', {
|
|
45
|
+
position,
|
|
46
|
+
instance: this,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
close() {
|
|
51
|
+
this.setData({ closed: true });
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
closeOther() {
|
|
55
|
+
ARRAY.filter((item) => item !== this).forEach((item) => item.close());
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
noop() {
|
|
59
|
+
return;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
onClick(event) {
|
|
63
|
+
const { key: position = 'outside' } = event.currentTarget.dataset;
|
|
64
|
+
this.triggerEvent('click', position);
|
|
65
|
+
|
|
66
|
+
if (this.data.closed) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.data.asyncClose) {
|
|
71
|
+
this.triggerEvent('close', {
|
|
72
|
+
position,
|
|
73
|
+
instance: this,
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
this.close();
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<template>
|
|
84
|
+
<wxs src="./swipe.wxs" module="swipe"></wxs>
|
|
85
|
+
|
|
86
|
+
<view
|
|
87
|
+
class="wr-class wr-swipeout [position:relative] [overflow:hidden]"
|
|
88
|
+
data-key="cell"
|
|
89
|
+
capture-bind:tap="onClick"
|
|
90
|
+
bindtouchstart="{{disabled || swipe.startDrag}}"
|
|
91
|
+
capture-bind:touchmove="{{disabled || swipe.onDrag}}"
|
|
92
|
+
bindtouchend="{{disabled || swipe.endDrag}}"
|
|
93
|
+
bindtouchcancel="{{disabled || swipe.endDrag}}"
|
|
94
|
+
closed="{{closed}}"
|
|
95
|
+
change:closed="{{swipe.onCloseChange}}"
|
|
96
|
+
leftWidth="{{leftWidth}}"
|
|
97
|
+
rightWidth="{{rightWidth}}"
|
|
98
|
+
change:leftWidth="{{swipe.initLeftWidth}}"
|
|
99
|
+
change:rightWidth="{{swipe.initRightWidth}}"
|
|
100
|
+
>
|
|
101
|
+
<view id="wrapper">
|
|
102
|
+
<view wx:if="{{ leftWidth }}" class="wr-swipeout__left [position:absolute] [top:0] [height:100%] [left:0] [transform:translate3d(-100%,_0,_0)]" data-key="left" catch:tap="onClick">
|
|
103
|
+
<slot name="left" />
|
|
104
|
+
</view>
|
|
105
|
+
<slot />
|
|
106
|
+
<view wx:if="{{ rightWidth }}" class="wr-swipeout__right [position:absolute] [top:0] [height:100%] [right:0] [transform:translate3d(100%,_0,_0)]" data-key="right" catch:tap="onClick">
|
|
107
|
+
<slot name="right" />
|
|
108
|
+
</view>
|
|
109
|
+
</view>
|
|
110
|
+
</view>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<json>
|
|
114
|
+
{
|
|
115
|
+
"component": true,
|
|
116
|
+
"usingComponents": {}
|
|
117
|
+
}
|
|
118
|
+
</json>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var THRESHOLD = 0.3;
|
|
2
|
+
var MIN_DISTANCE = 10;
|
|
3
|
+
var owner;
|
|
4
|
+
var state;
|
|
5
|
+
|
|
6
|
+
var getState = function(ownerInstance) {
|
|
7
|
+
owner = ownerInstance;
|
|
8
|
+
state = owner.getState();
|
|
9
|
+
state.leftWidth = state.leftWidth || 0;
|
|
10
|
+
state.rightWidth = state.rightWidth || 0;
|
|
11
|
+
state.offset = state.offset || 0;
|
|
12
|
+
state.startOffset = state.startOffset || 0;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var initRightWidth = function(newVal, oldVal, ownerInstance) {
|
|
16
|
+
getState(ownerInstance);
|
|
17
|
+
state.rightWidth = newVal;
|
|
18
|
+
if (state.offset < 0) {
|
|
19
|
+
swipeMove(-state.rightWidth);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var initLeftWidth = function(newVal, oldVal, ownerInstance) {
|
|
24
|
+
getState(ownerInstance);
|
|
25
|
+
state.leftWidth = newVal;
|
|
26
|
+
if (state.offset > 0) {
|
|
27
|
+
swipeMove(state.leftWidth);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var resetTouchStatus = function() {
|
|
32
|
+
state.direction = '';
|
|
33
|
+
state.deltaX = 0;
|
|
34
|
+
state.deltaY = 0;
|
|
35
|
+
state.offsetX = 0;
|
|
36
|
+
state.offsetY = 0;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var touchMove = function(event) {
|
|
40
|
+
var touchPoint = event.touches[0];
|
|
41
|
+
state.deltaX = touchPoint.clientX - state.startX;
|
|
42
|
+
state.deltaY = touchPoint.clientY - state.startY;
|
|
43
|
+
state.offsetX = Math.abs(state.deltaX);
|
|
44
|
+
state.offsetY = Math.abs(state.deltaY);
|
|
45
|
+
state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var getDirection = function(x, y) {
|
|
49
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
50
|
+
return 'horizontal';
|
|
51
|
+
}
|
|
52
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
53
|
+
return 'vertical';
|
|
54
|
+
}
|
|
55
|
+
return '';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var range = function(num, min, max) {
|
|
59
|
+
return Math.min(Math.max(num, min), max);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var swipeMove = function(_offset) {
|
|
63
|
+
if (_offset == null) {
|
|
64
|
+
_offset = 0;
|
|
65
|
+
}
|
|
66
|
+
state.offset = range(
|
|
67
|
+
_offset,
|
|
68
|
+
-state.rightWidth,
|
|
69
|
+
+state.leftWidth
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
var transform = 'translate3d(' + state.offset + 'px, 0, 0)';
|
|
73
|
+
var transition = state.dragging
|
|
74
|
+
? 'none'
|
|
75
|
+
: 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)';
|
|
76
|
+
owner.selectComponent('#wrapper').setStyle({
|
|
77
|
+
'-webkit-transform': transform,
|
|
78
|
+
'-webkit-transition': transition,
|
|
79
|
+
'transform': transform,
|
|
80
|
+
'transition': transition,
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var close = function() {
|
|
85
|
+
swipeMove(0);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var onCloseChange = function(newVal, oldVal, ownerInstance) {
|
|
89
|
+
getState(ownerInstance);
|
|
90
|
+
if (newVal === oldVal) return;
|
|
91
|
+
if (newVal) {
|
|
92
|
+
close();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var touchStart = function(event) {
|
|
97
|
+
resetTouchStatus();
|
|
98
|
+
state.startOffset = state.offset;
|
|
99
|
+
var touchPoint = event.touches[0];
|
|
100
|
+
state.startX = touchPoint.clientX;
|
|
101
|
+
state.startY = touchPoint.clientY;
|
|
102
|
+
owner.callMethod('closeOther');
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var startDrag = function(event, ownerInstance) {
|
|
106
|
+
getState(ownerInstance);
|
|
107
|
+
touchStart(event);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
var onDrag = function(event, ownerInstance) {
|
|
111
|
+
getState(ownerInstance);
|
|
112
|
+
touchMove(event);
|
|
113
|
+
if (state.direction !== 'horizontal') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
state.dragging = true;
|
|
117
|
+
swipeMove(state.startOffset + state.deltaX);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var open = function(position) {
|
|
121
|
+
var _offset = position === 'left' ? +state.leftWidth : -state.rightWidth;
|
|
122
|
+
owner.callMethod('open', { position: position });
|
|
123
|
+
swipeMove(_offset);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var endDrag = function(event, ownerInstance) {
|
|
127
|
+
getState(ownerInstance);
|
|
128
|
+
state.dragging = false;
|
|
129
|
+
// 左/右侧有可滑动区域,且当前不是已open状态,且滑动幅度超过阈值时open左/右侧(滚动到该侧的最边上)
|
|
130
|
+
if (+state.rightWidth > 0 && -state.startOffset < +state.rightWidth && -state.offset > +state.rightWidth * THRESHOLD) {
|
|
131
|
+
open('right');
|
|
132
|
+
}
|
|
133
|
+
else if (+state.leftWidth > 0 && state.startOffset < +state.leftWidth && state.offset > +state.leftWidth * THRESHOLD) {
|
|
134
|
+
open('left');
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// 仅在有发生侧滑的情况下自动关闭(由js控制是否异步关闭)
|
|
138
|
+
if (state.startOffset !== state.offset) {
|
|
139
|
+
close();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
module.exports = {
|
|
145
|
+
initLeftWidth: initLeftWidth,
|
|
146
|
+
initRightWidth: initRightWidth,
|
|
147
|
+
startDrag: startDrag,
|
|
148
|
+
onDrag: onDrag,
|
|
149
|
+
endDrag: endDrag,
|
|
150
|
+
onCloseChange: onCloseChange,
|
|
151
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
const systemInfo = wx.getSystemInfoSync();
|
|
3
|
+
Component({
|
|
4
|
+
externalClasses: ['t-class', 't-class-load'],
|
|
5
|
+
properties: {
|
|
6
|
+
loadFailed: {
|
|
7
|
+
type: String,
|
|
8
|
+
value: 'default',
|
|
9
|
+
},
|
|
10
|
+
loading: {
|
|
11
|
+
type: String,
|
|
12
|
+
value: 'default',
|
|
13
|
+
},
|
|
14
|
+
src: {
|
|
15
|
+
type: String,
|
|
16
|
+
value: '',
|
|
17
|
+
},
|
|
18
|
+
mode: {
|
|
19
|
+
type: String,
|
|
20
|
+
value: 'aspectFill',
|
|
21
|
+
},
|
|
22
|
+
webp: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
value: true,
|
|
25
|
+
},
|
|
26
|
+
lazyLoad: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
value: false,
|
|
29
|
+
},
|
|
30
|
+
showMenuByLongpress: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
value: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
data: {
|
|
36
|
+
thumbHeight: 375,
|
|
37
|
+
thumbWidth: 375,
|
|
38
|
+
systemInfo,
|
|
39
|
+
},
|
|
40
|
+
lifetimes: {
|
|
41
|
+
ready() {
|
|
42
|
+
const { mode } = this.properties;
|
|
43
|
+
// 获取容器的真实宽高,设置图片的裁剪宽度
|
|
44
|
+
this.getRect('.J-image').then((res) => {
|
|
45
|
+
if (res) {
|
|
46
|
+
const { width, height } = res;
|
|
47
|
+
this.setData(
|
|
48
|
+
mode === 'heightFix'
|
|
49
|
+
? {
|
|
50
|
+
thumbHeight: this.px2rpx(height) || 375,
|
|
51
|
+
}
|
|
52
|
+
: {
|
|
53
|
+
thumbWidth: this.px2rpx(width) || 375,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
px2rpx(px) {
|
|
62
|
+
return (750 / (systemInfo.screenWidth || 375)) * px;
|
|
63
|
+
},
|
|
64
|
+
getRect(selector) {
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
if (!this.selectorQuery) {
|
|
67
|
+
this.selectorQuery = this.createSelectorQuery();
|
|
68
|
+
}
|
|
69
|
+
this.selectorQuery.select(selector).boundingClientRect(resolve).exec();
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
onLoad(e) {
|
|
73
|
+
this.triggerEvent('load', e.detail);
|
|
74
|
+
},
|
|
75
|
+
onError(e) {
|
|
76
|
+
this.triggerEvent('error', e.detail);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<wxs src="./utils.wxs" module="Utils" />
|
|
84
|
+
<t-image
|
|
85
|
+
class="J-image"
|
|
86
|
+
src="{{Utils.getSrc({src, thumbWidth: thumbWidth || 0, thumbHeight: thumbHeight || 0, systemInfo, webp, mode})}}"
|
|
87
|
+
t-class="t-class"
|
|
88
|
+
t-class-load="t-class-load"
|
|
89
|
+
mode="{{ mode }}"
|
|
90
|
+
lazy="{{ lazyLoad }}"
|
|
91
|
+
show-menu-by-longpress="{{showMenuByLongpress}}"
|
|
92
|
+
error="{{loadFailed}}"
|
|
93
|
+
loading="{{loading}}"
|
|
94
|
+
binderror="onError"
|
|
95
|
+
bindload="onLoad"
|
|
96
|
+
/>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<json>
|
|
100
|
+
{
|
|
101
|
+
"component": true,
|
|
102
|
+
"usingComponents": {
|
|
103
|
+
"t-image": "tdesign-miniprogram/image/image"
|
|
104
|
+
}
|
|
105
|
+
}</json>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var isString = function (value) {
|
|
2
|
+
return typeof value === 'string';
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
var isNumber = function (value) {
|
|
6
|
+
return typeof value === 'number';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
var getFileExt = function (src) {
|
|
10
|
+
var fileUrl = src.split('?')[0];
|
|
11
|
+
var splitUlr = fileUrl.split('/');
|
|
12
|
+
var filepath = splitUlr[splitUlr.length - 1];
|
|
13
|
+
return filepath.split('.')[1] || 'jpg';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function isUrl(url) {
|
|
17
|
+
// NOCC:ToolNameCheck(非敏感词)
|
|
18
|
+
var urlReg = getRegExp(
|
|
19
|
+
'/[(http(s)?)://(www.)?a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/',
|
|
20
|
+
'ig',
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return urlReg.test(url);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function rpx2px(rpx, screenWidth) {
|
|
27
|
+
// px / systemWidth = rpx / 750
|
|
28
|
+
var result = (rpx * (screenWidth || 375)) / 750;
|
|
29
|
+
|
|
30
|
+
return Math.round(result);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function imageMogr(url, options) {
|
|
34
|
+
if (!isString(url) || !url) return '';
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
url.indexOf('qlogo.cn') !== -1 ||
|
|
38
|
+
url.indexOf('wxfile://') === 0 ||
|
|
39
|
+
url.indexOf('http://tmp/wx') === 0 ||
|
|
40
|
+
url.indexOf('imageMogr2') !== -1
|
|
41
|
+
) {
|
|
42
|
+
//qlogo.cn域名或者本地图片不做转换
|
|
43
|
+
return url;
|
|
44
|
+
} //强制转https
|
|
45
|
+
|
|
46
|
+
if (url.indexOf('http://') === 0) {
|
|
47
|
+
url = url.replace('http://', 'https://');
|
|
48
|
+
} else if (url.indexOf('//') === 0) {
|
|
49
|
+
url = 'https:' + url;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!options) return url;
|
|
53
|
+
|
|
54
|
+
var width = Math.ceil(options.width),
|
|
55
|
+
height = Math.ceil(options.height),
|
|
56
|
+
format = options.format,
|
|
57
|
+
_optionsQuality = options.quality,
|
|
58
|
+
quality = _optionsQuality === undefined ? 70 : _optionsQuality,
|
|
59
|
+
_optionsStrip = options.strip,
|
|
60
|
+
strip = _optionsStrip === undefined ? true : _optionsStrip,
|
|
61
|
+
crop = options.crop;
|
|
62
|
+
var isValidWidth = isNumber(width) && width > 0;
|
|
63
|
+
var isValidHeight = isNumber(height) && height > 0;
|
|
64
|
+
var imageMogrStr = '';
|
|
65
|
+
var size = '';
|
|
66
|
+
|
|
67
|
+
if (isValidWidth && isValidHeight) {
|
|
68
|
+
size = ''.concat(width, 'x').concat(height);
|
|
69
|
+
} else if (isValidWidth) {
|
|
70
|
+
size = ''.concat(width, 'x');
|
|
71
|
+
} else if (isValidHeight) {
|
|
72
|
+
size = 'x'.concat(height);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (size) {
|
|
76
|
+
//缩放或者裁剪
|
|
77
|
+
imageMogrStr += '/'.concat(crop ? 'crop' : 'thumbnail', '/').concat(size);
|
|
78
|
+
|
|
79
|
+
if (crop) {
|
|
80
|
+
//裁剪目前需求只有以图片中心为基准
|
|
81
|
+
imageMogrStr += '/gravity/center';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isNumber(quality)) {
|
|
86
|
+
//质量变换
|
|
87
|
+
imageMogrStr += '/quality/'.concat(quality);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (strip) {
|
|
91
|
+
//去除元信息
|
|
92
|
+
imageMogrStr += '/strip';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var ext = getFileExt(url);
|
|
96
|
+
|
|
97
|
+
// gif 图片不做格式转换,否则会损坏动图
|
|
98
|
+
if (ext === 'gif') {
|
|
99
|
+
imageMogrStr += '/cgif/1';
|
|
100
|
+
} else if (format) {
|
|
101
|
+
//格式转换
|
|
102
|
+
imageMogrStr += '/format/'.concat(format);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (format === 'jpg' || (!format && (ext === 'jpg' || ext === 'jpeg'))) {
|
|
106
|
+
//渐进式 jpg 加载
|
|
107
|
+
imageMogrStr += '/interlace/1';
|
|
108
|
+
}
|
|
109
|
+
if (!imageMogrStr) return url;
|
|
110
|
+
return ''
|
|
111
|
+
.concat(url)
|
|
112
|
+
.concat(url.indexOf('?') !== -1 ? '&' : '?', 'imageMogr2')
|
|
113
|
+
.concat(imageMogrStr);
|
|
114
|
+
}
|
|
115
|
+
function getSrc(options) {
|
|
116
|
+
if (!options.src) return '';
|
|
117
|
+
|
|
118
|
+
if (options.thumbWidth || options.thumbHeight) {
|
|
119
|
+
return imageMogr(options.src, {
|
|
120
|
+
width:
|
|
121
|
+
options.mode !== 'heightFix'
|
|
122
|
+
? rpx2px(options.thumbWidth, options.systemInfo.screenWidth) *
|
|
123
|
+
options.systemInfo.pixelRatio
|
|
124
|
+
: null,
|
|
125
|
+
height:
|
|
126
|
+
options.mode !== 'widthFix'
|
|
127
|
+
? rpx2px(options.thumbHeight, options.systemInfo.screenWidth) *
|
|
128
|
+
options.systemInfo.pixelRatio
|
|
129
|
+
: null,
|
|
130
|
+
format: options.webp ? 'webp' : null,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = {
|
|
138
|
+
imageMogr: imageMogr,
|
|
139
|
+
getSrc: getSrc,
|
|
140
|
+
};
|