123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <view class="content">
- <view class="row1">
- <view class="title">
- 圈子名称
- </view>
- <u--input placeholder="请输入圈子名称" border="none" v-model="formData.circleName" @change="change"
- :customStyle="custom"></u--input>
- </view>
- <view class="row1">
-
- <view class="flex flex-between" style="margin-top: 20rpx;">
- <view class="title">圈子标签</view>
- <uni-icons type="plus-filled" @click="add(item)" size="40" color="#112253"></uni-icons>
- </view>
- <view class="">
- <view v-for="(item,index) in labelList":key="index">
- <view class="flex">
- <u-input placeholder="请输入圈子标签,2-4个字" border="none" v-model="item.labelName" @change="change"
- :customStyle="custom">
- <template slot="suffix">
- <image src="../../static/imgs/mySet/del.png" mode="widthFix" style="width: 40rpx;" @click="subtract(index)"></image>
- </template>
- </u-input>
- <!-- <uni-icons type="minus-filled" @click="subtract(index)" size="40"></uni-icons> -->
- </view>
- </view>
- </view>
- </view>
- <view class="">
- <button type="default" @click="submit" class="submit">提交</button>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- var that;
- export default {
- data() {
- return {
- custom: {
- "margin-top":"20rpx",
- "background": "#fff",
- "border-radius": "20rpx",
- "padding":"20rpx"
- },
- value: '',
- labelList: [{
- labelName: ''
- },
- {
- labelName: ''
- }
- ],
- formData: {
- circleName: '',
- circleLabel: [],
- commonId: ''
- }
- };
- },
- onLoad() {
- that = this
- this.userInfo = uni.getStorageSync("userInfo")
- this.formData.commonId = this.userInfo.id
- },
- methods: {
- change(e) {
- console.log('change', e);
- },
- submit() {
- this.formData.circleLabel = []
- if (!this.formData.circleName) {
- this.$refs.uToast.show({
- type: 'error',
- message: '圈子名称不能为空!',
- })
- return
- }
- for (let i = 0; i < this.labelList.length; i++) {
- if (!this.labelList[i].labelName) {
- this.$refs.uToast.show({
- type: 'error',
- message: '标签内容不能为空!',
- })
- return
- }
- if (this.labelList[i].labelName.length > 4 || this.labelList[i].labelName.length < 2) {
- this.$refs.uToast.show({
- type: 'error',
- message: '标签内容2-4个字!',
- })
- return
- }
- this.formData.circleLabel.push(this.labelList[i].labelName)
- }
- this.formData.circleLabel = this.formData.circleLabel.toString()
- this.$request.baseRequest('admin.unimall.circleManagementInfo', 'add', {
- circleManagementInfo: JSON.stringify(this.formData)
- }, failres => {
- this.$refs.uToast.show({
- type: 'error',
- message: failres.errmsg,
- })
- uni.hideLoading()
- }).then(res => {
- this.$refs.uToast.show({
- type: 'success',
- message: '提交成功!',
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 500)
- })
- },
- add() {
- if (this.labelList.length > 3) {
- this.$refs.uToast.show({
- type: 'error',
- message: '“标签数量2-4个!',
- })
- return
- }
- this.labelList.push({
- labelName: ''
- })
- },
- subtract(index) {
- if (this.labelList.length < 3) {
- this.$refs.uToast.show({
- type: 'error',
- message: '“标签数量2-4个!',
- })
- return
- }
- this.labelList.splice(index, 1)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- padding: 20rpx;
- .title {
- font-size: 32rpx;
- font-weight: bold;
- color: #1A1A1A;
- }
- }
- .submit{
- position: fixed;
- bottom: 100rpx;
- background-color:#112253 ;
- color: #fff;
- width: calc(100% - 40rpx);
- }
- </style>
|