gx
queenwuli
2021-01-15 4b80c98ef5fda8d6358778f2efe8bb35cb20ccf9
hive-app/pages/member/editMember.vue
@@ -2,6 +2,13 @@
   <view class="container">
      <form @submit="submit" id="list">
         <view class="input-group-row">
            <text class="label">会员头像</text>
            <view class="right-text flex align-center justify-end" @click="showUploadImage">
               <image :src="formData.photo?formData.photo:'../../static/images/default-avatar.png'" class="avatar"></image>
               <text class="iconfont iconarrow-backimg gray"></text>
            </view>
         </view>
         <view class="input-group-row">
            <text class="label">会员姓名<text class="require">*</text></text>
            <input name="vipName" v-model="formData.vipName" type="text" maxlength="20"  placeholder="请填写会员姓名" placeholder-class='placeholder'/>
         </view>
@@ -10,13 +17,17 @@
            <input name="vipNo" v-model="formData.vipNo" type="text" maxlength="10" placeholder="请填写会员编号" placeholder-class='placeholder'/>
         </view>
         <view class="input-group-row">
            <text class="label">资金密码<text class="require">*</text></text>
            <input name="password" v-model="formData.password" type="password" maxlength="6" placeholder="6位数字格式密码" placeholder-class='placeholder'/>
         </view>
         <view class="input-group-row">
            <text class="label">手机号码<text class="require">*</text></text>
            <input name="phone" v-model="formData.phone" type="number" maxlength="11" placeholder="请填写手机号码" placeholder-class='placeholder'/>
         </view>
         <view class="input-group-row">
            <text class="label">性别<text class="require">*</text></text>
            <view class="right-text">
               <radio-group name="sex">
               <radio-group name="sex" @change="sexChange">
                  <label><radio value="男" color="#518EFF"  class="radio" :checked="formData.sex==='男'"/>男</label>
                  <label><radio value="女" color="#518EFF" class="radio" :checked="formData.sex==='女'"/>女</label>
               </radio-group>
@@ -53,32 +64,31 @@
         </view>
         <view class="input-group-row">
            <text class="label">推荐人</text>
            <view class="right-text">
               <picker mode="selector" range-key="vipName" :range="referrerList" @change="referrerChange">
                  <view>
                     <text :class="recommendName?'':'gray'">{{recommendName?recommendName:'请选择推荐人'}}</text>
                     <text class="iconfont iconjiantouarrow486 gray"></text>
                  </view>
               </picker>
            </view>
            <navigator :url="'./selectCustomer?selectId='+formData.recommendId" hover-class="none" class="right-text">
               <text :class="recommendName?'':'gray'">{{recommendName?recommendName:'请选择推荐人'}}</text>
               <text class="iconfont iconarrow-backimg gray"></text>
            </navigator>
         </view>
         <view class="input-group-row">
            <text class="label">备注</text>
            <input name="remark" v-model="formData.remark" maxlength="60" type="text" placeholder="请填写备注" placeholder-class='placeholder'/>
         </view>
         <view class="input-group-row">
         <navigator url="./addLabel" hover-class="none" class="input-group-row">
            <text class="label">标签</text>
            <view class="right-text">
               <!-- <text class="tag">大方<text class="iconfont iconguanbi gray"></text></text> -->
               <text class="tag" v-for="item in formData.labels">{{item.label}}</text>
            </view>
         </navigator>
         <view class="footer">
            <button form-type="submit" :disabled="isDisabled" class="blue-btn ">保存</button>
         </view>
         <button form-type="submit" :disabled="isDisabled" class="blue-btn sticky-footer">保存</button>
      </form>
      <region ref="simpleAddress" @onConfirm="addressChange" themeColor="#518EFF" cancelColor="#8c9fad"></region>
   </view>
</template>
<script>
   import imageUploadUtils from '../../common/jssdk/uploadImg.js'
   import region from '../../components/simple-address/simple-address.vue';
   export default{
      components:{
@@ -97,12 +107,13 @@
               arrivalWay: '',
               recommendId: '',
               remark: '',
               labels: []
               labels: [],
               photo: '',
               password: ''
            },
            id: '',
            isDisabled: false,
            arrivalWayList: [],
            referrerList: [],
            recommendName: ''
         }
      },
@@ -135,11 +146,11 @@
         loadReferrerList(){
            this.$httpUtils.request('/api/vip/findAllVipInfo').then((res) => {
               if(res.status == 200){
                  this.referrerList = res.rows;
                  let result = res.rows;
                  if(this.id){
                     for(var i in this.referrerList){
                        if(this.referrerList[i].id === this.formData.recommendId){
                           this.recommendName = this.referrerList[i].vipName;
                     for(var i in result){
                        if(result[i].id === this.formData.recommendId){
                           this.recommendName = result[i].vipName;
                           break;
                        }
                     }
@@ -162,6 +173,14 @@
                  this.formData.areas = arr.join('-')
               }
            })
         },
         showUploadImage(){
            imageUploadUtils.show((res) => {
               this.formData.photo = res;
            })
         },
         sexChange(e){
            this.formData.sex = e.detail.value;
         },
         dateChange(e){
            this.formData.birthday = e.detail.value;
@@ -188,18 +207,18 @@
         wayChange(e){
            this.formData.arrivalWay = this.arrivalWayList[e.detail.value].value;
         },
         referrerChange(e){
            this.formData.recommendId = this.referrerList[e.detail.value].id;
            this.recommendName = this.referrerList[e.detail.value].vipName;
         },
         valid(){
            const {vipName, vipNo, phone, sex} = this.formData;
            const {vipName, vipNo,password, phone, sex} = this.formData;
            if(!vipName){
               this.$toast.info('请填写会员姓名');
               return false;
            }
            if(!vipNo){
               this.$toast.info('请填写会员编号');
               return false;
            }
            if(!/^\d{6}$/.test(password)){
               this.$toast.info('请填写6位数字格式的密码');
               return false;
            }
            if(!this.$utils.checkPhone(phone)){
@@ -223,6 +242,10 @@
            } else {
               url = '/api/vip/addVip';
            }
            let labels = this.formData.labels.map((item) => {
               return item.label
            });
            this.formData.labels = labels;
            this.$httpUtils.request(url, this.formData, 'POST').then((res) => {
               if(res.status == 200){
                  uni.navigateBack()
@@ -233,6 +256,12 @@
               this.isDisabled = false;
            })
         },
         setData(selectItem){
            selectItem.forEach((item) => {
               this.recommendName = item.vipName;
               this.formData.recommendId = item.id;
            });
         }
      }
   }
</script>
@@ -241,5 +270,17 @@
   .container{
      padding: 10px 10px;
   }
   .avatar{
      width: 44px;
      height: 44px;
      border-radius: 50%;
   }
   .footer{
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: #FFFFFF;
      padding: 0 10px 20px;
   }
</style>