generationAsk.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. ArticleId: Number(this.id),
  44. Content: this.advice_content,
  45. SourceType: this.roadshow == 3 ? 2 : 1,
  46. Title: this.roadshowTitle,
  47. })
  48. : this.type == "文章"
  49. ? await Report.articleAskAdd({
  50. ArticleId: Number(this.id),
  51. Content: this.advice_content,
  52. })
  53. : 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. console.log(option);
  68. this.id = option.id;
  69. this.type = option.type || "";
  70. this.roadshow = option.roadshow || null;
  71. this.roadshowTitle = option.roadshowTitle || "";
  72. uni.setNavigationBarTitle({
  73. title: this.type == "文章" ? "留言" : this.type == "提问" ? "实时提问" : "帮我带问",
  74. });
  75. },
  76. };
  77. </script>
  78. <style scoped lang="scss">
  79. .ask-container {
  80. background-color: #fff;
  81. padding: 30rpx 34rpx;
  82. .advice-ipt-cont {
  83. height: 420rpx;
  84. border: 1rpx solid #d0cfd5;
  85. border-radius: 8rpx;
  86. padding: 30rpx;
  87. position: relative;
  88. font-size: 28rpx;
  89. color: #d0cfd5;
  90. .num-tag {
  91. position: absolute;
  92. bottom: 30rpx;
  93. right: 30rpx;
  94. }
  95. }
  96. .btn-cont {
  97. margin: 80rpx auto;
  98. width: 368rpx;
  99. height: 80rpx;
  100. font-size: 34rpx;
  101. line-height: 80rpx;
  102. text-align: center;
  103. color: #ffffff;
  104. background: linear-gradient(268deg, #2ddbff 0%, #1599ff 49%, #005eff 100%);
  105. opacity: 1;
  106. border-radius: 4rpx;
  107. }
  108. }
  109. </style>