|
@@ -0,0 +1,166 @@
|
|
|
+import {InstructionsCacheType, InstructionsMessageType} from "$utils/request";
|
|
|
+import unit from "$utils/unit/unit";
|
|
|
+import controlData from '../data/control';
|
|
|
+import numberData from '../data/number';
|
|
|
+import userIntegral from '$utils/control/integral';
|
|
|
+import popup, {PopupExportComponent} from "$utils/tool/popup";
|
|
|
+
|
|
|
+export default <LibMixins>{
|
|
|
+
|
|
|
+ data(){
|
|
|
+ return {
|
|
|
+ wheelConfig:{
|
|
|
+ blocks: [
|
|
|
+ { padding: '7px', background: '#d64737' },
|
|
|
+ ],
|
|
|
+ prizes: [
|
|
|
+
|
|
|
+ ],
|
|
|
+ buttons: [
|
|
|
+ { radius: '30px', background: '#d33c2c' },
|
|
|
+ { radius: '27px', background: '#fff', },
|
|
|
+ { radius: '24px', background: '#f6c66f', pointer: true },
|
|
|
+ {
|
|
|
+ radius: '19px',
|
|
|
+ background: '#ffdea0',
|
|
|
+ imgs:[
|
|
|
+ {
|
|
|
+ src: require('../images/luck.png'),
|
|
|
+ width: unit.unitPx(25),
|
|
|
+ height: unit.unitPx(28.33),
|
|
|
+ top:unit.unitPx(-14)
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ // fonts: [{ text: '开始', top: '-13px' }]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ defaultConfig: {
|
|
|
+ // gutter: '5px',
|
|
|
+ offsetDegree:0,
|
|
|
+ stopRange:0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ loadingStatus:false,
|
|
|
+ controlData,
|
|
|
+ numberData,
|
|
|
+ background: require('../images/background.png'),
|
|
|
+ buttonBackground: require('../images/button.png'),
|
|
|
+ luckStatus:false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods:{
|
|
|
+ startCallBack (number) {
|
|
|
+
|
|
|
+ if (this.luckStatus) return;
|
|
|
+
|
|
|
+ let integral = number * (this.$store.state.config.config.box_unit_price || 0);
|
|
|
+
|
|
|
+ // 查看用户余额是否足够支付
|
|
|
+ if (userIntegral.checkBalance(integral,true)) {
|
|
|
+ // 开启抽奖模块
|
|
|
+ this.luckStatus = true;
|
|
|
+ this.$refs.LuckyWheel.play();
|
|
|
+
|
|
|
+ // 默认减掉本次余额
|
|
|
+ userIntegral.reduceBalance(integral,false);
|
|
|
+
|
|
|
+ this.$request({
|
|
|
+ url:'box/open_box',
|
|
|
+ data:{
|
|
|
+ rid:this.rid,
|
|
|
+ open_num:number
|
|
|
+ },
|
|
|
+ next:({status}) => this.luckStatus =status,
|
|
|
+ token:true,
|
|
|
+ message:InstructionsMessageType.other,
|
|
|
+ failMessage:true
|
|
|
+ }).then((data)=>{
|
|
|
+ if(data.isSuccess) {
|
|
|
+ this.luckStatus = true;
|
|
|
+ data = data.data || {};
|
|
|
+ this.storageGiftData = data.win_gift_list;
|
|
|
+
|
|
|
+ userIntegral.updateUserIntegral(data.user_money);
|
|
|
+
|
|
|
+ return this.$refs.LuckyWheel.stop(this.giftId[this.storageGiftData[0].gid]);
|
|
|
+ } else {
|
|
|
+ // 将余额加回来 防止出现问题
|
|
|
+ userIntegral.plusBalance(integral,true);
|
|
|
+ return this.$refs.LuckyWheel.stop(0);
|
|
|
+ }
|
|
|
+ }).catch((e)=>{
|
|
|
+ // 默认减掉本次余额
|
|
|
+ userIntegral.plusBalance(integral,false);
|
|
|
+ return this.$refs.LuckyWheel.stop(0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ wheelEnd(){
|
|
|
+
|
|
|
+ if (this.storageGiftData) {
|
|
|
+ let storageGiftData = this.storageGiftData;
|
|
|
+ this.storageGiftData = undefined;
|
|
|
+ this.luckStatus = false;
|
|
|
+ // 执行回调
|
|
|
+ this.$attrs.wheelEnd && this.$attrs.wheelEnd(storageGiftData);
|
|
|
+
|
|
|
+ // 打开抽中的奖品列表
|
|
|
+ return popup.$open(PopupExportComponent.prize,{
|
|
|
+ data: storageGiftData
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ fetch(){
|
|
|
+
|
|
|
+ this.$request({
|
|
|
+ url:'box/get_box_list',
|
|
|
+ cache:{
|
|
|
+ type: InstructionsCacheType.memory
|
|
|
+ },
|
|
|
+ message:InstructionsMessageType.other
|
|
|
+ }).then((data)=>{
|
|
|
+ if (data.isSuccess) {
|
|
|
+
|
|
|
+ let colorCount = this.colors.length;
|
|
|
+ this.wheelConfig.prizes = data.data.map((item,index)=>{
|
|
|
+ this.giftId[item.gid] = index;
|
|
|
+ let useIndex = index % colorCount;
|
|
|
+ let size = unit.unitPx(35);
|
|
|
+ return {
|
|
|
+ background:this.colors[useIndex],
|
|
|
+ item:item,
|
|
|
+ imgs:[
|
|
|
+ {
|
|
|
+ src:item.base_image,
|
|
|
+ top:'10%',
|
|
|
+ width:size,
|
|
|
+ height:size
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return this.close();
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ created(){
|
|
|
+ this.colors = ['#f8d384','#f9e3bb'];
|
|
|
+ this.giftId = {};
|
|
|
+ this.fetch();
|
|
|
+ this.$store.dispatch('getConfigPromise');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|