api
liukangdong
2024-05-07 1e756198bc1568ca74858f0a6b81bba1950f80a4
api
已添加2个文件
已修改2个文件
83 ■■■■ 文件已修改
h5/pages/visitorApplication/visitorApplication.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/utils/config.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/utils/http.api.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/utils/service.js 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/pages/visitorApplication/visitorApplication.vue
@@ -108,7 +108,6 @@
            v-if="form1.starttime"
            :show="show5"
            :minDate="formatTimeStamp(form1.starttime)"
            :maxDate="formatTimeStamp(maxTime)"
            mode="datetime"
            @cancel="show5 = false"
            @confirm="setoutDate"
@@ -309,7 +308,9 @@
                show6: false,
                show7: false,
                fileList: [],
                columns1: [[{name: '身份证', id: 0}, {name: '港澳证件', id: 1},{name: '护照', id: 2}]],
                columns1: [
                    [{name: '身份证', id: 0}, {name: '港澳证件', id: 1},{name: '护照', id: 2}],
                ],
                columns: [],
                cars: [],
                day: null,
@@ -351,9 +352,9 @@
            if (options.data) {
                this.form = JSON.parse(options.data)
            }
            this.getvisit()
            this.getVisit1()
            this.getUserValid()
            // this.getvisit()
            // this.getVisit1()
            // this.getUserValid()
        },
        methods: {
            openInput(type) {
@@ -563,6 +564,7 @@
            seleIdcard(e) {
                this.withUserList.idcardType = e.value[0].id
                this.withUserList.idcardTypeName = e.value[0].name
                console.log(e);
                this.show6 = false
            },
            submitCart() {
@@ -612,7 +614,9 @@
            },
            setinDate(e) {
                this.form1.starttime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
                this.maxTime = getDaysAfterDate(uni.$u.timeFormat(e.value, 'yyyy-mm-dd'), this.day)
                // this.maxTime = getDaysAfterDate(uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM'), this.day)
                this.maxTime = this.form1.starttime
                console.log(this.form1.starttime);
                this.show4 = false
            },
            setoutDate(e) {
h5/utils/config.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,3 @@
export const baseUrl = 'api/'
export const uploadUrl = `${baseUrl}visitsAdmin/cloudService/web/public/uploadFtp.do`
h5/utils/http.api.js
@@ -1,5 +1,4 @@
export const baseUrl = 'api/'
export const uploadUrl = `${baseUrl}visitsAdmin/cloudService/web/public/uploadFtp.do`
import {baseUrl, uploadUrl} from './config'
const install = (Vue, vm) => {
    
@@ -8,7 +7,6 @@
            config.timeout = 60000;
        return config;
    })
    Vue.prototype.$baseUrl = baseUrl;
    Vue.prototype.$uploadUrl = uploadUrl;
    
h5/utils/service.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
import { baseUrl } from "./config.js"
export const http = function (options) {
    {
        return new Promise((resolve, reject) => {
            let token = uni.getStorageSync('token')
            // åœ¨ç™»å½•的时候需要储存 token uni.setStorageSync("authorization","这里是登录获取的token值")
            // uni.showLoading({
            //     title:"加载中..."
            // })
            uni.showLoading({
                title: '加载中',
                mask: true
            })
            uni.request({
                url: baseUrl + options.url,
                data: options.data || {},
                method: options.method || 'GET',
                header: options.header || {
                    // æ ¹æ®å®žé™…接口设计 key å– token æˆ–者 authorization
                    token: token,
                    "content-type": 'application/json'
                },
                success: (res) => {
                    let data = res.data
                    // æŽ§åˆ¶å°æ˜¾ç¤ºæ•°æ®ä¿¡æ¯
                    uni.hideLoading()
                    // ç™»å½•过期
                    if (data.code === 401) {
                        uni.navigateTo({
                            url: '/packageA/loginAgain/loginAgain'
                        })
                    }
                    if (data.code !== 200) {
                        uni.showToast({
                            title: response.data.message,
                            icon: "none",
                            duration: 2000
                        })
                    }
                    resolve(data)
                    // return response.data
                },
                fail: (err) => {
                    // é¡µé¢ä¸­å¼¹æ¡†æ˜¾ç¤ºå¤±è´¥
                    uni.showToast({
                        title: '请求接口失败'
                    })
                    // è¿”回错误消息
                    reject(err)
                    uni.hideLoading()
                    return Promise.reject(err)
                },
                catch: (e) => {
                    console.log(e)
                }
            })
        })
    }
}