<template>
	<div
		:style="styleData"
		ref="rotaryTable2"
		@click.stop="styleClick('click', 'rotaryTable2')"
		@mousemove.stop="styleClick('mousemove', 'rotaryTable2')"
		@mouseout.stop="styleClick('mouseout')"
	>
		<div v-show="isShowButton" class="signButton">
			<buttonCom :buttonStyle="styleDataNew.signButtonStyle" :title="signTitle" :isWebClick="isWebClick" :disabled="isDisabled" @btnClick="btnClick"></buttonCom>
			<!-- <buttonCom :buttonStyle="styleDataNew.signButtonStyle" :title="signTitle" @btnClick="btnClick"></buttonCom> -->
		</div>

		<div class="restDrawCount" :style="styleDataNew.restDrawCountStyle" v-if="isShowDrawCount" ref="restDrawCountStyle">
			当前还有
			<span :style="styleDataNew.restDrawCountStyle.restDrawCountSpanStyle">{{ restDrawCount }}次</span>
			抽奖机会
		</div>

		<div @click="closeClick()" v-show="isShowRotary" :style="styleDataNew.turnMaskBox">
			<div id="turnBox" @click.stop="" :style="styleDataNew.turnBox">
				<div
					:style="styleDataNew.turnBox1"
					ref="turnBox1"
					@click.stop="styleClick('click', 'rotaryTable2')"
					@mousemove.stop="styleClick('mousemove', 'rotaryTable2')"
					@mouseout.stop="styleClick('mouseout')"
				>
					<div v-show="isShowPaoMadengButton" class="turnBox2" :style="{ backgroundImage: 'url(' + datas[keyData.mainBg2] + ')' }"></div>
					<div v-show="isShowPaoMadengButton1" class="turnBox2" :style="{ backgroundImage: 'url(' + datas[keyData.mainBg3] + ')' }"></div>
					<ul id="turnUl" :style="styleDataNew.turnUl" ref="turnUl">
						<li class="itemLi" v-for="(item, index) in prizeListData" :key="index" :style="{ webkitTransform: 'rotate(' + item.angle + 'deg)' }">
							<div :style="styleDataNew.prizeName" v-if="item.prizeType">
								<div>
									<div
										style="
                      width: 1.8rem;
                      margin: 0 auto;
                      overflow: hidden;
                      white-space: nowrap;
                      -o-text-overflow: ellipsis;
                      text-overflow: ellipsis;
                    "
									>
										{{ item.prizeName }}
									</div>
									<div class=""><img :style="styleDataNew.img" :src="item[keyData.showImg]" /></div>
								</div>
							</div>
							<div class="prizeName1 prizeName2" :style="styleDataNew.prizeName1" v-else>{{ item[keyData.prizeName] }}</div>
						</li>
					</ul>

					<img
						v-if="!isStartPlay && !isWebClick"
						:src="styleDataNew.turnBtn.imageUrl"
						alt=""
						v-lz-click="'12'"
						@click="startPlay"
						:style="styleDataNew.turnBtn"
						class="turnBtn"
					/>
					<img v-else :src="styleDataNew.turnBtn.imageUrl" :style="styleDataNew.turnBtn" alt="" class="turnBtn" />
				</div>
			</div>

			<div v-if="isShowCircle && restDrawCount <= 0" :style="styleDataNew.jfBtn" class="f-tac jf-btn">
				<span :style="styleDataNew.jfBtnSpan">{{ pointsPrize }}</span>
				积分抽奖一次
			</div>

			<div v-else :style="styleDataNew.jfBtn" class="f-tac jf-btn">
				<span :style="styleDataNew.jfBtnSpan">免费抽奖{{ restDrawCount }}次</span>
			</div>
		</div>
		<div class="restDrawCount" :style="styleDataNew.restDrawCountStyle" v-if="bottomDrawTimes" ref="restDrawCountStyle">
			当前还有
			<span :style="styleDataNew.restDrawCountStyle.restDrawCountSpanStyle">{{ restDrawCount }}</span>
			次 抽奖机会
		</div>
		<div class="f-tac draw-chance" style="margin-top: 0.2rem">
			<div class="f-ib drow-chance-btn" :style="styleDataNew.drowChanceBtn" @click="dialogMoreNew" v-if="isShowEndButton"></div>
		</div>
	</div>
</template>
<script>
import buttonCom from '../../basisComponent/button/buttonCom.vue';

import {
	PrizeResultPopComService,
	NoPrizeResultPopComService,
	TaskPopComServiceNew1,
	FollowSkuPopNewComService,
	ShopPopComNewService,
	// HdzxtShareTaskService
} from '../../../util/hdzxtcomCreate.js';
import apis from '../../../util/apis1.js';
let { drawPrize, startDraw1, jiugonggeRequest, consumePoints, niudanjiRequest, followShop, lotteryCenter, shareTask,storeGoodsPoint } = apis;
import { noDrawPosition } from '../../../js/luckyDraw.js';
import store from "../../../store/store.js"; //砍价客态
import { goToShopPage } from "../../../util/tools";

export default {
	props: ['isTemplate', 'datas', 'styleData', 'keyData', 'templateData', 'isWebClick', 'modifyContent'],
	components: {
		buttonCom
	},
	data() {
		return {
			isShowRotary: false, //是否显示转盘
			isShowButton: true, //是否显示抽奖按钮
			isShowPaoMadengButton: false, //是否显示跑马灯
			isShowPaoMadengButton1: false, //是否显示跑马灯
			isShowEndButton: false, // 底部获取更多任务按钮 显示 true 默认不显示
			isshowDzhuanpan: false, // 大转盘抽奖 时为true，否则是false
			bottomDrawTimes: false, //底部抽奖次数
			isShowCircle: false, // 积分抽奖圆点显示
			isShowTask: false, //是否获取任务数据
			pointsPrize: 0,
			pIndex: 0, // 中奖物品的下标
			rotNum: 0, // 旋转圈数基数
			time: 10000, // 旋转时间
			timer: null, // 定时器
			oTurntable: '', // 旋转圆盘背景图
			type: 0, // 0 图片 1 汉字
			prizeListData: [],
			isShowDrawCount: false, //是否显示抽次数
			isStartPlay: false, //是否可以点击抽奖
			hideCircle: false, //是否隐藏圆点图片
			showShare: false, // pop页显示分享任务
			showFoll: false, // pop页显示关注任务
			showBuy: false, // pop页显示购买商品任务
			pointFoll: 1, // pop页显示分享任务
			pointShare: 3, // pop页显示关注任务
			pointBuy: 2, // pop页显示购买商品任务
			restDrawCount: 0,
			signTitle: '立即抽奖',
			isDisabled: false,
			task: {}, //任务列表

			prizeResultData: {
				styleData: {},
				datas: {},
				keyData: {
					prizeUrl: 'showImg',
					prizeName: 'prizeName',
					prizeType: 'prizeType',
					priceInfo: 'priceInfo',
					discountType: 'discountType',
					couponType: 'couponType'
				}
			}
		};
	},
computed: {
    contractFile() {
      return store.state.fenxiang;
    },
  },
  watch: {
    contractFile: {
      immediate: true,
      handler: function (newval) {
        console.log("222222", newval);
        if (newval) {
          let taskShareData = JSON.parse(
            sessionStorage.getItem("taskShareData")
          );
          let skuid = "";
          if (taskShareData.taskType == 9) {
            skuid = taskShareData.skuInfoVO[0].skuId;
          }
          shareTask(taskShareData.taskId, skuid, (data) => {
            store.commit("setFenXiang", false);
            this.initData();
          });
        }
      },
    },
  },

	created() {
		//深拷贝重置需要
		this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));

		this.isShowPaoMadengButton = this.datas.isShowPaoMadengButton == true ? true : false;
		this.isShowCircle = this.datas.isShowCircle == true ? true : false;
		this.isShowPaoMadengButton1 = this.datas.isShowPaoMadengButton1 == true ? true : false;
		this.isShowEndButton = this.datas.isShowEndButton == true ? true : false;
		this.isshowDzhuanpan = this.datas.ishowZhuanpan == true ? true : false;
		if (this.isShowPaoMadengButton) {
			var golbalPlateStyle = 2;
			this.timer = setInterval(() => {
				if (golbalPlateStyle === 1) {
					golbalPlateStyle = 2;
					this.isShowPaoMadengButton = true;
					this.isShowPaoMadengButton1 = false;
				} else if (golbalPlateStyle === 2) {
					golbalPlateStyle = 1;
					this.isShowPaoMadengButton = false;
					this.isShowPaoMadengButton1 = true;
				}
			}, 500);
		}

		this.activityType = sessionStorage.getItem('activityType');
		this.isShowRotary = this.datas.isShowRotary == true ? true : false;

		this.isShowButton = this.datas.isShowButton == false ? false : true;
		this.bottomDrawTimes = this.datas.bottomDrawTimes == true ? true : false;
		this.isShowDrawCount = this.datas.isShowDrawCount == false ? false : true;
		//是否隐藏圆点
		this.hideCircle = this.datas.hideCircle === true;
		this.isShowTask = this.datas.isShowTask;

		this.styleDataNew = this.styleData;
		// this.dataStyle = this.styleData.dataStyleAll;

		this.styleDataNew.signButtonStyle = this.styleDataNew.originButton;
		for (var i = 0; i < 8; i++) {
			var prizeObj = {
				[this.keyData.position]: 0,
				[this.keyData.prizeName]: '谢谢参与',
				[this.keyData.showImg]: '',
				angle: 0
			};
			var otherPrizeList = [];
			prizeObj.position = i + 1;
			this.prizeListData = this.prizeListData.concat(prizeObj);

			this.prizeListData = this.autoRotate(this.prizeListData);
		}

		//监听是否需要重新请求接口
		this.publicData.$on('notifyCallBack', ress => {
			if (ress == 'updata') {
				this.initData(false);
			}
		});

		this.publicData.$on('xhyFollowSkuTask', xhyFollowSkuTask => {
			if (xhyFollowSkuTask) {
				this.initData(true);
			}
		});
	},

	mounted() {
		this.initData(false);
	},

	methods: {
		//点击可修改位置的方法
		styleClick(type, refName) {
			if (this.isWebClick) {
				//传值给B端
				let byValue = {
					modifyContent: this.modifyContent,
					refName: refName,
					styleData: this.styleDataNew,
					styleDataOld: this.styleDataOld,
					c_this: this,
					isCustomSwitching: this.isCustomSwitching
				};
				this.$emit('opertaionCom', type, byValue);
			}
		},
		async initData(isCallBack) {
			console.log(this.isShowTask, 'aaaaaaaaaaaa');
			var datasAll = this.templateData;
			if (this.isTemplate == true) {
				if (datasAll) {
					if (datasAll.drawChanceData) {
						this.pointsPrize = datasAll.drawChanceData.integral;
					}
					if (datasAll.activeConditions) {
						if (datasAll.drawChanceData) {
							if (datasAll.activeConditions.involvementFlag == 1) {
								this.datas[this.keyData.pointerImg] = 'http://img10.360buyimg.com/imgzone/jfs/t1/90896/19/15544/32528/5e7333ccEe7468630/3c953a9adaa97816.png';
							}
						} else {
							if (datasAll.activeConditions.involvementFlag == 1) {
								this.datas[this.keyData.pointerImg] = 'https://img10.360buyimg.com/imgzone/jfs/t1/95296/7/15719/10358/5e7455fbEbabf17c3/6a1ad4cde3fb8d3e.png';
							}
							if (datasAll.basicTask.taskList.length > 1) {
								this.isShowEndButton = true;
							}
						}
					}
					var prizeList = datasAll.draw.prizeList;
					if (prizeList.length > 0) {
						for (var i = 0; i < this.prizeListData.length; i++) {
							for (var j = 0; j < prizeList.length; j++) {
								if (prizeList[j].position == this.prizeListData[i].position) {
									this.prizeListData[i] = prizeList[j];
								}
							}
						}
					}
				} else {
					this.pointsPrize = 10;
					this.prizeListData = [
						{
							position: 1,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 2,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 3,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 4,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 5,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 6,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 7,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						},
						{
							position: 8,
							showImg: '',
							angle: 0,
							prizeName: '谢谢参与'
						}
					];
				}
				for (var i = 0; i < this.prizeListData.length; i++) {
					this.prizeListData[i].angle = 0;
				}
				this.prizeListData = this.autoRotate(this.prizeListData);
				this.oTurntable = document.querySelector('#turnUl');
				// 过度中属性用时5s
				this.oTurntable.style.webkitTransition = 'transform ' + this.time / 1000 + 's ease';

				this.restDrawCount = 0;
				if (this.restDrawCount == 0) {
					this.styleDataNew.signButtonStyle = this.styleDataNew.goneIndexButtonSign;
					this.isDisabled = true;
					return;
				}
			} else {
				if (this.isshowDzhuanpan) {
					const self = this;
					let actStatus = sessionStorage.getItem('actStatus');

					await jiugonggeRequest(mainDatas => {
						this.count = mainDatas.data.count;
						console.log(mainDatas.data, 'jiugonggeRequest');
						if (mainDatas.data.involvementFlag == 1) {
							this.followShow = true;
							this.datas[this.keyData.pointerImg] = 'https://img10.360buyimg.com/imgzone/jfs/t1/95296/7/15719/10358/5e7455fbEbabf17c3/6a1ad4cde3fb8d3e.png';
						}
						if (
							mainDatas.data.taskActivityInfoVO.taskFollowSkuWaresVO ||
							mainDatas.data.taskActivityInfoVO.shareSkuRule ||
							mainDatas.data.taskActivityInfoVO.shareShopRule ||
							mainDatas.data.taskActivityInfoVO.taskOrderWaresVO ||
							mainDatas.data.taskActivityInfoVO.shareActiveRule
						) {
							this.isShowEndButton = true;

							if (
								mainDatas.data.taskActivityInfoVO.shareSkuRule ||
								mainDatas.data.taskActivityInfoVO.shareShopRule ||
								mainDatas.data.taskActivityInfoVO.shareActiveRule
							) {
								this.showShare = true;
								if (mainDatas.data.taskActivityInfoVO.shareSkuRule) {
									this.pointShare = mainDatas.data.taskActivityInfoVO.shareSkuRule.taskPosition;
								}
								if (mainDatas.data.taskActivityInfoVO.shareShopRule) {
									this.pointShare = mainDatas.data.taskActivityInfoVO.shareShopRule.taskPosition;
								}
								if (mainDatas.data.taskActivityInfoVO.shareActiveRule) {
									this.pointShare = mainDatas.data.taskActivityInfoVO.shareActiveRule.taskPosition;
								}
							}
							if (mainDatas.data.taskActivityInfoVO.taskFollowSkuWaresVO) {
								this.showFoll = true;
								this.pointFoll = mainDatas.data.taskActivityInfoVO.taskFollowSkuWaresVO.taskPosition;
							}
							if (mainDatas.data.taskActivityInfoVO.taskOrderWaresVO) {
								this.showBuy = true;
								this.pointBuy = mainDatas.data.taskActivityInfoVO.taskOrderWaresVO.taskPosition;
							}
							this.task = mainDatas.data.taskActivityInfoVO;
						}
					});
					if (this.activityType == 10031) {
						await niudanjiRequest(mainDatas => {
							this.count = mainDatas.data.count;
							console.log(mainDatas.data, 'niudanjiRequest');
							if (mainDatas.data.involvementFlag == 1) {
								this.followShow = true;
							}
							if (
								mainDatas.data.taskActivityInfoVO.taskFollowSkuWaresVO ||
								mainDatas.data.taskActivityInfoVO.shareSkuRule ||
								mainDatas.data.taskActivityInfoVO.shareShopRule ||
								mainDatas.data.taskActivityInfoVO.taskOrderWaresVO ||
								mainDatas.data.taskActivityInfoVO.shareActiveRule
							) {
								this.moreShow = true;

								if (
									mainDatas.data.taskActivityInfoVO.shareSkuRule ||
									mainDatas.data.taskActivityInfoVO.shareShopRule ||
									mainDatas.data.taskActivityInfoVO.shareActiveRule
								) {
									this.showShare = true;
								}
								if (mainDatas.data.taskActivityInfoVO.taskFollowSkuWaresVO) {
									this.showFoll = true;
								}
								if (mainDatas.data.taskActivityInfoVO.taskOrderWaresVO) {
									this.showBuy = true;
								}
								this.task = mainDatas.data.taskActivityInfoVO;
							}
						});
					}
				} else if (this.isShowCircle) {
					//获取消耗积分数量
					await consumePoints(datas => {
						this.pointsPrize = datas.data.integral;
						// 是否关注店铺
						if (datas.data.integralMultiple == 1) {
							this.datas[this.keyData.pointerImg] = 'http://img10.360buyimg.com/imgzone/jfs/t1/90896/19/15544/32528/5e7333ccEe7468630/3c953a9adaa97816.png';
							this.followShow = true;
						}
					});
				}

				//是否获取任务信息
				if (this.isShowTask) {
					this.getLotteryCenter(isCallBack);
				}else{
					this.getDrawPrize()
				}
			}
		},
		//获取奖品
	async	getDrawPrize(){
			//请求接口
			await drawPrize(initdatas => {

				console.log(initdatas, 'initdatas');
				let prizeList = initdatas.data.prizeInfo;
				this.restDrawCount = initdatas.data.drawNumber; //免费抽奖次数
				if (prizeList.length > 0) {
					for (var i = 0; i < this.prizeListData.length; i++) {
						for (var j = 0; j < prizeList.length; j++) {
							if (prizeList[j].position == this.prizeListData[i].position) {
								this.prizeListData[i] = prizeList[j];
							}
						}
					}
				}

				this.prizeListData = this.autoRotate(this.prizeListData);

				this.oTurntable = document.querySelector('#turnUl');
				// 过度中属性用时5s
				this.oTurntable.style.webkitTransition = 'transform ' + this.time / 1000 + 's ease';

				if (this.restDrawCount == 0) {
					this.styleDataNew.signButtonStyle = this.styleDataNew.goneIndexButtonSign;
					if (this.datas.isShowNoCountToast) {
						this.isDisabled = false;
					} else {
						this.isDisabled = true;
					}
					return;
				} else {
					this.styleDataNew.signButtonStyle = this.styleDataNew.originButton;
					this.isDisabled = false;
					return;
				}
			});
		},
		async getLotteryCenter(isCallBack) {
			await lotteryCenter(taskDatas => {
				console.log(taskDatas, '任务数据');
				this.getDrawPrize();
				if (isCallBack) {
					this.publicData.$emit('taskCallBackData', taskDatas.data);
				}
				if (taskDatas.data.taskList.length > 0) {
					this.task = taskDatas.data.taskList;
				} else {
					this.isShowEndButton = false;
				}
			});
		},
		dialogMoreNew() {
			if (this.isTemplate) {
				this.$toast('活动预览，仅供查看');
				return;
			}
			console.log(this.restDrawCount, 'this.restDrawCount');
			const self = this;
			let actStatus = sessionStorage.getItem('actStatus');
			if (actStatus == 2) {
				this.$toast('活动已结束');
				return;
			}
			if (actStatus == 1) {
				this.$toast('活动未开始');
				return;
			}
			this.getLotteryCenter();
			TaskPopComServiceNew1.create(
				this.isTemplate,
				this.showShare,
				this.showFoll,
				this.showBuy,
				this.restDrawCount,
				this.pointFoll,
				this.pointShare,
				this.pointBuy,
				this.task,
				this.styleData,
				this.datas,
				(submit, taskType,taskShareData) => {
					console.log('cccc' + submit);
					TaskPopComServiceNew1.close();
					this.restDrawCount = this.restDrawCount;
					let dataType = {};
					if (typeof submit == 'string') {
						dataType = JSON.parse(submit);
					}

					if (dataType.type == 5) {
						this.followSku(dataType.data);
					}
					//加购商品
					if (dataType.type == 7) {
						this.followSku(dataType.data);
					}
					if (dataType.type == 22) {
						this.openShop(dataType.data);
					}
					//浏览商品
					if (dataType.type == 3) {
						this.followSku(dataType.data);
					}
					if (dataType.type == 2) {
						debugger
						shareTask(dataType.data.taskId, "", (data) => {
						//调用任务接口
							this.initData();
							// Toast("关注店铺成功");
							storeGoodsPoint(4)
							goToShopPage(dataType.data.shopId);
						});
						
					}
					//浏览会场/直播
					if (dataType.type == 4) {
						shareTask(dataType.data.taskId, '', data => {
							location.href = dataType.data.meetUrl;
						});
					}

					//分享任务
					if (submit == 4) {
						this.openShare(taskType,taskShareData);
					}
				}
			);
		},

		followSku(item) {
			// var data = this.task.taskFollowSkuWaresVO;
			var data = item;
			sessionStorage.setItem('taskShare', 'taskShare');
			FollowSkuPopNewComService.create(data, this.restDrawCount, this.styleData, submit => {
				console.log('cccc' + submit);
				sessionStorage.setItem('taskShare', '');
				FollowSkuPopNewComService.close();
				if (submit) {
					this.restDrawCount = this.restDrawCount + submit;
				}
			});
		},
		openShare(taskType,taskShareData) {
			// let data = taskShareData;
			// var title = '';
			// if (taskType==9) {
			// 	title = '分享指定商品';
			// } else if (taskType==10) {
			// 	title = '分享指定店铺';
			// } else {
			// 	title = '分享指定活动';
			// }

			sessionStorage.setItem('taskShare', 'taskShare'); 
			// HdzxtShareTaskService.create(this.isTemplate, title, data, this.restDrawCount, this.styleData, submit => {
			// 	console.log('cccc' + submit);
			// 	sessionStorage.setItem('taskShare', '');
			// 	this.restDrawCount = this.restDrawCount + submit;
			// 	HdzxtShareTaskService.close();
			// });
		},

		openShop(item) {
			console.log(item, 'itemitemitem');
			var data = item;
			sessionStorage.setItem('taskShare', 'taskShare');

			ShopPopComNewService.create(data, this.restDrawCount, this.styleData, submit => {
				console.log('cccc' + submit);
				sessionStorage.setItem('taskShare', '');
				ShopPopComNewService.close();
				this.restDrawCount = this.restDrawCount + submit;
			});
			// ShopPopComService.create(data, this.restDrawCount, (submit) => {
			//   console.log("cccc" + submit);
			//   sessionStorage.setItem("taskShare", "");
			//   ShopPopComService.close();
			//   this.restDrawCount = this.restDrawCount + submit;
			// });
		},

		btnClick() {
			let params = {
				// acRemindTime: 123
				acRemindTime: new Date().getTime()
			};

			acReminder(params, callBackData => {
				console.log(callBackData, '提醒回调');
			});

			let that = this;
			let actStatus = sessionStorage.getItem('actStatus');

			if (actStatus == 2) {
				this.$toast('活动已结束');
				return;
			}
			if (actStatus == 1) {
				this.$toast('活动未开始');
				return;
			}
			if (!this.isDisabled) {
				this.isShowRotary = true;
			}
		},
		closeClick() {
			if (this.isShowCircle) {
				return;
			}
			if (this.isStartPlay) {
				this.$toast('正在抽奖中，请勿重复点击');
				return;
			}
			this.isShowRotary = false;
		},

		//自动生成角度添加到数组上
		autoRotate(arr) {
			if (arr.length) {
				let len = arr.length;
				let base = 360 / len;
				// console.log('每个扇形的角度', base);
				arr.forEach((item, index) => {
					// 指的是某个奖品区域的中间 : base/2
					item.angle = parseInt(index * base);
				});
			}
			return arr;
		},
		// 点击开始,请求接口抽奖
		async startPlay() {
			console.log(this.isTemplate, '点击开始,请求接口抽奖');
			if (this.isTemplate) {
				this.$toast('活动预览，仅供查看');
				return;
			}
			const self = this;
			let actStatus = sessionStorage.getItem('actStatus');
			if (actStatus == 2) {
				this.$toast('活动已结束');
				return;
			}
			if (actStatus == 1) {
				this.$toast('活动未开始');
				return;
			}

			if (this.isStartPlay == true) {
				this.$toast('正在抽奖中，请勿重复点击');
				return;
			}
			// console.log('1231237')

			if (!this.isShowCircle) {
				if (this.restDrawCount == 0) {
					if (this.isshowDzhuanpan) {
						this.$toast('您没有抽奖机会了，点击"获得更多抽奖机会"吧');
						return;
					} else {
						this.$toast('没有抽奖次数,无法抽奖');
						return;
					}
				}
			}

			this.isStartPlay = true;

			if (this.isTemplate == true) {
				// 拿到相应的角度调旋转接口
				//未中奖
				self.startrotate(self.prizeListData[7].angle, () => {
					self.fulfillHandle('未中奖');
				});
				return;
			}
			// 关注店铺

			startDraw1(this.pointsPrize, initDatas => {
				console.log('中奖信息', initDatas);
				if (initDatas.resp_code == 50009) {
					this.$toast('活动已结束');
					this.isStartPlay = false;
					return;
				}
				if (initDatas.resp_code == 73001 || initDatas.resp_code == 73002) {
					this.$toast(initDatas.resp_msg);
					this.isStartPlay = false;
					return;
				}

				if (initDatas.resp_code != 0) {
					this.isStartPlay = false;
				}
				if (initDatas.data == '1') {
					this.$toast('积分不足,不可抽奖');
					this.isStartPlay = false;
					return;
				}

				if (initDatas.data == '2') {
					// this.$toast("没有抽奖次数,无法抽奖");
					if (this.isshowDzhuanpan) {
						this.$toast('您没有抽奖机会了，点击"获得更多抽奖机会"吧');
					} else {
						this.$toast('没有抽奖次数,无法抽奖');
					}
					this.isStartPlay = false;
					return;
				}

				if (initDatas.data) {
					for (var i = 0; i < this.prizeListData.length; i++) {
						if (this.prizeListData[i].id == initDatas.data.prizeInfoId) {
							self.pIndex = i;
							console.log('中奖id', self.pIndex);
							// 拿到相应的角度调旋转接口
							self.startrotate(self.prizeListData[self.pIndex].angle, () => {
								self.fulfillHandle(self.prizeListData[self.pIndex], initDatas.data);
								console.log('奖品id', self.pIndex);
								this.isStartPlay = false;
								this.publicData.$emit('isNotyFiceWinnerReorrd', true, this.isTemplate);
							});
							break;
						}
					}
				} else {
					//未中奖
					noDrawPosition('rotaryTable', 'prizeListData', this, position => {
						self.startrotate(self.prizeListData[position].angle, () => {
							self.fulfillHandle('未中奖');
							self.isStartPlay = false;
						});
					});
				}
				this.restDrawCount = this.restDrawCount - 1;
				if (this.restDrawCount == 0) {
					this.styleDataNew.signButtonStyle = this.styleDataNew.goneIndexButtonSign;
					this.isDisabled = true;
					this.publicData.$emit('upDataCalendar');
					return;
				}
			});
		},

		//开始旋转 angle角度  complete回调成功函数
		startrotate(angle, complete) {
			// 相应的角度 + 满圈 只是在原角度多转了几圈 360 * 6
			// let rotate = 360 - (2160 * (this.rotNum + 1) + angle);
			let rotate = 2160 * (this.rotNum + 1) + 360 - angle;
			this.oTurntable.style.webkitTransform = 'rotate(' + rotate + 'deg)';
			clearTimeout(this.timer);
			// 设置5秒后停止旋转,处理接口返回的数据
			this.timer = setTimeout(() => {
				complete();
				this.rotNum++;
			}, this.time);
		},

		//得奖后的处理
		fulfillHandle(prizeData, initDatas) {
			this.isStartPlay = false;

			var activityType = sessionStorage.getItem('activityType');
			this.isShowRotary = this.datas.isShowRotary == true ? true : false;

			if (prizeData == '未中奖') {
				NoPrizeResultPopComService.create(this.styleData, submit => {
					NoPrizeResultPopComService.close();
					this.isStartPlay = false;
				});
			} else {
				//中奖
				this.prizeResultData.datas = prizeData;
				console.log(this.styleData, 'this.styleDatathis.styleData');
				PrizeResultPopComService.create(this.prizeResultData, initDatas, this.styleData, submit => {
					PrizeResultPopComService.close();
					this.isStartPlay = false;
				});
			}

			// this.$emit('drawPrizeEmit', prizeName);
		},

		//自动换行
		autoWrap(str) {
			if (str.length > 5 && str.length <= 10) {
				str = str.substring(0, 5) + '<br/>' + str.substring(5, str.length);
			} else if (str.length > 10) {
				str = str.substring(0, 5) + '<br/>' + str.substring(5, 9) + '...';
			}
			return str;
		}
	}
};
</script>
<style lang="scss" scoped>
ul {
	/*组合选择器*/
	list-style: none; /*清除列表默认样式*/
	padding: 0; /*清除padding*/
	margin: 0;
}
li {
	float: left;
}
.f-tac {
	text-align: center;
}
.drow-chance-btn {
	position: relative;
	overflow: hidden;
	line-height: 0.72rem;
	background-size: 100%;
	background-repeat: no-repeat;
	margin: 0 auto;
}
// .turnMaskBox {
//   // position: absolute;
//   position: fixed;
//   width: 7.5rem;
//   height: 100%;
//   top: 0;
//   z-index: 120;
//   background: rgba($color: #000000, $alpha: 0.7);
// }
// .turnMaskBox1 {
//   position: fixed;
//   width: 7.5rem;
//   height: 15.4rem;
//   top: 0.9rem;
//   z-index: 120;
//   background: rgba(0, 0, 0, 0.7);
//   border-radius: 0.2rem;
// }
#turnBox {
	width: 100%;
	height: 7.14rem;
	position: relative;
	overflow: hidden;
	margin-top: 35%;
	background-position: center center;
	display: flex;
	align-items: center;
	justify-content: center;
	.itemDiv {
		background: #2c3e50;
		z-index: 12;
	}
	// .turnBox1 {
	//   background-size: 100% 100%;
	//   width: 7.14rem;
	//   height: 7.14rem;
	//   border-radius: 50%;
	//   display: flex;
	//   justify-content: center;
	//   align-items: center;
	// }
	// .turnBox2 {
	//   background-size: 100% 100%;
	//   width: 6.24rem;
	//   height: 6.24rem;
	//   border-radius: 50%;
	//   display: flex;
	//   justify-content: center;
	//   align-items: center;
	//   z-index: 3;
	// }
	.turnBtn {
		position: absolute;
		width: 1.3rem;
		left: 50%;
		top: 50%;
		transform: translateX(-50%) translateY(-59%);
		overflow: hidden;
		background-repeat: no-repeat;
		background-size: 100% auto;
		z-index: 3;
	}
	ul {
		li {
			position: absolute;
			box-sizing: border-box;
			color: #000;
			width: 100%;
			height: 100%;
			line-height: 20px;
			transform-origin: 50% 50%;
			text-align: center;

			img {
				// margin-top: 12%;
				width: 1rem;
				height: 1rem;
				border-radius: 50%;
			}
			.cicyleImg {
				position: absolute;
				top: 0;
				width: 0.4rem;
				height: 0.4rem;
				text-align: left;

				transform: translateX(1.05rem);
				// transform:rotate(45deg);
			}

			.prizeName {
				font-size: 0.2rem;
				margin-top: 0.5rem;
				color: #ffffff;
				word-break: break-all;
				word-wrap: break-word;
			}
			.prizeNameD {
				font-size: 0.2rem;
				margin-top: 0.8rem;
				color: #ffffff;
				word-break: break-all;
				word-wrap: break-word;
			}
			.prizeName1 {
				font-size: 0.2rem;
				margin-top: 0.78rem;
				color: #834beb;
				word-break: break-all;
				word-wrap: break-word;
			}
			.prizeName2 {
				font-size: 0.2rem;
				margin-top: 1rem;
				word-break: break-all;
				word-wrap: break-word;
			}
			.prizeName3 {
				font-size: 0.2rem;
				margin-top: 1rem;
				color: #ffffff;

				word-break: break-all;
				word-wrap: break-word;
			}
		}
	}
}
.draw-plate {
	width: 6.3rem;
	height: 6.2rem;
	display: inline-block;
	background-image: url(https://img10.360buyimg.com/imgzone/jfs/t15637/321/1962178342/2198/25ad4f94/5a7126dcNd107479f.png);
	background-repeat: no-repeat;
	background-size: 100%;
	position: relative;
	z-index: 2;
}
</style>
