createCirclce.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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}}
  16. <u-icon 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-6个字" 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;height: auto;" @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. list:[],
  70. formData: {
  71. circleName: '',
  72. circleLabel: [],
  73. commonId: '',
  74. cardBusiness:''
  75. },
  76. currectData:{}
  77. };
  78. },
  79. onLoad() {
  80. that = this
  81. this.userInfo = uni.getStorageSync("userInfo")
  82. this.formData.commonId = this.userInfo.id
  83. },
  84. onShow() {
  85. uni.showLoading({
  86. title: '数据加载中'
  87. })
  88. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  89. commonId: uni.getStorageSync("userInfo").id
  90. }, failres => {
  91. uni.showToast({
  92. icon:"none",
  93. title: failres.errmsg,
  94. duration: 3000
  95. });
  96. uni.hideLoading()
  97. }).then(res => {
  98. uni.hideLoading()
  99. this.cardList = [res.data.items]
  100. this.list = res.data.items
  101. this.formData.cardBusiness = res.data.items[0].cardBusiness
  102. })
  103. },
  104. methods: {
  105. cardConfirm(e){
  106. console.log(e)
  107. this.formData.cardBusiness=e.value[0].cardBusiness
  108. this.formData.cardId=e.value[0].id
  109. this.show=false
  110. console.log(this.labelList)
  111. },
  112. cardShow(){
  113. if(this.list.length>0){
  114. this.show=true
  115. }else{
  116. uni.showToast({
  117. icon:"none",
  118. title: '暂无名片',
  119. duration: 2000
  120. });
  121. }
  122. },
  123. change(e) {
  124. console.log('change', e);
  125. },
  126. submit() {
  127. this.formData.circleLabel = []
  128. if (!this.formData.circleName) {
  129. uni.showToast({
  130. icon:"none",
  131. title: '圈子名称不能为空!',
  132. duration: 2000
  133. });
  134. return
  135. }
  136. for (let i = 0; i < this.labelList.length; i++) {
  137. if (!this.labelList[i].labelName) {
  138. uni.showToast({
  139. icon:"none",
  140. title: '标签内容不能为空!',
  141. duration: 2000
  142. });
  143. return
  144. }
  145. if (this.labelList[i].labelName.length > 6 || this.labelList[i].labelName.length < 2) {
  146. uni.showToast({
  147. icon:"none",
  148. title: '标签内容2-6个字!',
  149. duration: 2000
  150. });
  151. return
  152. }
  153. this.formData.circleLabel.push(this.labelList[i].labelName)
  154. }
  155. this.formData.circleLabel = this.formData.circleLabel.toString()
  156. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'add', {
  157. circleManagementInfo: JSON.stringify(this.formData)
  158. }, failres => {
  159. uni.showToast({
  160. icon:"none",
  161. title: failres.errmsg,
  162. duration: 3000
  163. });
  164. uni.hideLoading()
  165. }).then(res => {
  166. uni.showToast({
  167. icon:"none",
  168. title: '信息审核中,请留意消息通知!',
  169. duration: 2000
  170. });
  171. })
  172. setTimeout(() => {
  173. uni.navigateBack()
  174. }, 3000)
  175. },
  176. add() {
  177. if (this.labelList.length > 5) {
  178. uni.showToast({
  179. icon:"none",
  180. title: '标签数量2-6个!',
  181. duration: 2000
  182. });
  183. return
  184. }
  185. this.labelList.push({
  186. labelName: '',
  187. })
  188. },
  189. subtract(index) {
  190. if (this.labelList.length < 3) {
  191. uni.showToast({
  192. icon:"none",
  193. title: '标签数量2-6个!',
  194. duration: 2000
  195. });
  196. return
  197. }
  198. this.labelList.splice(index, 1)
  199. },
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .content {
  205. padding: 20rpx;
  206. .title {
  207. font-size: 32rpx;
  208. font-weight: bold;
  209. color: #1A1A1A;
  210. }
  211. }
  212. .submit{
  213. position: fixed;
  214. bottom: 100rpx;
  215. background-color:#112253 ;
  216. color: #fff;
  217. width: calc(100% - 40rpx);
  218. }
  219. .select-card{
  220. background:#fff;padding:20rpx 0 20rpx 20rpx;
  221. margin:10rpx 0;
  222. border-radius: 20rpx;
  223. }
  224. </style>