generationAsk.vue 3.3 KB

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