createCirclce.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="flex justify-space-between select-card">
  11. <view class="title">
  12. 选择名片
  13. </view>
  14. <view style="font-size:12px;padding-right:20rpx;" class='flex align-item-center' @click="cardShow">
  15. {{formData.cardBusiness?formData.cardBusiness:'暂无名片'}}
  16. <u-icon v-if='!formData.cardBusiness' name="arrow-right" size="12"></u-icon>
  17. </view>
  18. </view>
  19. <view class="row1">
  20. <view class="flex flex-between" style="margin-top: 20rpx;">
  21. <view class="title">圈子标签</view>
  22. <uni-icons type="plus-filled" @click="add(item)" size="40" color="#112253"></uni-icons>
  23. </view>
  24. <view class="">
  25. <view v-for="(item,index) in labelList":key="index">
  26. <view>
  27. <view class="flex">
  28. <u-input placeholder="请输入圈子标签,2-4个字" border="none" v-model="item.labelName" @change="change"
  29. :customStyle="custom">
  30. <template slot="suffix">
  31. <image src="../../static/imgs/mySet/del.png" mode="widthFix" style="width: 40rpx;" @click="subtract(index)"></image>
  32. </template>
  33. </u-input>
  34. </view>
  35. <!-- <uni-icons type="minus-filled" @click="subtract(index)" size="40"></uni-icons> -->
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="">
  41. <button type="default" @click="submit" class="submit">提交</button>
  42. </view>
  43. <u-picker keyName="cardBusiness" title="选择名片" @close="show=false"
  44. @cancel="show=false" closeOnClickOverlay @confirm="cardConfirm" :show="show" :columns="cardList"></u-picker>
  45. <u-toast ref="uToast"></u-toast>
  46. </view>
  47. </template>
  48. <script>
  49. var that;
  50. export default {
  51. data() {
  52. return {
  53. custom: {
  54. "margin-top":"20rpx",
  55. "background": "#fff",
  56. "border-radius": "20rpx",
  57. "padding":"20rpx"
  58. },
  59. value: '',
  60. show:false,
  61. cardList:[],
  62. labelList: [{
  63. labelName: '',
  64. },
  65. {
  66. labelName: '',
  67. }
  68. ],
  69. formData: {
  70. circleName: '',
  71. circleLabel: [],
  72. commonId: '',
  73. },
  74. currectData:{}
  75. };
  76. },
  77. onLoad() {
  78. that = this
  79. this.userInfo = uni.getStorageSync("userInfo")
  80. this.formData.commonId = this.userInfo.id
  81. },
  82. onShow() {
  83. uni.showLoading({
  84. title: '数据加载中'
  85. })
  86. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  87. commonId: uni.getStorageSync("userInfo").id
  88. }, failres => {
  89. this.$refs.uToast.show({
  90. type: 'error',
  91. message: failres.errmsg,
  92. })
  93. uni.hideLoading()
  94. }).then(res => {
  95. uni.hideLoading()
  96. this.cardList = [res.data.items]
  97. })
  98. },
  99. methods: {
  100. cardConfirm(e){
  101. console.log(e)
  102. this.formData.cardBusiness=e.value[0].cardBusiness
  103. this.formData.cardId=e.value[0].id
  104. this.show=false
  105. console.log(this.labelList)
  106. },
  107. cardShow(){
  108. this.show=true
  109. },
  110. change(e) {
  111. console.log('change', e);
  112. },
  113. submit() {
  114. this.formData.circleLabel = []
  115. if (!this.formData.circleName) {
  116. this.$refs.uToast.show({
  117. type: 'error',
  118. message: '圈子名称不能为空!',
  119. })
  120. return
  121. }
  122. for (let i = 0; i < this.labelList.length; i++) {
  123. if (!this.labelList[i].labelName) {
  124. this.$refs.uToast.show({
  125. type: 'error',
  126. message: '标签内容不能为空!',
  127. })
  128. return
  129. }
  130. if (this.labelList[i].labelName.length > 4 || this.labelList[i].labelName.length < 2) {
  131. this.$refs.uToast.show({
  132. type: 'error',
  133. message: '标签内容2-4个字!',
  134. })
  135. return
  136. }
  137. this.formData.circleLabel.push(this.labelList[i].labelName)
  138. }
  139. this.formData.circleLabel = this.formData.circleLabel.toString()
  140. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'add', {
  141. circleManagementInfo: JSON.stringify(this.formData)
  142. }, failres => {
  143. this.$refs.uToast.show({
  144. type: 'error',
  145. message: failres.errmsg,
  146. })
  147. uni.hideLoading()
  148. }).then(res => {
  149. this.$refs.uToast.show({
  150. type: 'success',
  151. message: '提交成功!',
  152. })
  153. setTimeout(() => {
  154. uni.navigateBack()
  155. }, 500)
  156. })
  157. },
  158. add() {
  159. if (this.labelList.length > 3) {
  160. this.$refs.uToast.show({
  161. type: 'error',
  162. message: '“标签数量2-4个!',
  163. })
  164. return
  165. }
  166. this.labelList.push({
  167. labelName: '',
  168. })
  169. },
  170. subtract(index) {
  171. if (this.labelList.length < 3) {
  172. this.$refs.uToast.show({
  173. type: 'error',
  174. message: '“标签数量2-4个!',
  175. })
  176. return
  177. }
  178. this.labelList.splice(index, 1)
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .content {
  185. padding: 20rpx;
  186. .title {
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. color: #1A1A1A;
  190. }
  191. }
  192. .submit{
  193. position: fixed;
  194. bottom: 100rpx;
  195. background-color:#112253 ;
  196. color: #fff;
  197. width: calc(100% - 40rpx);
  198. }
  199. .select-card{
  200. background:#fff;padding:20rpx 0 20rpx 20rpx;
  201. margin:10rpx 0;
  202. border-radius: 20rpx;
  203. }
  204. </style>