parent
4aed2a78e0
commit
4dd71968a5
|
@ -34,6 +34,13 @@ export function getBargainRecordSummary() {
|
|||
});
|
||||
}
|
||||
|
||||
// 获得砍价记录的分页
|
||||
export function getBargainRecordPage(data) {
|
||||
return request.get("app-api/promotion/bargain-record/page", data, {
|
||||
noAuth: true // TODO 芋艿:后续要做调整
|
||||
});
|
||||
}
|
||||
|
||||
// 获得砍价活动详情
|
||||
export function getBargainRecordDetail(id, activityId) {
|
||||
return request.get("app-api/promotion/bargain-record/get-detail", {
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
<template>
|
||||
<view>
|
||||
<view class="priceChange" :class="change === true ? 'on' : ''">
|
||||
<view class="priceTitle">
|
||||
{{
|
||||
status == 0
|
||||
? orderInfo.refund_status === 1
|
||||
? "立即退款"
|
||||
: "一键改价"
|
||||
: "订单备注"
|
||||
}}
|
||||
<span class="iconfont icon-guanbi" @click="close"></span>
|
||||
</view>
|
||||
<view class="listChange" v-if="status == 0">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="orderInfo.refund_status === 0"
|
||||
>
|
||||
<view>商品总价(¥)</view>
|
||||
<view class="money">
|
||||
{{ orderInfo.total_price }}<span class="iconfont icon-suozi"></span>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="orderInfo.refund_status === 0"
|
||||
>
|
||||
<view>原始邮费(¥)</view>
|
||||
<view class="money">
|
||||
{{ orderInfo.pay_postage }}<span class="iconfont icon-suozi"></span>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="orderInfo.refund_status === 0"
|
||||
>
|
||||
<view>实际支付(¥)</view>
|
||||
<view class="money">
|
||||
<input
|
||||
type="text"
|
||||
v-model="price"
|
||||
:class="focus === true ? 'on' : ''"
|
||||
@focus="priceChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="orderInfo.refund_status === 1"
|
||||
>
|
||||
<view>实际支付(¥)</view>
|
||||
<view class="money">
|
||||
{{ orderInfo.pay_price }}<span class="iconfont icon-suozi"></span>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="orderInfo.refund_status === 1"
|
||||
>
|
||||
<view>退款金额(¥)</view>
|
||||
<view class="money">
|
||||
<input
|
||||
type="text"
|
||||
v-model="refund_price"
|
||||
:class="focus === true ? 'on' : ''"
|
||||
@focus="priceChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="listChange" v-else>
|
||||
<textarea
|
||||
:placeholder="
|
||||
orderInfo.remark ? orderInfo.remark : '请填写备注信息...'
|
||||
"
|
||||
v-model="remark"
|
||||
></textarea>
|
||||
</view>
|
||||
<view class="modify" @click="save">
|
||||
{{
|
||||
status === 1 || orderInfo.refund_status == 0 ? "立即修改" : "确认退款"
|
||||
}}
|
||||
</view>
|
||||
<view
|
||||
class="modify1"
|
||||
@click="refuse"
|
||||
v-if="orderInfo.refund_status == 1 && status == 0"
|
||||
>
|
||||
拒绝退款
|
||||
</view>
|
||||
</view>
|
||||
<view class="mask" @touchmove.prevent v-show="change === true"></view>
|
||||
</view>
|
||||
</template>
|
||||
<style>
|
||||
.priceChange{position:fixed;width:580upx;height:670upx;background-color:#fff;border-radius:10upx;top:50%;left:50%;margin-left:-290upx;margin-top:-335upx;z-index:666;transition:all 0.3s ease-in-out 0s;transform: scale(0);opacity:0;}
|
||||
.priceChange.on{opacity:1;transform: scale(1);}
|
||||
.priceChange .priceTitle{background:url("~@/static/images/pricetitle.jpg") no-repeat;background-size:100% 100%;width:100%;height:160upx;border-radius:10upx 10upx 0 0;text-align:center;font-size:40upx;color:#fff;line-height:160upx;position:relative;}
|
||||
.priceChange .priceTitle .iconfont{position:absolute;font-size:40upx;right:26upx;top:23upx;width:40upx;height:40upx;line-height:40upx;}
|
||||
.priceChange .listChange{padding:0 40upx;}
|
||||
.priceChange .listChange textarea{box-sizing: border-box;}
|
||||
.priceChange .listChange .item{height:103upx;border-bottom:1px solid #e3e3e3;font-size:32upx;color:#333;}
|
||||
.priceChange .listChange .item .money{color:#666;width:300upx;text-align:right;}
|
||||
.priceChange .listChange .item .money .iconfont{font-size:32upx;margin-left:20upx;}
|
||||
.priceChange .listChange .item .money input{width:100%;height:100%;text-align:right;color:#ccc;}
|
||||
.priceChange .listChange .item .money input.on{color:#666;}
|
||||
.priceChange .modify{font-size:32upx;color:#fff;width:490upx;height:90upx;text-align:center;line-height:90upx;border-radius:45upx;background-color:#2291f8;margin:53upx auto 0 auto;}
|
||||
.priceChange .modify1{font-size:32upx;color:#312b2b;width:490upx;height:90upx;text-align:center;line-height:90upx;border-radius:45upx;background-color:#eee;margin:30upx auto 0 auto;}
|
||||
.priceChange .listChange textarea {
|
||||
border: 1px solid #eee;
|
||||
width: 100%;
|
||||
height: 200upx;
|
||||
margin-top: 50upx;
|
||||
border-radius: 10upx;
|
||||
color: #333;
|
||||
padding: 20upx;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
export default {
|
||||
name: "PriceChange",
|
||||
components: {},
|
||||
props: {
|
||||
change: Boolean,
|
||||
orderInfo: Object,
|
||||
status: String
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
focus: false,
|
||||
price: 0,
|
||||
refund_price: 0,
|
||||
remark: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
orderInfo: function(nVal) {
|
||||
this.price = this.orderInfo.pay_price;
|
||||
this.refund_price = this.orderInfo.pay_price;
|
||||
this.remark = "";
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
},
|
||||
methods: {
|
||||
priceChange: function() {
|
||||
this.focus = true;
|
||||
},
|
||||
close: function() {
|
||||
this.price = this.orderInfo.pay_price;
|
||||
this.$emit("closechange", false);
|
||||
},
|
||||
save: function() {
|
||||
let that = this;
|
||||
that.$emit("savePrice", {
|
||||
price: that.price,
|
||||
refund_price: that.refund_price,
|
||||
type: 1,
|
||||
remark: that.remark
|
||||
});
|
||||
},
|
||||
refuse: function() {
|
||||
let that = this;
|
||||
that.$emit("savePrice", {
|
||||
price: that.price,
|
||||
refund_price: that.refund_price,
|
||||
type: 2,
|
||||
remark: that.remark
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
11
pages.json
11
pages.json
|
@ -458,17 +458,6 @@
|
|||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "poster-poster/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "砍价海报"
|
||||
// #ifdef MP
|
||||
,
|
||||
"navigationBarTextStyle": "#fff",
|
||||
"navigationBarBackgroundColor": "#e93323"
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bargain/index",
|
||||
"style": {
|
||||
|
|
|
@ -5,39 +5,41 @@
|
|||
<div class="item borRadius14" v-for="(item, index) in bargain" :key="index">
|
||||
<div class="picTxt acea-row row-between-wrapper">
|
||||
<div class="pictrue">
|
||||
<image :src="item.image" />
|
||||
<image :src="item.picUrl" />
|
||||
</div>
|
||||
<div class="text acea-row row-column-around">
|
||||
<div class="line1" style="width: 100%;">{{ item.title }}</div>
|
||||
<div class="line1" style="width: 100%;">{{ item.activityName }}</div>
|
||||
<count-down :justify-left="'justify-content:left'" :bgColor="bgColor" :is-day="true" :tip-text="'倒计时 '" :day-text="'天'"
|
||||
:hour-text="' 时 '" :minute-text="' 分 '"
|
||||
:second-text="' 秒 '" :datatime="item.stopTime/1000" v-if="item.status === 1"></count-down>
|
||||
<div class="successTxt font-color-red" v-else-if="item.status === 3">砍价成功</div>
|
||||
:second-text="' 秒 '" :datatime="item.expireTime / 1000" v-if="item.status === 1"></count-down>
|
||||
<div class="successTxt font-color-red" v-else-if="item.status === 2">砍价成功</div>
|
||||
<div class="endTxt" v-else>活动已结束</div>
|
||||
<div class="money">
|
||||
已砍至<span class="symbol font-color-red">¥</span><span class="num font-color-red">{{ item.surplusPrice }}</span>
|
||||
已砍至<span class="symbol font-color-red">¥</span><span class="num font-color-red">{{ fen2yuan(item.payPrice) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom acea-row row-between-wrapper">
|
||||
<div class="purple" v-if="item.status === 1">活动进行中</div>
|
||||
<div class="success" v-else-if="item.status === 3">砍价成功</div>
|
||||
<div class="success" v-else-if="item.status === 2">砍价成功</div>
|
||||
<div class="end" v-else>活动已结束</div>
|
||||
<div class="acea-row row-middle row-right">
|
||||
<div class="bnt bg-color-red" v-if="item.status === 3 && !item.isOrder" @click="goConfirm(item)">
|
||||
去付款
|
||||
</div>
|
||||
<div class="bnt bg-color-red" v-if="item.status === 3 && !item.isDel && item.isOrder && !item.isPay" @click="goPay(item.surplusPrice,item.orderNo)">
|
||||
<div class="bnt bg-color-red" v-if="item.status === 2 && !item.orderId" @click="goConfirm(item)">
|
||||
去付款
|
||||
</div>
|
||||
<div class="bnt bg-color-red" v-if="item.status === 2 && item.orderId && !item.payStatus" @click="goPay(item.surplusPrice,item.orderNo)">
|
||||
立即付款
|
||||
</div>
|
||||
<div class="bnt bg-color-red" v-if="item.status === 1" @click="goDetail(item.id)">
|
||||
继续砍价
|
||||
</div>
|
||||
<div class="bnt bg-color-red" v-if="item.status === 2" @click="goList">重开一个</div>
|
||||
<div class="bnt bg-color-red" v-if="item.status === 3" @click="goList">
|
||||
重开一个
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Loading :loaded="status" :loading="loadingList"></Loading>
|
||||
<Loading :loaded="status" :loading="loadingList" />
|
||||
</div>
|
||||
</block>
|
||||
<block v-if="bargain.length === 0">
|
||||
|
@ -50,17 +52,14 @@
|
|||
<script>
|
||||
import CountDown from "@/components/countDown";
|
||||
import emptyPage from '@/components/emptyPage.vue'
|
||||
import {
|
||||
getBargainUserList,
|
||||
getBargainUserCancel
|
||||
} from "@/api/activity";
|
||||
import Loading from "@/components/Loading";
|
||||
import { getBargainUserCancel } from "@/api/activity";
|
||||
import * as BargainApi from '@/api/promotion/bargain.js';
|
||||
import Loading from "@/components/Loading";
|
||||
import home from '@/components/home';
|
||||
import payment from '@/components/payment';
|
||||
import {
|
||||
mapGetters
|
||||
} from "vuex";
|
||||
export default {
|
||||
import { mapGetters } from "vuex";
|
||||
import * as Util from '@/utils/util.js';
|
||||
export default {
|
||||
name: "BargainRecord",
|
||||
components: {
|
||||
CountDown,
|
||||
|
@ -81,10 +80,12 @@
|
|||
'isDay': false
|
||||
},
|
||||
bargain: [],
|
||||
status: false, //砍价列表是否获取完成 false 未完成 true 完成
|
||||
loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
|
||||
page: 1, //页码
|
||||
limit: 20, //数量
|
||||
status: false, // 砍价列表是否获取完成 false 未完成 true 完成
|
||||
loadingList: false, // 当前接口是否请求完成 false 完成 true 未完成
|
||||
page: 1, // 页码
|
||||
limit: 20, // 数量
|
||||
|
||||
// TODO 芋艿:这里后续要干掉,应该单独有支付页
|
||||
payMode: [{
|
||||
name: "微信支付",
|
||||
icon: "icon-weixinzhifu",
|
||||
|
@ -106,22 +107,86 @@
|
|||
},
|
||||
onLoad: function() {
|
||||
this.getBargainUserList();
|
||||
// this.$scroll(this.$refs.container, () => {
|
||||
// !this.loadingList && this.getBargainUserList();
|
||||
// });
|
||||
},
|
||||
onShow() {
|
||||
if (this.isLogin) {
|
||||
this.payMode[1].number = this.userInfo.nowMoney;
|
||||
this.$set(this, 'payMode', this.payMode);
|
||||
} else {
|
||||
toLogin();
|
||||
if (!this.isLogin) {
|
||||
toLogin();
|
||||
return
|
||||
}
|
||||
|
||||
this.payMode[1].number = this.userInfo.nowMoney;
|
||||
this.$set(this, 'payMode', this.payMode);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获得拼团记录
|
||||
*/
|
||||
getBargainUserList: function() {
|
||||
if (this.loadingList || this.status) {
|
||||
return;
|
||||
}
|
||||
this.loadingList = true
|
||||
BargainApi.getBargainRecordPage({
|
||||
pageNo: this.page,
|
||||
pageSize: this.limit
|
||||
}).then(res => {
|
||||
this.status = res.data.list.length < this.limit;
|
||||
this.bargain.push.apply(this.bargain, res.data.list);
|
||||
this.page++;
|
||||
this.loadingList = false;
|
||||
}).catch(res => {
|
||||
this.$dialog.error(res);
|
||||
this.loadingList = false;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 立即下单
|
||||
*/
|
||||
goConfirm: function(item) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/users/order_confirm/index?skuId=' + item.skuId + '&count=1'
|
||||
+ '&bargainRecordId=' + item.id
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 前往砍价记录的详情
|
||||
*/
|
||||
goDetail: function(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/activity/goods_bargain_details/index?id=${id}&startBargainUid=${this.uid}`
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 前往砍价活动的列表
|
||||
*/
|
||||
goList: function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/activity/goods_bargain/index'
|
||||
})
|
||||
},
|
||||
// TODO @芋艿:貌似没看到调用的地方,估计暂时没实现
|
||||
getBargainUserCancel: function(bargainId) {
|
||||
var that = this;
|
||||
getBargainUserCancel({
|
||||
bargainId: bargainId
|
||||
}).then(res => {
|
||||
that.status = false;
|
||||
that.loadingList = false;
|
||||
that.page = 1;
|
||||
that.bargain = [];
|
||||
that.getBargainUserList();
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
})
|
||||
}).catch(res => {
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 打开支付组件
|
||||
*
|
||||
*/
|
||||
goPay(pay_price, order_id) {
|
||||
this.$set(this, 'pay_close', true);
|
||||
|
@ -130,7 +195,6 @@
|
|||
},
|
||||
/**
|
||||
* 事件回调
|
||||
*
|
||||
*/
|
||||
onChangeFun: function(e) {
|
||||
let opt = e;
|
||||
|
@ -160,65 +224,10 @@
|
|||
pay_fail: function() {
|
||||
this.pay_close = false;
|
||||
},
|
||||
goConfirm: function(item) { //立即支付
|
||||
if (this.isLogin === false) {
|
||||
toLogin();
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/activity/goods_bargain_details/index?id=${item.id}&startBargainUid=${this.uid}&storeBargainId=${item.bargainUserId}`
|
||||
})
|
||||
}
|
||||
},
|
||||
goDetail: function(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/activity/goods_bargain_details/index?id=${id}&startBargainUid=${this.uid}`
|
||||
})
|
||||
},
|
||||
// 砍价列表
|
||||
goList: function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/activity/goods_bargain/index'
|
||||
})
|
||||
},
|
||||
getBargainUserList: function() {
|
||||
var that = this;
|
||||
if (that.loadingList) return;
|
||||
if (that.status) return;
|
||||
getBargainUserList({
|
||||
page: that.page,
|
||||
limit: that.limit
|
||||
})
|
||||
.then(res => {
|
||||
that.status = res.data.list.length < that.limit;
|
||||
that.bargain.push.apply(that.bargain, res.data.list);
|
||||
that.page++;
|
||||
that.loadingList = false;
|
||||
})
|
||||
.catch(res => {
|
||||
that.$dialog.error(res);
|
||||
});
|
||||
},
|
||||
getBargainUserCancel: function(bargainId) {
|
||||
var that = this;
|
||||
getBargainUserCancel({
|
||||
bargainId: bargainId
|
||||
})
|
||||
.then(res => {
|
||||
that.status = false;
|
||||
that.loadingList = false;
|
||||
that.page = 1;
|
||||
that.bargain = [];
|
||||
that.getBargainUserList();
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
})
|
||||
})
|
||||
.catch(res => {
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fen2yuan(price) {
|
||||
return Util.fen2yuan(price)
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
this.getBargainUserList();
|
||||
|
|
|
@ -1,280 +0,0 @@
|
|||
<template>
|
||||
<view>
|
||||
<view class='poster-poster'>
|
||||
<view class='tip'><text class='iconfont icon-shuoming'></text>提示:点击图片即可保存至手机相册 </view>
|
||||
<view class='pictrue' v-if="canvasStatus">
|
||||
<image :src='imagePath'></image>
|
||||
</view>
|
||||
<view class="canvas">
|
||||
<canvas style="width:750px;height:1130px;" canvas-id="firstCanvas" id="firstCanvas"></canvas>
|
||||
<canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" style="opacity: 0;"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCombinationPink, getCombinationPoster } from '../../../api/activity.js';
|
||||
import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js';
|
||||
import { imageBase64 } from "@/api/public";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
parameter: {
|
||||
'navbar': '1',
|
||||
'return': '1',
|
||||
'title': '拼团海报',
|
||||
'color': true,
|
||||
'class': '0'
|
||||
},
|
||||
type: 0,
|
||||
id: 0,
|
||||
image: '',
|
||||
from:'',
|
||||
storeCombination: {},
|
||||
qrcodeSize: 600,
|
||||
posterbackgd: '/static/images/canbj.png',
|
||||
PromotionCode: '',//二维码
|
||||
canvasStatus: false,
|
||||
imgTop: '' //商品图base64位
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// #ifdef MP
|
||||
this.from = 'routine'
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
this.from = 'wechat'
|
||||
// #endif
|
||||
var that = this;
|
||||
if (options.hasOwnProperty('type') && options.hasOwnProperty('id')) {
|
||||
this.type = options.type
|
||||
this.id = options.id
|
||||
if (options.type == 1) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '砍价海报'
|
||||
})
|
||||
} else {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '拼团海报'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return app.Tips({
|
||||
title: '参数错误',
|
||||
icon: 'none'
|
||||
}, {
|
||||
tab: 3,
|
||||
url: 1
|
||||
});
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.getPosterInfo();
|
||||
},
|
||||
methods: {
|
||||
getPosterInfo: function() {
|
||||
var that = this,url = '';
|
||||
let data = {
|
||||
pinkId: parseFloat(that.id),
|
||||
from: that.from
|
||||
};
|
||||
if (that.type == 1) {
|
||||
|
||||
} else {
|
||||
this.getCombinationPink();
|
||||
}
|
||||
},
|
||||
//拼团信息
|
||||
getCombinationPink: function() {
|
||||
var that = this;
|
||||
getCombinationPink(this.id)
|
||||
.then(res => {
|
||||
this.storeCombination = res.data;
|
||||
this.getImageBase64(res.data.storeCombination.image);
|
||||
// #ifdef H5
|
||||
that.make(res.data.userInfo.uid);
|
||||
// #endif
|
||||
})
|
||||
.catch(err => {
|
||||
this.$util.Tips({
|
||||
title: err
|
||||
});
|
||||
uni.redirectTo({
|
||||
success(){},
|
||||
fail() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
getImageBase64:function(images){
|
||||
let that = this;
|
||||
imageBase64({url:images}).then(res=>{
|
||||
that.imgTop = res.data.code
|
||||
})
|
||||
},
|
||||
// 生成二维码;
|
||||
make(uid) {
|
||||
let href = location.protocol + '//' + window.location.host + '/pages/activity/goods_combination_status/index?id=' + this.id + "&spread=" + uid;
|
||||
uQRCode.make({
|
||||
canvasId: 'qrcode',
|
||||
text: href,
|
||||
size: this.qrcodeSize,
|
||||
margin: 10,
|
||||
success: res => {
|
||||
this.PromotionCode = res;
|
||||
let arrImages = [this.posterbackgd, this.imgTop, this.PromotionCode];
|
||||
let storeName = this.storeCombination.storeCombination.title;
|
||||
let price = this.storeCombination.storeCombination.price;
|
||||
let people = this.storeCombination.storeCombination.people;
|
||||
let otPrice = this.storeCombination.storeCombination.otPrice;
|
||||
let count = this.storeCombination.count;
|
||||
setTimeout(() => {
|
||||
this.PosterCanvas(arrImages, storeName, price, people,otPrice,count);
|
||||
}, 300);
|
||||
},
|
||||
complete: () => {
|
||||
},
|
||||
fail:res=>{
|
||||
this.$util.Tips({
|
||||
title: '海报二维码生成失败!'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
// 生成海报
|
||||
PosterCanvas:function(arrImages, storeName, price, people,otPrice,count){
|
||||
uni.showLoading({
|
||||
title: '海报生成中',
|
||||
mask: true
|
||||
});
|
||||
let context = uni.createCanvasContext('firstCanvas')
|
||||
context.clearRect(0, 0, 0, 0);
|
||||
let that = this;
|
||||
uni.getImageInfo({
|
||||
src: arrImages[0],
|
||||
success: function (image) {
|
||||
context.drawImage(arrImages[0], 0, 0, 750, 1190);
|
||||
context.setFontSize(36);
|
||||
context.setTextAlign('center');
|
||||
context.setFillStyle('#282828');
|
||||
let maxText = 20;
|
||||
let text = storeName;
|
||||
let topText = '';
|
||||
let bottomText = '';
|
||||
let len = text.length;
|
||||
if(len>maxText*2){
|
||||
text = text.slice(0,maxText*2-4)+'......';
|
||||
topText = text.slice(0,maxText-1);
|
||||
bottomText = text.slice(maxText-1,len);
|
||||
}else{
|
||||
if(len>maxText){
|
||||
topText = text.slice(0,maxText-1);
|
||||
bottomText = text.slice(maxText-1,len);
|
||||
}else{
|
||||
topText = text;
|
||||
bottomText = '';
|
||||
}
|
||||
}
|
||||
context.fillText(topText, 750/2, 60);
|
||||
context.fillText(bottomText, 750/2, 100);
|
||||
|
||||
context.drawImage(arrImages[1], 150, 350, 450, 450);
|
||||
context.save();
|
||||
context.drawImage(arrImages[2], 300, 950, 140, 140);
|
||||
context.restore();
|
||||
|
||||
context.setFontSize(72);
|
||||
context.setFillStyle('#fc4141');
|
||||
context.fillText(price, 250, 210);
|
||||
|
||||
context.setFontSize(32);
|
||||
context.setFillStyle('#FFFFFF');
|
||||
context.fillText( people+'人团', 538, 198);
|
||||
|
||||
|
||||
context.setFontSize(26);
|
||||
context.setFillStyle('#3F3F3F');
|
||||
context.setTextAlign('center');
|
||||
context.fillText( '原价:¥'+otPrice +' 还差 ' + count + '人 拼团成功', 750 / 2, 275);
|
||||
|
||||
context.draw(true,function(){
|
||||
uni.canvasToTempFilePath({
|
||||
destWidth: 750,
|
||||
destHeight: 1190,
|
||||
canvasId: 'firstCanvas',
|
||||
fileType: 'jpg',
|
||||
success: function(res) {
|
||||
// 在H5平台下,tempFilePath 为 base64
|
||||
uni.hideLoading();
|
||||
that.imagePath = res.tempFilePath;
|
||||
that.canvasStatus = true;
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
fail: function(err) {
|
||||
uni.hideLoading();
|
||||
that.$util.Tips({
|
||||
title: '无法获取图片信息'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
showImage: function() {
|
||||
var that = this;
|
||||
let imgArr = this.image.split(',')
|
||||
uni.previewImage({
|
||||
urls: imgArr,
|
||||
longPressActions: {
|
||||
itemList: ['发送给朋友', '保存图片', '收藏'],
|
||||
success: function(data) {
|
||||
console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
|
||||
},
|
||||
fail: function(err) {
|
||||
console.log(err.errMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page {
|
||||
background-color: #d22516 !important;
|
||||
}
|
||||
.canvas {
|
||||
position:fixed;
|
||||
z-index: -5;
|
||||
opacity: 0;
|
||||
}
|
||||
.poster-poster .tip {
|
||||
height: 80rpx;
|
||||
font-size: 26rpx;
|
||||
color: #e8c787;
|
||||
text-align: center;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
.poster-poster .tip .iconfont {
|
||||
font-size: 36rpx;
|
||||
vertical-align: -4rpx;
|
||||
margin-right: 18rpx;
|
||||
}
|
||||
|
||||
.poster-poster .pictrue {
|
||||
width: 690rpx;
|
||||
height: 1130rpx;
|
||||
margin: 0 auto 50rpx auto;
|
||||
}
|
||||
|
||||
.poster-poster .pictrue image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue