|
@@ -136,39 +136,22 @@
|
|
|
<view class="close-wrap" @click="posterShow=false">
|
|
|
<u-icon name="close-circle" color="#fff" size="56rpx"></u-icon>
|
|
|
</view>
|
|
|
- <view class="poster" :style="posterStyle" id="poster" ref="poster" >
|
|
|
- <img class="posterBg" :src="staticUrl+'/img/poster-bg.png'" alt="">
|
|
|
- <img class="placard" :src="details.placard" alt="">
|
|
|
- <!-- <u--image :showLoading="true" :src="details.placard" width="100%" mode="widthFix"></u--image> -->
|
|
|
- <view class="bottom u-flex u-row-between">
|
|
|
- <view class="left">
|
|
|
- <view class="price">
|
|
|
- ¥<text class="num">{{details.salePrice}}</text>
|
|
|
- </view>
|
|
|
- <view class="goodsName ellipsis-2">{{details.goodsName}}</view>
|
|
|
- <view class="slogan" v-if="details.slogan" :style="{color:details.sloganColor||'#00A447'}">{{details.slogan}}</view>
|
|
|
- </view>
|
|
|
- <view class="right">
|
|
|
- <image :src="details.qrcodeUrl" style="width: 108rpx;height: 108rpx"></image>
|
|
|
- <view class="imgTip">长按扫码购买</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ <view class="poster" id="poster" ref="poster" >
|
|
|
+ <u--image :showLoading="true" :src="posterSrc" width="100%" height="65vh" mode="aspectFit"></u--image>
|
|
|
</view>
|
|
|
- <view class="poster-btn" @click="savePoster">保存图片</view>
|
|
|
+ <!-- savePoster -->
|
|
|
+ <view class="poster-btn" @click="saveImage">保存图片</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
- <xWxmlToCanvas ref="xWxmlToCanvas" :hide="true" :width="300" :height="544" :xStyle="posterStyle" :xWxml="wxml">
|
|
|
- </xWxmlToCanvas>
|
|
|
<u-toast ref="uToast"></u-toast>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import xWxmlToCanvas from '@/components/x-wxml-to-canvas/x-wxml-to-canvas';
|
|
|
export default {
|
|
|
components: {
|
|
|
- xWxmlToCanvas
|
|
|
+
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -183,93 +166,23 @@
|
|
|
},
|
|
|
hasAddr:false,
|
|
|
shareShow:false,
|
|
|
- posterShow:true,
|
|
|
+ posterShow:false,
|
|
|
mode:'aspectFill',
|
|
|
wxml:'',
|
|
|
- posterStyle:{
|
|
|
- poster:{
|
|
|
- with:300,
|
|
|
- height:544,
|
|
|
- position: 'relative',
|
|
|
- paddingBottom: 90,
|
|
|
- backgroundColor:'#fff',
|
|
|
- },
|
|
|
- posterBg:{
|
|
|
- position: 'absolute',
|
|
|
- left: 0,
|
|
|
- bottom: 0,
|
|
|
- right: 0,
|
|
|
- width: 300,
|
|
|
- height:544,
|
|
|
- },
|
|
|
- placard:{
|
|
|
- position: 'relative',
|
|
|
- with:300,
|
|
|
- height:387,
|
|
|
- },
|
|
|
- bottom:{
|
|
|
- width:320,
|
|
|
- height:157,
|
|
|
- position: 'relative',
|
|
|
- zIndex: 20,
|
|
|
- flexDirection: 'row',
|
|
|
- justifyContent: 'space-between',
|
|
|
- },
|
|
|
- left:{
|
|
|
- width:125,
|
|
|
- height:157,
|
|
|
- paddingLeft:20,
|
|
|
- marginRight: 58,
|
|
|
- },
|
|
|
- price:{
|
|
|
- width:125,
|
|
|
- height:40,
|
|
|
- marginBottom: 10,
|
|
|
- },
|
|
|
- rmb:{
|
|
|
- fontSize: 12,
|
|
|
- color: '#FF3538',
|
|
|
- position:'relative',
|
|
|
- top:6
|
|
|
- },
|
|
|
- num:{
|
|
|
- fontSize: 20,
|
|
|
- color: '#FF3538',
|
|
|
- },
|
|
|
- goodsName:{
|
|
|
- width:125,
|
|
|
- height:40,
|
|
|
- fontSize: 30,
|
|
|
- color: '#333',
|
|
|
- marginBottom: 16,
|
|
|
- },
|
|
|
- slogan:{
|
|
|
- fontSize: 26,
|
|
|
- fontWeight: 600,
|
|
|
- lineHeight: 37,
|
|
|
- },
|
|
|
- right:{
|
|
|
- textAlign: 'center',
|
|
|
- },
|
|
|
- imgTip:{
|
|
|
- width:60,
|
|
|
- height:14,
|
|
|
- marginTop: 12,
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: 400,
|
|
|
- color: '#333333',
|
|
|
- lineHeight: 28,
|
|
|
- },
|
|
|
- qrcode:{
|
|
|
- width: 108,
|
|
|
- height:108
|
|
|
- }
|
|
|
- },
|
|
|
+ posterStyle:{},
|
|
|
posterSrc:''
|
|
|
}
|
|
|
},
|
|
|
onLoad(page) {
|
|
|
this.id = page.id;
|
|
|
+ if(page.goodsId){
|
|
|
+ this.id = page.goodsId;
|
|
|
+ }
|
|
|
+ const scene = decodeURIComponent(page.scene);
|
|
|
+ scene&&uni.setStorage({
|
|
|
+ key:'scene',
|
|
|
+ data:scene
|
|
|
+ });
|
|
|
// console.log('this.id',this.id);
|
|
|
this.getDetails(this.id);
|
|
|
},
|
|
@@ -306,30 +219,8 @@
|
|
|
getDetails(id){
|
|
|
this.$u.api.memberGoodDetails({id:id}).then(res=>{
|
|
|
this.loadingPage = false;
|
|
|
- console.log('res',res.data);
|
|
|
+ // console.log('res',res.data);
|
|
|
this.details = res.data;
|
|
|
- // <image class="posterBg" src="${this.staticUrl}/img/poster-bg.png"></image>
|
|
|
- // <image class="placard" src="${this.details.placard||''}"></image>
|
|
|
- this.wxml = `
|
|
|
- <view class="poster" id="poster" ref="poster" >
|
|
|
- <image class="posterBg" src="${this.staticUrl}/img/poster-bg.png"></image>
|
|
|
- <image class="placard" src="${this.details.slideImgList[0]}"></image>
|
|
|
- <view class="bottom">
|
|
|
- <view class="left">
|
|
|
- <view class="price">
|
|
|
- <text class="rmb">¥ </text>
|
|
|
- <text class="num">${this.details.salePrice}</text>
|
|
|
- </view>
|
|
|
- <view class="goodsName">${this.details.goodsName}</view>
|
|
|
- <view class="slogan" style="color:${this.details.sloganColor||'#00A447'}">${this.details.slogan}</view>
|
|
|
- </view>
|
|
|
- <view class="right">
|
|
|
- <image class="qrcode" src="${this.details.qrcodeUrl||''}"></image>
|
|
|
- <view class="imgTip">长按扫码购买</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- `;
|
|
|
if(!res.data.slideImgList&&res.data.mainImg){
|
|
|
this.details.slideImgList = [];
|
|
|
this.details.slideImgList.push(res.data.mainImg)
|
|
@@ -504,32 +395,81 @@
|
|
|
getPoster(){
|
|
|
this.posterShow = true;
|
|
|
this.shareShow = false;
|
|
|
- },
|
|
|
- savePoster(){
|
|
|
- console.log('savePoster',this.wxml);
|
|
|
- this.$refs.xWxmlToCanvas.renderToCanvas() //渲染至canvas
|
|
|
- this.getCanvasImage();
|
|
|
- },
|
|
|
- canvasToTempFilePath() {//生成图片
|
|
|
- this.$refs.xWxmlToCanvas.canvasToTempFilePath().then(res => {
|
|
|
- this.posterSrc = res;
|
|
|
- });
|
|
|
- },
|
|
|
- getCanvasImage() {//获取图片
|
|
|
- this.$refs.xWxmlToCanvas.getCanvasImage().then(res => {
|
|
|
- this.posterSrc = res;
|
|
|
- console.log('posterSrc',this.posterSrc);
|
|
|
- // this.saveImageToPhotosAlbum()
|
|
|
- });
|
|
|
- },
|
|
|
- saveImageToPhotosAlbum() {//下载图片
|
|
|
- if (!this.posterSrc) return uni.showToast({
|
|
|
- title: '未获取路径',
|
|
|
- icon: 'none'
|
|
|
+ this.$u.api.getPoster({goodsId:this.id}).then(res=>{
|
|
|
+ this.posterSrc = res.data.imageUrl;
|
|
|
+ // console.log('getPoster',res.data);
|
|
|
+ }).catch(err=>{
|
|
|
+ console.log('getPoster',err);
|
|
|
})
|
|
|
- console.log('wxml',this.wxml);
|
|
|
- this.$refs.xWxmlToCanvas.saveImageToPhotosAlbum(this.posterSrc)
|
|
|
},
|
|
|
+ saveImage() {
|
|
|
+ let that = this;
|
|
|
+ uni.showLoading({
|
|
|
+ title: '保存中'
|
|
|
+ });
|
|
|
+ uni.downloadFile({
|
|
|
+ url: this.posterSrc,
|
|
|
+ success(res) {
|
|
|
+ if (res.statusCode === 200) {
|
|
|
+ uni.saveImageToPhotosAlbum({
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ success() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '保存到相册成功',
|
|
|
+ icon: 'success'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ console.log('保存图片失败',err);
|
|
|
+ if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
|
|
|
+ uni.getSetting({
|
|
|
+ success(res) {
|
|
|
+ if (!res.authSetting['scope.writePhotosAlbum']) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '您还没有授权访问相册,请前往设置页面打开权限。',
|
|
|
+ confirmText: '去设置',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.openSetting();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '保存图片失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '保存图片失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete() {
|
|
|
+ uni.hideLoading();
|
|
|
+ that.posterShow = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '下载图片失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '下载图片失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 海报相关结束
|
|
|
}
|
|
|
}
|
|
@@ -704,8 +644,8 @@
|
|
|
}
|
|
|
.poster{
|
|
|
position: relative;
|
|
|
- padding-bottom: 90rpx;
|
|
|
- background-color: #fff;
|
|
|
+ // padding-bottom: 90rpx;
|
|
|
+ background-color: transparent;
|
|
|
.posterBg{
|
|
|
position: absolute;
|
|
|
left: 0;
|