ソースを参照

增加禁止微信浏览器滑动

master
suizhijia 5年前
コミット
cc9e835e91
3個のファイルの変更59行の追加0行の削除
  1. +1
    -0
      src/App.vue
  2. +2
    -0
      src/main.js
  3. +56
    -0
      src/utils/common.js

+ 1
- 0
src/App.vue ファイルの表示

@@ -38,6 +38,7 @@
that.bgLoop = false;
})
this.calculateJumpRules();
this.$stopPullDown();
},
methods: {
playMusic() {

+ 2
- 0
src/main.js ファイルの表示

@@ -4,6 +4,8 @@ import router from './router'
import store from './store'
import rem from './plugins/rem'
Vue.use(rem);
import {stopPullDown } from './utils/common';
Vue.prototype.$stopPullDown = stopPullDown;

Vue.config.productionTip = false


+ 56
- 0
src/utils/common.js ファイルの表示

@@ -0,0 +1,56 @@
import qs from 'qs';
let httpRoot = 'http://news.envisioncn.com/api/web';//接口根路径
// let httpRoot = 'http://www.jiyou-tech.com/2019/404/api/web/';//接口根路径
/*
* http方法
* 参数:{
* url:接口路径
* params:传入的参数
* callback:回调函数
* thisArg:指向接口调用页面(接口调用页面的this)
* type:调用方式(post or get)
* }
*/
function httpFun(url,params,callback, thisArg,uid,type) {
if(!type || type.toUpperCase() == "GET"){
this.axios.get(httpRoot+url,{params,
headers:{
uid:uid || ""
}
}).then((response)=>{
if (callback && thisArg) {
callback.call(thisArg,response.data);
}
}).catch((response)=>{
console.log(response);
})
}else{
this.axios.post(httpRoot+url,qs.stringify(params),{
headers:{
uid:uid || "",
"Content-Type":"application/x-www-form-urlencoded"
}
}).then((response)=>{
if (callback && thisArg) {
callback.call(thisArg,response.data);
}
}).catch((response)=>{
console.log(response);
})
}
}
function stopPullDown (){
let that = this;
let all = document.getElementById("app");
let startSite = 0;
all.addEventListener("touchstart",function () {
startSite=event.touches[0].clientY;
});
all.addEventListener("touchmove",function () {
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
if(scrollTop==0 && event.touches[0].clientY>startSite && !that.$store.state.menuState){
event.preventDefault();
}
},false);
}
export {httpFun,stopPullDown};

読み込み中…
キャンセル
保存