ccjgmwz 3 年 前
コミット
6f364fb2f2
5 ファイル変更11 行追加237 行削除
  1. 6 8
      App.vue
  2. 2 2
      components/APPPush/app_push.js
  3. 0 209
      components/APPPush/h5_push.vue
  4. 1 16
      components/APPPush/index.js
  5. 2 2
      config/index.js

+ 6 - 8
App.vue

@@ -7,6 +7,8 @@
 		mapMutations
 	} from 'vuex';
 	import appUpdate from 'common/appUpdate.js'
+	import app_push from './components/APPPush/app_push.js'
+	
 	export default {
 		methods: {
 			...mapMutations(['login'])
@@ -32,12 +34,6 @@
 			});
 			// 监听在线消息事件  
 			plus.push.addEventListener( "receive", function( msg ) {  
-				if ( msg.aps ) {  // Apple APNS message  
-					//APNS下发的消息,应用在前台  
-				} else {  
-					//其它情况接收消息  
-					
-				}  
 				let params = {
 					inApp: true, // app内横幅提醒
 					voice: true,    // 声音提醒
@@ -47,8 +43,10 @@
 					messageContent: msg.content,
 					messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
 				}
-				console.log("params",params,msg)
-				that.$appPush(params)
+				console.log("params",params)
+				new app_push({
+					...params
+				}).show();
 				var userInfo = uni.getStorageSync("userInfo")
 				var that = this
 				this.$api.doRequest('get', '/salePlanInfo/getTips', {phone:userInfo.phone}).then(res => {

+ 2 - 2
components/APPPush/app_push.js

@@ -1,6 +1,6 @@
 export class appPush{
 	constructor(option = {}) {
-		console.log(option)
+		console.log("appPush",option)
 		// app内横幅提醒
 		this.inApp = option.inApp;
 		// 声音提醒
@@ -59,7 +59,7 @@ export class appPush{
 	
 	// 生成弹框主体
 	createView() {
-		// console.log((this.propotation * 20) + this.system.statusBarHeight+ '--------------')
+		console.log((this.propotation * 20) + this.system.statusBarHeight+ '--------------')
 		let view = new plus.nativeObj.View('popupView', {
 			// tag: 'rect',
 			top: (this.propotation * 20) + this.system.statusBarHeight,

+ 0 - 209
components/APPPush/h5_push.vue

@@ -1,209 +0,0 @@
-<template>
-	<view>
-		<transition name="slide-fade">
-			<view class="h5_push" @touchstart.stop.prevent="touchstart" @touchmove.stop.prevent="touchmove" @touchend.stop.prevent="touchend" v-if="show" :style="style">
-				<view class="push-title">
-					<view class="push-type">
-						<image src="/static/push/message-icon.png"></image>
-						{{messageType}}
-					</view>
-					{{messageTime}}
-				</view>
-				<view class="push-body">
-					<view class="push-content">
-						<view class="push-content-title">{{messageTitle}}</view>
-						<view class="push-content-text">{{messageContent}}</view>
-					</view>
-					<image :src="messageImage" class="push-img" mode="aspectFill"></image>
-				</view>
-			</view>
-		</transition>
-	</view>
-</template>
-
-<script>
-	export default{
-		data() {
-			return {
-				show: false,
-				// 关闭时间
-				closeTime: 3000,
-				// app内横幅提醒
-				inApp: false,
-				// 声音提醒
-				voice: true,
-				// 振动提醒
-				vibration: false,
-				// 消息分类
-				messageType: '',
-				// 通知标题
-				messageTitle: '',
-				// 时间
-				messageTime: '现在',
-				// 通知文案
-				messageContent: '',
-				// 缩略图
-				messageImage: '',
-				
-				top: 20,
-				left: 20,
-				cur: {
-					x: 0,
-					y: 0,
-					pageX: 0,
-					pageY: 0
-				}
-			}
-		},
-		computed:{
-			style() {
-				let system = uni.getSystemInfoSync()
-				let statusBarHeight = system.statusBarHeight
-				return `top: calc(${statusBarHeight}px + ${this.top}rpx);left: ${this.left}rpx`
-			}
-		},
-		created() {
-			setTimeout(() => {
-				this.show = false
-			}, this.closeTime)
-		},
-		methods:{
-			touchstart(event) {
-				console.log(event)
-				var touch;  
-				if (event.touches) {
-					touch = event.touches[0];  
-				} else {  
-					touch = event;  
-				}  
-				this.cur.x = touch.clientX;  
-				this.cur.y = touch.clientY;
-				this.cur.pageX = touch.pageX;
-				this.cur.pageY = touch.pageY;  
-				console.log(this.cur)
-			},
-			touchmove(event) {
-				var touch;
-				if (event.touches) {  
-					touch = event.touches[0];  
-				} else {  
-					touch = event;
-				}  
-				let moveX = touch.pageX - this.cur.x;   
-				let moveY = touch.pageY - this.cur.y;   
-				let x = moveX;  
-				let y = moveY;
-				// console.log(x, y)
-				// console.log(this.cur, touch)
-				let system = uni.getSystemInfoSync()
-				if (y >= (uni.upx2px(20) + system.statusBarHeight)) {  
-					y = (uni.upx2px(20) + system.statusBarHeight);  
-				}
-				this.top = y / (uni.upx2px(y) / y)
-				this.left = x / (uni.upx2px(x) / x)
-				
-				// this.body.setStyle({  
-				// 	top: y + 'px',  
-				// 	left: x + 'px'  
-				// });
-			},
-			touchend(event) {
-				console.log(event)
-				var touch;
-				if (event.touches.length) {  
-					touch = event.touches[0];  
-				} else {  
-					touch = event.changedTouches[0];  
-				}
-				console.log(this.cur, touch)
-				let differX = Math.abs(this.cur.pageX) - Math.abs(touch.pageX)
-				let differY = Math.abs(this.cur.pageY) - Math.abs(touch.pageY)
-				// console.log(differX, differY)
-				if(Math.abs(differX) > 5 || Math.abs(differY) > 5) {	// 上下移动或左右移动超过5px则关闭弹窗
-					this.show = false
-				} else {	// 否则当作单击事件
-					console.log('-------------------')
-					this.show = false
-				}
-			}
-		}
-	}
-</script>
-
-<style lang="scss" scoped>
-	.h5_push{
-		width: 710rpx;
-		height: 192rpx;
-		background: #FFFFFF;
-		box-shadow: 0px 3rpx 18rpx 0px rgba(54, 58, 68, 0.08);
-		border-radius: 20rpx;
-		position: fixed;
-		z-index: 9999999;
-		.push-title{
-			padding: 30rpx 30rpx 15rpx;
-			display: flex;
-			align-items: center;
-			justify-content: space-between;
-			font-size: 24rpx;
-			font-weight: 400;
-			color: #4F555B;
-			.push-type{
-				display: flex;
-				align-items: center;
-				font-size: 24rpx;
-				font-weight: 400;
-				color: #4F555B;
-				image{
-					width: 24rpx;
-					height: 24rpx;
-					margin-right: 10rpx;
-				}
-			}
-		}
-		.push-body{
-			display: flex;
-			align-items: center;
-			justify-content: space-between;
-			padding: 0 24rpx 0 30rpx;
-			.push-content{
-				width: calc(100% - 150rpx);
-				.push-content-title{
-					font-size: 30rpx;
-					font-weight: 500;
-					color: #202123;
-					margin-bottom: 20rpx;
-					overflow: hidden;
-					text-overflow: ellipsis;
-					white-space: nowrap;
-				}
-				.push-content-text{
-					font-size: 24rpx;
-					font-weight: 400;
-					color: #4F555B;
-					overflow: hidden;
-					text-overflow: ellipsis;
-					white-space: nowrap;
-				}
-			}
-			.push-img{
-				width: 100rpx;
-				height: 100rpx;
-				background: #F2F2F3;
-				border: 0.5px solid #E9E9E9;
-				border-radius: 10rpx;
-				margin-left: 50rpx;
-			}
-		}
-	}
-	.slide-fade-enter-active {
-	  transition: all .3s ease;
-	}
-	.slide-fade-leave-active {
-	  transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
-	}
-	.slide-fade-enter, .slide-fade-leave-to
-	/* .slide-fade-leave-active for below version 2.1.8 */ {
-	  transform: translateX(10px);
-	  opacity: 0;
-	}
-</style>

+ 1 - 16
components/APPPush/index.js

@@ -1,27 +1,12 @@
 import app_push from './app_push.js'
-import h5Push from './h5_push.vue'
 
 const appPush = {
 	install: function(Vue) {
 		Vue.prototype.$appPush = function(op = {}) {
-			// #ifdef APP-PLUS
+			console.log("进入appPush")
 			new app_push({
 				...op
 			}).show();
-			// #endif
-			// #ifdef H5
-			// Vue.component('h5Push', h5Push)
-			// 创建构造器
-			const H5PushInstance = Vue.extend(h5Push)
-			let instance = new H5PushInstance({
-				data: op
-			})
-			instance.$mount()
-			document.body.appendChild(instance.$el)
-			Vue.nextTick(() => {
-				instance.show = true
-			})
-			// #endif
 		}
 	}
 }

+ 2 - 2
config/index.js

@@ -1,8 +1,8 @@
 const dev = {
-	baseUrlNew: 'http://192.168.1.122:9100/',
+	// baseUrlNew: 'http://192.168.1.122:9100/',
 	baseUrl: 'https://www.zthymaoyi.com',
 	// baseUrlNew: 'http://192.168.1.120:8090/',
-	  // baseUrlNew: 'http://api.eliangeyun.com/',
+	  baseUrlNew: 'http://api.eliangeyun.com/',
 	h5Appid: 'wxb66b599f7f61b46f',
 	debug: false
 }