zhengshuiqi 3 years ago
parent
commit
cd8424f7b9
  1. 86
      App.vue
  2. 30
      common/lib.js
  3. 36
      ios/index.js
  4. 6
      main.js
  5. 2
      pages/category/index.vue
  6. 2
      pages/category/productList.vue
  7. 8
      pages/index/index.vue
  8. 3
      pages/productDetails/index.vue
  9. 3
      pages/shippingCart/index.vue
  10. 5
      store/store.js

86
App.vue

@ -1,61 +1,22 @@
<script> <script>
import {defaultRequest,defaultRequest4} from 'api/index.js' import {
defaultRequest,
defaultRequest4
} from 'api/index.js'
var jpushModule = uni.requireNativePlugin("JG-JPush"); var jpushModule = uni.requireNativePlugin("JG-JPush");
export default { export default {
data() { data() {
return { return {
globalData:{
},
backButtonPress: 0, backButtonPress: 0,
} }
}, },
onLaunch: function() { onLaunch: function() {
let channel=plus.runtime.channel || '';
let channelName='';
let isInstall=0;
let firstTime=uni.getStorageSync('firstTime') || '';
if(!firstTime){
isInstall=1;
uni.setStorageSync('firstTime','1');
}
addAppCount({channel:channel,is_install:isInstall});
// uni.getNetworkType({
// success: function(res) {
// console.log(res.networkType);
// // wifi2g3g4gethernetunknownnone
// setTimeout(function() {
// if (res.networkType === "none") {
// console.log("", that.typee);
// uni.showToast({
// title: ',........',
// duration: 20000
// });
// } else {
// console.log("", that.typee);
// uni.showToast({
// title: ',........',
// duration: 2000
// });
// }
// }, 1)
// }
// });
// console.log('App Launch')
uni.hideTabBar() uni.hideTabBar()
// uni.onTabBarMidButtonTap(()=>{
// console.log("")
// //
// //
// uni.navigateTo({
// url:"../index/index2",
// animationType:'slide-in-bottom'
// })
// })
plus.screen.lockOrientation("portrait-primary");
setTimeout(() => { setTimeout(() => {
plus.navigator.closeSplashscreen();
}, 2400); }, 2400);
//#ifdef APP-PLUS //#ifdef APP-PLUS
@ -108,28 +69,49 @@
let extras = result.extras let extras = result.extras
console.log("自定义消息", result) console.log("自定义消息", result)
}) })
//#endif //#endif
}, },
onShow: function() { onShow: function() {
// console.log('App Show') console.log('App Show')
console.log('App Show')
console.log('11111')
console.log(this.$store.state.hasNEt);
let that = this;
uni.onNetworkStatusChange(function(res) {
console.log(res);
if (res.isConnected) {
that.$store.commit("changeNetStatus", true);
uni.showToast({
title: "有网络",
icon: "none",
duration: 200000
})
console.log('有网络');
} else {
that.$store.commit("changeNetStatus", false);
uni.showToast({
title:"无网络",
icon: "none",
duration: 200000
})
console.log('无网络');
}
})
}, },
onHide: function() { onHide: function() {
// console.log('App Hide') // console.log('App Hide')
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
@import "@/common/common.scss"; @import "@/common/common.scss";
page { page {
overflow-x: hidden; overflow-x: hidden;
} }
</style> </style>

30
common/lib.js

@ -0,0 +1,30 @@
const NetWork = {
// 网络状态
isConnect:false,
// 监听网络状态
On(){
// 获取当前网络状态
uni.getNetworkType({
success: (res) => {
if(res.networkType!=='none'){ this.isConnect=true; return;}
uni.showToast({
icon:"none",
title: '请先连接网络',
});
}
})
// 监听网络状态变化
uni.onNetworkStatusChange((res)=>{
this.isConnect = res.isConnected;
if(!res.isConnected){
uni.showToast({
icon:"none",
title: '您目前处于断网状态',
});
}
})
}
}
export default {
NetWork
}

36
ios/index.js

@ -21,4 +21,38 @@
// } // }
// }; // };
// } // }
/**
* 全局混入型
*/
// export default{
// data(){
// return {
// //设置默认的分享参数
// typee: ''
// }
// },
// onShareAppMessage(res) {
// return {
// let that = this;
// let s = 0;
// let time = setInterval(() => {
// uni.getNetworkType({
// success: (res) => {
// console.log(res.networkType, s);
// if (res.networkType == 'none') {
// uni.showToast({
// icon: 'none',
// title: 'Please connect to the network',
// duration: 3000,
// })
// } else if (res.networkType !== 'none') {
// that.typee = 2;
// clearInterval(time);
// }
// }
// })
// s++;
// }, 1);
// }
// }
// }

6
main.js

@ -1,6 +1,7 @@
import App from './App' import App from './App'
import store from '@/store/store.js' import store from '@/store/store.js'
import ios from '@/ios/index.js' import ios from '@/ios/index.js'
import lib from "./common/lib.js"
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
@ -8,12 +9,13 @@ import Vue from 'vue'
// Vue.prototype.$isResolve = resolve // Vue.prototype.$isResolve = resolve
// }) // })
Vue.config.productionTip = false Vue.config.productionTip = false
// Vue.prototype.lib=lib
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App, ...App,
store, store,
ios ios,
lib
}) })

2
pages/category/index.vue

@ -63,6 +63,7 @@
export default { export default {
data() { data() {
return { return {
typee: '',
scrollTop: 0, //tab scrollTop: 0, //tab
oldScrollTop: 0, oldScrollTop: 0,
current: 0, // current: 0, //
@ -123,7 +124,6 @@
}, },
onLoad() { onLoad() {
this.getList() this.getList()
this.getCartNum() this.getCartNum()
uni.hideTabBar() uni.hideTabBar()

2
pages/category/productList.vue

@ -148,6 +148,7 @@
export default { export default {
data() { data() {
return { return {
typee: '',
pets_index: 0, pets_index: 0,
navWidth: "160rpx", navWidth: "160rpx",
sum: 0, sum: 0,
@ -513,6 +514,7 @@
} }
}, },
onLoad(e) { onLoad(e) {
console.log(e) console.log(e)
if (e.first) { if (e.first) {
this.first = e.first this.first = e.first

8
pages/index/index.vue

@ -204,14 +204,6 @@
onLoad() { onLoad() {
let that = this; let that = this;
let s = 0; let s = 0;
// if (res.networkType == 'none') {
// that.typee = 1;
// uni.showToast({
// title: 'Please connect to the network',
// icon: 'exception',
// duration: 850
// });
// }
let time = setInterval(() => { let time = setInterval(() => {
uni.getNetworkType({ uni.getNetworkType({
success: (res) => { success: (res) => {

3
pages/productDetails/index.vue

@ -469,6 +469,7 @@
export default { export default {
data() { data() {
return { return {
typee: '',
navWidth: '80rpx', navWidth: '80rpx',
current: 0, current: 0,
max: 0, max: 0,
@ -1149,7 +1150,7 @@
console.info(this.shipping_list) console.info(this.shipping_list)
}, },
onShow() { onShow() {
this.getCartNum() this.getCartNum();
}, },
// //
onReachBottom() { onReachBottom() {

3
pages/shippingCart/index.vue

@ -1122,10 +1122,11 @@
this.getCatList(0) this.getCatList(0)
this.getAddress() this.getAddress()
this.getorder() this.getorder()
this.lib()
}, },
async onShow() { async onShow() {
this.isLogin = uni.getStorageSync('isLogin') this.isLogin = uni.getStorageSync('isLogin')
console.log(this.isLogin) console.log(this.isLogin)
// uni.startPullDownRefresh() // uni.startPullDownRefresh()

5
store/store.js

@ -3,12 +3,17 @@ import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
state() { state() {
hasNet: true
return { return {
count: 0, count: 0,
goodslist: [] goodslist: []
} }
}, },
mutations: { mutations: {
// 网络监听
changeNetStatus(state, stauts) {
state.hasNet = stauts;
},
addSave(state, data) { addSave(state, data) {
let str = data let str = data
console.log(data) console.log(data)

Loading…
Cancel
Save