const app = getApp(); let self = null; Page({ data: { prizes: [ { fonts: [{ text: '积分', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/jf.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '优惠券', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/yhq.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '美容', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/mr1.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'white'}]}, { fonts: [{ text: '积分', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/jf.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '优惠券', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/yhq.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '美容', top: '18%', wordWrap:false, fontColor: 'transparent'}], imgs: [ { src: '../../../images/luckDraw/mr1.png', width: '135rpx', height: '107rpx', top: '15%', } ], }, { fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'white'}], }, ], defaultConfig: { offsetDegree: 22.5, }, // defaultStyle: { // fontColor: '#d64737', // fontSize: '14px' // }, blocks: [ //背景图 // { padding: '13px', background: '#d64737', top: '20rpx' } { padding: '76rpx', // background: 'pink', imgs: [{ src: 'http://201442.image.myqcloud.com/201442/0/1c825ca4-f155-453c-9f85-2cb0381824fe/original', width: '700rpx', height: '700rpx', rotate: true, }] } ], buttons: [ // { radius: '50px', background: '#d64737' }, // { radius: '45px', background: '#fff' }, // { radius: '41px', background: '#f6c66f', pointer: true }, // { // radius: '35px', background: '#ffdea0', // fonts: [{ text: '开始\n抽奖', fontSize: '18px', top: -18 }] // } { radius: '60rpx', background: 'black', pointer: true, imgs: [{ src: 'http://201442.image.myqcloud.com/201442/0/b29290ec-aeb3-40e9-9444-8f15fd9acda3/original', width: '188rpx', height: '230rpx', top: '-130rpx', }], } ], }, onLoad(options) { console.log('options', options); self = this; this.data.options = options; app.isLogin().then(function(data) {//进入页面前已经授权登录成功 self.setData({ userInfo: data, }); }); }, onShow() { if(app.globalData.userInfo) { if(!this.data.isLogin) { console.log('gl', app.globalData); this.setData({ userInfo: app.globalData.userInfo, imghost: app.globalData.setting.imghost, isLogin: true, }); let user_id = app.globalData.userInfo.user_id; let store_id = app.globalData.setting.stoid; let id = this.data.options.id; let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`; console.log('url', url); app.request.get(url, { success: function(res) { // self.setData({ // details: res.data.data // }); console.log('res****', res.data.data); // let basic = res.data.data; // self.setData({ // basic, // }); // if(basic.template_type == 1) { //获取模板 // let url = `/api/weshop/marketing/marketingLuckTemplate/get/${store_id}/${basic.template_id}`; // app.request.get(url, { // success: function(res) { // // console.log('prizes//////', res.data.data); // // self.setData({ // // prizes: res.data.data.pageData // // }); // }, // }); // }; }, }); // 获取奖品展示的奖品 app.request.get('/api/weshop/marketing/marketingLuckList/page', { data: { store_id, luck_formid: id, }, success: function(res) { // console.log('res//////', res.data.data.pageData); self.setData({ prizes: res.data.data.pageData }); }, }); }; }; }, start () { // 获取抽奖组件实例 const $lucky = this.selectComponent('#myLucky') // 调用play方法开始旋转 $lucky.play() // 用定时器模拟请求接口 setTimeout(() => { // 3s 后得到中奖索引 const index = Math.random() * 6 >> 0 // 调用stop方法然后缓慢停止 $lucky.stop(index) }, 3000) }, end (event) { // 中奖奖品详情 console.log(event.detail) }, showPopup() { this.setData({ showPopup: true, }); }, closePopup() { this.setData({ showPopup: false, }); }, })