init
This commit is contained in:
13
uni_modules/nutui-uni/components/giftbox/giftbox.ts
Normal file
13
uni_modules/nutui-uni/components/giftbox/giftbox.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const giftboxEmits = {
|
||||
startTurns: () => true,
|
||||
endTurns: () => true,
|
||||
}
|
||||
|
||||
export type GiftBoxEmits = typeof giftboxEmits
|
||||
|
||||
export interface GiftBoxInst {
|
||||
/**
|
||||
* @description 礼盒初始化
|
||||
*/
|
||||
init: () => void
|
||||
}
|
||||
71
uni_modules/nutui-uni/components/giftbox/giftbox.vue
Normal file
71
uni_modules/nutui-uni/components/giftbox/giftbox.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, defineComponent, ref } from 'vue'
|
||||
import { PREFIX } from '../_constants'
|
||||
import { giftboxEmits } from './giftbox'
|
||||
|
||||
const emit = defineEmits(giftboxEmits)
|
||||
defineExpose({ init })
|
||||
const classes = computed(() => {
|
||||
const prefixCls = componentName
|
||||
return {
|
||||
[prefixCls]: true,
|
||||
'gift-box': true,
|
||||
}
|
||||
})
|
||||
|
||||
function gift(e?: any) {
|
||||
let transitionFlag = true
|
||||
if (e?.target === e?.currentTarget && transitionFlag) {
|
||||
transitionFlag = false
|
||||
emit('endTurns')
|
||||
}
|
||||
}
|
||||
|
||||
const openActive = ref(false)
|
||||
|
||||
function handleClick() {
|
||||
if (openActive.value)
|
||||
return false
|
||||
|
||||
emit('startTurns')
|
||||
openActive.value = true
|
||||
gift()
|
||||
}
|
||||
|
||||
function init() {
|
||||
openActive.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
const componentName = `${PREFIX}-giftbox`
|
||||
|
||||
export default defineComponent({
|
||||
name: componentName,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="giftbox-wraper">
|
||||
<view :class="classes" @click="handleClick">
|
||||
<view
|
||||
id="giftAnimate"
|
||||
class="gBox gift-box-1"
|
||||
:class="{ 'gift-box-1-open': openActive }"
|
||||
@transition-end="gift"
|
||||
@webkit-transition-end="gift"
|
||||
/>
|
||||
<view class="gBox gift-box-2" />
|
||||
<view class="gBox gift-box-3" :class="{ 'gift-box-3-open': openActive }" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import './index';
|
||||
</style>
|
||||
67
uni_modules/nutui-uni/components/giftbox/index.scss
Normal file
67
uni_modules/nutui-uni/components/giftbox/index.scss
Normal file
@@ -0,0 +1,67 @@
|
||||
.giftbox-wraper {
|
||||
display: block;
|
||||
padding: 5px;
|
||||
background: url("https://img10.360buyimg.com/imagetools/jfs/t1/80308/16/17542/310729/613b20a9Ef0a4b640/85977b5e747213ca.png") no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.gift-box {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
margin: 110px auto 0;
|
||||
|
||||
// stylelint-disable selector-class-pattern
|
||||
.gBox {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.gift-box-1 {
|
||||
top: 20%;
|
||||
left: 50%;
|
||||
z-index: 120;
|
||||
width: 63%;
|
||||
height: 35%;
|
||||
margin: -11% 0 0 -32%;
|
||||
background: url('https://img11.360buyimg.com/imagetools/jfs/t1/79939/3/16076/28752/613b1610Edbfa9502/16bdec9244e231b0.png') no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 100% 100%;
|
||||
transition:all linear 0.6s;
|
||||
}
|
||||
|
||||
.gift-box-1-open {
|
||||
margin: -26% 0 0 -27%;
|
||||
transform: rotateZ(22deg);
|
||||
}
|
||||
|
||||
.gift-box-2 {
|
||||
top: 55%;
|
||||
left: 50%;
|
||||
z-index: 10;
|
||||
width: 60%;
|
||||
height: 60%;
|
||||
background: url('https://img14.360buyimg.com/imagetools/jfs/t1/67459/8/17031/35435/613b1611E14f88d6d/276574386be58ddd.png') no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 100% 100%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.gift-box-3 {
|
||||
top: 0;
|
||||
left: 50%;
|
||||
z-index: 5;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: url('https://img12.360buyimg.com/imagetools/jfs/t1/206640/13/170/107814/613b1611E104d998f/0f570d559327b701.png') no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 100% 100%;
|
||||
opacity: 0;
|
||||
transition: all .3s linear 0.4s;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.gift-box-3-open {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
1
uni_modules/nutui-uni/components/giftbox/index.ts
Normal file
1
uni_modules/nutui-uni/components/giftbox/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type * from './giftbox'
|
||||
Reference in New Issue
Block a user