intent-picker.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="ip-mask" v-if="show" @click="onMaskTap">
  3. <view class="ip-panel" @click.stop>
  4. <view class="ip-header">
  5. <text class="ip-title">花一分钟,做个小测试</text>
  6. <text class="ip-sub">回答几个问题,看看我能为您做点儿什么</text>
  7. </view>
  8. <!-- 开始测试 -->
  9. <view class="ip-card" @click="onStart">
  10. <view class="ip-card-icon" style="background:rgba(249,115,22,0.12)">
  11. <text class="ip-card-emoji">✨</text>
  12. </view>
  13. <view class="ip-card-body">
  14. <text class="ip-card-title">开始测试</text>
  15. <text class="ip-card-desc">3分钟了解你的家庭健康需求,生成专属成长方案</text>
  16. </view>
  17. <text class="ip-card-arrow">›</text>
  18. </view>
  19. <!-- 以后再说 -->
  20. <view class="ip-skip" @click="onSkip">
  21. <text class="ip-skip-text">{{ skipHint }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { skipUserIntent } from '../utils/api.js'
  28. export default {
  29. name: 'IntentPicker',
  30. props: {
  31. show: {
  32. type: Boolean,
  33. default: false
  34. }
  35. },
  36. data() {
  37. return {
  38. skipping: false
  39. }
  40. },
  41. computed: {
  42. skipHint() {
  43. var count = parseInt(uni.getStorageSync('intent_skip_count') || '0')
  44. if (count >= 3) return ''
  45. if (count > 0) return '以后再说(' + (3 - count) + '次机会)'
  46. return '以后再说'
  47. }
  48. },
  49. methods: {
  50. onMaskTap() {},
  51. onStart() {
  52. this.$emit('select', { intentType: 'B' })
  53. },
  54. onSkip() {
  55. var self = this
  56. if (self.skipping) return
  57. self.skipping = true
  58. skipUserIntent().then(function(res) {
  59. self.skipping = false
  60. if (res.code === 200 && res.data) {
  61. var count = (res.data.skipCount || 0) + 1
  62. uni.setStorageSync('intent_skip_count', count)
  63. if (count >= 3) {
  64. uni.setStorageSync('intent_skip_max', '1')
  65. }
  66. uni.showToast({ title: '好的,随时可以回来测', icon: 'none' })
  67. setTimeout(function() { self.$emit('close') }, 500)
  68. } else {
  69. self.$emit('close')
  70. }
  71. }).catch(function() {
  72. self.skipping = false
  73. self.$emit('close')
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .ip-mask {
  81. position: fixed;
  82. top: 0; left: 0; right: 0; bottom: 0;
  83. background: rgba(0, 0, 0, 0.55);
  84. display: flex;
  85. align-items: flex-end;
  86. justify-content: center;
  87. z-index: 9999;
  88. }
  89. .ip-panel {
  90. width: 100%;
  91. background: #FFF7ED;
  92. border-radius: 32rpx 32rpx 0 0;
  93. padding: 56rpx 40rpx 64rpx;
  94. box-sizing: border-box;
  95. }
  96. .ip-header { margin-bottom: 36rpx; }
  97. .ip-title {
  98. display: block;
  99. font-size: 40rpx; font-weight: bold; color: #333;
  100. text-align: center; line-height: 1.3;
  101. }
  102. .ip-sub {
  103. display: block;
  104. font-size: 26rpx; color: #888;
  105. text-align: center; margin-top: 12rpx; line-height: 1.5;
  106. }
  107. .ip-card {
  108. display: flex; align-items: center;
  109. background: #fff; border-radius: 24rpx;
  110. padding: 32rpx 28rpx;
  111. box-shadow: 0 4rpx 20rpx rgba(249,115,22,0.1);
  112. border: 2rpx solid rgba(249,115,22,0.15);
  113. }
  114. .ip-card:active { opacity: 0.88; }
  115. .ip-card-icon {
  116. width: 88rpx; height: 88rpx;
  117. border-radius: 22rpx;
  118. display: flex; align-items: center; justify-content: center;
  119. margin-right: 24rpx; flex-shrink: 0;
  120. }
  121. .ip-card-emoji { font-size: 44rpx; }
  122. .ip-card-body { flex: 1; min-width: 0; }
  123. .ip-card-title {
  124. display: block;
  125. font-size: 30rpx; font-weight: 600; color: #333;
  126. }
  127. .ip-card-desc {
  128. display: block;
  129. font-size: 24rpx; color: #999;
  130. margin-top: 6rpx; line-height: 1.4;
  131. }
  132. .ip-card-arrow { font-size: 36rpx; color: #F97316; flex-shrink: 0; }
  133. .ip-skip { text-align: center; margin-top: 28rpx; padding: 12rpx 0; }
  134. .ip-skip-text { font-size: 26rpx; color: #bbb; }
  135. </style>