Commit f582a698 authored by zhijie.xue's avatar zhijie.xue

商品图片后端改为dpg;奖品图片使用webp

parent 0dbacc8c
function isLuckiiResource(url) {
return url && url.indexOf('luckiistatic.q-gp.com') !== -1
}
function lottery(url) {
if (isLuckiiResource(url)) {
return url + '?imageMogr2/auto-orient/thumbnail/500x/gravity/Center/crop/x600/format/webp/blur/1x0/quality/75';
}
return url;
}
function prize(url) {
if (isLuckiiResource(url)) {
return url + '?imageMogr2/format/webp/blur/1x0/quality/75';
}
return url
module.exports = {
lottery: lottery,
prize: prize
}
\ No newline at end of file
......@@ -44,3 +44,14 @@ export function debounce(func, wait, immediate) {
return result;
};
}
function isLuckiiResource(url) {
return url && url.indexOf('luckiistatic.q-gp.com') !== -1;
}
export function compressShareImage(url) {
if (isLuckiiResource(url)) {
return url + '?imageMogr2/auto-orient/thumbnail/500x800!/gravity/Center/crop/x500/format/webp/blur/1x0/quality/75';
}
return url;
}
......@@ -27,7 +27,6 @@
<van-image use-loading-slot src="{{item.images}}" class="img" width="220rpx" height="210rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<!--<image src="{{item.images}}" class="img"></image>-->
<view class="title">{{item.title}}</view>
<p class="price">¥{{item.price}}</p>
<p class="buy">{{item.saleCount}}人购买</p>
......@@ -114,9 +113,7 @@
appId: 'wx91d27dbf599dff74',
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径
// 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release',
success(res) {
}
envVersion: 'release'
});
this.showLoading = false;
}).catch(() => {
......
......@@ -31,7 +31,7 @@
<van-loading type="spinner" size="40" v-if="videoLoading" custom-class="video-loading"/>
<!--<video-loading v-if="videoLoading" :snapshot="item.videoSnapUrl"/>-->
</video>
<van-image wx:if="{{item.showType && item.showType.value ==1}}" use-loading-slot src="{{item.photoUrl || item.videoSnapUrl}}" class="images" radius="10rpx" fit="contain" width="100%" height="100%">
<van-image wx:if="{{item.showType && item.showType.value ==1}}" use-loading-slot src="{{ic.prize(item.photoUrl || item.videoSnapUrl)}}" class="images" radius="10rpx" fit="contain" width="100%" height="100%">
<van-loading slot="loading" type="spinner" size="20" vertical/>
</van-image>
<view class="rightcont" v-show="item.id > 0">
......@@ -47,8 +47,9 @@
</swiper>
<van-popup show="{{showPopup}}" close-on-click-overlay="{{false}}" overlay-style="background-color:transparent"></van-popup>
</view>
<wxs module="rp" src="../../common/raffleProbability.wxs"></wxs>
<wxs module="ic" src="../../common/imageCompress.wxs"></wxs>
</template>
<wxs module="rp" src="../../common/raffleProbability.wxs"></wxs>
<script>
import wepy from '@wepy/core';
import { getAwardsDetail, getPrizeList } from '../../common/api.js';
......
......@@ -229,12 +229,11 @@
</van-popup>
</view>
</template>
<script>
import store from '../store';
import { mapState, mapActions } from '@wepy/x';
import wepy from '@wepy/core';
import { debounce } from '../common/utils';
import { debounce, compressShareImage } from '../common/utils';
import Notify from '../components/vant/notify/notify';
import Dialog from '../components/vant/dialog/dialog';
import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
......@@ -505,8 +504,7 @@
return {
title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}&prizeId=${this.$wepy.awardsInfo.id}`,
// todo: 图片大小减少了50%,但仍然偏大
imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl) + '?imageMogr2/auto-orient/thumbnail/500x800!/gravity/Center/crop/x500/blur/1x0/quality/75'
imageUrl: compressShareImage(decodeURIComponent(this.$wepy.awardsInfo.photoUrl))
};
}
},
......
......@@ -209,9 +209,10 @@
}
</style>
<template>
<view class="raffle-wrapper">
<view class="raffle-content">
<van-image use-loading-slot src="{{photoUrl}}" class="img" width="610rpx" height="610rpx" radius="10rpx" fit="widthFix">
<van-image use-loading-slot src="{{ic.lottery(photoUrl)}}" class="img" width="610rpx" height="610rpx" radius="10rpx" fit="widthFix">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<view class="goodsinfo">
......@@ -252,6 +253,7 @@
</view>
</view>
</template>
<wxs module="ic" src="../common/imageCompress.wxs"></wxs>
<script>
import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify';
......@@ -436,7 +438,7 @@
this.quantity = quantity || '';
this.name = name;
this.chance = chance;
this.photoUrl = decodeURIComponent(photoUrl) + '?imageMogr2/auto-orient/thumbnail/500x/gravity/Center/crop/x600/blur/1x0/quality/75';
this.photoUrl = decodeURIComponent(photoUrl);
this.hasPhone = wx.getStorageSync('hasPhone');
innerActivity = wx.getStorageSync('innerActivity');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment