819527061@qq.com
2024-07-30 e52e720168541aa02e0326a505d251f42828aedf
pages/customer-page/addTo-freightForwarder-driver/addTo-freightForwarder-driver.vue
@@ -5,19 +5,22 @@
         <u--form labelPosition="top" ref="form1">
            <u-form-item labelWidth="20%" label="姓名" ref="item1"><u--input v-model="name" :customStyle="{ border: '1px solid #dddddd' }"></u--input></u-form-item>
            <u-form-item labelWidth="25%" label="手机号" ref="item1"><u--input v-model="phone" :customStyle="{ border: '1px solid #dddddd' }"></u--input></u-form-item>
            <u-form-item labelWidth="25%" label="汽车车牌号" ref="item1" v-if="role == 2">
               <u--input v-model="carNo" :customStyle="{ border: '1px solid #dddddd' }"></u--input>
            </u-form-item>
<!--            <u-form-item labelWidth="25%" label="汽车车牌号" ref="item1" v-if="role == 2">
               <u&#45;&#45;input v-model="carNo" :customStyle="{ border: '1px solid #dddddd' }"></u&#45;&#45;input>
            </u-form-item>-->
         </u--form>
      </view>
      <view class="addBtn"><u-button text="邀请" type="primary" @click="addToHuoDaiOrDriver"></u-button></view>
      <view class="addBtn">
      <u-button text="邀请" :loading="yaoqingLoading" type="primary" @click="addToHuoDaiOrDriver"></u-button>
    </view>
   </view>
</template>
<script>
import { customerId } from '@/utils/status.js';
import { mapMutations } from 'vuex';
export default {
   onLoad(params) {
   onLoad(params) {
      this.role = params.role;
      if (params.fleetId) {
         this.fleetId = params.fleetId;
@@ -30,10 +33,12 @@
         name: '',
         phone: '',
         carNo: '',
         customerId
         customerId,
      yaoqingLoading: false,  //邀请loading
      };
   },
   methods: {
      ...mapMutations(['lengthchange']),
      init() {},
      addToHuoDaiOrDriver() {
         switch (this.role) {
@@ -49,7 +54,7 @@
               }
               break;
            case '2':
               if (this.name == '' || this.phone == '' || this.carNo == '') {
               if (this.name == '' || this.phone == '') {
                  uni.showToast({
                     title: '请规范输入!',
                     icon: 'error',
@@ -64,9 +69,11 @@
      },
      // 邀请货代
      bindHuoDai() {
      this.yaoqingLoading = true
         // this.$reqPost('bindHuoDai', { customerId: this.customerId, name: this.name, phone: this.phone }, 'params').then(res => {
         this.$reqPost('bindHuoDai', { name: this.name, phone: this.phone }, 'params').then(res => {
            if (res.code == 0) {
          this.yaoqingLoading = false
               this.$u.toast('添加成功');
               setTimeout(() => {
                  uni.navigateBack({
@@ -76,26 +83,38 @@
            } else {
               this.$u.toast(res.msg ? res.msg : '未成功添加');
            }
            console.log('邀请货代', res);
         });
         }).catch(() => {
        this.yaoqingLoading = false
      }).finally(() => {
        this.yaoqingLoading = false
      });
      },
      // 邀请司机
      bindUserFleet() {
      this.yaoqingLoading = true
         this.$reqPost('bindUserFleet', { fleetId: this.fleetId, name: this.name, phone: this.phone, carNo: this.carNo }, 'params').then(res => {
            console.log('邀请司机', res);
            if (res.code == 0) {
               this.$u.toast(res.data ? res.data : '操作成功');
          this.yaoqingLoading = false
               this.$u.toast(res.msg ? res.msg : '操作成功');
               this.$reqGet('GetUserFleet', { fleetId: this.fleetId }).then(response => {
                  this.lengthchange(response.data.length);
               });
               uni.navigateBack({
                  delta: 1
               });
            } else {
               uni.showToast({
                  title: res.msg,
                  title: res.msg ? res.msg : '操作失败',
                  icon: 'null',
                  duration: 2000
               });
            }
         });
         }).catch(() => {
        this.yaoqingLoading = false
      }).finally(() => {
        this.yaoqingLoading = false
      });
      }
   }
};