index.vue 3.37 KB
<template>
  <view class="wrap">
    <u-radio-group v-model="userType" placement="row" @change="groupChange">
      <view class="choose-type" v-for="(item, index) in typeList">
        <u-radio size="28" labelSize="28" :key="index" :label="item.name" :name="item.name" @change="radioChange">
        </u-radio>
      </view>
    </u-radio-group>
    <!-- 角色信息匹配 -->
    <view class="rule-label-info-box">
      <view class="manager-info" v-if="userType === '居民用户'">
        <view class="manager-info-parent-company-name">
          派单前请输先完善地址信息~
        </view>
      </view>
      <view class="manager-info" v-if="userType === '运输驾驶员'">
        <view class="manager-info-parent-company-name">
          长沙有限运输运输公司-运输驾驶员-李伟
        </view>
        <view class="manager-info-parent-company-name">
          未匹配到该手机号绑定的运输公司!
        </view>
      </view>
      <view class="manager-info" v-if="userType === '企业负责人'">
        <view class="manager-info-parent-company-name">
          长沙有限运输运输公司公司服务账号!
        </view>
        <view class="manager-info-parent-company-name">
          未匹配到该手机号绑定运输公司公司服务账号!
        </view>
      </view>
    </view>
    <view class="choose-button">
      <u-button shape="circle" color="#a9e08f" @click="submit(userType)">确定</u-button>
    </view>
  </view>
</template>

<script setup>
import { updateUserInfo } from "@/apis/user.js";
import { useMainStore } from '@/stores/index.js';
import { setRequestToken } from '@/utils/request/request.js';
import { onLoad } from "@dcloudio/uni-app";
import { ref } from 'vue';
const store = useMainStore();
const userType = ref("居民用户")
const typeList = ref([{ name: "居民用户" }, { name: "运输驾驶员" }, { name: "企业负责人" }])
const unitInfo = ref({})
const radioChange = (e) => {
}
const groupChange = (e) => {
}

const submit = (userType) => {
  setRequestToken(store.tempToken)
  updateUserInfo({ garUserType: userType }).then(res => {
    store.token = store.tempToken
    store.tempToken = "";
    if (res.data.success) {
      store.userType = userType;
      unitInfo.value.userType = userType
      store.userInfo = unitInfo.value
      uni.$u.route({
        type: "switchTab",
        url: `pages/home/index`,
      })
    }
  })

}
onLoad((options) => {
  unitInfo.value = options
  userType.value = options.userType
  // submit(options.userType)
})
</script>

<style lang="scss" scoped>
.wrap {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 20rpx;
  background-color: $u-info-light;

  .choose-type {
    // width: 100%;
    box-sizing: border-box;
    padding: 20rpx;
    background-color: #ffffff;
    border-radius: 20rpx;
    margin-right: 20rpx;
    display: flex;
    align-items: center;
    justify-content: center;

    &:last-child {
      margin-right: 20rpx;
    }


  }

  .rule-label-info-box {
    box-sizing: border-box;
    margin-top: 20rpx;

    .manager-info {
      font-size: 25rpx;
      color: $u-main-color;
      box-sizing: border-box;

      .manager-info-parent-company-name {
        color: $u-info;
      }
    }
  }


  .choose-button {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>