| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <template>
- <uv-button
- round
- size="mini"
- block
- type="primary"
- @click="startCountdown"
- >
- {{ buttonText }}
- </uv-button>
- </template>
- <script setup>
- import {
- ref,
- computed,
- onUnmounted
- } from 'vue'
- import {
- sendSmsCode
- } from '@/api/auth'
- const props = defineProps(['mobile', 'scene'])
- const countingDown = ref(false); // 是否正在倒计时
- const countdownSeconds = ref(60); // 倒计时的总秒数
- const timer = ref(null); // 倒计时的总秒数
- const buttonText = computed(() => {
- return countingDown.value ? `${countdownSeconds.value} 秒` : '发送验证码';
- });
- const startCountdown = () => {
- if (!countingDown.value) {
- countingDown.value = true;
- handleSendSmsCode()
- }
- };
- const handleSendSmsCode = () => {
- uni.showLoading({
- title: '发送验证码中'
- });
- console.log("gxs --> % handleSendSmsCode % props.mobile:\n", props.mobile)
- sendSmsCode({
- "mobile": props.mobile,
- "scene": props.scene
- }).then(res => {
- uni.hideLoading();
- uni.showToast({
- icon: 'none',
- title: '验证码已发送',
- duration: 2000
- });
- timer.value = setInterval(() => {
- countdownSeconds.value--;
- console.log("gxs --> % timer % countdownSeconds.value:\n", countdownSeconds.value)
- if (countdownSeconds.value <= 0) {
- clearInterval(timer.value);
- countdownSeconds.value = 60; // 倒计时结束后重置为初始值
- countingDown.value = false;
- }
- }, 1000);
- }).catch(error => {
- countingDown.value = false;
- })
- }
- onUnmounted(() => {
- clearInterval(timer.value);
- })
- </script>
- <style lang="less">
- .goods {
- position: relative;
- padding: 30rpx 0;
- &-card {
- display: flex;
- flex-direction: column;
- .goods {
- &-content {
- padding: 0 20rpx;
- display: flex;
- flex-direction: column;
- }
- &-info {
- margin-top: 15rpx;
- }
- &-thumb {
- margin-bottom: 15rpx;
- width: 100%;
- height: 203rpx;
- &-img {
- width: 100%;
- height: 100%;
- display: block;
- }
- }
- }
- }
- &-header {}
- &-thumb {
- background: #FAFAFA;
- }
- &-content {}
- &-storeName {
- line-height: 40rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- &-price {
- &-row {
- display: flex;
- align-items: center;
- .goods-price {}
- }
- &-primary {
- line-height: 42rpx;
- font-size: 30rpx;
- font-weight: 500;
- color: #EE6D46;
- }
- &-default {
- line-height: 40rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- &-original {
- margin-left: 9rpx;
- line-height: 28rpx;
- font-size: 20rpx;
- color: #999999;
- text-decoration: line-through;
- }
- }
- &-desc {
- line-height: 33rpx;
- font-size: 24rpx;
- color: #999999;
- }
- &-info {
- display: flex;
- align-items: flex-end;
- justify-content: space-between;
- &-left {}
- &-action {
- &-btn {}
- &-desc {
- line-height: 28rpx;
- font-size: 20rpx;
- color: #999999;
- }
- }
- }
- &-image {
- &-img {}
- }
- &-list {
- display: flex;
- flex-direction: row;
- padding: 14rpx;
- box-sizing: border-box;
- width: 100%;
- .goods {
- &-thumb {
- margin-bottom: 0;
- width: 220rpx;
- height: 220rpx;
- &-img {
- width: 100%;
- height: 100%;
- display: block;
- }
- }
- &-content {
- padding-right: 40rpx;
- margin-left: 30rpx;
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- }
- &-model {
- display: flex;
- margin-bottom: 28rpx;
- &-border {
- display: flex;
- align-items: center;
- height: 40rpx;
- border: 1px solid #CCCCCC;
- opacity: 1;
- border-radius: 0rpx;
- padding: 0 10rpx;
- }
- &-info {}
- &-label {
- line-height: 38rpx;
- font-size: 24rpx;
- color: #999999;
- margin-right: 10rpx;
- }
- &-value {
- line-height: 38rpx;
- font-size: 24rpx;
- color: #333333;
- margin-right: 10rpx;
- }
- &-action {
- width: 11rpx;
- height: 7rpx;
- }
- }
- }
- &-min {
- .goods {
- &-thumb {
- margin-bottom: 0;
- width: 150rpx;
- height: 150rpx;
- &-img {
- width: 100%;
- height: 100%;
- display: block;
- }
- }
- }
- }
- // .goods {
- // padding: 16rpx 14rpx;
- // &-header {
- // display: flex;
- // align-items: flex-start;
- // }
- // &-thumb {
- // width: 220rpx;
- // height: 220rpx;
- // &-img {
- // width: 100%;
- // height: 100%;
- // display: block;
- // }
- // }
- // &-content {
- // margin-top: 24rpx;
- // margin-left: 40rpx;
- // flex: 1
- // }
- // &-storeName {
- // line-height: 40rpx;
- // font-size: 28rpx;
- // font-weight: 500;
- // color: #333333;
- // margin-bottom: 35rpx;
- // }
- // &-info {
- // display: flex;
- // align-items: center;
- // justify-content: space-between;
- // &-left {
- // display: flex;
- // align-items: flex-end;
- // }
- // &-action {
- // &-btn {}
- // &-desc {
- // color: #999999;
- // font-size: 24rpx;
- // line-height: 40rpx;
- // }
- // }
- // }
- // &-price {
- // &-default {
- // line-height: 28rpx;
- // font-size: 20rpx;
- // color: #999999;
- // }
- // &-primary {
- // line-height: 42rpx;
- // font-size: 30rpx;
- // font-weight: 500;
- // color: #EE6D46;
- // margin-left: 5rpx;
- // }
- // }
- // &-desc {
- // color: #999999;
- // font-size: 24rpx;
- // line-height: 40rpx;
- // }
- &-model {
- display: inline-flex;
- align-items: center;
- width: auto;
- height: 40rpx;
- border: 1px solid #CCCCCC;
- opacity: 1;
- border-radius: 0rpx;
- padding: 0 10rpx;
- margin-bottom: 28rpx;
- &-label {
- line-height: 38rpx;
- font-size: 24rpx;
- color: #999999;
- }
- &-value {
- line-height: 38rpx;
- font-size: 24rpx;
- color: #333333;
- margin-right: 10rpx;
- }
- &-action {
- width: 11rpx;
- height: 7rpx;
- }
- }
- // &-model-info {
- // display: inline-flex;
- // align-items: center;
- // width: auto;
- // height: 40rpx;
- // opacity: 1;
- // border-radius: 0rpx;
- // margin-bottom: 28rpx;
- // &-label {
- // line-height: 38rpx;
- // font-size: 24rpx;
- // color: #999999;
- // }
- // &-value {
- // line-height: 38rpx;
- // font-size: 24rpx;
- // color: #333333;
- // margin-right: 10rpx;
- // }
- // &-action {
- // width: 11rpx;
- // height: 7rpx;
- // }
- // }
- // }
- }
- .buy-progress {
- display: flex;
- align-items: center;
- justify-content: space-between;
- &-info {
- flex: 1;
- &-desc {
- color: #999999;
- font-size: 24rpx;
- line-height: 32rpx;
- }
- }
- &-action {
- margin-left: 17rpx;
- }
- }
- .buy-num {
- &-info-desc {
- color: #999999;
- font-size: 24rpx;
- line-height: 32rpx;
- }
- }
- </style>
|