Jelajahi Sumber

生成海报初始化

yuxingxing 2 tahun lalu
induk
melakukan
4fb0592482

+ 9 - 0
api/home.js

@@ -159,3 +159,12 @@ export function postLoginAuth(data) {
 		noVerify: true
 	});
 }
+
+// 获取分享连接
+export function postLinkedUrl(data) {
+	let url = "?code="+data.code+"&getPhoneNumberCode="+data.getPhoneNumberCode
+	return request.post("v1/linked/getLinkedUrl"+url,data,{
+		noAuth: true,
+		noVerify: true
+	});
+}

+ 5 - 4
components/shareRedPackets/index.vue

@@ -1,11 +1,12 @@
 <template>
 	<view v-if="sharePacket.isState" class='sharing-packets' :class='sharePacket.isState && showAnimate ? "":"right"'>
 		<view class='sharing-con' @click='goShare'>
-			<image :src="imgHost + '/statics/images/red-packets.png'" />
+			<!-- <image :src="imgHost + '/statics/images/red-packets.png'" /> -->
+			<image src="@/static/images/red-packets.png" />
 			<view class='text font-color'>
-				<view>{{$t(`最高返佣`)}}</view>
-				<view class='money'><text class='label'>{{$t(`¥`)}}</text>{{sharePacket.priceName}}</view>
-				<view class='tip'>{{$t(`推广享佣金`)}}</view>
+				<view>{{$t(`共富1580`)}}</view>
+				<view class='money'><text class='label'></text>{{sharePacket.priceName}}</view>
+				<view class='tip'>{{$t(`推广享红积分`)}}</view>
 				<view class='shareBut'>{{$t(`立即分享`)}}</view>
 			</view>
 		</view>

+ 51 - 32
mixins/sharePoster.js

@@ -92,6 +92,7 @@ export const sharePoster = {
 					// #endif
 				},
 				success() {
+					console.log(that);
 					if (arr2[2] == "") {
 						//海报二维码不存在则从新下载
 						that.downloadFilePromotionCode(function(msgPromotionCode) {
@@ -102,9 +103,9 @@ export const sharePoster = {
 								});
 							that.$util.PosterCanvas(
 								arr2,
-								that.storeInfo.store_name,
-								that.storeInfo.price,
-								that.storeInfo.ot_price,
+								that.storeInfo.goodsName,
+								that.storeInfo.salePrice - 0,
+								that.$Cache.get("USER_INFO", true).code,
 								function(tempFilePath) {
 									that.$set(that, "posterImage", tempFilePath);
 									that.$set(that, "posterImageStatus", true);
@@ -119,9 +120,9 @@ export const sharePoster = {
 						that.$nextTick(e => {
 							that.$util.PosterCanvas(
 								arr2,
-								that.storeInfo.store_name,
-								that.storeInfo.price,
-								that.storeInfo.ot_price,
+								that.storeInfo.goodsName,
+								that.storeInfo.salePrice - 0,
+								that.$Cache.get("USER_INFO", true).code,
 								function(tempFilePath) {
 									that.$set(that, "posterImage", tempFilePath);
 									that.$set(that, "posterImageStatus", true);
@@ -137,17 +138,21 @@ export const sharePoster = {
 			});
 		},
 		//替换安全域名
+		// setDomain(url) {
+		// 	url = url ? url.toString() : "";
+		// 	//本地调试打开,生产请注销
+		// 	if (url.indexOf("https://") > -1) return url;
+		// 	else return url.replace("http://", "https://");
+		// },
+		//替换安全域名
 		setDomain(url) {
-			url = url ? url.toString() : "";
-			//本地调试打开,生产请注销
-			if (url.indexOf("https://") > -1) return url;
-			else return url.replace("http://", "https://");
+			return url
 		},
 		//获取海报产品图
 		downloadFilestoreImage() {
 			let that = this;
 			uni.downloadFile({
-				url: that.setDomain(that.storeInfo.image),
+				url: that.setDomain(that.storeInfo.goodsCover),
 				success: function(res) {
 					that.storeImage = res.tempFilePath;
 					that.storeImageBase64 = res.tempFilePath;
@@ -168,29 +173,43 @@ export const sharePoster = {
 		downloadFilePromotionCode(successFn) {
 			let that = this;
 			// #ifdef MP
-			getProductCode(that.id)
-				.then((res) => {
-					uni.downloadFile({
-						url: that.setDomain(res.data.code),
-						success: function(res) {
-							that.$set(that, "isDown", false);
-							that.$set(that, "PromotionCode", res.tempFilePath)
-							if (typeof successFn == "function")
-								successFn && successFn(res.tempFilePath);
-						},
-						fail: function() {
-							that.$set(that, "isDown", false);
-							that.$set(that, "PromotionCode", "");
-						},
-					});
-				})
-				.catch((err) => {
+			uni.downloadFile({
+				url: that.setDomain("https://demo26.crmeb.net/uploads/routine/product/119_34391_1_product.jpg"),
+				success: function(res) {
+					that.$set(that, "isDown", false);
+					that.$set(that, "PromotionCode", res.tempFilePath)
+					that.goPoster()
+					if (typeof successFn == "function")
+						successFn && successFn(res.tempFilePath);
+				},
+				fail: function() {
 					that.$set(that, "isDown", false);
 					that.$set(that, "PromotionCode", "");
-					return that.$util.Tips({
-						title: err,
-					});
-				});
+				},
+			});
+			// getProductCode(that.id)
+			// 	.then((res) => {
+			// 		uni.downloadFile({
+			// 			url: that.setDomain(res.data.code),
+			// 			success: function(res) {
+			// 				that.$set(that, "isDown", false);
+			// 				that.$set(that, "PromotionCode", res.tempFilePath)
+			// 				if (typeof successFn == "function")
+			// 					successFn && successFn(res.tempFilePath);
+			// 			},
+			// 			fail: function() {
+			// 				that.$set(that, "isDown", false);
+			// 				that.$set(that, "PromotionCode", "");
+			// 			},
+			// 		});
+			// 	})
+			// 	.catch((err) => {
+			// 		that.$set(that, "isDown", false);
+			// 		that.$set(that, "PromotionCode", "");
+			// 		return that.$util.Tips({
+			// 			title: err,
+			// 		});
+			// 	});
 			// #endif
 			// #ifdef APP-PLUS
 			uni.downloadFile({

+ 122 - 72
pages/goods_details/index.vue

@@ -247,6 +247,9 @@
 						</view>
 					</view> -->
 			</view>
+			<shareRedPackets :sharePacket="sharePacket" @listenerActionSheet="listenerActionSheet"
+				@closeChange="closeChange" :showAnimate="showAnimate" @boxStatus="boxStatus">
+			</shareRedPackets>
 			<!-- 组件 -->
 			<productWindow v-if="attr.cartAttr" :attr="attr" :isShow="1" :iSplus="1" @myevent="onMyEvent"
 				@ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum"
@@ -259,6 +262,42 @@
 				@tabCouponType="tabCouponType">
 			</couponListWindow>
 			<!-- 分享按钮 -->
+			<view class="generate-posters acea-row row-middle" :class="posters ? 'on' : ''">
+				<!-- #ifndef MP -->
+				<button class="item" hover-class="none" v-if="weixinStatus === true" @click="H5ShareBox = true">
+					<view class="iconfont icon-weixin3"></view>
+					<view class="">{{$t(`发送给朋友`)}}</view>
+				</button>
+				<!-- #endif -->
+				<!-- #ifdef MP -->
+				<button class="item" open-type="share" hover-class="none" @click="goFriend">
+					<view class="iconfont icon-weixin3"></view>
+					<view class="">{{$t(`发送给朋友`)}}</view>
+				</button>
+				<!-- #endif -->
+				<!-- #ifdef H5  -->
+				<div class="item copy-data" v-if="storeInfo.command_word != ''"
+					:data-clipboard-text="storeInfo.command_word">
+					<view class="iconfont icon-fuzhikouling"></view>
+					<text>{{$t(`复制口令`)}}</text>
+				</div>
+				<!-- #endif -->
+				<!-- #ifdef APP-PLUS -->
+				<view class="item" @click="appShare('WXSceneSession')">
+					<view class="iconfont icon-weixin3"></view>
+					<view class="">{{$t(`微信好友`)}}</view>
+				</view>
+				<view class="item" @click="appShare('WXSenceTimeline')">
+					<view class="iconfont icon-pengyouquan"></view>
+					<view class="">{{$t(`微信朋友圈`)}}</view>
+				</view>
+				<!-- #endif -->
+				<button class="item" hover-class="none" @click="goPoster">
+					<view class="iconfont icon-haibao"></view>
+					<view class="">{{$t(`生成海报`)}}</view>
+				</button>
+			</view>
+			<!-- 分享按钮 -->
 			<view class="mask" v-if="posters" @click="listenerActionClose"></view>
 			<!-- #ifdef MP -->
 			<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
@@ -324,7 +363,7 @@ import productConSwiper from "@/components/productConSwiper";
 import couponListWindow from "@/components/couponListWindow";
 import productWindow from "@/components/productWindow";
 import userEvaluation from "@/components/userEvaluation";
-// import shareRedPackets from "@/components/shareRedPackets";
+import shareRedPackets from "@/components/shareRedPackets";
 import kefuIcon from "@/components/kefuIcon";
 import {
 	silenceBindingSpread,
@@ -353,7 +392,7 @@ export default {
 		couponListWindow,
 		productWindow,
 		userEvaluation,
-		// shareRedPackets,
+		shareRedPackets,
 		kefuIcon,
 		cusPreviewImg,
 		// #ifdef MP
@@ -410,8 +449,9 @@ export default {
 			PromotionCode: "", //二维码图片
 			canvasStatus: false, //海报绘图标签
 			posterImage: "", //海报路径
+			posterbackgd: "/static/images/posterbackgd.png",
 			sharePacket: {
-				isState: true, //默认不显示
+				isState: false, //默认不显示
 			}, //分销商详细
 			circular: false,
 			autoplay: false,
@@ -463,10 +503,10 @@ export default {
 			skuArr: [],
 			selectSku: {},
 			currentPage: false,
-			svip_price_open: 1
+			svip_price_open: 1,
 		};
 	},
-	computed: mapGetters(["isLogin", "uid", "userInfo","selectAddr"]),
+	computed: mapGetters(["isLogin", "uid", "userInfo", "selectAddr"]),
 	watch: {
 		isLogin: {
 			handler: function (newV, oldV) {
@@ -504,73 +544,74 @@ export default {
 			});
 			setTimeout(() => {
 				// 未登录跳转登录
-				uni.reLaunch({
+				uni.navigateTo({
 					url: '/pages/users/wechat_login/index'
 				})
 			}, 1500);
-		}
-		let userInfo = this.$Cache.get("USER_INFO", true)
-		console.log("用户自己的推荐码:" + userInfo.code);
-		console.log("受邀的推荐码:" + options.inviteCode);
-		//1580 进入时
-		if (options.zoneType == 8) {
-			//判断是否为自己的要求码进入
-			if (options.inviteCode !== userInfo.code) {
-				if (options.inviteCode != "undefined") {
-					this.$Cache.set('INVITE_CODE', options.inviteCode);
+		} else {
+			let userInfo = this.$Cache.get("USER_INFO", true)
+			console.log("用户自己的推荐码:" + userInfo.code);
+			console.log("受邀的推荐码:" + options.inviteCode);
+			//1580 进入时
+			if (options.zoneType == 8) {
+				//判断是否为自己的要求码进入
+				if (options.inviteCode !== userInfo.code) {
+					if (options.inviteCode != "undefined") {
+						this.$Cache.set('INVITE_CODE', options.inviteCode);
+					}
 				}
 			}
-		}
-		let that = this;
-		var pages = getCurrentPages();
-		that.returnShow = pages.length === 1 ? false : true;
-		// #ifdef MP
-		that.navH = app.globalData.navHeight;
-		// #endif
-		// #ifdef H5
-		that.navH = 96;
-		// #endif
-		// #ifdef APP-PLUS
-		that.navH = 30;
-		// #endif
-		that.id = options.id;
-		uni.getSystemInfo({
-			success: function (res) {
-				that.height = res.windowHeight;
-				//res.windowHeight:获取整个窗口高度为px,*2为rpx;98为头部占据的高度;
-				// #ifndef APP-PLUS || H5 || MP-ALIPAY
-				that.navbarRight =
-					res.windowWidth - uni.getMenuButtonBoundingClientRect().left;
-				// #endif
-			},
-		});
-		//扫码携带参数处理
-		// #ifdef MP
-		if (options.scene) {
-			let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
-			if (value.id) options.id = value.id;
-			//记录推广人uid
-			if (value.pid) app.globalData.spid = value.pid;
-		}
-		if (!options.id) {
-			this.showSkeleton = false;
-			return that.$util.Tips({
-				title: that.$t(`缺少参数无法查看商品`),
-			}, {
-				tab: 3,
-				url: 1,
-			});
-		} else {
+			let that = this;
+			var pages = getCurrentPages();
+			that.returnShow = pages.length === 1 ? false : true;
+			// #ifdef MP
+			that.navH = app.globalData.navHeight;
+			// #endif
+			// #ifdef H5
+			that.navH = 96;
+			// #endif
+			// #ifdef APP-PLUS
+			that.navH = 30;
+			// #endif
 			that.id = options.id;
+			uni.getSystemInfo({
+				success: function (res) {
+					that.height = res.windowHeight;
+					//res.windowHeight:获取整个窗口高度为px,*2为rpx;98为头部占据的高度;
+					// #ifndef APP-PLUS || H5 || MP-ALIPAY
+					that.navbarRight =
+						res.windowWidth - uni.getMenuButtonBoundingClientRect().left;
+					// #endif
+				},
+			});
+			//扫码携带参数处理
+			// #ifdef MP
+			if (options.scene) {
+				let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
+				if (value.id) options.id = value.id;
+				//记录推广人uid
+				if (value.pid) app.globalData.spid = value.pid;
+			}
+			if (!options.id) {
+				this.showSkeleton = false;
+				return that.$util.Tips({
+					title: that.$t(`缺少参数无法查看商品`),
+				}, {
+					tab: 3,
+					url: 1,
+				});
+			} else {
+				that.id = options.id;
+			}
+			//记录推广人uid
+			if (options.spid) app.globalData.spid = options.spid;
+			// #endif
+			that.getGoodsDetails();
+			// that.getCouponList(0);
+			//#ifdef H5
+			that.isLogin && silenceBindingSpread();
+			//#endif
 		}
-		//记录推广人uid
-		if (options.spid) app.globalData.spid = options.spid;
-		// #endif
-		that.getGoodsDetails();
-		// that.getCouponList(0);
-		//#ifdef H5
-		that.isLogin && silenceBindingSpread();
-		//#endif
 	},
 	onReady: function () {
 		this.isNodes++;
@@ -614,7 +655,7 @@ export default {
 		return {
 			title: that.storeInfo.store_name || "",
 			imageUrl: that.storeInfo.image || "",
-			path: "/pages/goods_details/index?id=" + that.id + "&spid=" + that.uid,
+			path: "/pages/goods_details/index?id=" + that.id + "&inviteCode=" + that.$Cache.get("USER_INFO", true).code,
 		};
 	},
 
@@ -906,9 +947,14 @@ export default {
 				.then((res) => {
 					let storeInfo = res.data;
 					that.storeInfo = res.data
+					// 处理分享
+					if (that.storeInfo.zoneType == 8) {
+						that.sharePacket.isState = true
+					}
 					that.skuArr = storeInfo.goodsSpecList
 					that.$set(that, "storeInfo", storeInfo);
 					that.$set(that.attr, "productAttr", storeInfo.goodsSpecList);
+					that.downloadFilestoreImage();
 					that.getUserAddressByUserId()
 					setTimeout(function () {
 						that.infoScroll();
@@ -1003,6 +1049,10 @@ export default {
 					if (value.canSale) {
 						this.attrValue = value.spceName
 						this.storeInfo.obtainIntegral = value.obtainIntegral - 0
+						// 处理分享
+						if (this.storeInfo.zoneType == 8) {
+							this.sharePacket.priceName = this.storeInfo.obtainIntegral
+						}
 						this.storeInfo.salePrice = value.salePrice - 0
 						this.attr.productSelect.totalStock = value.stock - 0
 						this.attr.attrValueId = value.id
@@ -1163,9 +1213,9 @@ export default {
 				toLogin();
 			} else {
 				//判断是否有地址
-				if(!this.attrAddrValue && !this.attrAddrValue.id){
+				if (!this.attrAddrValue && !this.attrAddrValue.id) {
 					this.goCat();
-				}else{
+				} else {
 					this.$util.Tips({
 						title: this.$t(`请先至个人中心设置默认地址`),
 					});
@@ -1277,9 +1327,9 @@ export default {
 				toLogin();
 			} else {
 				//判断是否有地址
-				if(this.attrAddrValue && this.attrAddrValue.id){
+				if (this.attrAddrValue && this.attrAddrValue.id) {
 					this.goCat(true);
-				}else{
+				} else {
 					this.$util.Tips({
 						title: this.$t(`请先配置送至地址`),
 					});
@@ -1320,8 +1370,8 @@ export default {
 
 				}
 				// #endif
-
-				this.posters = true;
+				// this.goPoster()
+				// this.posters = true;
 			}
 		},
 		// 分享关闭

+ 1 - 1
pages/users/wechat_login/index.vue

@@ -264,7 +264,7 @@ export default {
 						title: this.$t(`登录成功`),
 						icon: 'success'
 					}, {
-						tab: 3
+						tab: 4
 					});
 				})
 				.catch(res => {

TEMPAT SAMPAH
static/images/posterbackgd.png


TEMPAT SAMPAH
static/images/red-packets.png


+ 20 - 20
utils/util.js

@@ -234,28 +234,28 @@ export default {
 				ctx.setFillStyle('#999');
 					
 				if(ot_price){
-					ctx.fillText(i18n.t(``) + ot_price, 50, 876 + contentHh);
-					var underline = function(ctx, text, x, y, size, color, thickness, offset) {
-						var width = ctx.measureText(text).width;
-						switch (ctx.textAlign) {
-							case "center":
-								x -= (width / 2);
-								break;
-							case "right":
-								x -= width;
-								break;
-						}
+					ctx.fillText(i18n.t(`推荐码 `) + ot_price, 50, 876 + contentHh);
+					// var underline = function(ctx, text, x, y, size, color, thickness, offset) {
+					// 	var width = ctx.measureText(text).width;
+					// 	switch (ctx.textAlign) {
+					// 		case "center":
+					// 			x -= (width / 2);
+					// 			break;
+					// 		case "right":
+					// 			x -= width;
+					// 			break;
+					// 	}
 					
-						y += size + offset;
+					// 	y += size + offset;
 					
-						ctx.beginPath();
-						ctx.strokeStyle = color;
-						ctx.lineWidth = thickness;
-						ctx.moveTo(x, y);
-						ctx.lineTo(x + width, y);
-						ctx.stroke();
-					}
-					underline(ctx, i18n.t(`¥`) + ot_price, 55, 865, 36, '#999', 2, 0)
+					// 	ctx.beginPath();
+					// 	ctx.strokeStyle = color;
+					// 	ctx.lineWidth = thickness;
+					// 	ctx.moveTo(x, y);
+					// 	ctx.lineTo(x + width, y);
+					// 	ctx.stroke();
+					// }
+					// underline(ctx, i18n.t(`¥`) + ot_price, 55, 865, 36, '#999', 2, 0)
 				} 
 				ctx.setTextAlign('left')
 				ctx.setFontSize(28);