generationAsk.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="container ask-container">
  3. <view class="advice-ipt-cont">
  4. <u-input v-model="advice_content" type="textarea" maxlength="100" :clearable="false" :placeholder="titlePlaceholder" height="300" class="ipt" />
  5. <text class="num-tag">{{ advice_content.length }}/100</text>
  6. </view>
  7. <view class="btn-cont" @click="submitHandle"> 提交 </view>
  8. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  9. </view>
  10. </template>
  11. <script>
  12. import { activity, Report, Home } from "@/config/api.js";
  13. import freeCharge from "@/components/freeCharge";
  14. export default {
  15. data() {
  16. return {
  17. advice_content: "",
  18. id: "",
  19. type: "",
  20. roadshowTitle: "", // 微路演标题
  21. roadshow: null, // 判断微路演的类型
  22. };
  23. },
  24. components: {
  25. freeCharge,
  26. },
  27. computed: {
  28. titlePlaceholder() {
  29. return this.type == "文章" ? "可以留下您对报告内容的看法或者疑问" : "请描述您的问题,分析师会代您向专家提问。";
  30. },
  31. },
  32. methods: {
  33. async submitHandle() {
  34. if (!this.advice_content)
  35. return uni.showToast({
  36. title: "内容不能为空",
  37. icon: "none",
  38. duration: 2000,
  39. });
  40. const res =
  41. this.roadshow && this.type == "文章"
  42. ? await Home.microRoadshowAdd({
  43. Id: Number(this.id),
  44. Content: this.advice_content,
  45. SourceType: Number(this.roadshow),
  46. Title: this.roadshowTitle,
  47. PageRouter: this.$store.state.pageRouterReport,
  48. })
  49. : this.type == "文章"
  50. ? await Report.articleAskAdd({
  51. ArticleId: Number(this.id),
  52. Content: this.advice_content,
  53. PageRouter: this.$store.state.pageRouterReport,
  54. })
  55. : await activity.activityAskAdd({
  56. ActivityId: Number(this.id),
  57. Content: this.advice_content,
  58. PageRouter: this.$store.state.pageRouterReport,
  59. });
  60. if (res.Ret === 200) {
  61. this.$util.toast("提交成功");
  62. this.advice_content = "";
  63. setTimeout(() => {
  64. uni.navigateBack();
  65. }, 500);
  66. }
  67. },
  68. },
  69. onLoad(option) {
  70. this.id = option.id;
  71. this.type = option.type || "";
  72. this.roadshow = option.roadshow || null;
  73. this.roadshowTitle = option.roadshowTitle || "";
  74. uni.setNavigationBarTitle({
  75. title: this.type == "文章" ? "留言" : this.type == "提问" ? "实时提问" : "帮我带问",
  76. });
  77. },
  78. };
  79. </script>
  80. <style scoped lang="scss">
  81. .ask-container {
  82. background-color: #fff;
  83. padding: 30rpx 34rpx;
  84. .advice-ipt-cont {
  85. height: 420rpx;
  86. border: 1rpx solid #d0cfd5;
  87. border-radius: 8rpx;
  88. padding: 30rpx;
  89. position: relative;
  90. font-size: 28rpx;
  91. color: #d0cfd5;
  92. .num-tag {
  93. position: absolute;
  94. bottom: 30rpx;
  95. right: 30rpx;
  96. }
  97. }
  98. .btn-cont {
  99. margin: 80rpx auto;
  100. width: 368rpx;
  101. height: 80rpx;
  102. font-size: 34rpx;
  103. line-height: 80rpx;
  104. text-align: center;
  105. color: #ffffff;
  106. background: linear-gradient(268deg, #2ddbff 0%, #1599ff 49%, #005eff 100%);
  107. opacity: 1;
  108. border-radius: 4rpx;
  109. }
  110. }
  111. </style>