| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <template>
- <up-modal :show="showModal" title="完工验证" @cancel="showModal = false" @confirm="completion" ref="uModal"
- confirmText="确认完工" showCancelButton :asyncClose="true">
- <view class="slot-content">
- <view style="padding: 20rpx 0 20rpx 0;">
- <up-code-input v-model="code" :maxlength="6" />
- </view>
- </view>
- </up-modal>
- </template>
- <script setup>
- import { getCurrentInstance, ref, defineProps, defineEmits } from 'vue';
- const emit = defineEmits(['callBack'])
- const { $Http } = getCurrentInstance().proxy;
- const props = defineProps({
- sa_workorderid: {
- type: [Number, String],
- },
- callBack: {
- type: Function
- }
- });
- let code = ref(''),
- showModal = ref(false),
- interval = null,
- uModal = ref(null);
- function completion(e) {
- if (code.value.trim() == '') {
- uModal.value.loading = false;
- return uni.showToast({
- title: '请输入客户确认码',
- icon: 'none'
- });
- }
- $Http.basic({
- "id": "20230215173203",
- "content": {
- "sa_workorderid": props.sa_workorderid,
- "code": code.value
- }
- }).then(res1 => {
- console.log("校验验证码", res1)
- if (res1.code == 1) {
- $Http.basic({
- "id": "20230209144903",
- "content": { "sa_workorderid": props.sa_workorderid }
- }).then(res => {
- console.log("完结工单", res)
- if (res.code == 1) {
- uni.showToast({
- title: '工单成功完结',
- icon: 'none'
- });
- setTimeout(() => {
- showModal.value = false;
- code.value = '';
- clearInterval(interval);
- }, 300)
- emit('callBack', true)
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- uModal.value.loading = false;
- }
- })
- } else {
- uni.showToast({
- title: res1.msg,
- icon: 'none'
- });
- uModal.value.loading = false;
- }
- })
- }
- function openModal() {
- getCode()
- showModal.value = true;
- }
- // 获取客户确认码
- function getCode() {
- return new Promise((resolve) => {
- $Http.basic({
- id: 20230215173103,
- "content": {
- "sa_workorderid": props.sa_workorderid
- }
- }).then(res => {
- console.log("获取验证码结果", res)
- resolve(res.code == 1);
- if (res.code == 1 && res.data.msg.includes("手机验证码为")) {
- uni.showToast({
- title: '客户确认码已发送至客户手机',
- icon: 'none'
- });
- code.value = res.data.msg.split(":")[1].trim();
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- })
- })
- }
- // 将内部方法暴露给模板使用
- defineExpose({
- openModal
- });
- </script>
|