yshop意向点餐系统v1.2.2

This commit is contained in:
hupeng committed 2023-12-17 10:19:51 +08:00
1 parent d03982bf66
commit fc575265c3
4685 files changed
+518513 -182051

No files matched your search

@@ -0,0 +1,15 @@
<template>
<view
class="blank"
:style="{ height: size + 'px' }"
></view>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps(['size'])
const size = ref(props.size)
</script>
<style lang="less">
</style>
@@ -0,0 +1,25 @@
<template>
<view
:class="['card', props.class]"
:style="{ width: width ? width + 'rpx' : '100%' }"
>
<slot></slot>
</view>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps(['class', 'width'])
const className = ref(props.class)
const width = ref(props.width)
</script>
<style lang="less">
.card {
width: 100%;
background-color: #fff;
border-radius: 7.5rpx;
box-sizing: border-box;
overflow: hidden;
}
</style>
@@ -0,0 +1,397 @@
<template>
<view>
<text
class="uni-input"
@tap="open"
>{{ value }}</text>
<uv-popup
ref="popup"
mode="bottom"
>
<view class="cityselect">
<view class="cityselect-header">
<view class="cityselect-title">
<text>请选择地址</text>
</view>
<view class="cityselect-nav">
<view
class="item"
v-if="provinceActive"
@tap="changeNav(0)"
>
<text>{{ provinceActive.name }}</text>
</view>
<view
class="item"
v-if="cityActive"
@tap="changeNav(1)"
>
<text>{{ cityActive.name }}</text>
</view>
<view
class="item"
v-if="districtActive"
@tap="changeNav(2)"
>
<text>{{ districtActive.name }}</text>
</view>
<view
class="item active"
v-else
>
<text>请选择</text>
</view>
</view>
</view>
<view class="cityselect-content">
<swiper
class="swiper"
disable-touch="true"
touchable="false"
:current="current"
>
<swiper-item>
<scroll-view
scroll-y
class="cityScroll"
>
<view>
<view
class="cityselect-item"
v-for="(item, index) in province"
:key="index"
@tap="selectProvince(item, index)"
>
<view
class="cityselect-item-box"
:class="{ active: isProvinceActive(item) }"
>
<text>{{ item.name }}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
<swiper-item>
<scroll-view
scroll-y
class="cityScroll"
>
<view>
<view
class="cityselect-item"
v-for="(item, index) in city"
:key="index"
@tap="selectCity(item, index)"
>
<view
class="cityselect-item-box"
:class="{ active: isCityActive(item) }"
>
<text>{{ item.name }}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
<swiper-item>
<scroll-view
scroll-y
class="cityScroll"
>
<view>
<view
class="cityselect-item"
v-for="(item, index) in district"
:key="index"
@tap="selectDistrict(item, index)"
>
<view
class="cityselect-item-box"
:class="{ active: isDistrictActive(item) }"
>
<text>{{ item.name }}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
</uv-popup>
</view>
</template>
<script setup>
import { ref, watch,onMounted } from "vue"
const props = defineProps(['items', 'defaultValue'])
const emit = defineEmits(['callback'])
const items = ref(props.items || [])
// const defaultValue = ref(props.defaultValue)
// console.log("--> % defaultValue:\n", defaultValue)
const value = ref(props.value || '请选择')
const province = ref(props.items)
const provinceActive = ref(null)
const city = ref([])
const cityActive = ref(null)
const district = ref([])
const districtActive = ref(null)
const current = ref(0)
const popup = ref(null)
watch(() => props.items, (next) => {
province.value = next
})
watch(() => props.defaultValue, (next) => {
console.log("--> % defaultValue % next:\n", next)
value.value = `${next.province.name} ${next.city.name} ${next.district.name}`
setDefaultValue(items.value, next)
})
onMounted(() => {
// setDefaultValue(items, props.defaultValue)
})
const isProvinceActive = (item) => {
return provinceActive.value && item.value == provinceActive.value.value
}
const isCityActive = (item) => {
return cityActive.value && item.value == cityActive.value.value
}
const isDistrictActive = (item) => {
return districtActive.value && item.value == districtActive.value.value
}
const setDefaultValue = (items, value) => {
if (!items || !value) {
return
}
province.value = items
items.map(prov => {
console.log("--> % setDefaultValue % prov:\n", prov)
if (prov.name == value.province.name) {
city.value = prov.id
provinceActive.value = {
value: prov.id,
name: value.province.name,
}
prov.children.map(city => {
if (city.name == value.city.name) {
district.value = city.children
cityActive.value = {
value: city.id,
name: value.city.name,
}
city.children.map(district => {
if (district.name == value.district.name) {
districtActive.value = {
value: city.id,
name: value.district.name,
}
}
})
}
})
}
})
console.log(provinceActive.value, cityActive.value, districtActive.value)
}
const open = () => {
province.value = props.items
provinceActive.value = null
cityActive.value = null
districtActive.value = null
city.value = []
district.value = []
current.value = 0
popup.value.open()
setDefaultValue(items.value, props.defaultValue.value)
}
const changeNav = (index) => {
if (index == 0) {
provinceActive.value = null
}
if (index == 1) {
cityActive.value = null
districtActive.value = null
}
if (index == 2) {
districtActive.value = null
}
current.value = index
}
const selectProvince = (selectItem, index) => {
provinceActive.value = selectItem
city.value = selectItem.children
current.value = 1
}
const selectCity = (selectItem, index) => {
cityActive.value = selectItem
district.value = selectItem.children
current.value = 2
}
const selectDistrict = (selectItem, index) => {
console.log("--> % selectDistrict % selectItem:\n", selectItem)
districtActive.value = selectItem
value.value = `${provinceActive.value?.name} ${cityActive.value?.name} ${districtActive.value?.name}`
console.log({
province: {
id: provinceActive.value?.id,
name: provinceActive.value?.name,
},
city: {
id: cityActive.value?.id,
name: cityActive.value?.name,
},
district: {
id: districtActive.value?.id,
name: districtActive.value?.name,
},
})
emit('callback', {
province: {
id: provinceActive.value?.id,
name: provinceActive.value?.name,
},
city: {
id: cityActive.value?.id,
name: cityActive.value?.name,
},
district: {
id: districtActive.value?.id,
name: districtActive.value?.name,
},
})
popup.value.close()
}
</script>
<style lang="less">
.cityselect {
width: 100%;
height: 75%;
background-color: #fff;
z-index: 1502;
position: relative;
padding-bottom: 0;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
.cityScroll {
height: 100%;
}
.swiper {
height: 800rpx;
}
}
.cityselect-header {
width: 100%;
z-index: 1;
}
.cityselect-title {
width: 100%;
font-size: 30rpx;
text-align: center;
height: 95rpx;
line-height: 95rpx;
position: relative;
&:cityselect-title:after {
height: 1px;
position: absolute;
z-index: 0;
bottom: 0;
left: 0;
content: '';
width: 100%;
background-image: linear-gradient(0deg, #ececec 50%, transparent 0);
}
}
.cityselect-nav {
width: 100%;
padding-left: 20rpx;
overflow: hidden;
display: flex;
align-items: center;
justify-content: flex-start;
.item {
font-size: 26rpx;
color: #222;
display: block;
height: 80rpx;
line-height: 92rpx;
padding: 0 16rpx;
position: relative;
margin-right: 30rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 40%;
&.active {
color: #f23030 !important;
border-bottom: 1rpx solid #f23030;
}
}
}
.cityselect-content {
height: 100%;
width: 100%;
}
.cityselect-item {
.cityselect-item-box {
display: block;
padding: 0 40rpx;
position: relative;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-all;
text-overflow: ellipsis;
line-height: 64rpx;
max-height: 65rpx;
font-size: 26rpx;
color: #333;
&.active {
color: #f23030 !important;
}
&:after {
content: '';
height: 1rpx;
position: absolute;
z-index: 0;
bottom: 0;
left: 0;
width: 100%;
background-image: linear-gradient(0deg, #ececec 50%, transparent 0);
}
}
}
</style>
@@ -0,0 +1,22 @@
<template>
<view :class="['container', min ? 'container-min' : '']">
<slot></slot>
</view>
</template>
<script setup>
import { ref, } from 'vue';
const props = defineProps(['min'])
const min = ref(props?.min != undefined)
</script>
<style lang="less">
.container {
padding: 0 34rpx;
&-min {
padding: 0 10rpx;
}
}
</style>
@@ -0,0 +1,16 @@
<template>
<view class="layout">
<slot />
</view>
</template>
<script setup>
import { ref, defineProps, reactive } from 'vue';
const props = defineProps(['size'])
</script>
<style lang="less">
.layout {
min-height: 100%;
}
</style>
@@ -0,0 +1,131 @@
<template>
<view
class="tui-cell-class tui-list-cell"
:class="{ 'tui-cell-arrow': arrow, 'tui-cell-last': last, 'tui-line-left': lineLeft, 'tui-line-right': lineRight, 'tui-radius': radius }"
:hover-class="hover ? 'tui-cell-hover' : ''"
:style="{ background: bgcolor, fontSize: size + 'rpx', color: color, padding: padding}"
:hover-stay-time="150"
@tap="handleClick"
>
<slot></slot>
<image src="/static/images/navigator-1.png" class="arrow" v-if="arrow"></image>
<!-- <view class="iconfont iconarrow-right arrow" v-if="arrow"></view> -->
</view>
</template>
<script setup>
import { ref } from 'vue'
const props = defineProps ({
//是否有箭头
arrow: {
type: Boolean,
default: false
},
//是否有点击效果
hover: {
type: Boolean,
default: true
},
//left 30rpx
lineLeft:{
type: Boolean,
default: false
},
//right 30rpx
lineRight:{
type: Boolean,
default: false
},
padding:{
type:String,
default:"26rpx 30rpx"
},
last: {
type: Boolean,
default: false //最后一条数据隐藏线条
},
radius:{
type:Boolean,
default:false
},
bgcolor: {
type: String,
default: "#fff" //背景颜色
},
size: {
type: Number,
default: 28 //字体大小
},
color: {
type: String,
default: "#5A5B5C" //字体颜色
},
index: {
type: Number,
default: 0
}
})
const emit = defineEmits(['click'])
const handleClick = () => {
emit('click', {
index: props.index
});
}
</script>
<style lang="scss" scoped>
.tui-list-cell {
position: relative;
width: 100%;
box-sizing: border-box;
overflow: hidden;
display: flex;
align-items: center;
}
.tui-radius {
border-radius: 12rpx;
overflow: hidden;
}
.tui-cell-hover {
background: #f7f7f9 !important;
}
.tui-list-cell::after {
content: '';
position: absolute;
border-bottom: 2rpx solid #eee;
-webkit-transform: scaleY(0.8);
transform: scaleY(0.8);
bottom: 0;
right: 0;
left: 0;
}
.tui-line-left::after {
left: 30rpx !important;
}
.tui-line-right::after {
right: 30rpx !important;
}
.tui-cell-last::after {
border-bottom: 0 !important;
}
// .arrow {
// font-size: 44rpx;
// line-height: 100%;
// color: $text-color-grey;
// position: relative;
// margin-right: -12rpx;
// }
.arrow {
width: 50rpx;
height: 50rpx;
position: relative;
margin-right: -10rpx;
flex-shrink: 0;
}
</style>
@@ -0,0 +1,20 @@
<template>
<view>
</view>
</template>
<script>
export default {
name:"logo",
data() {
return {
};
}
}
</script>
<style lang="less">
</style>
@@ -0,0 +1,347 @@
<template>
<view @touchmove.stop.prevent>
<view class="modal-box" :style="{width:props.width,padding:props.padding,borderRadius:props.radius}" :class="[(fadein || props.show)?'modal-normal':'modal-scale',props.show?'modal-show':'']">
<view v-if="props.custom">
<slot></slot>
</view>
<view v-else>
<view class="modal-title" v-if="props.title">{{props.title}}</view>
<view class="modal-content" :class="[props.title?'':'mtop']" :style="{color:props.color,fontSize:props.size+'rpx'}">
<slot></slot>
</view>
<view class="modalBtn-box" :class="[props.button.length!=2?'flex-column':'']">
<block v-for="(item,index) in props.button" :key="index">
<button class="modal-btn"
:class="[
''+(item.type || 'primary')+(item.plain?'-outline':''),
props.button.length!=2?'btn-width':'',
props.button.length>2?'mbtm':'',
props.shape=='circle'?'circle-btn':'',
'btn-' + (item.size || 'default'),
]"
:hover-class="''+(item.plain?'outline':(item.type || 'primary'))+'-hover'" :data-index="index" @tap="handleClick">{{item.text || "确定"}}</button>
</block>
</view>
</view>
</view>
<view class="modal-mask" :class="[props.show?'mask-show':'']" @tap="handleClickCancel"></view>
</view>
</template>
<script setup>
import { ref } from 'vue'
//const props = defineProps(['show','custom','width','padding','radius','title','content','color','size','shape','button','maskClosable','fadein'])
const props = defineProps ({
show: {type: Boolean,default: false},
custom: {type: Boolean,default: false},
width: {type: String,default: "84%"},
padding: {type: String,default: "40rpx"},
radius: {type: String,default: "24rpx"},
title: {type: String,default: ""},
content: {type: String,default: ""},
color: {type: String,default: "#999"},
size: {type: Number,default: 28},
shape: {type: String,default: 'square'}, //形状 circle, square
button: {type: Array,
default: function() {
return [{
text: "取消",
type: "red",
plain: true //是否空心
}, {
text: "确定",
type: "red",
plain: false
}]
}},
maskClosable: {type: Boolean,default: true},
custom: {type: Boolean,default: false},
fadein: {type: Boolean,default: false} //淡入效果,自定义弹框插入input输入框时传true
})
// const show = ref(props.show)
// const maskClosable = ref(props.maskClosable)
const emit = defineEmits(['click','cancel','test'])
const handleClick = (e) => {
if (!props.show) return;
const dataset = e.currentTarget.dataset;
emit('click', {
index: Number(dataset.index)
});
}
const handleClickCancel = () => {
if (!props.maskClosable) return;
emit('cancel');
}
</script>
<style lang="scss">
.modal-box {
position: fixed;
left: 50%;
top: 50%;
margin: auto;
background: #fff;
z-index: 201;
transition: all 0.3s ease-in-out;
opacity: 0;
box-sizing: border-box;
visibility: hidden;
}
.modal-scale {
transform: translate(-50%, -50%) scale(0);
}
.modal-normal {
transform: translate(-50%, -50%) scale(1);
}
.modal-show {
opacity: 1;
visibility: visible;
}
.modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 98;
transition: all 0.3s ease-in-out;
opacity: 0;
visibility: hidden;
}
.mask-show {
visibility: visible;
opacity: 1;
}
.modal-title {
text-align: center;
font-size: 34rpx;
color: #333;
padding-top: 20rpx;
font-weight: bold;
}
.modal-content {
color: #999;
font-size: 28rpx;
padding-top: 20rpx;
padding-bottom: 60rpx;
}
.mtop {
margin-top: 30rpx;
}
.mbtm {
margin-bottom: 30rpx;
}
.modalBtn-box {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between
}
.flex-column {
flex-direction: column;
}
.modal-btn {
width: 46%;
height: 68rpx;
line-height: 68rpx;
position: relative;
border-radius: 60rpx;
font-size: 28rpx;
overflow: visible;
margin-left: 0;
margin-right: 0;
&.btn-default {
font-size: 28rpx;
}
&.btn-lg {
font-size: 32rpx;
}
&.btn-sm {
font-size: 24rpx;
}
}
.modal-btn::after {
content: "";
position: absolute;
width: 200%;
height: 200%;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5, 0.5);
transform: scale(0.5, 0.5);
left: 0;
top: 0;
border-radius: 60rpx;
}
.btn-width {
width: 80% !important;
}
.primary {
background: #97AF13;
color: #fff;
}
.primary-hover {
background: #97AF13;
color: #e5e5e5;
}
.primary-outline {
color: #97AF13;
background: none;
}
.primary-outline::after {
border: 1px solid #97AF13;
}
.danger {
background: #ed3f14;
color: #fff;
}
.danger-hover {
background: #d53912;
color: #e5e5e5;
}
.danger-outline {
color: #ed3f14;
background: none;
}
.danger-outline::after {
border: 1px solid #ed3f14;
}
.red {
background: #e41f19;
color: #fff;
}
.red-hover {
background: #c51a15;
color: #e5e5e5;
}
.red-outline {
color: #e41f19;
background: none;
}
.red-outline::after {
border: 1px solid #e41f19;
}
.warning {
background: #ff7900;
color: #fff;
}
.warning-hover {
background: #e56d00;
color: #e5e5e5;
}
.warning-outline {
color: #ff7900;
background: none;
}
.warning-outline::after {
border: 1px solid #ff7900;
}
.green {
background: #19be6b;
color: #fff;
}
.green-hover {
background: #16ab60;
color: #e5e5e5;
}
.green-outline {
color: #19be6b;
background: none;
}
.green-outline::after {
border: 1px solid #19be6b;
}
.white {
background: #fff;
color: #333;
}
.white-hover {
background: #f7f7f9;
color: #666;
}
.white-outline {
color: #333;
background: none;
}
.white-outline::after {
border: 1px solid #333;
}
.gray {
background: #ededed;
color: #999;
}
.gray-hover {
background: #d5d5d5;
color: #898989;
}
.gray-outline {
color: #999;
background: none;
}
.gray-outline::after {
border: 1px solid #999;
}
.outline-hover {
opacity: 0.6;
}
.circle-btn {
border-radius: 40rpx !important;
}
.circle-btn::after {
border-radius: 80rpx !important;
}
</style>
@@ -0,0 +1,220 @@
<template>
<view
:class="classObject"
:style="[getStyle]"
>
<slot></slot>
</view>
</template>
<script setup>
import { ref, watch, onMounted } from "vue"
const props = defineProps([
'direction',
'align',
'wrap',
'justify',
'size',
'height',
'padding',
'flex',
'border'
])
console.log("--> % props:\n", props)
const classObject = ref({})
const handleClassObject = (props) => {
console.log("--> % handleClassObject % props:\n", props.value)
let className = 'yshop-space'
let direction = props.direction
let align = props.align
let wrap = props.wrap
let justify = props.justify
let flex = props.flex
let border = props.border
if (border) {
className += ' yshop-space-border'
}
if (direction) {
className += ` yshop-space-${direction}`
}
if (wrap) {
className += ` yshop-space-${wrap}`
}
if (align) {
className += ` yshop-space-align-${align}`
}
if (justify) {
className += ` yshop-space-justify-${justify}`
}
console.log("--> % handleClassObject % className:\n", className)
classObject.value = className
}
const getStyle = ({
size = 6,
wrap,
height,
padding,
flex
}) => {
let innerStyle = {}
// let size = size.value
// let wrap = wrap.value
// let height = height.value
// let padding = padding.value
if (height) {
innerStyle.height = `${height}rpx`
}
if (typeof size === 'number') {
innerStyle.gap = size + 'px'
}
if (wrap) {
innerStyle.flexWrap = 'wrap'
}
if (typeof size === 'string') {
switch (size) {
case 'small':
innerStyle.gap = '8rpx'
break
case 'middle':
innerStyle.gap = '16rpx'
break
case 'large':
innerStyle.gap = '24rpx'
break
}
}
if (typeof padding === 'string') {
innerStyle.padding = `${padding}rpx`
}
if (Object.prototype.toString.call(padding) === '[object Array]') {
if (typeof padding === 'object') {
if (padding.length == 1) {
innerStyle.padding = `${padding[0]}rpx`
}
if (padding.length == 2) {
innerStyle.padding = `${padding[0]}rpx ${padding[1]}rpx`
}
}
}
if (Object.prototype.toString.call(size) === '[object Array]') {
if (typeof size === 'object') {
if (size.length == 1) {
innerStyle.gap = `${size[0]}rpx`
}
if (size.length == 2) {
innerStyle.gap = `${size[0]}rpx ${size[1]}rpx`
}
}
}
if (flex) {
innerStyle.flex = flex
}
return innerStyle
}
onMounted(() => {
handleClassObject(props)
getStyle(props)
})
</script>
<style lang="less">
space {
width: 100%;
}
.yshop-space {
display: flex;
width: 100%;
flex: 1;
&-vertical {
flex-direction: column;
}
&-align-center {
align-items: center;
}
&-align-start {
align-items: flex-start;
}
&-align-end {
align-items: flex-end;
}
&-justify-center {
justify-content: center;
}
&-justify-between {
justify-content: space-between;
}
&-justify-around {
justify-content: space-around;
}
&-align-end {
align-items: flex-end;
}
&-align-baseline {
align-items: baseline;
}
&-item:empty {
display: none;
}
&-border {
border-bottom: 1rpx solid #f9f9f9;
}
}
// #ifdef APP-PLUS
.yshop-space {
&>view {
margin-right: 8rpx;
}
&>text {
margin-right: 8rpx;
}
&>image {
margin-right: 8rpx;
}
.u-tag-wrapper {
margin-right: 8rpx;
}
.u-tag {
margin-right: 8rpx;
}
}
// #endif
</style>
@@ -0,0 +1,125 @@
<template>
<uv-upload
:fileList="list"
name="1"
multiple
:maxCount="10"
@afterRead="afterRead"
@delete="handleDeletePic"
></uv-upload>
</template>
<script setup>
import { VUE_APP_UPLOAD_URL } from '@/config';
import { ref } from 'vue';
const props = defineProps(['modelValue'])
console.log("--> % modelValue:\n", props.modelValue)
const emit = defineEmits(['update:modelValue'])
const list = ref(props.modelValue)
const handleDeletePic = (event) => {
list.value.splice(event.index, 1)
emit('update:modelValue', list.value)
}
const afterRead = async (event) => {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = list.value.length
lists.map((item) => {
list.value.push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url)
console.log("gxs --> % afterRead % result:\n", result)
let item = list.value[fileListLen]
list.value.splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
emit('update:modelValue', list.value)
}
const uploadFilePromise = (url) => {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: VUE_APP_UPLOAD_URL, // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
formData: {
user: 'test'
},
success: (res) => {
console.log("gxs --> % returnnewPromise % res:\n", res)
setTimeout(() => {
resolve(res.data.data)
}, 10)
}
});
})
}
</script>
<style lang="less">
.activity {
&-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
&-info {
display: flex;
align-items: flex-end;
}
&-title {
line-height: 45rpx;
font-size: 32rpx;
color: #333333;
}
&-subtitle {
margin-left: 10rpx;
line-height: 33rpx;
font-size: 24rpx;
color: #EE6D46;
}
&-more {
display: flex;
align-items: center;
&-info {
line-height: 33rpx;
font-size: 24rpx;
color: #999999;
}
.image {
margin-left: 10rpx;
display: block;
width: 20rpx;
height: 20rpx;
}
}
&-body {}
}
}
</style>
@@ -0,0 +1,452 @@
<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>