uniapp推送PUSH1.0的

<template>
	<view>
		<view class="header p-4">
			<view class="status_bar"></view>
			<view class="d-flex ">
				<view class="mr-5 pt-1">
					<u-avatar :src="userInfo.avatar" size='60'></u-avatar>
				</view>
				<view>
					<view class="text-white font-20 font-weight">试验综合管理系统</view>
					<view class="my-1 text-white font-14">部门: {{userInfo.organizationName}}</view>
					<view class="font-14 text-white">职务: {{userInfo.dutyName ==''?'未分配':userInfo.dutyName}}</view>
					<view class="font-14 text-white mt-1">位置: {{city}}</view>
				</view>
			</view>
		</view>
		<view class="px-2 pt-2">
			<view class="bg-white p-2 wrapbox d-flex a-center j-sb font-14">
				<view class="d-flex flex-column a-center">
					<view class="font-weight">{{weekday[new Date().getDay()]}}</view>
					<view class="font-weight">{{$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')}}</view>
				</view>

				<view>天气 : {{weather}}</view>
				<view>温度 : {{temperature}}℃</view>
				<view>湿度 : {{humidity}}%</view>
			</view>
		</view>
		<view class="p-2 d-flex flex-wrap a-center j-sb">
			<view class="wrap wrapOne mb-2 d-flex a-center j-center flex-column" @tap="navAction(0)">
				<u-badge class="badge" shape="horn" :type="type" max="99" :value="countNum"></u-badge>
				<!-- <u-icon name="file-text-fill" color="#2979ff" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/11.png" mode=""></image>
				<view class="font-14">待处理</view>
			</view>
			<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(1)">
				<!-- <u-icon name="order" color="#f97aaf" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/22.png" mode=""></image>
				<view class="font-14">已处理</view>
			</view>
			<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(2)">
				<!-- <u-icon name="edit-pen-fill" color="#19be6b" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/33.png" mode=""></image>
				<view class="font-14">抄送我的</view>
			</view>
			<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(3)">
				<!-- <u-icon name="plus-people-fill" color="#aec" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/44.png" mode=""></image>
				<view class="font-14">我创建的</view>
			</view>
			<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(4)">
				<!-- <u-icon name="play-circle-fill" color="#cad" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/55.png" mode=""></image>
				<view class="font-14">实时查看</view>
			</view>
			<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(5)">
				<!-- <u-icon name="list-dot" color="#ff9900" size="36"></u-icon> -->
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/66.png" mode=""></image>
				<view class="font-14">查询统计</view>
			</view>
			<!-- <view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(6)">
				<u-icon name="calendar-fill" color="#a0cfff" size="36"></u-icon>
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/77.png" mode=""></image>
				<view class="font-14">设备使用记录</view>
			</view> -->
		<!-- 	<view class="wrap mb-2 d-flex a-center j-center flex-column" @tap="navAction(7)">
				<u-icon name="file-text-fill" color="#18b566" size="36"></u-icon>
				<image style="width: 65rpx;height: 65rpx; margin-bottom: 5rpx;" src="../../static/images/88.png" mode=""></image>
				<view class="font-14">药品使用记录</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		computed: mapState(['userInfo']),
		data() {
			return {
				type: "error",
				countNum: 0,
				tableData: {
					page: 1,
					limit: 10,
					total: 0,
					keyword: ''
				},
				city: '',
				weather: '',
				temperature: '',
				humidity: '',
				weekday: ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
				clientId: '', // 个推 CID
			}
		},
		onLoad() {
			
			this.initUser()
			this.getAssignment()
			console.log(this.userInfo);
			var that = this
			uni.getLocation({
				type: 'wgs84 ',
				altitude: true,
				geocode: true,
				success: function(res) {
					console.log('当前位置的经度:' + res.longitude);
					console.log('当前位置的纬度:' + res.latitude);
					console.log(res)
					uni.request({
						url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${res.longitude},${res.latitude}&key=506f1c5c025383c7279b50a25906cf53`,
						success: function(res) {
							console.log('得到的信息是', res);
							that.city = res.data.regeocode.addressComponent.city
							let adcode = res.data.regeocode.addressComponent.adcode
							uni.request({
								url: `https://restapi.amap.com/v3/weather/weatherInfo?city=${adcode}&key=506f1c5c025383c7279b50a25906cf53`,
								success: function(res) {
									console.log('得到的信息是', res);
									that.weather = res.data.lives[0].weather
									that.temperature = res.data.lives[0].temperature,
										that.humidity = res.data.lives[0].humidity
								}
							})

						}
					})
				}
			});
			//#ifdef APP-PLUS
			this.getPushClientID();
			uni.getProvider({
				service: 'push',
				success: function(res) {
					console.log(res.provider)
					console.log('----------' + JSON.stringify(res));
				}
			});
			uni.subscribePush({
				success: function(res) {
					console.log('--22222--------' + JSON.stringify(res));
				}
			});
			//#endif
		},
		onShow() {
			this.noReadData()
		},
		methods: {
			...mapMutations(['initUser']),
			navAction(type) {
				switch (type) {
					case 0:
						uni.navigateTo({
							url: '../assignment/assignment'
						});
						break;
					case 1:
						uni.navigateTo({
							url: '../assignment/accept/accept'
						});
						break;
					case 2:
						uni.navigateTo({
							url: '../assignment/ccInstance/ccInstance'
						});
						break;
					case 3:
						uni.navigateTo({
							url: '../assignment/myCreate/myCreate'
						});
						break;
					case 4:
						uni.showToast({
							icon: 'none',
							title: '敬请期待'
						})
						break;
					case 5:
						uni.showToast({
							icon: 'none',
							title: '敬请期待'
						})
						break;
					// case 6:
					// 	uni.navigateTo({
					// 		url:'/pages/equipmentUsage/equipmentUsage'
					// 	})
					// 	break;
					// case 7:
					// 	uni.navigateTo({
					// 		url:'/pages/drugRecords/drugRecords'
					// 	})
					// 	break;
					default:
				}
			},
			noReadData() {
				this.$http.get('/system/sys-notify/page', {
					isRead: 0
				}).then(res => {
					if (res.data.count > 0) {
						let count = res.data.count + ''
						uni.setTabBarBadge({ //显示数字
							index: 1, //tabbar下标
							text: count
						})
					} else {
						uni.hideTabBarRedDot({
							index: 1
						})
					}
				})
			},
			getAssignment() {
				this.$http.get('/flow/flow-instance/page', {}).then(res => {
					console.log(res.data);
					console.log(res.data.list);
					this.countNum = res.data.count
				})
			},
			getPushClientID() {
				//setTimeout(function(){
				var clientObj = plus.push.getClientInfo();
				console.log(JSON.stringify(clientObj));
				console.log("打印clientid:", clientObj.clientid);
				this.clientId = clientObj.clientid;
				var params = {};
				params.userId = this.userInfo.userId;
				params.clientId = clientObj.clientid;
				params.clientObj = JSON.stringify(clientObj)
				console.log(JSON.stringify(params));
				// var params={};
				// params.userId = this.userInfo.userId;
				// params.clientId = '68d3fcf461858efd01731c65f9f24623';
				// params.clientObj = JSON.stringify('{\"id\":\"unipush\",\"token\":\"68d3fcf461858efd01731c65f9f24623\",\"clientid\":\"68d3fcf461858efd01731c65f9f24623\",\"appid\":\"pPyZWvH3Fa6PXba10aJ009\",\"appkey\":\"b7dOGlNPHR7pqwUxDhpTi4\"}')
				// console.log(JSON.stringify(params));

				this.$http.post('/updateClient', params, {
					isToken: 2
				}).then(res => {
					console.log(res);
				})
				//},2000);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	.header {
		padding-bottom: 40rpx;
		background-color: #02A7F0;
	}

	.wrap {
		width: 49%;
		height: 180rpx;
		// border: 1px solid #000;
		border-radius: 16rpx;
		background-color: #fff;
		box-shadow: 0 5rpx 10rpx rgba(0, 0, 0, .2);
	}

	.wrapbox {
		border-radius: 16rpx;
		background-color: #fff;
		box-shadow: 0 5rpx 10rpx rgba(0, 0, 0, .2);
	}

	.wrapOne {
		position: relative;
	}

	.badge {
		position: absolute;
		top: 24rpx;
		right: 110rpx;

	}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值