add-circle.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="add-circle-box iPhone-bottom flex-common-css box-border-box">
  3. <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
  4. <Nav title='发圈子' bgckgroundBox='#fff'></Nav>
  5. <view class="scroll-view-css box-border-box ptp-24">
  6. <view class="bgc-f box-border-box p-32">
  7. <view class="fs-34 fw-600 mb-20">内容描述 <span class='fs-34 fc-9 fw-400'>(必填)</span></view>
  8. <textarea v-model="fromData.content" class="textarea-class fs-24" :maxlength='500' placeholder='这一刻说些什么'
  9. @input='input'></textarea>
  10. <view class="text-align-right fs-28 fc-9">
  11. {{inputNum>=500?'500':inputNum}}/500
  12. </view>
  13. </view>
  14. <view class="bgc-f mb-20">
  15. <EnUpload v-model="fromData.image" number='9'></EnUpload>
  16. </view>
  17. <view class="bgc-f box-border-box p-32 flex-justify-space align-items-center" @click="openPop()">
  18. <view class="fs-34 fw-600">{{typeName}}</view>
  19. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  20. </view>
  21. </view>
  22. <view class="box-border-box p-32" @click="save()">
  23. <view class="b-bottom text-align-center fs-32 fw-600 fc-f">发布</view>
  24. </view>
  25. <uni-popup ref="popup" type="bottom" background-color="#fff" @change="change">
  26. <view class="pop-box box-border-box p-24">
  27. <view class="head-pop flex-justify-space align-items-center mb-24">
  28. <uni-icons @click.stop="closePop(1)" type="closeempty" size="24"></uni-icons>
  29. <view class="fs-36 fc-0 fw-600">选发布类型</view>
  30. <view class="fs-28 fw-600 fc-41ABF5" @click.stop="closePop(2)">确定</view>
  31. </view>
  32. <view class="scroll-view-css">
  33. <view class="item-box fs-32 "
  34. :class="fromData.topic_id==item.id?'fc-41ABF5 bgc-D5EDFB':'bgc-F3F4F6'"
  35. v-for="(item,i) in classList" :key="i" @click="selectPopAddEditType(item)">{{item.name}}</view>
  36. </view>
  37. </view>
  38. </uni-popup>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. getTopic
  44. } from '@/api/category.js';
  45. import {
  46. alumniSave
  47. } from '@/api/alumni.js';
  48. import tools from '@/service/tools';
  49. import EnUpload from '@/components/en-from/en-upload/en-upload.vue';
  50. export default {
  51. components: {
  52. EnUpload
  53. },
  54. data() {
  55. return {
  56. fromData: {
  57. news_id: '',
  58. content: '',
  59. image: [],
  60. school_id: '',
  61. topic_id: '',
  62. },
  63. isAJAX: false,
  64. classList: [],
  65. typeName: '请选择发布类型',
  66. show: 'false',
  67. inputNum: 0
  68. }
  69. },
  70. onLoad(e) {
  71. if (e.news_id) {
  72. this.fromData.news_id = e.news_id;
  73. } else {
  74. this.fromData.news_id = '';
  75. }
  76. },
  77. methods: {
  78. input(e) {
  79. console.log(e.detail);
  80. this.inputNum = e.detail.cursor
  81. },
  82. change(e) {
  83. this.show = e.show
  84. },
  85. selectPopAddEditType(item) {
  86. if (this.fromData.topic_id != item.id) {
  87. this.fromData.topic_id = item.id;
  88. this.typeName = item.name;
  89. }
  90. },
  91. openPop() {
  92. getTopic().then((res) => {
  93. if (res.code === 1) {
  94. this.classList = res.data;
  95. this.$refs.popup.open();
  96. }
  97. })
  98. },
  99. closePop(type) {
  100. if (type === 1) {
  101. this.fromData.topic_id = '';
  102. this.typeName = '请选择发布类型';
  103. }
  104. this.$refs.popup.close();
  105. },
  106. save() {
  107. if (this.isAJAX) {
  108. return
  109. }
  110. this.isAJAX = true;
  111. let circleSchoolId = uni.getStorageSync('circleSchoolId');
  112. let school_id = uni.getStorageSync('school_id');
  113. this.fromData.school_id = circleSchoolId ? circleSchoolId : school_id;
  114. alumniSave(this.fromData).then((res) => {
  115. if (res.code === 1) {
  116. tools.success(res.msg, 1000)
  117. setTimeout(() => {
  118. this.isAJAX = false;
  119. uni.$emit('operateType', true);
  120. uni.navigateBack({
  121. delta: 1,
  122. });
  123. }, 1000)
  124. } else {
  125. tools.error(res.msg)
  126. this.isAJAX = false;
  127. }
  128. })
  129. },
  130. }
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .textarea-class {
  135. width: 100%;
  136. }
  137. .add-circle-box {
  138. .b-bottom {
  139. width: 686rpx;
  140. height: 88rpx;
  141. line-height: 88rpx;
  142. background: linear-gradient(105deg, #57CAFF 0%, #41ABF5 100%);
  143. border-radius: 200rpx;
  144. }
  145. .right-icon {
  146. width: 32rpx;
  147. height: 32rpx;
  148. }
  149. .head-pop {
  150. padding-bottom: 34rpx !important;
  151. border-bottom: 1rpx solid #F2F2F2;
  152. }
  153. .pop-box {
  154. width: 100%;
  155. height: 50vh;
  156. // background-color: #fff;
  157. border-radius: 24rpx 24rpx 0rpx 0rpx;
  158. display: flex;
  159. flex-direction: column;
  160. .item-box {
  161. width: 100%;
  162. height: 92rpx;
  163. border-radius: 200rpx;
  164. line-height: 92rpx;
  165. text-align: center;
  166. margin-bottom: 24rpx;
  167. }
  168. }
  169. }
  170. </style>