paySuccess.vue 2.51 KB
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';

import { ElButton } from 'element-plus';

import EnvironmentDetector from '#/composables/environmentDetector';

const route = useRoute();
const loadLoading = ref(false);

const queryData = ref<any>({});
const detector = ref();
const init = async () => {
  queryData.value = route.query || {};
};

const handleBack = () => {
  if (
    typeof jWeixin !== 'undefined' &&
    jWeixin.miniProgram &&
    detector.value?.env.isMiniProgram
  ) {
    jWeixin.miniProgram.switchTab({
      url: `/pages/newhome/newhome`,
    });
  }
};

onMounted(() => {
  init();
  detector.value = new EnvironmentDetector();
});
</script>

<template>
  <div class="cashier-container" v-loading="loadLoading">
    {{ detector?.env }}
    <!-- 正常支付界面 -->
    <div class="cashier-wrapper">
      <div class="pt-[40px]">
        <div class="flex flex-col items-center justify-center">
          <img src="/success.png" class="w-[64px]" />
          <p class="color-[#49250B] mt-2 text-[18px] font-bold">支付成功</p>
        </div>
        <div class="color-[#333] flex flex-col gap-4 p-[40px]">
          <div class="flex justify-between">
            <div>支付方式</div>
            <div>{{ queryData?.payType }}</div>
          </div>
          <div class="flex justify-between">
            <div>支付金额</div>
            <div>{{ queryData?.amount }} 元</div>
          </div>
          <div class="mt-10 flex justify-between">
            <ElButton
              class="pay-button"
              plain
              type="primary"
              size="large"
              @click="handleBack"
            >
              完成
            </ElButton>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.cashier-container {
  min-height: 100vh;
  background: linear-gradient(
    to bottom,
    #fff9f1 0%,
    #ffe9d4 20%,
    #ffe3c8 29%,
    #fff 45%,
    #fff 100%
  );
}

.cashier-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 500px;
  min-height: 100vh;
  margin: 0 auto;
}

.pay-button {
  width: 100%;
  height: 42px;
  font-size: 18px;
  font-weight: 600;
  color: #ea4200;
  background: #fff;
  border: 1px solid #ea4200;
  border-radius: 21px;

  &:hover:not(:disabled) {
    background: #f7f7f7;
    box-shadow: 0 6px 20px rgb(234 66 0 / 40%);
  }

  &:active:not(:disabled) {
    transform: scale(0.98);
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}
</style>