generationAsk.vue 3.2 KB

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