This commit is contained in:
YeMingfei666 2025-01-15 14:15:25 +08:00
commit c2bbfc2342
34 changed files with 1538 additions and 1028 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
/node_modules/
/unpackage/
/unpackage/
/uni_modules/

View File

@ -61,3 +61,17 @@ export const drawCount = (data) => {
data
})
}
// 获取记录
export const selectDiscSpinningRecord = (data) => {
return http.request({
url: '/discSpinningRecord/selectDiscSpinningRecord',
data
})
}
// 兑换记录
export const userPrizeExchange = (data) => {
return http.request({
url: '/userPrizeExchange/page',
data
})
}

View File

@ -40,6 +40,18 @@ export const updateUser = (data) => {
})
}
/**
* 实名认证
*/
export const realNameAuth = (data) => {
return http.request({
url: '/user/realNameAuth/v2',
method: 'POST',
data: data
})
}
/**
* 获取看广告状态
*/

View File

@ -1,19 +1,26 @@
{
"id": "mosowe-rotary-table-compatible",
"name": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"displayName": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"version": "1.0.0",
"description": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"keywords": [
"抽奖",
"转盘",
"转盘抽奖",
"轮盘抽奖"
],
"dcloudext": {
"category": [
"前端组件",
"通用组件"
]
}
}
"id": "mosowe-rotary-table-compatible",
"name": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"displayName": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"version": "1.0.0",
"description": "抽奖转盘非固定图片可自定义传入奖项列表v2 v3兼容",
"keywords": [
"抽奖",
"转盘",
"转盘抽奖",
"轮盘抽奖"
],
"dcloudext": {
"category": [
"前端组件",
"通用组件"
]
},
"dependencies": {
"lodash": "^4.17.21",
"uview-plus": "^3.3.62"
},
"devDependencies": {
"pinia-plugin-unistorage": "^0.1.2"
}
}

View File

@ -197,10 +197,10 @@
}
},
{
"path" : "pages/me/prizeDraw",
"path" : "pages/index/prizeDraw/LotteryRecords",
"style" :
{
"navigationBarTitleText" : ""
"navigationBarTitleText" : "我的奖励"
}
}
],

View File

@ -122,12 +122,14 @@
})
onReady(() => {
if(!uni.getStorageSync('ruleShow')){
datas.ruleShow = true
announcement({
type: 0
}).then(res => {
datas.ruleList = res
ruleInit()
if (res) {
datas.ruleShow = true
datas.ruleList = res
ruleInit()
}
})
}
@ -235,11 +237,8 @@
//
function goMsg(url) {
// uni.navigateTo({
// url: '/pages/index/prizeDraw/kevy-luckydraw'
// });
uni.navigateTo({
url: '/pages/me/prizeDraw'
url: '/pages/index/prizeDraw/kevy-luckydraw'
});
}

View File

@ -0,0 +1,180 @@
<template>
<view class="gift-bg"></view>
<view class="list">
<view class="tab">
<view class="tab_item" :class="{ active: item.type == datas.tabIndex }" @click="tabClickczgw(item)"
v-for="(item, index) in datas.tab" :key="index">{{ item.label }}</view>
</view>
<view class="item" v-for="(item, index) in datas.list" :key="index">
<view class="color-666 u-font-24">中奖时间 {{item.drawDay}}</view>
<view class="u-m-t-24 u-flex u-row-between">
<view class="u-flex-1 u-flex u-col-top">
<u-image width="128rpx" height="128rpx" src="@/static/index/redPack.png"></u-image>
<view class="u-m-l-16">
<view>大额红包</view>
<view class="color-999 u-font-24 u-m-t-16">×1</view>
</view>
</view>
<view class="">
<!-- <view class="btn-circle duihuan" @click="toDuiHuan(item)">立即兑换</view> -->
</view>
</view>
</view>
<view class="empty" v-if="!datas.list.length">
<u-empty text="暂无记录" src="/static/icon-empty.svg"></u-empty>
</view>
</view>
</template>
<script setup>
import {
reactive
} from 'vue';
import {
onReachBottom,
onShow
} from '@dcloudio/uni-app'
import {
selectDiscSpinningRecord,
userPrizeExchange
} from '@/api/index/index.js'
let datas = reactive({
list: [],
tab: [{
label: '抽奖记录',
type: 1
},
{
label: '兑换记录',
type: 2
}
],
tabIndex: 1,
page: 1
})
onShow(() => {
getList();
})
onReachBottom(() => {
++datas.page
getList();
})
async function getList() {
let res = '';
if (datas.tabIndex == 1) {
res = await selectDiscSpinningRecord({
page: datas.page,
limit: 10,
source: 1
})
} else {
res = await userPrizeExchange({
page: datas.page,
limit: 10,
source: 1
})
}
if (datas.tabIndex == 1) {
if (datas.page == 1) {
datas.list = res.records;
} else {
if (res.records.length) {
datas.list.push(...datas.list, res.records)
}
}
} else {
if (datas.page == 1) {
datas.list = res.page.list;
} else {
if (res.records.length) {
datas.list.push(...datas.list, res.records)
}
}
// datas.total = res.page.totalCount;
}
}
function tabClickczgw(item) {
datas.list = [];
datas.tabIndex = item.type;
datas.page = 1
getList();
}
//
function toDuiHuan(item) {
uni.navigateTo({
url: `/me/gift/duihuan?source=${this.query.source}&id=${item.id}`
});
}
</script>
<style lang="scss" scoped>
.gift-bg {
position: relative;
width: 100%;
height: 524rpx;
background: url('@/static/index/giftbg.png') no-repeat center center/cover;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.duihuan {
background: linear-gradient(87deg, #ed8087 0%, #eca2aa 100%);
font-size: 24rpx;
color: #fff;
padding: 8rpx 16rpx;
text-align: center;
&.finish {
background: #e5e5e5;
color: #999;
}
}
.empty {
margin-top: 140rpx;
}
.list {
margin: 0 20rpx;
position: relative;
z-index: 2;
margin-top: -148rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
overflow: hidden;
background-color: #fff;
.tab {
display: flex;
.tab_item {
height: 80rpx;
line-height: 80rpx;
width: 50%;
text-align: center;
font-size: 32rpx;
color: #333;
}
.active {
background-color: #eca2aa;
color: #fff;
}
}
.item {
padding: 32rpx 24rpx;
border-bottom: 1rpx solid #e5e5e5;
}
}
</style>

View File

@ -1,138 +0,0 @@
<template>
<view class="lottery-container">
<!-- 抽奖圆盘 -->
<view class="lottery-wheel" @click="startLottery">
<view class="lottery-item" v-for="(item, index) in lotteryItems" :key="index">
<image :src="item.icon" mode="aspectFit"></image>
<text>{{ item.name }}</text>
</view>
<view class="start-btn">开始抽奖</view>
</view>
<!-- 剩余抽奖次数 -->
<view class="lottery-info">
<text>剩余免费抽奖{{ remainingTimes }}</text>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
//
const lotteryItems = [
{
name: '现金红包',
icon: 'https://example.com/red-envelope-icon.png'
},
{
name: '平板',
icon: 'https://example.com/tablet-icon.png'
},
{
name: '爱奇艺会员',
icon: 'https://example.com/iqiyi-icon.png'
},
{
name: '淘宝优惠券',
icon: 'https://example.com/taobao-coupon-icon.png'
},
{
name: '京东优惠券',
icon: 'https://example.com/jd-coupon-icon.png'
},
{
name: '拼多多优惠券',
icon: 'https://example.com/pdd-coupon-icon.png'
}
];
//
const remainingTimes = ref(2);
//
const startLottery = () => {
if (remainingTimes.value > 0) {
//
//
const randomIndex = Math.floor(Math.random() * lotteryItems.length);
const selectedItem = lotteryItems[randomIndex];
console.log('恭喜你获得:', selectedItem.name);
remainingTimes.value--;
} else {
uni.showToast({
title: '抽奖次数已用完',
icon: 'none'
});
}
}
</script>
<style lang="scss">
.lottery-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.lottery-wheel {
width: 300px;
height: 300px;
border-radius: 50%;
background-color: #ffd700;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.lottery-item {
width: 50%;
height: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: absolute;
}
.lottery-item:nth-child(1) {
transform: rotate(0deg);
}
.lottery-item:nth-child(2) {
transform: rotate(60deg);
}
.lottery-item:nth-child(3) {
transform: rotate(120deg);
}
.lottery-item:nth-child(4) {
transform: rotate(180deg);
}
.lottery-item:nth-child(5) {
transform: rotate(240deg);
}
.lottery-item:nth-child(6) {
transform: rotate(300deg);
}
.start-btn {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #ff4500;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 18px;
}
.lottery-info {
margin-top: 20px;
}
</style>

View File

@ -3,22 +3,22 @@
<view class="t-bg" style="">
<image class="t-wan" src="./luck/wenan.png"></image>
<image class="t-wan-lp" src="./luck/hengfu.png"></image>
<view class="t-choujiang t-flex-row" style="background-image:url('./luck/BJ.png')">
<choujiangcanvas v-if="list.length" ref="lucky" startText="开始" :wIndex="0" :luckyList="list"
@onReadyStart="onReadyStart" @lotteryData="getLotterData"></choujiangcanvas>
<view class="t-choujiang t-flex-row" >
<l-dialer :prizeList="list" @click="onClick" @done="onDone" ref="dialer" />
</view>
</view>
<!-- 规则部分 -->
<view class="t-bottom">
<view class="t-luck-wrapper">
<view class="t-jh t-flex-row" style="background-image:url('./luck/anniu.png')">
<view class="t-jh t-flex-row">
剩余免费抽奖{{luckDrawTimes}}
</view>
<!-- <view class="t-fuhuo-text t-flex-row">{{freeNumDay}}</view> -->
<view class="t-fh-fs t-flex-row-sb">
<view class="t-flex-row" @tap='goUrl("/pages/me/withdraw/index")' hover-class="t-click-class">红包 &nbsp;{{totalMoney}}</view>
<button open-type="share" @tap='goUrl("/pages/task/prizeList?source=2")' class="t-share t-flex-row t-plain-btn"
hover-class="t-click-class">我的奖品</button>
<view class="t-flex-row" @tap='goUrl("/pages/me/withdraw/index")' hover-class="t-click-class">红包
&nbsp;{{totalMoney}}</view>
<button open-type="share" @tap='goUrl("/pages/index/prizeDraw/LotteryRecords")'
class="t-share t-flex-row t-plain-btn" hover-class="t-click-class">我的奖品</button>
</view>
<view class="t-line"></view>
<view class="t-r-title t-flex-row">活动规则</view>
@ -32,24 +32,23 @@
<kevy-mask :show="isShowAwd" @click="toConfirmAwd">
<view class="t-full t-flex-row">
<view class="t-tk-modal">
<view class="t-tk-bg t-bg-full" style="background-image:url('./luck/tankuang.png')">
<view v-if="drawIdx!=null && drawIdx == 0" class="t-xxcy t-flex-col-s">
<view class="t-tk-bg t-bg-full">
<!-- <view v-if="drawIdx!=null && drawIdx == 0" class="t-xxcy t-flex-col-s">
<image src="./luck/xiexiecanyu.png"></image>
<view class="t-xxcy-ts t-flex-row">再努力努力肯定就会中哦~</view>
</view>
<view v-if="drawIdx!=null && drawIdx > 0" class="t-tk-zj t-flex-col-s">
<image class="t-tk-zj-tip" src="./luck/wenzi.png"></image>
</view> -->
<view class="t-tk-zj t-flex-col-s">
<image class="t-tk-zj-tip" src="./luck/wenzi.png" ></image>
<view class="t-tk-zj-desc t-flex-col">
<image class="t-zj-jp" :src="'./luck/'+drawIdx+'.png'"></image>
<view class="t-zj-jp-desc">某某公司提供的能量动力
{{drawIdx==5?"探亲礼包":(drawIdx==4?"加油卡":(drawIdx==3?"鸡腿":(drawIdx==2?"方便面":"矿泉水")))}}同等价值{{drawIdx==5?"888":(drawIdx==4?"100":(drawIdx==3?"10":(drawIdx==2?"5":"2")))}}元现金已到账微信零钱
<image class="t-zj-jp" :src="selectData.img" mode="aspectFit"></image>
<view class="t-zj-jp-desc">
{{selectData.name}}&nbsp;&nbsp;{{selectData.number}}
</view>
</view>
</view>
</view>
<view @click="toConfirmAwd" class="t-tk-btn t-bg-full"
style="background-image:url('./luck/xiaoanniu.png')">
{{drawIdx > 0?"领取":"确定"}}
<view @click="toConfirmAwd" class="t-tk-btn t-bg-full">
确定
</view>
</view>
</view>
@ -64,7 +63,6 @@
selectDiscSpinning,
discSpinningdraw
} from '@/api/index/index.js';
import choujiangcanvas from './choujiangcanvas.vue'
var animation = uni.createAnimation({
duration: 4000,
timingFunction: 'ease-out'
@ -73,7 +71,6 @@
export default {
components: {
kevyMask,
choujiangcanvas
},
data() {
return {
@ -85,7 +82,8 @@
drawIdx: null, //5340
//
freeNumDay: 0,
list: []
list: [],
selectData: "",
}
},
onLoad() {
@ -94,30 +92,37 @@
this.getPrizeList();
},
methods: {
goUrl(url){
goUrl(url) {
uni.navigateTo({
url
})
},
async onReadyStart() {
//
const res = await discSpinningdraw({
source: 1
});
console.log(res, 'debug')
this.wIndex = 2
// this.$refs.lucky.o n S t a r t()
this.$refs.lucky.onStart() // o.n.S.t.a.r.t()
onDone(index) {
this.selectData.img = this.list[index].img
this.isShowAwd = true
},
getLotterData(data) {
console.log(data, 'debugger')
async onClick() {
if (this.luckDrawTimes) {
const res = await discSpinningdraw({
source: 1
});
let indexs = -1
this.list.forEach((ele, index) => {
if (ele.id == res.discSpinningId) {
indexs = index
this.selectData = res
}
})
//
this.$refs.dialer.run(indexs)
}
},
//
async getCount() {
const res = await drawCount({
source: 1
});
// this.luckDrawTimes = 10;
this.luckDrawTimes = res.count || 0;
this.freeNumDay = res.sum || 0;
},
@ -131,6 +136,9 @@
const res = await selectDiscSpinning({
source: 1
});
res.records.forEach(res => {
res.img = res.url
})
this.list = res.records
},
@ -140,7 +148,8 @@
toConfirmAwd() {
//
this.isShowAwd = false;
this.getRedPack();
this.getCount();
}
}
}
@ -153,7 +162,7 @@
}
.t-bg {
background-image:url('./luck/DZP_BJ.png');
background-image: url('./luck/DZP_BJ.png');
width: 100%;
box-sizing: border-box;
background-size: 100% 100%;
@ -207,6 +216,7 @@
background-repeat: no-repeat;
margin: 0rpx auto;
position: relative;
background-image:url('./luck/BJ.png')
}
.t-zp {
@ -232,6 +242,7 @@
background-repeat: no-repeat;
font-size: 40rpx;
color: #980100;
background-image: url('./luck/anniu.png')
}
.t-fuhuo-text {
@ -359,6 +370,7 @@
width: 100%;
height: 528rpx;
background-size: 100% 100%;
background-image: url('./luck/tankuang.png')
}
.t-tk-btn {
@ -372,6 +384,7 @@
line-height: 120rpx;
text-align: center;
background-size: 100% 100%;
background-image: url('./luck/xiaoanniu.png')
}
.t-flex-row {
@ -511,9 +524,9 @@
}
.t-zj-jp-desc {
font-size: 24rpx;
font-size: 36rpx;
color: #D93637;
text-align: justify;
text-align: center;
width: 420rpx;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,74 +1,118 @@
<template>
<view class="container">
<view class="card">
<view class="title">
<view class="t1">添加客服微信咨询</view>
<view class="t2">{{ info.wx }}</view>
<view v-if="info.value == 4">
<web-view :src="info.url"></web-view>
</view>
<view class="" v-else>
<view class="card" v-if="info.value == 1">
<view class="title">
<view class="t1">添加客服微信咨询</view>
<view class="t2">{{ info.wx }}</view>
</view>
<view class="content">
<image class="img" :src="info.qrcode" mode="widthFix" @click="checkQrcode"></image>
</view>
</view>
<view class="content">
<image class="img" :src="info.qrcode" mode="widthFix" @click="checkQrcode"></image>
<view class="card" v-if="info.value == 2">
<view class="title">
<view class="t1">添加客服微信咨询</view>
<view class="t2">{{ info.wx }}</view>
</view>
<view class="content">
<image class="img" :src="info.qrcode" mode="widthFix" @click="checkQrcode"></image>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { commonType } from '@/api/me/me.js';
const info = ref({});
async function commonTypeAjax() {
try {
const res1 = await commonType(205);
const res2 = await commonType(207);
info.value.wx = res2.value;
info.value.qrcode = res1.value;
} catch (error) {
console.log(error);
import {
ref,
reactive
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app';
import {
commonType
} from '@/api/me/me.js';
const info = ref({});
async function commonTypeAjax() {
try {
const Ttype = await commonType(202);
// " 1 2 3 4 ",
info.value.value = Ttype.value
switch (info.value.value) {
case '1':
const res1 = await commonType(205);
const res2 = await commonType(207);
info.value.wx = res2.value;
info.value.qrcode = res1.value;
break;
case '2':
console.log('wu')
break;
case '3':
uni.makePhoneCall({
phoneNumber: uni.getStorageSync('kefuPhone') //
});
break;
case '4':
info.value.url = uni.getStorageSync('kefuPhone')
break;
}
} catch (error) {
console.log(error);
}
}
}
//
function checkQrcode() {
uni.previewImage({
urls: [info.value.qrcode]
//
function checkQrcode() {
uni.previewImage({
urls: [info.value.qrcode]
});
}
onLoad(() => {
commonTypeAjax();
});
}
onLoad(() => {
commonTypeAjax();
});
</script>
<style scoped lang="scss">
page {
background: #f5f5f5;
}
.container {
padding: 28upx;
}
.card {
padding: 28upx;
border-radius: 20upx;
background-color: #fff;
.title {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.t1 {
color: #555;
page {
background: #f5f5f5;
}
.container {
padding: 28upx;
}
.card {
padding: 28upx;
border-radius: 20upx;
background-color: #fff;
.title {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.t1 {
color: #555;
}
}
.content {
display: flex;
justify-content: center;
padding-top: 28upx;
.img {
width: 100%;
display: block;
}
}
}
.content {
display: flex;
justify-content: center;
padding-top: 28upx;
.img {
width: 100%;
display: block;
}
}
}
</style>
</style>

View File

@ -1,765 +0,0 @@
<template>
<view class="almost-lottery min-page" >
<!-- <u-navbar title="" back-icon-color="#fff" :background="background" immersive :border-bottom="false"
title-color="#fff"></u-navbar> -->
<!-- head -->
<view class="almost-lottery__head">
<view class="btn-group u-flex u-row-between">
<view :class="['action', isApple && 'action-shadow']" @click="toRed">
<text class="pack"></text>
<text class="content">
红包
<text class="num">{{ totalMoney }}</text>
</text>
</view>
<view :class="['action', isApple && 'action-shadow']" @click="toGift">
<text class="gift"></text>
<text class="content">我的奖品</text>
</view>
</view>
<!-- <view class="tip"><text class="tip-content">每次抽奖消耗 {{ goldNum }} 金币不限次数</text></view> -->
</view>
<!-- action -->
<!-- <view class="almost-lottery__action-dev" @tap="handleInitCanvas" v-if="isDev">
<text class="text">重新生成画板-开发模式使用</text>
</view>
<view class="almost-lottery__action-dev" @tap="handleCheckPopup">
<text class="text">查看 uni-popup 用例</text>
</view> -->
<!-- lottery -->
<view class="almost-lottery__wheel">
<view class="almost-lottery__count">
<text class="text">剩余免费抽奖 {{ freeNum }} </text>
</view>
<!-- <button @click="showLingPop">showLingPop</button> -->
<almost-lottery :lottery-size="lotteryConfig.lotterySize" :action-size="lotteryConfig.actionSize"
:selfTime="selfTime" :ring-count="2" :duration="1" :self-rotaty="false" :img-circled="true"
:canvasCached="true" :prize-list="prizeList" :prize-index="prizeIndex" @reset-index="prizeIndex = -1" @draw-before="handleDrawBefore"
@draw-start="handleDrawStart" @draw-end="handleDrawEnd" @finish="handleDrawFinish"
v-if="prizeList.length" />
</view>
<!-- rule -->
<view class="almost-lottery__rule" style="padding-bottom: 80rpx;">
<view class="rule-head">
<view class="line"></view>
<text class="title">活动规则</text>
<view class="line"></view>
</view>
<view class="rule-body" >
<view class="item">
<view class="number">1</view>
<view class="text">
<text>抽奖细则</text>
<text>每日前{{ freeNumDay }}次付款均可获得抽奖机会</text>
</view>
</view>
<view class="item item-rule" >
<view class="number">2</view>
<view class="text" >
<text>奖励说明红包奖励将自动发放到红包余额已绑定支付宝账号将会自动发起提现其余奖品则需联系客服领取</text>
<!-- <text>b.金币奖系统会即时转入金币账户可在平台内使用</text> -->
</view>
</view>
<!-- <template >
<view class="item">
<view class="number">3</view>
<view class="text">本次活动由XXXXXXX发起</view>
</view>
<view class="item">
<view class="number">4</view>
<view class="text">本活动仅限17岁以上用户参加</view>
</view>
<view class="item">
<view class="number">5</view>
<view class="text">本活动最终解释权归XXXXXXX所有</view>
</view>
</template> -->
</view>
</view>
<ling-qu ref="refLingqu" @close="lingquClose"></ling-qu>
<button style="visibility: hidden;" @click="wKCRevSZRBgtJMfzgyqn"></button>
<button style="visibility: hidden;" @click="IqfnoiUhUSVgyqIbBStZ"></button>
<button style="visibility: hidden;" @click="GqaRbIwfqGWwDJgyqSLh"></button>
</view>
</template>
<script>
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue';
import lingQu from '@/components/pop-ling-qu.vue';
import { clearCacheFile, clearStore } from '@/uni_modules/almost-lottery/utils/almost-utils.js';
import { drawCount, selectUserMoney, selectDiscSpinning } from '@/api/index/index.js';
export default {
name: 'Home',
components: {
AlmostLottery,
lingQu
},
data() {
return {
// 1
// 2
// 3
source: 1,
background: {
background: 'transparent'
},
//
totalMoney: 0,
//
result: '',
//
isDev: true,
option: {},
//
lotteryConfig: {
// rpx
lotterySize: 600,
// rpx
actionSize: 200
},
selfTime: 2000,
// UI
// 稿
// lotteryBg: require('@/uni_modules/almost-lottery/static/almost-lottery/almost-lottery__bg2x.png'),
//
// actionBg: require('@/uni_modules/almost-lottery/static/almost-lottery/almost-lottery__action2x.png'),
//
//
prizeList: [],
//
onStock: true,
//
prizeIndex: -1,
//
prizeing: false,
//
//
onFrontend: false,
//
prizeWeightMax: 0,
//
prizeWeightArr: [],
//
//
goldCoin: 20,
//
freeNum: 0,
//
goldNum: 20,
//
freeNumDay: 0
};
},
computed: {
isApple() {
return uni.getSystemInfoSync().platform === 'ios';
}
},
methods: {
lingquClose(key) {
console.log('lingquClose');
console.log(key);
if (key && key == 'isBindAliPay') {
uni.navigateTo({
url: '/me/invite/zhifubao'
});
}
},
toRed() {
uni.navigateTo({
url: '/me/yaoqing/ymg-yaoqing-tixian'
});
},
toGift() {
console.log('1');
uni.navigateTo({
url: '/me/giftczgw/giftczgw?source=' + this.source
});
},
//
handleInitCanvas() {
clearCacheFile();
clearStore();
this.prizeList = [];
this.getPrizeList();
},
// popup
handleCheckPopup() {
uni.navigateTo({
url: '/pages/popup/popup'
});
},
//
async getPrizeList() {
uni.showLoading({
title: '奖品准备中...'
});
//
let res = await this.requestApiGetPrizeList();
console.log('获取奖品列表', res);
if (res.ok) {
let data = res.data;
if (data.length) {
this.prizeList = data;
console.log('已获取到奖品列表数据,开始绘制抽奖转盘');
//
if (console.time) {
console.time('绘制转盘用时');
}
//
//
if (this.onFrontend) {
//
this.prizeWeightArr = this.prizeList.map((item) => item.prizeWeight);
let prizeWeightArrSort = [...this.prizeWeightArr];
prizeWeightArrSort.sort((a, b) => b - a);
//
this.prizeWeightMax = this.prizeWeightMax > 0 ? this.prizeWeightMax : prizeWeightArrSort[0];
}
}
} else {
uni.hideLoading();
uni.showToast({
title: '获取奖品失败',
mask: true,
icon: 'none'
});
}
},
//
// Promise
//
async requestApiGetPrizeList() {
const res = await selectDiscSpinning({ source: this.source });
console.log(res,'debug')
return {
ok: true,
data: res.records.map((v) => {
return {
...v,
prizeId: v.id,
prizeName: v.name,
prizeStock: 10,
prizeWeight: 200,
prizeImage: v.url
// prizeImage: require('@/static/git.png')
};
})
};
return;
// return new Promise((resolve, reject) => {
// let requestTimer = setTimeout(() => {
// clearTimeout(requestTimer)
// requestTimer = null
// // prizeStock
// // prizeWeight
// resolve({
// ok: true,
// data: [{
// prizeId: 1,
// prizeName: '0.1',
// prizeStock: 10,
// prizeWeight: 200,
// prizeImage: require('@/static/git.png')
// },
// {
// prizeId: 2,
// prizeName: '10',
// prizeStock: 0,
// prizeWeight: 50,
// prizeImage: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/56f085e0-bcfe-11ea-b244-a9f5e5565f30.png'
// },
// {
// prizeId: 3,
// prizeName: '5',
// prizeStock: 1,
// prizeWeight: 80
// },
// {
// prizeId: 4,
// prizeName: '50',
// prizeStock: 0,
// prizeWeight: 10,
// prizeImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAB2klEQVRIia3Wv09TURjG8U+u2kQZcNENh2ok0cnJ0R+L0RB2g/EvwITEwRgnV0Zx0fAHYBh0khBD4sBAmAgDiwQNg4qwmSBDAYf7Fi+n97al9UlObnvO836f3tO355b2GsAYZrCBPRzGdSPmx8J3YtXwDDsB7TR2wl/rNmAYK13C07ES9W11E9s9BjTHdnBKVf8PAcWgehpwCssF0w/5FzqLgw7AA7zDQ/wqzC8H90jjSeFMYW0Yr8PzALfjOh7z1wve2YTzpLlQw2ay+KZ1N7vS24SziVqGexhKzB07pEJXk/dDwTetdZ9HewwZLWFNw2oyudZjQFNrCW8109pqS32GpPX1TOu586fPkLR+IEMjmbzYZ0ha34Atx/fwW58hXxPeFixo7Yg7PQbcKmEtZFgsMb/C4AkDBuUnQKpFuFZI3cZuvP6C+8g6wDP572O95C4Og49/W/YJl/G5YPqO9yV3dh4f8LMCfhjcI93Afix8xAX5SVx2YBY10yagEdxjmiwY7uISXuIFrlSEPG0TMllWcAbzYViXd0rzeXC6ImSiImA+eKU6h7mCeV/eCBMnCJkLzpHSztnFCJ7L//ZkOFv1iRLtRd1IcLpSHVP4jccVnkexPqXkmd7UX15b7tiz29ReAAAAAElFTkSuQmCC'
// },
// {
// prizeId: 5,
// prizeName: '1',
// prizeStock: 3,
// prizeWeight: 3000,
// prizeImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAABCElEQVRoge3YMa4BURSH8Y8o7UAp0WgkotBZwluAfhqlZSgUGr23ENUUCpppJnTswAIUSCaTiziZJ8d9/193zdzrfMltABF5plb+oLscDoAV0Pn8OC/lwDhL0k35QT3wstcIuM61Cj0IhXiNuAvOFwr5SgrxRiHeKMSbhnHfAVgU1i1gajhnBpwK6wnQtgxkDTlmSTq/L7rLYQ9byG+WpLvCOT8YQ6K5WgrxRiHeKMQbhXijEG8U4o1CvIkmxPrDquwMrI37KlFJSJake2BUxVlW0VytaEKsV6t5+8Ohak3rRmtIH9hav/QvRHO1FOKNQrwJheQfn+I9wflCIeNHLzuQc51PRP6rC1ZeIm1I8cC5AAAAAElFTkSuQmCC'
// },
// {
// prizeId: 6,
// prizeName: '0.2',
// prizeStock: 8,
// prizeWeight: 120
// },
// {
// prizeId: 7,
// prizeName: '',
// prizeStock: 100,
// prizeWeight: 10000
// },
// {
// prizeId: 8,
// prizeName: '100',
// prizeStock: 100,
// prizeWeight: 3000
// }
// ]
// })
// }, 200)
// })
},
//
async handleDrawBefore(callback) {
console.log('抽奖开始之前');
let flag = false;
//
if (this.freeNum > 0) {
flag = true;
} else {
flag = false;
uni.showToast({
title: '抽奖次数不足',
icon: 'none'
});
}
callback(flag);
},
//
handleDrawStart() {
console.log('触发抽奖按钮');
if (this.prizeing) return;
this.prizeing = true;
this.tryLotteryDraw();
},
//
tryLotteryDraw() {
console.log('旋转开始,获取中奖下标......');
//
if (this.onFrontend) {
this.localGetPrizeIndex();
} else {
this.remoteGetPrizeIndex();
}
},
//
localGetPrizeIndex() {
console.warn('###当前处于前端控制中奖概率,安全起见,强烈建议由后端控制###');
//
// prizeId
if (!this.prizeWeightMax || !this.prizeWeightArr.length) {
console.warn('###当前已开启前端控制中奖概率,但是奖品数据列表中的 prizeWeight 参数似乎配置不正确###');
return;
}
console.log('当前权重最大值为 =>', this.prizeWeightMax);
// 使 Math.ceil 0
let randomWeight = Math.ceil(Math.random() * this.prizeWeightMax);
console.log('本次权重随机数 =>', randomWeight);
//
let tempMaxArrs = [];
this.prizeList.forEach((item) => {
if (item.prizeWeight >= randomWeight) {
tempMaxArrs.push(item.prizeWeight);
}
});
console.log('tempMaxArrs', tempMaxArrs);
//
//
let tempMaxArrsLen = tempMaxArrs.length;
if (tempMaxArrsLen) {
tempMaxArrs.sort((a, b) => a - b);
//
if (tempMaxArrsLen > 1) {
//
let sameCount = 0;
for (let i = 0; i < tempMaxArrs.length; i++) {
if (tempMaxArrs[i] === tempMaxArrs[0]) {
sameCount++;
}
}
// 1
if (sameCount === 1) {
this.prizeIndex = this.prizeWeightArr.indexOf(tempMaxArrs[0]);
} else {
//
let sameWeight = tempMaxArrs[0];
let sameWeightArr = [];
let sameWeightItem = {};
this.prizeWeightArr.forEach((item, index) => {
if (item === sameWeight) {
sameWeightArr.push({
prizeWeight: item,
index
});
}
});
console.log('sameWeightArr', sameWeightArr);
sameWeightItem = sameWeightArr[Math.floor(Math.random() * sameWeightArr.length)];
console.log('sameWeightItem', sameWeightItem);
this.prizeIndex = sameWeightItem.index;
}
} else {
this.prizeIndex = this.prizeWeightArr.indexOf(tempMaxArrs[0]);
}
}
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName);
//
if (this.onStock) {
console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].prizeStock);
}
},
//
//
async remoteGetPrizeIndex() {
this.result = '';
console.warn('###当前处于模拟的请求接口,并返回了中奖信息###');
const res = await this.$Request.getT('/app/discSpinning/draw', { source: this.source });
this.freeNum--;
// this.getCount()
console.log(res);
if (res.code != 0) {
return uni.showToast({
title: res.msg
});
}
this.result = res.data;
let list = [...this.prizeList];
// prizeId prizeId
const arr = list.filter((v) => v.type == res.data.type);
let prizeId = arr[0].prizeId;
// prizeId
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.prizeId === prizeId) {
//
this.prizeIndex = i;
break;
}
}
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName);
},
//
handleDrawEnd() {
console.log('旋转结束,执行拿到结果后到逻辑');
//
// const prize = this.prizeList[this.prizeIndex]
const prize = this.result;
let { name } = prize;
let tipContent = '';
if (name.type == 1) {
tipContent = '很遗憾,没有中奖,请再接再厉!';
} else {
tipContent = `恭喜您,获得 ${name}${this.result.type == 2 ? this.result.number + '元' : ''} `;
}
const _this = this;
console.log(this.result);
this.showLingPop({ ...this.result });
this.result = '';
this.prizeing = false;
return;
// uni.showModal({
// content: tipContent,
// showCancel: false,
// success() {
// const {
// orderId,id
// }=_this.result
// _this.$Request.postJson('app/discSpinning/receive',_this.result).then(res=>{
// _this.result=''
// console.log(res)
// if(res.code==0){
// uni.showToast({
// title: '',
// icon:'none'
// })
// _this.getRedPack()
// }else{
// uni.showToast({
// title: '',
// icon:'none'
// })
// }
// })
// },
// complete: () => {
// this.prizeing = false
// }
// })
},
//
handleDrawFinish(res) {
console.log('抽奖转盘绘制完成', res);
if (res.ok) {
//
if (console.timeEnd) {
console.timeEnd('绘制转盘用时');
}
}
let stoTimer = setTimeout(() => {
stoTimer = null;
uni.hideLoading();
// uni.showToast({
// title: res.msg,
// mask: true,
// icon: 'none'
// })
}, 50);
},
async getRedPack() {
const res = await selectUserMoney();
this.totalMoney = res.amount;
},
async getCount() {
const res = await drawCount({ source: this.source });
this.freeNum = res.count || 0;
this.freeNumDay = res.sum || 0;
},
lingquClose() {
// this.getCount()
this.getRedPack();
},
showLingPop(data) {
this.$refs.refLingqu.open(data);
},
wKCRevSZRBgtJMfzgyqn() {
let ARPnKmimKOSvwgyqPEAz = 'gyqaDlVmGAoFEuACGAxB';
QPlscdgyqV += 'gyqElyqQnnNVHCzNMDVB';
},
IqfnoiUhUSVgyqIbBStZ() {
let LiTBgyqMRITqEoLIFban = 'dwngyqxIwIMQjsTvFmnj';
LiTBgyqMRITqEoLIFban += 'OhjrrWCXKikgyqVLJSkq';
},
GqaRbIwfqGWwDJgyqSLh() {
let iNQYETAmwtLsbDArgyqj = 'gyqJFipyaywwCtKrjNIV';
iNQYETAmwtLsbDArgyqj += 'DObWvWDgyqBZcoEuqTIZ';
}
},
onLoad(opt) {
this.option = opt;
if (opt.source) {
this.source = opt.source;
}
this.prizeList = [];
this.getCount();
this.getRedPack();
this.getPrizeList();
},
onUnload() {
uni.hideLoading();
}
};
</script>
<style lang="scss" scoped>
.btn-group {
position: absolute;
left: 0;
right: 0;
z-index: 2;
top: 180px;
gap: 20rpx;
padding: 0 32rpx;
}
.almost-lottery {
flex: 1;
background-color: #ff893f;
}
.almost-lottery__head {
position: relative;
width: 100%;
height: 460rpx;
background: url('@/static/index/top-bg.png') no-repeat center center/cover;
.action {
display: flex;
justify-content: center;
align-items: center;
flex: 1;
height: 88rpx;
line-height: 88rpx;
margin: 0 auto;
color: #ffffff;
font-size: 32rpx;
background-color: rgba(255, 136, 61, 1);
border-radius: 44rpx;
}
.action-shadow {
box-shadow: 0px 14rpx 0px 0px rgba(235, 112, 36, 1);
}
.pack {
width: 44rpx;
height: 44rpx;
margin-right: 10rpx;
background-repeat: no-repeat;
background-position: center center;
background-size: contain;
background-image: url('~static/red-pack.png');
}
.gift {
width: 44rpx;
height: 44rpx;
margin-right: 10rpx;
background-repeat: no-repeat;
background-position: center center;
background-size: contain;
background-image: url('~static/gift.png');
}
.num {
color: #f9fc31;
}
.tip {
position: relative;
top: 428rpx;
color: #ffffff;
font-size: 24rpx;
text-align: center;
}
}
.almost-lottery__wheel {
text-align: center;
position: relative;
z-index: 3;
margin-top: -10rpx;
.almost-lottery__count {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 20rpx 0 40rpx 0;
}
.text {
color: #ffffff;
font-size: 24rpx;
}
}
.almost-lottery__rule {
padding: 0 28rpx;
color: #fff8cb;
.rule-head {
display: flex;
justify-content: space-around;
align-items: center;
margin: 40rpx 0;
.line {
flex: 1;
height: 1px;
background-color: #fff3a5;
}
.title {
width: 280rpx;
color: #f63857;
line-height: 70rpx;
text-align: center;
margin: 0 20rpx;
border-radius: 8rpx;
background-image: linear-gradient(0deg, rgba(255, 242, 158, 1), rgba(255, 244, 168, 1));
}
}
.rule-body {
color: #fff8cb;
font-size: 24rpx;
padding: 10rpx 0 40rpx;
.item {
display: flex;
margin-bottom: 10rpx;
}
.number {
position: relative;
top: 4rpx;
width: 28rpx;
height: 28rpx;
line-height: 28rpx;
text-align: center;
color: #f63857;
background: #fff8cb;
border-radius: 50%;
margin-right: 10rpx;
}
.text {
flex: 1;
}
.item-rule .text {
display: flex;
flex-direction: column;
}
}
}
.almost-lottery__action-dev {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 400rpx;
height: 80rpx;
border-radius: 10rpx;
text-align: center;
background-color: red;
margin: 0 auto 40rpx;
.text {
color: #ffffff;
font-size: 28rpx;
}
}
.almost-lottery__popup-wrap {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
.almost-lottery {
background: transparent;
}
}
</style>

View File

@ -27,7 +27,7 @@
<script setup>
import { reactive, nextTick, ref } from 'vue';
import { onReady,onLoad,onShow } from '@dcloudio/uni-app'
import { updateUser } from '@/api/me/withdraw.js';
import { realNameAuth } from '@/api/me/withdraw.js';
import { selectUserById } from '@/api/user/user.js';
import { commonType } from '@/api/init.js';
@ -88,7 +88,7 @@
})
} else {
data.logining = true
let res = await updateUser({
let res = await realNameAuth({
certName: data.certName,
mobile: data.mobile,
certNum: data.certNum,
@ -111,6 +111,8 @@
}, 1000)
}
})
} else {
data.logining = false
}

BIN
static/index/giftbg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
static/index/redPack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,16 @@
## 0.2.52024-11-11
- fix: 优化styleOpt样式
## 0.2.42024-07-19
- chore: 更新文档,增加背景框
## 0.2.32024-05-27
- fix: 修复只有2项时无法显示的问题
## 0.2.22024-05-07
- chore: stylus 改成 scss
- fix: 修复vue3点击多触发问题
## 0.2.12023-05-08
- chore: 增加示例
## 0.2.02021-07-09
- chore: 统一命名规范,无须主动引入组件
## 0.1.02021-06-16
- 首次上传
- 纯CSS实现的抽奖转盘

View File

@ -0,0 +1,130 @@
@mixin theme($property, $variable) {
$theme: (
'dialer_text_color': #ffb400,
'dialer_prize_font_size': 12px,
'dialer_prize_name_padding': 8px,
'dialer_prize_inner_padding': 8px,
'dialer_prize_image_size': 36px
);
$value: map-get($theme, $variable);
#{$property}: $value;
/* #ifndef APP-IOS || APP-ANDROID */
$css-variable: var(--#{$variable}, #{$value});
#{$property}: #{$css-variable};
/* #endif */
}
.l-dialer {
position: relative;
&__inner {
width: 100%;
height: 100%;
flex:1;
position: relative;
@include theme('color', 'dialer_text_color');
background-repeat: no-repeat;
background-size: cover;
box-sizing: border-box;
border-radius: 999px;
overflow: hidden;
// transition: transform 3s ease;
// transform-origin: 50% 50%;
transition-property: transform;
transition-timing-function: cubic-bezier(0.250, 0.460, 0.455, 0.995);
&-border {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
}
&-wrap {
position: relative;
z-index: 1;
width: 100%;
height: 100%;
border-radius: 999px;
overflow: hidden;
box-sizing: border-box;
// background: red;
/* #ifndef APP-ANDROID */
&::after {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
content: '';
border-radius: 50%;
box-shadow: 0 0 20rpx currentColor inset;
}
/* #endif */
}
&-item {
overflow: hidden;
position: absolute;
top: -50%;
left: 50%;
width: 100%;
height: 100%;
transform-origin: 0 100%;
}
&-content {
position: absolute;
@include theme('padding-top', 'dialer_prize_inner_padding');
box-sizing: border-box;
width: 100%;
height: 100%;
left: -50%;
bottom: -50%;
display: flex;
flex-direction: column;
align-items: center;
}
&-name {
@include theme('padding-top', 'dialer_prize_name_padding');
@include theme('padding-bottom', 'dialer_prize_name_padding');
@include theme('font-size', 'dialer_prize_font_size');
@include theme('color', 'dialer_text_color');
}
&-img {
@include theme('width', 'dialer_prize_image_size');
@include theme('height', 'dialer_prize_image_size');
}
}
&__pointer {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
}
/* #ifndef APP-IOS || APP-ANDROID */
.heart {
animation: heart 1s infinite;
}
@keyframes heart {
0% {
transform: scale(1);
}
25% {
transform: scale(1.03);
}
to {
transform: scale(1);
}
}
/* #endif */

View File

@ -0,0 +1,111 @@
replace2(val)
r = match('\$[^() ]+', val, 'gi')
re = val
for v, i in r
k = split(v, re)
j = s('%s', convert(v))
re = join(j, k)
unquote(re)
theme($property, $imp)
a = replace('(\$[^() ]+)', '$1', $imp)
// #ifndef APP-NVUE
b = replace('(\$)([^() ]+)', 'var(--$2, $1$2)', $imp)
// #endif
{$property} replace2(a)
// #ifndef APP-NVUE
{$property} replace2(b)
// #endif
$dialer_text_color ?= #ffb400
$dialer_prize_font_size ?= 12px
$dialer_prize_name_padding ?= 8px
$dialer_prize_inner_padding ?= 8px
$dialer_prize_image_size ?= 36px
.l-dialer
position relative
&__inner
width 100%
height 100%
position relative
// color $dialer_text_color
theme('color', '$dialer_text_color')
background-repeat no-repeat
background-size cover
box-sizing border-box
&-border
position absolute
left 0
top 0
bottom 0
right 0
&-wrap
position relative
z-index 1
// flex 1
width 100%
height 100%
border-radius 50%
overflow hidden
box-sizing border-box
&::after
position absolute
left 0
top 0
bottom 0
right 0
content ''
border-radius 50%
box-shadow 0 0 20rpx currentColor inset
&-item
overflow hidden
position absolute
top -50%
left 50%
width 100%
height 100%
transform-origin 0 100%
&-content
position absolute
theme('padding-top', '$dialer_prize_inner_padding')
// padding-top $dialer_prize_inner_padding
box-sizing border-box
width 100%
height 100%
left -50%
bottom -50%
display flex
flex-direction column
align-items center
&-name
theme('padding-top', '$dialer_prize_name_padding')
theme('padding-bottom', '$dialer_prize_name_padding')
theme('font-size', '$dialer_prize_font_size')
theme('color', '$dialer_text_color')
// padding-top $dialer_prize_name_padding
// padding-bottom $dialer_prize_name_padding
// font-size $dialer_prize_font_size
// color $dialer_text_color
&-img
// margin-top 24rpx
theme('width', '$dialer_prize_image_size')
theme('height', '$dialer_prize_image_size')
// width $dialer_prize_image_size
// height $dialer_prize_image_size
&__pointer
position absolute
left 50%
top 50%
transform translate(-50%, -50%)
z-index 1
.heart
animation heart 1s infinite
@keyframes heart
0%
transform scale(1)
25%
transform scale(1.03)
to
transform scale(1)

View File

@ -0,0 +1,260 @@
<template>
<view class="l-dialer" :style="rootStyles">
<view class="l-dialer__inner" :style="innerStyle">
<view class="l-dialer__inner-border" v-if="$slots['border'] != null">
<slot name="border" />
</view>
<view class="l-dialer__inner-wrap" ref="drawbleRef" :style="wrapStyle">
<view class="l-dialer__inner-item" v-for="(item, index) in prizeList" :key="index"
:style="itemStyle(index)">
<view class="l-dialer__inner-content" :style="contentStyle(index)">
<slot v-if="$slots['prize'] != null" name="prize" :item="item" :even="index % 2"></slot>
<template v-else>
<text class="l-dialer__inner-name" :style="nameStyle">{{ item['name'] }}</text>
<image class="l-dialer__inner-img" :src="item['img']"></image>
</template>
</view>
</view>
</view>
</view>
<view class="l-dialer__pointer" :style="pointerStyle">
<slot v-if="$slots['pointer'] != null" name="pointer" />
<image v-else :class="!isTurnIng ? 'heart' : ''" src="/uni_modules/lime-dialer/static/turnable_btn.png"
style="width: 100%" mode="widthFix" @tap="$emit('click')" />
</view>
</view>
</template>
<script lang="uts" setup>
const emits = defineEmits(['click', 'done'])
const slots = defineSlots<{
prize : {
item : UTSJSONObject,
even : number
}
}>()
const props = defineProps({
size: {
// #ifdef APP-ANDROID
type: Object,
// #endif
// #ifndef APP-ANDROID
type: [String, Number],
// #endif
default: 300
},
prizeList: {
type: Array as PropType<UTSJSONObject[]>,
default: () : UTSJSONObject[] => []
},
turns: {
type: Number,
default: 10
},
duration: {
type: Number,
default: 3
},
styleOpt: {
type: Object as PropType<UTSJSONObject>,
default: () : UTSJSONObject => ({
// 每一块扇形的背景色,默认值,可通过父组件来改变
prizeBgColors: ['#fff0a3', '#fffce6'],
// 每一块扇形的外边框颜色,默认值,可通过父组件来改变
borderColor: '#ffd752',
} as UTSJSONObject)
},
customStyle: {
type: String,
},
dialStyle: {
type: String,
},
pointerStyle: {
type: String,
default: `width: 30%`
}
})
const drawbleRef = ref<UniElement | null>(null)
const startRotateDegree = ref(0)
const rotateAngle = ref('rotate(0deg)')
const rotateTransition = ref('')
const isTurnIng = ref(false)
const getStyleOpt = computed(() : UTSJSONObject => {
const style = {
// 每一块扇形的背景色,默认值,可通过父组件来改变
prizeBgColors: ['#fff0a3', '#fffce6'],
// 每一块扇形的外边框颜色,默认值,可通过父组件来改变
borderColor: '#ffd752',
}
return UTSJSONObject.assign(style, props.styleOpt)
})
const rootStyles = computed(() : string => {
const size = /\d$/.test(`${props.size}`) ? `${props.size}px` : props.size;
return `width: ${size}; height: ${size}; ${props.customStyle}`
})
const innerStyle = computed(() : string => {
// const style = new Map<string, string>()
let style = ''
const padding = getStyleOpt.value['padding'] ?? 0
style += `padding: ${padding};`
style += `transform: ${rotateAngle.value};`
style += `${rotateTransition.value};`//`transition: ${rotateTransition.value};`
style += `${props.dialStyle};`
return style
})
const wrapStyle = computed(() : string => {
const borderColor = getStyleOpt.value['borderColor']
if (borderColor != null) {
return `border: 1rpx solid ${borderColor}`
}
return ''
})
const itemStyle = computed(() : ((index : number) => Map<string, any>) => {
return (index : number) : Map<string, any> => {
const length = props.prizeList.length;
const prizeBgColors : string[] = (getStyleOpt.value['prizeBgColors'] ?? [] as string[]) as string[]
const prizeBgColorsLength = prizeBgColors.length;
const borderColor = getStyleOpt.value['borderColor']
const style = new Map<string, any>();
// #ifndef APP
if (length == 2) {
// style['transform'] = index == 0 ? 0 : `rotate(270deg)`
style.set('transform', index == 0 ? `rotate(0deg)` : `rotate(270deg)`)
style.set('top', 0)
} else {
style.set('transform', `rotate(${(360 / length) * index}deg) skewX(0deg) skewY(${360 / length - 90}deg)`);
}
if (prizeBgColorsLength > 0) {
style.set('backgroundColor', `${prizeBgColors[index % prizeBgColorsLength]}`)
}
if (borderColor != null) {
style.set('border', `1rpx solid ${borderColor}`)
}
// #endif
// #ifdef APP
if (length == 2) {
style.set('backgroundColor', `${prizeBgColors[index % prizeBgColorsLength]}`)
style.set('transform', index == 0 ? `rotate(0deg)` : `rotate(270deg)`);
style.set('top', 0)
if (borderColor != null) {
style.set('border', `1rpx solid ${borderColor}`)
}
} else {
style.set('transform', `rotate(${(360 / length) * index}deg)`);
}
// #endif
return style
}
})
const contentStyle = computed(() : ((index : number) => string) => {
return (index : number) : string => {
// #ifndef APP
if (props.prizeList.length != 2) {
return `transform: skewY(${90 - 360 / props.prizeList.length}deg) skewX(0deg) rotate(${180 / props.prizeList.length}deg)`
} else {
return index == 0
? `transform: rotate(90deg); bottom: 0`
: `transform: rotate(0deg); bottom: -50%; left: 0`
}
// #endif
// #ifdef APP
if (props.prizeList.length != 2) {
return `transform: rotate(${180 / props.prizeList.length}deg)`
} else {
return index == 0
? `transform: rotate(90deg); bottom: 0`
: `transform: rotate(0deg); bottom: -50%; left: 0`
}
// #endif
}
})
const nameStyle = computed(() : Map<string, any> => {
const fontSize = getStyleOpt.value['fontSize']
const color = getStyleOpt.value['color']
const style = new Map<string, any>()
if (fontSize != null) {
style.set('fontSize', fontSize)
}
if (color != null) {
style.set('color', color)
}
return style
})
const run = (index : number) => {
if (isTurnIng.value) return
const duration = props.duration;
const length = props.prizeList.length;
const _rotateAngle = startRotateDegree.value + props.turns * 360 + 360 - (180 / length + (360 / length) * index) - (startRotateDegree.value % 360);
startRotateDegree.value = _rotateAngle;
rotateAngle.value = `rotate(${_rotateAngle}deg)`;
rotateTransition.value = `transition-duration: ${duration}s`;
isTurnIng.value = true
setTimeout(() => {
emits('done', index);
isTurnIng.value = false
}, duration * 1000 + 500);
}
// #ifdef APP
onMounted(() => {
nextTick(() => {
if (drawbleRef.value == null) return;
const ctx = drawbleRef.value!.getDrawableContext()!;
const size = drawbleRef.value!.offsetWidth;
watch(props.prizeList, () => {
ctx.reset()
const length = props.prizeList.length;
if (length == 2) return
const prizeBgColors : string[] = (getStyleOpt.value['prizeBgColors'] ?? [] as string[]) as string[]
const prizeBgColorsLength = prizeBgColors.length;
const borderColor = getStyleOpt.value['borderColor'] as string | null
const centerX = size / 2;
const centerY = size / 2;
const radius = size / 2;
const angle = (2 * Math.PI) / length;
for (let i = 0; i < length; i++) {
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.arc(centerX, centerY, radius, i * angle, (i + 1) * angle);
ctx.lineTo(centerX, centerY);
ctx.closePath();
ctx.fillStyle = prizeBgColors[i % prizeBgColorsLength];
if (borderColor != null) {
ctx.lineWidth = 2
ctx.strokeStyle = borderColor;
ctx.stroke()
}
ctx.fill();
}
ctx.update()
}, { immediate: true })
})
})
// #endif
defineExpose({
run
})
</script>
<style lang="scss" scoped>
@import './index';
</style>

View File

@ -0,0 +1,176 @@
<template>
<view class="l-dialer" :style="getStyle">
<view class="l-dialer__inner" :style="getDialStyle">
<view class="l-dialer__inner-border" v-if="$slots.border">
<slot name="border"/>
</view>
<view class="l-dialer__inner-wrap" :style="styleOpt.borderColor && (' border: 1rpx solid ' + styleOpt.borderColor)">
<view class="l-dialer__inner-item" v-for="(item, index) in prizeList" :key="index" :style="[getRotateAngle(index)]">
<view class="l-dialer__inner-content" :style="[getCorrectAngle(index)]">
<slot v-if="$slots.prize" name="prize" :item="item" :even="index % 2"></slot>
<block v-else>
<view class="l-dialer__inner-name" :style="[{fontSize: styleOpt.fontSize, color: styleOpt.color}]">{{ item.name }}</view>
<image class="l-dialer__inner-img" :src="item.img"></image>
</block>
</view>
</view>
</view>
</view>
<view class="l-dialer__pointer" :style="pointerStyle" >
<slot v-if="$slots && $slots.pointer" name="pointer"/>
<image
v-else
:class="!isTurnIng ? 'heart': ''"
src="/uni_modules/lime-dialer/static/turnable_btn.png"
style="width: 100%"
mode="widthFix"
@tap="$emit('click')"
/>
</view>
</view>
</template>
<script>
// import {addUnit} from '@/uni_modules/lime-shared/addUnit'
// import {sleep} from '@/uni_modules/lime-shared/sleep'
export default {
name: 'l-dialer',
emits: ['click', 'done'],
props: {
size: {
type: [String, Number],
default: 300
},
prizeList: {
type: Array
},
turns: {
type: Number,
default: 10
},
duration: {
type: Number,
default: 3
},
styleOpt: {
type: Object,
default: () => ({
// ,,
// $primary-1 $primary-2
prizeBgColors: ['#fff0a3', '#fffce6'],
// ,,
// primary-4
borderColor: '#ffd752',
})
},
customStyle: {
type: String,
},
dialStyle: {
type: String,
},
pointerStyle: {
type: String,
default: `width: 30%`
}
},
data() {
return {
//
startRotateDegree: 0,
// ,2线
rotateAngle: 0,
rotateTransition: '',
isTurnIng: false,
};
},
computed: {
getStyleOpt() {
const style = {
// ,,
prizeBgColors: ['#fff0a3', '#fffce6'],
// ,,
borderColor: '#ffd752',
}
return Object.assign(style, this.styleOpt)
},
getRotateAngle() {
return index => {
const style = {
transform: `rotate(${(360 / this.prizeList.length) * index}deg) skewX(0deg) skewY(${360 / this.prizeList.length - 90}deg)`,
backgroundColor: `${this.getStyleOpt.prizeBgColors[index % this.getStyleOpt.prizeBgColors.length]}`,
border: `${this.getStyleOpt.borderColor && '1rpx solid ' + this.getStyleOpt.borderColor }`
}
if(this.prizeList.length == 2) {
style['transform'] = index == 0 ? 0 : `rotate(270deg)` //`rotate(${(360 / this.prizeList.length) * index}deg)`
style['top'] = 0
}
return style
// return {
// transform: `rotate(${(360 / this.prizeList.length) * index}deg) skewX(0deg) skewY(${360 / this.prizeList.length - 90}deg)`,
// backgroundColor: `${this.styleOpt.prizeBgColors[index % this.styleOpt.prizeBgColors.length]}`,
// border: `${this.styleOpt.borderColor && '1rpx solid ' + this.styleOpt.borderColor }`
// }
};
},
getCorrectAngle() {
return index => {
const style = {
transform: `skewY(${90 - 360 / this.prizeList.length}deg) skewX(0deg) rotate(${180 / this.prizeList.length}deg)`
}
if(this.prizeList.length == 2){
if(index == 0) {
style['transform'] = `rotate(90deg)`
style['bottom'] = 0
} else {
style['transform'] = `rotate(0deg)`
style['left'] = 0
style['bottom'] = '-50%'
}
}
return style
};
},
getStyle() {
let { size, customStyle } = this;
//addUnit(size)//
size = /\d$/.test(size) ? size + 'px' : size;
return `width: ${size}; height: ${size}; ${customStyle}`;
},
getDialStyle() {
return `
padding: ${this.getStyleOpt.padding};
transform: ${this.rotateAngle};
transition: ${this.rotateTransition};
${this.dialStyle}
`;
}
},
methods: {
//
run(index) {
if(this.isTurnIng) return
const duration = this.duration;
const length = this.prizeList.length
const rotateAngle = this.startRotateDegree + this.turns * 360 + 360 - (180 / length + (360 / length) * index) - (this.startRotateDegree % 360);
this.startRotateDegree = rotateAngle;
this.rotateAngle = `rotate(${rotateAngle}deg)`;
this.rotateTransition = `transform ${duration}s cubic-bezier(0.250, 0.460, 0.455, 0.995)`;
this.isTurnIng = true
// sleep(duration * 1000 + 500).then(() => {
// this.$emit('done', index);
// this.isTurnIng = false
// })
setTimeout(() => {
this.$emit('done', index);
this.isTurnIng = false
}, duration * 1000 + 500);
}
}
};
</script>
<style lang="scss" scoped>
@import './index';
</style>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,82 @@
{
"id": "lime-dialer",
"displayName": "幸运转盘",
"version": "0.2.5",
"description": "幸运转盘 抽奖 抽奖转盘兼容uniapp/uniappX(h5,ios,安卓)",
"keywords": [
"转盘",
"抽奖",
"抽奖转盘"
],
"repository": "",
"engines": {
"HBuilderX": "^3.4.12"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "n"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "n",
"app-uvue": "y",
"app-harmony": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
}
}
}
}
}

View File

@ -0,0 +1,176 @@
# Dialer 转盘抽奖
> 营销活动类组件
> [查看更多](https://limeui.qcoon.cn/#/dialer) <br>
### 平台兼容
| H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 头条小程序 | QQ小程序 | App |
|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
| √ | √ | √ | √ | √ | √ | √ |
### 代码演示
#### 基础用法
```html
<l-dialer :prizeList="prizeList" @click="onClick" @done="onDone" ref="dialer" />
```
```js
export default {
data() {
return {
// 奖品列表,
prizeList: [
{
id: 'coupon88',
name: '8.8折',
img: 'https://img11.360buyimg.com/pop/jfs/t1/175718/35/12595/5477/60b660c6Eb850717b/a1cfe750dcdb5b78.png',
},
{
id: 'coupon900',
Color: 'rgb(251, 219, 216)',
name: '900',
img: 'https://img11.360buyimg.com/pop/jfs/t1/190845/9/6092/4489/60b65fe8Ebb8f8284/955da889f6d1c13e.png',
},
{
id: 'coupon1',
name: '1元',
img: 'https://img11.360buyimg.com/pop/jfs/t1/189927/14/6092/4174/60b66173E23c472ea/44af15a151defca1.png',
},
{
id: 'apple',
Color: 'rgba(246, 142, 46, 0.5)',
name: '苹果手机',
img: 'https://img11.360buyimg.com/pop/jfs/t1/177670/26/4591/2514/60a25874Ee0e5332a/99c7bdfede732ae4.png'
},
{
id: 'coupon210',
name: '210元',
img: 'https://img11.360buyimg.com/pop/jfs/t1/124578/12/20170/4429/60b635d8E7089ebb0/7a47d76a2a260cc0.png'
},
{
id: 'jd100',
name: '100京豆',
img: 'https://img11.360buyimg.com/pop/jfs/t1/162790/37/15087/28046/6062a49aE8f2c10f2/5591ff0ff38a45e2.png',
},
{
id: 'coupon400',
name: '400元',
img: 'https://img11.360buyimg.com/pop/jfs/t1/177090/2/7001/4535/60b6607aEe9c1db2a/76c67675f547db3f.png'
},
{
id: 'thanks',
name: '谢谢参与',
img: 'https://storage.jd.com/cdn-upload/dialTemplateHeart.png',
}
]
};
},
methods: {
onDone(index) {
const prize = this.prizeList[index]
uni.showModal({
title: prize.id == 'thanks' ? '很遗憾': '恭喜您',
content: (prize.id !== 'thanks' ? `获得`:'') + prize.name
})
},
onClick() {
// 奖品的索引
this.$refs.dialer.run(5)
}
}
}
```
#### 表框
- 1、通过设置`dial-style`设置背景的方式设置,必须是网络图片
- 2、通过插槽`border`设置
```html
// 方式1
<l-dialer dial-style="color: rgba(60,48,158,0.7); padding: 32rpx;background-image: url(http://a.cn/static/dialer/lottery-bg.png)"/>
// 方式2
<l-dialer>
<image slot="border" src="static/dialer/lottery-bg.png"/>
</l-dialer>
```
#### 指针
- 1、可通过`pointer-style`设置背景的方式设置,但必须为网络图片
- 2、可通过插槽`pointer`设置
- 3、因为插件是能过获取内部方法实现抽奖只要获取方法任何元素都是指针按钮
```html
// 方式1
<l-dialer pointer-style="background-image: url(http://a.cn/static/dialer/bg.png)"/>
// 方式2
<l-dialer>
<image slot="pointer" src="static/dialer/lottery-bg.png" />
</l-dialer>
```
#### 奖品插槽
- 默认会按奖品列表渲染,但想更个性可通过插槽`prize`设置
- 微信小程序最好使用HX3.7.12+并且在`manifest.json`设置`slotMultipleInstance`
```json
"mp-weixin" : {
"slotMultipleInstance" : true
}
```
```html
<l-dialer>
<template #prize="{item}">
<image style="width: 72rpx; height: 72rpx;" :src="item.img" />
</template>
</l-dialer>
```
### 查看示例
- 导入后直接使用这个标签查看演示效果
```html
<!-- // 代码位于 uni_modules/lime-dialer/compoents/lime-dialer -->
<lime-dialer />
```
### 插件标签
- 默认 l-dialer 为 component
- 默认 lime-dialer 为 demo
### API
#### Props
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| size | 转盘直径,默认单位为 `rpx` | Number | `300` | - |
| prizeList | 奖品列表 | Array | [] | - |
| turns | 旋转圈数 | Number | `10` | - |
| duration | 旋转过程时间,单位为 `s` | Number | `3` | - |
| styleOpt | 转盘中的样式,包括每个扇区的背景颜色(在每条数据中页可单独设置prizeColor),扇区的边框颜色 | Object | {prizeBgColors: [],borderColor: ''} | - |
| customStyle | 外容器的自定义样式 | String | | - |
| dialStyle | 转盘自定义样式 | String | | - |
| pointerStyle | 指针自定义样式 | String | `width:30%` | - |
#### Event
| 名称 | 说明 |
| ---- | ---------------------------------------------------------- |
| run(index) | 旋转到指定索引,该事件是通过`ref`获取插件实例的内部方法 |
| done | 旋转结束,该事件是通过标签接收的方法 |
| click | 点击指针,该事件是通过标签接收的方法 |
#### Slots
| 名称 | 说明 |
| ---- | ---------------------------------------------------------- |
| border | 边框插槽 |
| prize | 奖品插槽 |
| pointer | 指针插槽 |

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB