| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <view class="cg-overlay" v-if="show">
- <view class="cg-card">
- <!-- 顶部主题色条 -->
- <view class="cg-topbar" :style="{ background: themeColor }"></view>
- <!-- 步骤内容 -->
- <view class="cg-content">
- <!-- 单步弹窗:无 steps 时直接用 title/description/icon -->
- <block v-if="!isMulti">
- <text v-if="iconType === 0 && icon" class="cg-icon">{{ icon }}</text>
- <image v-if="iconType === 1 && icon" class="cg-img" :src="icon" mode="aspectFit" />
- <text class="cg-title">{{ title }}</text>
- <text class="cg-desc">{{ description }}</text>
- </block>
- <!-- 多步向导:steps 数组渲染 -->
- <block v-else>
- <text v-if="currentStepObj.iconType === 0 && currentStepObj.icon" class="cg-icon">{{ currentStepObj.icon }}</text>
- <image v-if="currentStepObj.iconType === 1 && currentStepObj.icon" class="cg-img" :src="currentStepObj.icon" mode="aspectFit" />
- <text class="cg-title" :class="{ 'cg-title--intro': currentStepObj.isIntro }">{{ currentStepObj.title }}</text>
- <text class="cg-desc">{{ currentStepObj.desc }}</text>
- </block>
- </view>
- <!-- 步进器(仅多步) -->
- <view class="cg-dots" v-if="isMulti">
- <view v-for="(s, i) in steps" :key="i" class="cg-dot" :class="{ 'cg-dot--active': i === currentStep }"></view>
- </view>
- <!-- 按钮 -->
- <view class="cg-action">
- <view class="cg-btn" :style="{ background: themeColor }" @click="handleClick">
- <text>{{ btnLabel }}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'ConfigurableGuide',
- props: {
- popup: { type: Object, default: null },
- show: { type: Boolean, default: false }
- },
- data() {
- return {
- currentStep: 0
- }
- },
- computed: {
- isMulti() {
- return this.popup && this.popup.steps && this.popup.steps.length > 0
- },
- title() { return this.popup && this.popup.title ? this.popup.title : '' },
- description() { return this.popup && this.popup.description ? this.popup.description : '' },
- icon() { return this.popup && this.popup.icon ? this.popup.icon : '' },
- iconType() { return this.popup && this.popup.iconType !== undefined ? this.popup.iconType : 0 },
- themeColor() { return this.popup && this.popup.themeColor ? this.popup.themeColor : '#F97316' },
- steps() { return this.isMulti ? this.popup.steps : [] },
- currentStepObj() {
- if (!this.isMulti) return {}
- return this.steps[this.currentStep] || {}
- },
- btnLabel() {
- if (!this.isMulti) {
- return this.popup && this.popup.btnText ? this.popup.btnText : '知道了'
- }
- var isLast = this.currentStep >= this.steps.length - 1
- if (isLast) {
- return this.popup && this.popup.btnText ? this.popup.btnText : '开始体验'
- }
- return this.currentStepObj.btnText || '下一步'
- }
- },
- watch: {
- show(val) {
- if (val) this.currentStep = 0
- }
- },
- methods: {
- handleClick() {
- if (this.isMulti && this.currentStep < this.steps.length - 1) {
- this.currentStep++
- return
- }
- // 最后一步 / 单步:跳转 + 消费
- var action = ''
- if (this.isMulti) {
- action = this.currentStepObj.btnAction || this.popup.btnAction || ''
- } else {
- action = this.popup.btnAction || ''
- }
- this.$emit('done', { popup: this.popup, btnAction: action, buttonClicked: true })
- },
- handleClose() {
- this.$emit('done', { popup: this.popup, btnAction: '', buttonClicked: false })
- }
- }
- }
- </script>
- <style scoped>
- .cg-overlay {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9998;
- }
- .cg-card {
- width: 640rpx;
- min-height: 560rpx;
- background: #FFFFFF;
- border-radius: 32rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- overflow: hidden;
- }
- .cg-topbar { width: 100%; height: 12rpx; flex-shrink: 0; }
- .cg-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 72rpx 56rpx 40rpx;
- }
- .cg-icon { font-size: 80rpx; margin-bottom: 32rpx; display: block; }
- .cg-img { width: 160rpx; height: 160rpx; margin-bottom: 32rpx; }
- .cg-title {
- font-size: 36rpx;
- font-weight: 700;
- color: #1E293B;
- text-align: center;
- margin-bottom: 20rpx;
- display: block;
- line-height: 1.3;
- }
- .cg-title--intro { font-size: 32rpx; font-weight: 800; }
- .cg-desc {
- font-size: 28rpx;
- color: #64748B;
- text-align: center;
- line-height: 1.6;
- display: block;
- padding: 0 16rpx;
- }
- .cg-dots { display: flex; align-items: center; justify-content: center; padding: 0 56rpx 32rpx; }
- .cg-dot { width: 14rpx; height: 14rpx; border-radius: 50%; background: #CBD5E1; margin: 0 8rpx; }
- .cg-dot--active { background: #F97316; transform: scale(1.3); }
- .cg-action { width: 100%; padding: 0 56rpx 48rpx; box-sizing: border-box; }
- .cg-btn {
- width: 100%;
- height: 88rpx;
- border-radius: 999rpx;
- color: #FFFFFF;
- font-size: 32rpx;
- font-weight: 700;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- </style>
|