generationAsk.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. })
  48. : this.type == "文章"
  49. ? await Report.articleAskAdd({
  50. ArticleId: Number(this.id),
  51. Content: this.advice_content,
  52. })
  53. : await activity.activityAskAdd({
  54. ActivityId: Number(this.id),
  55. Content: this.advice_content,
  56. });
  57. if (res.Ret === 200) {
  58. this.$util.toast("提交成功");
  59. this.advice_content = "";
  60. setTimeout(() => {
  61. uni.navigateBack();
  62. }, 500);
  63. }
  64. },
  65. },
  66. onLoad(option) {
  67. this.id = option.id;
  68. this.type = option.type || "";
  69. this.roadshow = option.roadshow || null;
  70. this.roadshowTitle = option.roadshowTitle || "";
  71. uni.setNavigationBarTitle({
  72. title: this.type == "文章" ? "留言" : this.type == "提问" ? "实时提问" : "帮我带问",
  73. });
  74. },
  75. };
  76. </script>
  77. <style scoped lang="scss">
  78. .ask-container {
  79. background-color: #fff;
  80. padding: 30rpx 34rpx;
  81. .advice-ipt-cont {
  82. height: 420rpx;
  83. border: 1rpx solid #d0cfd5;
  84. border-radius: 8rpx;
  85. padding: 30rpx;
  86. position: relative;
  87. font-size: 28rpx;
  88. color: #d0cfd5;
  89. .num-tag {
  90. position: absolute;
  91. bottom: 30rpx;
  92. right: 30rpx;
  93. }
  94. }
  95. .btn-cont {
  96. margin: 80rpx auto;
  97. width: 368rpx;
  98. height: 80rpx;
  99. font-size: 34rpx;
  100. line-height: 80rpx;
  101. text-align: center;
  102. color: #ffffff;
  103. background: linear-gradient(268deg, #2ddbff 0%, #1599ff 49%, #005eff 100%);
  104. opacity: 1;
  105. border-radius: 4rpx;
  106. }
  107. }
  108. </style>