index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <Container
  3. title="挑战"
  4. :scrollStyle="{
  5. padding: 0,
  6. }"
  7. :showBack="false"
  8. >
  9. <view>
  10. <view class="bg">
  11. <div class="setting" @click="toRule">规则</div>
  12. </view>
  13. </view>
  14. <template #stick>
  15. <button class="btn" @click="toAdd">
  16. {{ isPay ? "查看报名信息" : "立即报名!参与挑战!" }}
  17. </button>
  18. </template>
  19. </Container>
  20. </template>
  21. <script setup>
  22. import Container from "../../components/Container/Container.vue";
  23. import { request } from "../../utils/request";
  24. import { router } from "../../utils/router";
  25. import { onShow } from "@dcloudio/uni-app";
  26. import { ref } from "vue";
  27. const isPay = ref(true);
  28. const p = ref(0);
  29. onShow(async () => {
  30. const a = uni.getStorageSync("pages/challenge/index");
  31. let res = {
  32. data: false,
  33. };
  34. isPay.value = a === "" ? true : a;
  35. if (a === "") {
  36. isPay.value = true;
  37. try {
  38. res = await request(
  39. "api/question_bank/question_reception/challenge_registration_log/detail",
  40. {
  41. showToast: false,
  42. }
  43. );
  44. isPay.value = res.data !== "";
  45. } catch (e) {
  46. isPay.value = false;
  47. }
  48. uni.setStorageSync("pages/challenge/index", isPay.value);
  49. }
  50. await request(
  51. "api/question_bank/question_reception/recharge_package/list",
  52. {
  53. package_type: 2,
  54. },
  55. "post"
  56. ).then(async (res) => {
  57. p.value = res.data.data[0].id;
  58. });
  59. });
  60. const toRule = () => {
  61. router.push({
  62. url: "/pages/challenge/rule",
  63. params: {
  64. id: p.value,
  65. },
  66. });
  67. };
  68. const toAdd = async () => {
  69. const isLogin = uni.getStorageSync("userLogin");
  70. console.log(isLogin);
  71. if (!isLogin) {
  72. uni.showModal({
  73. title: "请登录",
  74. success(res) {
  75. if (res.confirm) {
  76. // 用户点击确定按钮
  77. router.push({
  78. url: "/pages/login/index",
  79. });
  80. }
  81. },
  82. });
  83. return;
  84. }
  85. router.push({
  86. url: !isPay.value
  87. ? "/pages/challenge/registration"
  88. : "/pages/challenge/addContant",
  89. params: {
  90. id: p.value,
  91. isPay: isPay.value,
  92. },
  93. });
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .bg {
  98. width: 100%;
  99. height: 1824rpx;
  100. background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/mrFDMhG0TOSn9DcVQupf8b6w2UgGGhq6LhdfaZWn.png");
  101. background-size: cover;
  102. padding: 32rpx;
  103. box-sizing: border-box;
  104. position: relative;
  105. .setting {
  106. position: absolute;
  107. right: 0;
  108. top: 200rpx;
  109. background: rgba(0, 0, 0, 0.5);
  110. border-radius: 500rpx 0rpx 0rpx 500rpx;
  111. font-weight: 500;
  112. font-size: 24rpx;
  113. color: #ffffff;
  114. padding: 8rpx;
  115. }
  116. }
  117. .btn {
  118. width: 660rpx;
  119. position: absolute;
  120. bottom: 3%;
  121. left: 50%;
  122. transform: translateX(-50%);
  123. }
  124. </style>