123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <view class="oderPage">
- <u-form :model="form" ref="myForm" :error-type="errorType">
- <view class="from">
- <u-form-item v-if="(form.type==='2'||form.type==='3')" prop="equipmentState">
- <view class="from_item">
- <text><text style="color: red">*</text>是否有设备注销::</text>
- <u-radio-group v-model="form.equipmentState">
- <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
- v-for="(item, index) in radiolist" :key="index" :label="item.disabled" :name="item.name"
- @change="radioChange(item)">
- {{ item.name }}
- </u-radio>
- </u-radio-group>
- </view>
- </u-form-item>
- <u-form-item prop="phone">
- <view class="from_item" style="background-color: #f7f7f7">
- <text><text style="color: red"></text>手机号:</text>
- <u-input v-model="form.mobile" class="input" />
- </view>
- </u-form-item>
- <u-form-item prop="code">
- <view class="from_item">
- <text><text style="color: red"></text>验证码:</text>
- <u-input v-model="form.code" placeholder="请输入验证码" class="input" />
- <view class="hint2">
- <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
- <view class="grey" @click="getCode">{{
- codeDuration === 0 ? "发送验证码" : "秒后可重发"
- }}</view>
- </view>
- </view>
- </u-form-item>
- </view>
- </u-form>
-
- <button class="submit" @click="toPage()">下一步</button>
- </view>
- </template>
-
- <script setup lang="ts">
- import navBar from "./components/nav-bar.vue";
- import {
- checkStr
- } from "@/utils/utils";
- import {
- ref,
- reactive
- } from "vue";
- import {
- navTo
- } from "../../utils/utils";
- import {
- onReady,
- onLoad
- } from "@dcloudio/uni-app";
- import {
- request
- } from "../../utils/network/request.js";
- import {
- sendCode,
- checkCode
- } from "@/utils/network/api.js";
- import {
- msg
- } from "@/utils/utils";
- // 表单数据
- const form = reactive({
- equipmentState: "",
- mobile: "",
- code: '',
- type: undefined,
- });
- //入参
- const params = reactive({
- cardId: '',
- obuId: '',
- orderId: ''
-
- });
- // 验证规则
- const rules = {
- code: [{
- required: true,
- message: "请输入验证码",
- trigger: ["change", "blur"],
- }],
- };
- // 验证提示类型(toast要版本为1.3.5才支持)
- const errorType = ["toast"];
-
- // 单选数据列表
- const radiolist = reactive([{
- name: "是",
- disabled: false,
- },
- {
- name: "否",
- disabled: false,
- },
- ]);
- // 设置验证规则
- const myForm = ref(null);
- //倒计时时常
- const codeDuration = ref(0);
- let interval = null;
-
- /* 验证码倒计时 */
- const codeInterval = () => {
- codeDuration.value = 60;
- interval = setInterval(() => {
- codeDuration.value--;
- if (codeDuration.value === 0) {
- if (interval) {
- clearInterval(interval);
- interval = null;
- }
- }
- }, 1000);
- };
-
- onReady(() => {
- myForm.value.setRules(rules);
- });
-
- onLoad((option) => {
- form.mobile = option.mobile
- form.type = option.type
- params.cardId = option.cardId
- params.obuId = option.obuId
- });
-
- const getCode = () => {
- if (codeDuration.value !== 0) {
- return;
- }
- const options = {
- type: 2,
- data: {
- mobile: form.mobile
- },
- method: "POST",
- showLoading: true,
- };
- request(sendCode, options)
- .then((res) => {
- codeInterval();
- msg("验证码发送成功!");
- })
- .catch((err) => {
- console.log(err);
- });
- }
-
-
- // 单选
- const radioChange = (val: any) => {
- if (val.name === '是') {
- form.equipmentState = '1';
- } else {
- form.equipmentState = '2';
- }
- };
- //下一步
- const toPage = () => {
- myForm.value.validate((valid) => {
- console.log(valid);
- if (valid) {
- const options = {
- type: 2,
- data: {
- mobile: form.mobile,
- code: form.code
- },
- method: "POST",
- showLoading: true,
- };
- request(checkCode, options)
- .then(() => {
- navTo(
- `/after-sale/ETC-log-off/upload-card?obuId=${params.obuId}&&cardId=${params.cardId}&&orderId=${params.orderId}&&equipmentState=${form.equipmentState}`
- );
- })
- .catch((err) => {
- console.log(err);
- });
- } else {
- console.log("验证未通过");
- }
- });
- };
- </script>
-
- <style>
- page {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- background-color: ##eef7f7;
- }
- </style>
- <style lang="scss" scoped>
- .hint2 {
- display: flex;
-
- .green {
- font-size: 28rpx;
- color: #00b38b;
- }
-
- .grey {
- font-size: 24rpx;
- color: #000000;
- margin-left: 16rpx;
- }
- }
-
- .oderPage {
- flex: 1;
- width: 100%;
-
- .from1 {
- background-color: #fff;
- margin-top: 30rpx;
- padding: 0 30rpx;
-
- ::v-deep .uni-forms-item {
- border-bottom: 1rpx solid #ccc;
- padding: 15rpx 0;
- margin-bottom: 0;
-
- .uni-forms-item__label {
- font-size: 28rpx;
- height: 50rpx;
- }
-
- .uni-forms-item__content {
- display: flex;
- }
-
- .uni-easyinput__content-input {
- font-size: 28rpx;
- height: 50rpx;
- }
- }
-
- .btn {
- line-height: 38rpx;
- font-size: 24rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- background: #00b38b;
- border-radius: 10rpx;
- padding: 10rpx 15rpx;
- }
- }
-
- .from {
- background-color: #fff;
- margin-top: 30rpx;
- padding: 0 30rpx;
-
- ::v-deep .u-form-item {
- padding: 0;
- line-height: normal;
-
- .u-form-item__message {
- margin-bottom: 12rpx;
- }
- }
-
- .from_item {
- display: flex;
- flex-wrap: nowrap;
- justify-content: space-between;
- align-items: center;
- height: 80rpx;
- border-bottom: 1rpx solid #dcdcdc;
-
- .btn {
- font-size: 24rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- background: #00b38b;
- border-radius: 10rpx;
- padding: 10rpx 15rpx;
- }
-
- ::v-deep .input {
- text-align: left;
- flex: 1;
-
- input {
- text-align: left;
- }
- }
- }
-
- .from_item1 {
- display: flex;
- flex-wrap: nowrap;
- flex-direction: column;
- justify-content: space-between;
- padding: 30rpx;
- border-bottom: #dcdcdc 1px solid;
-
- input {
- text-align: right;
- }
-
- .textarea {
- background-color: #f1f1f1;
- width: 100%;
- border-radius: 20rpx;
- margin-top: 10rpx;
- text-indent: 1rem;
- height: 180rpx;
- padding: 20rpx;
- box-sizing: border-box;
- }
- }
- }
- }
-
- .submit {
- background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
- width: 670rpx;
- height: 80rpx;
- color: #fff;
- border-radius: 100rpx;
- position: fixed;
- left: 50%;
- transform: translate(-50%);
- bottom: 60rpx;
- font-size: 32rpx;
- }
- </style>
|