董国庆
2025-02-24 cc372b16570e00a52a882dae3e7686d9db61b2b8
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/H5/threeSide
5个文件已修改
4个文件已添加
250 ■■■■■ 已修改文件
H5/config/index.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/index.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/main.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/components/certificate/certificate.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/index/index.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/index/service.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/location/location.vue 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/store/index.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/utils/request.js 175 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/config/index.js
New file
@@ -0,0 +1,3 @@
export default {
    BASE_URL: 'http://192.168.110.188:6194',
}
H5/index.html
@@ -9,6 +9,7 @@
        '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
        (coverSupport ? ', viewport-fit=cover' : '') + '" />')
    </script>
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=W3x8DhCWKc2UFIwYgclpRBdL6BeGLLQt"></script>
    <title></title>
    <!--preload-links-->
    <!--app-context-->
H5/main.js
@@ -2,23 +2,27 @@
// #ifndef VUE3
import Vue from 'vue'
import store from '@/store/index.js'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
Vue.prototype.$store = store
import uView from '@/uni_modules/uview-ui'
App.mpType = 'app'
const app = new Vue({
  ...App
    ...App
})
app.$mount()
// #endif
Vue.use(uView)
// #ifdef VUE3
import { createSSRApp } from 'vue'
import {
    createSSRApp
} from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
    const app = createSSRApp(App)
    return {
        app
    }
}
// #endif
H5/pages/components/certificate/certificate.vue
@@ -52,7 +52,7 @@
            },
            onclose() {
                this.show = false
                this.$emit('onCancel',false)
            },
        },
        created() {},
H5/pages/index/index.vue
@@ -95,12 +95,15 @@
            </view>
        </view>
        <popupCertificate :show="isClick"></popupCertificate>
        <popupCertificate :show="isClick" @onCancel="isClick=false"></popupCertificate>
    </view>
</template>
<script>
    import popupCertificate from '../components/certificate/certificate.vue'
    import {
        getBanner
    } from './service.js'
    export default {
        components: {
            popupCertificate
@@ -114,15 +117,20 @@
            }
        },
        onLoad() {
this.getBanner()
        },
        methods: {
            getBanner(){
                getBanner().then(resp=>{
                    console.log(resp,'获取banner');
                })
            },
            change() {
                console.log('1111');
            },
            onClick() {
                this.isClick = !this.isClick
                this.isClick = true
                console.log('this.isClick', this.isClick);
            },
            goTopage() {
H5/pages/index/service.js
New file
@@ -0,0 +1,5 @@
import request from '@/utils/request.js'
export const getBanner =(params)=>{
    return request.get(`/api/huacheng-sangeshenbian/applet/home/banner-list`,params)
}
H5/pages/location/location.vue
@@ -5,7 +5,7 @@
                <image src="/static/location/back.png" class="w-19 h-35" mode=""></image>
            </view>
        </u-navbar>
        <map id="map" longitude="113.324520" latitude="23.099994" scale="14"></map>
        <div id="baidu-map"></div>
        <view class="">
            <view class="searchMain mb-35">
@@ -18,12 +18,12 @@
                        确定
                    </view>
                </view>
            </view>
            <view class="card" :class="" v-for="item in 5">
                <text>天府新谷九号楼二单元</text>
                <text class="font-w500 fs-23 mt-25" style="color: rgba(0, 0, 0, 0.6);">四川省成都市高新区府城大道西段399号天</text>
            </view>
        </view>
@@ -37,12 +37,27 @@
                latitude: 39.909,
                longitude: 116.39742,
            };
        },
        mounted() {
            this.initMap();
        },
        methods: {
            initMap() {
                // 创建地图实例
                const map = new BMapGL.Map('baidu-map');
                // 设置中心点坐标
                const point = new BMapGL.Point(116.404, 39.915);
                // 初始化地图,设置中心点和缩放级别
                map.centerAndZoom(point, 15);
                // 开启鼠标滚轮缩放
                map.enableScrollWheelZoom(true);
            }
        }
    }
</script>
<style lang="scss" scoped>
    map {
    #baidu-map {
        width: 100vw;
        height: 517rpx;
    }
H5/store/index.js
New file
@@ -0,0 +1,11 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {},
    mutations: {},
    actions: {}
})
export default store
H5/utils/request.js
New file
@@ -0,0 +1,175 @@
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const FORM = 'FORM';
const DELETE = 'DELETE';
import config from '@/config/index.js'
const baseURL = config.BASE_URL;
const waitingList = [] //等待队列
const excutingList = [] //执行队列
let showLogoutModal = true //是否显示冻结弹窗
function request(method, url, data, type, lodingFlag) {
    if (lodingFlag) {
        uni.showLoading({
            mask: true,
        })
    }
    return new Promise(function(resolve, reject) {
        let token = uni.getStorageSync('token')
        let header = {
            'content-type': type ? 'application/x-www-form-urlencoded;charset=UTF-8' : 'application/json',
            'Authorization': token,
            'lang': uni.getStorageSync('locale') === 'zh-Hans' ? 'zh_CN' : 'zh-tw',
        }
        const requestTask = uni.request({
            url: baseURL + url,
            method: method,
            data: data,
            header: header,
            success: (res) => {
                //判断状态码
                if (lodingFlag) {
                    uni.hideLoading()
                }
                if (res.data.code == 200) {
                    resolve(res.data);
                    return
                }
                if (res.data.code == 502) {
                    resolve(res.data);
                    uni.showToast({
                        title: res.data.msg,
                        duration: 2000,
                        icon: 'none',
                        mask: true,
                    })
                    return
                }
                if (res.data.code == 500 && url.includes('/applet/user/check')) {
                    resolve(res.data);
                    return
                }
                if (res.data.code == 1 || res.data.code == 500) {
                    uni.showToast({
                        title: res.data.msg || res.data.data || '服务器错误',
                        duration: 2000,
                        icon: 'none',
                        mask: true,
                    })
                    return
                }
                if (res.data.code == 401 || res.data.code == 510 || res.data.code == 504 || res.data
                    .code == 505) {
                    uni.removeStorageSync('token')
                    if (res.data.code == 504) {
                        uni.showToast({
                            title: res.data.msg,
                            duration: 2000,
                            icon: 'none',
                            mask: true,
                        })
                    } else if (res.data.code == 505) {
                        handleLogout('当前登录账号在其他设备登录')
                    } else {
                        handleLogout('登录失效,请重新登录')
                    }
                    return
                }
                if (res.data.code == 501) {
                    uni.showToast({
                        title: res.data.msg,
                        duration: 2000,
                        icon: 'none',
                        mask: true,
                    })
                    return
                }
                if (res.data.code == 506) {
                    resolve(res.data);
                    return
                }
                uni.showToast({
                    title: res.data.msg || '服务器错误',
                    duration: 2000,
                    icon: 'none',
                    mask: true,
                })
            },
            fail(err) {
                if (lodingFlag) {
                    uni.hideLoading()
                }
                reject(err)
            },
            complete: () => {
                const excutingIndex = excutingList.findIndex(item => item === requestTask)
                excutingList.splice(excutingIndex, 1)
                const [apiFn] = waitingList
                if (excutingList.length === 0 && typeof apiFn === 'function') {
                    apiFn()
                    waitingList.splice(0, 1)
                }
            },
        })
        excutingList.push(requestTask)
    })
}
// 被冻结跳转到登录页并取消后续请求
function handleLogout(str) {
    let routeStr = getCurrentPages()[getCurrentPages().length - 1].route
    if (excutingList.length >= 1) {
        showLogoutModal = true
    }
    if (showLogoutModal) {
        showLogoutModal = false
        uni.showModal({
            title: '提示',
            content: str,
            showCancel: false,
            success: function(res) {
                if (res.confirm) {
                    if (routeStr == 'pages/login/index') {
                        uni.reLaunch({
                            url: '/pages/login/index'
                        })
                        return
                    }
                    uni.reLaunch({
                        url: '/pages/login/index'
                    })
                }
            }
        });
        clearAllRequest()
    }
}
// 清除请求队列
function clearAllRequest() {
    if (excutingList.length > 0) {
        for (var i = 0; i < excutingList.length; i++) {
            const item = excutingList[i]
            if (item && item.abort) {
                item.abort()
            }
        }
        excutingList.length = 0
        waitingList.length = 0
    }
}
export default {
    get: (url, data, type = false, lodingFlag = true) => request(GET, url, data, type, lodingFlag),
    post: (url, data, type = false, lodingFlag = true) => request(POST, url, data, type, lodingFlag),
    put: (url, data, type = false, lodingFlag = true) => request(PUT, url, data, type, lodingFlag),
    FORM: (url, data, type = false, lodingFlag = true) => request(FORM, url, data, type, lodingFlag),
    delete: (url, data, type = false, lodingFlag = true) => request(DELETE, url, data, type, lodingFlag),
}