wk
2024-05-29 4746960c1714ecc8c4204a956d904f1c58a3e5e3
pages/customer-page/addTo-freightForwarder-driver/addTo-freightForwarder-driver.vue
@@ -21,15 +21,19 @@
            </u-form-item>
         </u--form>
      </view>
      <view class="else-invite"
         @click="elseInvite">
         +从其他车队选择
      </view>
      <view class="addBtn"><u-button text="邀请"
            type="primary"
            @click="addToHuoDaiOrDriver"></u-button></view>
            @click="addToHuoDaiOrDriver"
            :loading="loading"></u-button></view>
   </view>
</template>
<script>
   import { customerId } from '@/utils/status.js';
   import { mapMutations } from 'vuex';
   export default {
      onLoad(params) {
         this.role = params.role;
@@ -44,11 +48,11 @@
            name: '',
            phone: '',
            carNo: '',
            customerId
            customerId,
            loading: false
         };
      },
      methods: {
         ...mapMutations(['lengthchange']),
         init() {},
         addToHuoDaiOrDriver() {
            switch (this.role) {
@@ -79,40 +83,60 @@
         },
         // 邀请货代
         bindHuoDai() {
            // this.$reqPost('bindHuoDai', { customerId: this.customerId, name: this.name, phone: this.phone }, 'params').then(res => {
            this.loading = true
            this.$reqPost('bindHuoDai', { name: this.name, phone: this.phone }, 'params').then(res => {
               this.loading = false
               if (res.code == 0) {
                  this.$u.toast('添加成功');
                  setTimeout(() => {
                     uni.navigateBack({
                        delta: 1
                     });
                     uni.navigateBack()
                     uni.$emit('needRefresh')
                     // uni.switchTab({
                     //    url: '/pages/tabbar-page/myPage-tabbar/myPage-tabbar'
                     // });
                  }, 1000);
               } else {
                  this.$u.toast(res.msg ? res.msg : '未成功添加');
               }
            });
            }).catch(e => {
               this.loading = false
            })
         },
         // 邀请司机
         bindUserFleet() {
            this.$reqPost('bindUserFleet', { fleetId: this.fleetId, name: this.name, phone: this.phone, carNo: this
                  .carNo }, 'params').then(res => {
            this.loading = true
            this.$reqPost('bindUserFleet', {
               fleetId: this.fleetId,
               name: this.name,
               phone: this.phone,
               carNo: this
                  .carNo
            }, 'params').then(res => {
               console.log('邀请司机', res);
               this.loading = false
               if (res.code == 0) {
                  this.$u.toast(res.msg ? res.msg : '操作成功');
                  this.$reqGet('GetUserFleet', { fleetId: this.fleetId }).then(response => {
                     this.lengthchange(response.data.length);
                  });
                  uni.navigateBack({
                     delta: 1
                  });
                  setTimeout(() => {
                     uni.navigateBack()
                     uni.$emit('needRefresh')
                     // uni.switchTab({
                     //    url: '/pages/tabbar-page/myPage-tabbar/myPage-tabbar'
                     // });
                  }, 1000)
               } else {
                  uni.showToast({
                     title: res.msg ? res.msg : '操作失败',
                     duration: 2000
                  });
               }
            });
            }).catch(e => {
               this.loading = false
            })
         },
         elseInvite() {
            uni.navigateTo({
               url: `/pages/public-page/selectFleet/selectFleet?fleetId=${this.fleetId}`
            })
         }
      }
   };
@@ -128,6 +152,13 @@
         margin: 0 auto;
      }
      .else-invite {
         width: vww(150);
         margin: 0 auto;
         color: #3c9cff;
         margin-top: vww(40);
      }
      .addBtn {
         width: 90%;
         position: fixed;