createCirclce.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <view class="title">
  5. 圈子名称
  6. </view>
  7. <u--input placeholder="请输入圈子名称" border="none" v-model="formData.circleName" @change="change"
  8. :customStyle="custom"></u--input>
  9. </view>
  10. <view class="row1">
  11. <view class="flex flex-between" style="margin-top: 20rpx;">
  12. <view class="title">圈子标签</view>
  13. <uni-icons type="plus-filled" @click="add(item)" size="40" color="#112253"></uni-icons>
  14. </view>
  15. <view class="">
  16. <view v-for="(item,index) in labelList":key="index">
  17. <view class="flex">
  18. <u-input placeholder="请输入圈子标签,2-4个字" border="none" v-model="item.labelName" @change="change"
  19. :customStyle="custom">
  20. <template slot="suffix">
  21. <image src="../../static/imgs/mySet/del.png" mode="widthFix" style="width: 40rpx;" @click="subtract(index)"></image>
  22. </template>
  23. </u-input>
  24. <!-- <uni-icons type="minus-filled" @click="subtract(index)" size="40"></uni-icons> -->
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="">
  30. <button type="default" @click="submit" class="submit">提交</button>
  31. </view>
  32. <u-toast ref="uToast"></u-toast>
  33. </view>
  34. </template>
  35. <script>
  36. var that;
  37. export default {
  38. data() {
  39. return {
  40. custom: {
  41. "margin-top":"20rpx",
  42. "background": "#fff",
  43. "border-radius": "20rpx",
  44. "padding":"20rpx"
  45. },
  46. value: '',
  47. labelList: [{
  48. labelName: ''
  49. },
  50. {
  51. labelName: ''
  52. }
  53. ],
  54. formData: {
  55. circleName: '',
  56. circleLabel: [],
  57. commonId: ''
  58. }
  59. };
  60. },
  61. onLoad() {
  62. that = this
  63. this.userInfo = uni.getStorageSync("userInfo")
  64. this.formData.commonId = this.userInfo.id
  65. },
  66. methods: {
  67. change(e) {
  68. console.log('change', e);
  69. },
  70. submit() {
  71. this.formData.circleLabel = []
  72. if (!this.formData.circleName) {
  73. this.$refs.uToast.show({
  74. type: 'error',
  75. message: '圈子名称不能为空!',
  76. })
  77. return
  78. }
  79. for (let i = 0; i < this.labelList.length; i++) {
  80. if (!this.labelList[i].labelName) {
  81. this.$refs.uToast.show({
  82. type: 'error',
  83. message: '标签内容不能为空!',
  84. })
  85. return
  86. }
  87. if (this.labelList[i].labelName.length > 4 || this.labelList[i].labelName.length < 2) {
  88. this.$refs.uToast.show({
  89. type: 'error',
  90. message: '标签内容2-4个字!',
  91. })
  92. return
  93. }
  94. this.formData.circleLabel.push(this.labelList[i].labelName)
  95. }
  96. this.formData.circleLabel = this.formData.circleLabel.toString()
  97. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'add', {
  98. circleManagementInfo: JSON.stringify(this.formData)
  99. }, failres => {
  100. this.$refs.uToast.show({
  101. type: 'error',
  102. message: failres.errmsg,
  103. })
  104. uni.hideLoading()
  105. }).then(res => {
  106. this.$refs.uToast.show({
  107. type: 'success',
  108. message: '提交成功!',
  109. })
  110. setTimeout(() => {
  111. uni.navigateBack()
  112. }, 500)
  113. })
  114. },
  115. add() {
  116. if (this.labelList.length > 3) {
  117. this.$refs.uToast.show({
  118. type: 'error',
  119. message: '“标签数量2-4个!',
  120. })
  121. return
  122. }
  123. this.labelList.push({
  124. labelName: ''
  125. })
  126. },
  127. subtract(index) {
  128. if (this.labelList.length < 3) {
  129. this.$refs.uToast.show({
  130. type: 'error',
  131. message: '“标签数量2-4个!',
  132. })
  133. return
  134. }
  135. this.labelList.splice(index, 1)
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .content {
  142. padding: 20rpx;
  143. .title {
  144. font-size: 32rpx;
  145. font-weight: bold;
  146. color: #1A1A1A;
  147. }
  148. }
  149. .submit{
  150. position: fixed;
  151. bottom: 100rpx;
  152. background-color:#112253 ;
  153. color: #fff;
  154. width: calc(100% - 40rpx);
  155. }
  156. </style>