祁鹏飞 2 mesiacov pred
rodič
commit
b3e8444a9b
3 zmenil súbory, kde vykonal 288 pridanie a 269 odobranie
  1. 46 48
      pages/lottery/index.vue
  2. 228 217
      pages/message/message.vue
  3. 14 4
      store/index.js

+ 46 - 48
pages/lottery/index.vue

@@ -1,59 +1,57 @@
 <template>
 	<view class="content">
-		<web-view :webview-styles="webviewStyles"
-			:src="to_url"
-			@message="getMessage"></web-view>
+		<web-view :webview-styles="webviewStyles" :src="to_url" @message="getMessage"></web-view>
 	</view>
 </template>
 <script>
-	export default {
-		data() {
-			return {
-				webviewStyles: {
-					progress: {
-						color: '#FF3333'
-					}
-				},
-				to_url: '',
-			}
-		},
-		onLoad(options) {
-			// jzg-7kP9xL2mN5vQ8zR1jW  ,晋掌柜
-			// gyy-aB4cD6eF8gH0iJ2kL4  ,广誉源
-			// bdsh-X9yZ1wV3uT5sR7qP9o  ,本地生活
-			
-			
-			let currentPlatform = 'gyy-aB4cD6eF8gH0iJ2kL4';// 当前平台
-			
-			// let currentUser = '2043971820430372866'
-			let currentUser = '2049045470263193601'// 当前用户id
-			
-			let tenantId = '2049045470263193601'// 晋掌柜 租户id  需要传不需要不传
-			
-			let activityId = '2029805805219950593';// 当前活动id
-			
-			// this.to_url = 'http://192.168.5.21:8080/custh5/#/packageF/pages/activity/lottery/turntable?activityId='+ activityId + '&currentPlatform='+currentPlatform+'&currentUser='+currentUser;
-			
-			this.to_url = 'https://life.baoxianzhanggui.com/custh5/#/packageF/pages/activity/lottery/turntable?activityId='+ activityId + '&currentPlatform='+currentPlatform+'&currentUser='+currentUser+'&tenantId='+tenantId;
-		},
-		methods: {
-			// 这个 getMessage 在 H5 下其实不会被调到,可以保留给 App/小程序用
-			getMessage(event) {
-				console.log("🚀 ~ event:", event)
-				const list = event.detail && event.detail.data
-				const urlType = list && list[list.length - 1]
-				switch (urlType && urlType.type) {
-					case 'back':
-						uni.navigateBack()
-						break
-					default:
+import { mapState } from 'vuex';
+export default {
+	data() {
+		return {
+			webviewStyles: {
+				progress: {
+					color: '#FF3333'
 				}
-			}
+			},
+			to_url: '',
 		}
+	},
+	computed: {
+		...mapState(['userInfo', 'system_code']),
+	},
+	onLoad(options) {
+		// jzg-7kP9xL2mN5vQ8zR1jW  ,晋掌柜
+		// gyy-aB4cD6eF8gH0iJ2kL4  ,广誉源
+		// bdsh-X9yZ1wV3uT5sR7qP9o  ,本地生活
+
+		let currentPlatform = 'gyy-aB4cD6eF8gH0iJ2kL4';// 当前平台
+
+		// let currentUser = '2043971820430372866'
+		let currentUser = this.userInfo.sysUser.userId // 当前用户id
+
+		let tenantId = this.system_code// 晋掌柜 租户id  需要传不需要不传
+
+		let activityId = options.activityId;// 当前活动id
 
+		// this.to_url = 'http://192.168.5.21:8080/custh5/#/packageF/pages/activity/lottery/turntable?activityId='+ activityId + '&currentPlatform='+currentPlatform+'&currentUser='+currentUser;
+
+		this.to_url = 'https://life.baoxianzhanggui.com/custh5/#/packageF/pages/activity/lottery/turntable?activityId=' + activityId + '&currentPlatform=' + currentPlatform + '&currentUser=' + currentUser + '&tenantId=' + tenantId;
+	},
+	methods: {
+		// 这个 getMessage 在 H5 下其实不会被调到,可以保留给 App/小程序用
+		getMessage(event) {
+			const list = event.detail && event.detail.data
+			const urlType = list && list[list.length - 1]
+			switch (urlType && urlType.type) {
+				case 'back':
+					uni.navigateBack()
+					break
+				default:
+			}
+		}
 	}
-</script>
 
-<style lang="scss" scoped>
+}
+</script>
 
-</style>
+<style lang="scss" scoped></style>

+ 228 - 217
pages/message/message.vue

@@ -2,53 +2,53 @@
 	<view class="page">
 		<u-sticky zIndex="999">
 			<view class="tabView">
-				<view class="item dis f-c a-c " v-for="(item,index) in tabViewList" :key="index"
+				<view class="item dis f-c a-c " v-for="(item, index) in tabViewList" :key="index"
 					@click="tabClick(item)">
 					<view class="iconImage">
 						<image :src="item.image" mode=""></image>
-						<view class="badge dis a-c j-c" v-if="item.sum">{{item.sum > 99?'...':item.sum}}</view>
+						<view class="badge dis a-c j-c" v-if="item.sum">{{ item.sum > 99 ? '...' : item.sum }}</view>
 					</view>
-					<text>{{item.text}}</text>
+					<text>{{ item.text }}</text>
 				</view>
 			</view>
 		</u-sticky>
 
-		<view class="content" v-show="datalist.length!=0">
+		<view class="content" v-show="datalist.length != 0">
 			<!-- 系统消息列表 -->
-			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type=='1'" v-for="(item,index) in datalist"
-				:key="index">
+			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '1'" v-for="(item, index) in datalist"
+				:key="index" @click="detailClick(item)">
 				<view class="title dis a-c ">
 					<image src="/static/icon/message/message.png" mode=""></image>
-					<text class="font-weight ml-1">{{item.title}}</text>
-					<text class="time">{{item.createTime}}</text>
+					<text class="font-weight ml-1">{{ item.title }}</text>
+					<text class="time">{{ item.createTime }}</text>
 				</view>
 				<view class="message-content">
-					{{item.content}}
+					{{ item.content }}
 				</view>
 			</view>
 			<!-- 订单消息列表 -->
-			<view class="viewitem dis f-c mb-2 " v-if="pageQuery.type=='2'" v-for="(item,index) in datalist"
+			<view class="viewitem dis f-c mb-2 " v-if="pageQuery.type == '2'" v-for="(item, index) in datalist"
 				:key="index">
 				<view class="title dis a-c ">
-					<view class="status ">{{item.content.orderStatus}}</view>
-					<text class="font-weight ml-1">{{item.title}}</text>
+					<view class="status ">{{ item.content.orderStatus }}</view>
+					<text class="font-weight ml-1">{{ item.title }}</text>
 				</view>
 				<view class="order-content dis j-s a-end">
 					<view class="dis f-c ">
 						<view class="item mb-1">
 							<text>车牌</text>
-							<text class="ml-3">{{item.content.licenseNo}}</text>
+							<text class="ml-3">{{ item.content.licenseNo }}</text>
 						</view>
 						<view class="item">
 							<text>保费</text>
-							<text class="ml-3">{{item.content.amount}}</text>
+							<text class="ml-3">{{ item.content.amount }}</text>
 						</view>
 					</view>
-					<text class="time">{{item.createTime}}</text>
+					<text class="time">{{ item.createTime }}</text>
 				</view>
 			</view>
 			<!-- 佣金消息列表 -->
-			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type=='3'" v-for="(item,index) in datalist"
+			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '3'" v-for="(item, index) in datalist"
 				:key="index">
 				<view class="title dis a-c ">
 					<image src="/static/icon/message/commission.png" mode=""></image>
@@ -71,7 +71,7 @@
 				</view>
 			</view>
 			<!-- 增员信息列表 -->
-			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type=='0'" v-for="(item,index) in datalist"
+			<view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '0'" v-for="(item, index) in datalist"
 				:key="index">
 				<view class="title dis a-c ">
 					<image src="/static/icon/message/addmember.png" mode=""></image>
@@ -99,245 +99,256 @@
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				status: 'loadmore',
-				tabViewList: [{
-					sum: 0,
-					text: '系统信息',
-					image: "/static/icon/message/tab-message.png",
-					type: "1",
-				}, {
-					sum: 0,
-					text: '订单进度',
-					image: "/static/icon/message/tab-order.png",
-					type: "2",
-				}, {
-					sum: 0,
-					text: '佣金消息',
-					image: "/static/icon/message/tab-commission.png",
-					type: "3",
-				}, {
-					sum: 0,
-					text: '增员信息',
-					image: "/static/icon/message/tab-addmember.png",
-					type: '0',
-				}],
-				pageQuery: {
-					type: '1',
-					pages: 1,
-					size: 20,
-				},
-				totalPages: 0, //数据总页数
-				datalist: [], //消息数据列表
+export default {
+	data() {
+		return {
+			status: 'loadmore',
+			tabViewList: [{
+				sum: 0,
+				text: '系统信息',
+				image: "/static/icon/message/tab-message.png",
+				type: "1",
+			}, {
+				sum: 0,
+				text: '订单进度',
+				image: "/static/icon/message/tab-order.png",
+				type: "2",
+			}, {
+				sum: 0,
+				text: '佣金消息',
+				image: "/static/icon/message/tab-commission.png",
+				type: "3",
+			}, {
+				sum: 0,
+				text: '增员信息',
+				image: "/static/icon/message/tab-addmember.png",
+				type: '0',
+			}],
+			pageQuery: {
+				type: '1',
+				pages: 1,
+				size: 20,
+			},
+			totalPages: 0, //数据总页数
+			datalist: [], //消息数据列表
+		}
+	},
+	onShow() {
+		this.getmessage();
+		this.getMessageCount();
+	},
+	onLoad() { },
+	onReachBottom() {
+		if (this.pageQuery.pages >= this.totalPages) return;
+		this.status = 'loading';
+		this.pageQuery.pages = ++this.pageQuery.pages;
+		setTimeout(async () => {
+			let res = await this.$http.post('/message/messageList', this.pageQuery);
+			if (res.code == '200') {
+				this.datalist = [...this.datalist, ...res.data.records]
 			}
-		},
-		onShow() {
-			this.getmessage();
-			this.getMessageCount();
-		},
-		onLoad() {},
-		onReachBottom() {
-			if (this.pageQuery.pages >= this.totalPages) return;
-			this.status = 'loading';
-			this.pageQuery.pages = ++this.pageQuery.pages;
-			setTimeout(async () => {
-				let res = await this.$http.post('/message/messageList', this.pageQuery);
-				if (res.code == '200') {
-					this.datalist = [...this.datalist, ...res.data.records]
-				}
-				if (this.pageQuery.pages >= this.totalPages) this.status = 'nomore';
-				else this.status = 'loading';
-			}, 1000)
-		},
-		computed: {
+			if (this.pageQuery.pages >= this.totalPages) this.status = 'nomore';
+			else this.status = 'loading';
+		}, 1000)
+	},
+	computed: {
 
+	},
+	methods: {
+		//获取未读数量
+		async getMessageCount() {
+			let res = await this.$http.get('/message/getMessageCount')
+			if (res.code == 200) {
+				this.tabViewList.map(item => {
+					if (res.data.hasOwnProperty(Number(item.type))) {
+						item.sum = res.data[Number(item.type)];
+					}
+					return item;
+				});
+			}
 		},
-		methods: {
-			//获取未读数量
-			async getMessageCount() {
-				let res = await this.$http.get('/message/getMessageCount')
-				if (res.code == 200) {
-					this.tabViewList.map(item => {
-						if (res.data.hasOwnProperty(Number(item.type))) {
-							item.sum = res.data[Number(item.type)];
-						}
-						return item;
-					});
-				}
-			},
-			//获取信息
-			async getmessage() {
-				let res = await this.$http.post('/message/messageList', this.pageQuery)
-				if (res.code == 200) {
-					//消息类型为1,转成对象
-					if (this.pageQuery.type != 1) {
-						res.data.records.map(val => {
-							val.content = JSON.parse(val.content);
-							return val;
-						})
+		//获取信息
+		async getmessage() {
+			let res = await this.$http.post('/message/messageList', this.pageQuery)
+			if (res.code == 200) {
+				//消息类型为1,转成对象
+				res.data.records.map(val => {
+					const obj = JSON.parse(val.content);
+					if (['template_13'].includes(val.tplCode)) {
+						val.content = obj.message
+						val.activityId = obj.eventId
 					}
-					this.datalist = res.data.records;
-					this.totalPages = res.data.pages; //总页数
-				}
-			},
-			//设置已读
-			async markAsRead(type) {
-				let res = await this.$http.post('/message/readEdit', {
-					type: type
+
+					return val;
 				})
-			},
-			//切换消息
-			tabClick(item) {
-				this.pageQuery.type = item.type;
-				this.pageQuery.pages = 1;
-				this.pageQuery.size = 20;
-				this.getmessage();
-				//未读消息>0,设置已读
-				if (item.sum > 0) {
-					this.markAsRead(item.type)
-				}
-				this.getMessageCount();
-			},
-		}
+				this.datalist = res.data.records;
+				this.totalPages = res.data.pages; //总页数
+			}
+		},
+		// 
+		detailClick(item) {
+			if (item.tplCode === 'template_13') {
+				uni.navigateTo({
+					url: '/pages/lottery/index?activityId='+item.activityId,
+				})
+			}
+		},
+		//设置已读
+		async markAsRead(type) {
+			let res = await this.$http.post('/message/readEdit', {
+				type: type
+			})
+		},
+		//切换消息
+		tabClick(item) {
+			this.pageQuery.type = item.type;
+			this.pageQuery.pages = 1;
+			this.pageQuery.size = 20;
+			this.getmessage();
+			//未读消息>0,设置已读
+			if (item.sum > 0) {
+				this.markAsRead(item.type)
+			}
+			this.getMessageCount();
+		},
 	}
+}
 </script>
 
 <style lang="scss" scoped>
-	page {
-		background-color: #f8f8f8;
-	}
+page {
+	background-color: #f8f8f8;
+}
 
-	.page {
-		background-color: #f8f8f8;
-		padding-bottom: 20rpx;
-		box-sizing: border-box;
-	}
+.page {
+	background-color: #f8f8f8;
+	padding-bottom: 20rpx;
+	box-sizing: border-box;
+}
 
-	.tabView {
-		width: 100%;
-		background-color: #fff;
-		padding: 25rpx 22rpx 20rpx;
-		box-sizing: border-box;
-		display: grid;
-		grid-template-columns: repeat(4, 1fr);
-		grid-template-rows: auto;
+.tabView {
+	width: 100%;
+	background-color: #fff;
+	padding: 25rpx 22rpx 20rpx;
+	box-sizing: border-box;
+	display: grid;
+	grid-template-columns: repeat(4, 1fr);
+	grid-template-rows: auto;
 
-		.item {
-			font-size: 30rpx;
-			color: #333;
+	.item {
+		font-size: 30rpx;
+		color: #333;
 
-			.iconImage {
-				position: relative;
+		.iconImage {
+			position: relative;
 
-				image {
-					width: 120rpx;
-					height: 120rpx;
-				}
+			image {
+				width: 120rpx;
+				height: 120rpx;
+			}
 
-				// 徽标数
-				.badge {
-					position: absolute;
-					top: 14rpx;
-					right: 14rpx;
-					width: 28rpx;
-					height: 28rpx;
-					background: #FF4545;
-					border-radius: 50%;
-					font-size: 18rpx;
-					color: #fff;
-					line-height: 1;
-				}
+			// 徽标数
+			.badge {
+				position: absolute;
+				top: 14rpx;
+				right: 14rpx;
+				width: 28rpx;
+				height: 28rpx;
+				background: #FF4545;
+				border-radius: 50%;
+				font-size: 18rpx;
+				color: #fff;
+				line-height: 1;
 			}
 		}
 	}
+}
 
-	.content {
-		padding: 20rpx;
-		box-sizing: border-box;
-
-		.viewitem {
-			width: 100%;
-			background: #FFFFFF;
-			padding: 25rpx 30rpx 30rpx;
-			box-sizing: border-box;
-			border-radius: 10rpx 10rpx 10rpx 10rpx;
-
-			.title {
-				image {
-					width: 48rpx;
-					height: 48rpx;
-				}
+.content {
+	padding: 20rpx;
+	box-sizing: border-box;
 
-				.status {
-					padding: 5rpx 11rpx;
-					box-sizing: border-box;
-					background: linear-gradient(270deg, #FDE935 0%, #F1FF91 100%);
-					border-radius: 20rpx 20rpx 0rpx 20rpx;
-					font-size: 22rpx;
-					color: #1F1F1F;
-					font-weight: bold;
-					text-align: center;
-				}
+	.viewitem {
+		width: 100%;
+		background: #FFFFFF;
+		padding: 25rpx 30rpx 30rpx;
+		box-sizing: border-box;
+		border-radius: 10rpx 10rpx 10rpx 10rpx;
 
-				.time {
-					font-size: 20rpx;
-					color: #999;
-					margin-left: auto;
-				}
+		.title {
+			image {
+				width: 48rpx;
+				height: 48rpx;
+			}
 
-				font-size: 32rpx;
-				color: #333;
-				font-family: PingFang SC,
-				PingFang SC;
-				margin-bottom: 20rpx;
+			.status {
+				padding: 5rpx 11rpx;
+				box-sizing: border-box;
+				background: linear-gradient(270deg, #FDE935 0%, #F1FF91 100%);
+				border-radius: 20rpx 20rpx 0rpx 20rpx;
+				font-size: 22rpx;
+				color: #1F1F1F;
+				font-weight: bold;
+				text-align: center;
 			}
 
-			.message-content {
-				font-size: 28rpx;
-				color: #666;
+			.time {
+				font-size: 20rpx;
+				color: #999;
+				margin-left: auto;
 			}
 
-			.order-content {
-				.item {
-					font-size: 28rpx;
+			font-size: 32rpx;
+			color: #333;
+			font-family: PingFang SC,
+			PingFang SC;
+			margin-bottom: 20rpx;
+		}
+
+		.message-content {
+			font-size: 28rpx;
+			color: #666;
+		}
 
-					text:first-child {
-						color: #999;
-					}
+		.order-content {
+			.item {
+				font-size: 28rpx;
 
-					text:last-child {
-						color: #333;
-					}
+				text:first-child {
+					color: #999;
 				}
 
-				.time {
-					font-size: 20rpx;
-					color: #999;
+				text:last-child {
+					color: #333;
 				}
 			}
 
-			.commission-content {
-				.item {
-					width: 50%;
-					font-size: 28rpx;
+			.time {
+				font-size: 20rpx;
+				color: #999;
+			}
+		}
 
-					text:first-child {
-						color: #999;
-					}
+		.commission-content {
+			.item {
+				width: 50%;
+				font-size: 28rpx;
 
-					text:last-child {
-						color: #333;
-						margin-left: 58rpx;
-					}
+				text:first-child {
+					color: #999;
 				}
 
-				.time {
-					font-size: 20rpx;
-					color: #999;
+				text:last-child {
+					color: #333;
+					margin-left: 58rpx;
 				}
 			}
+
+			.time {
+				font-size: 20rpx;
+				color: #999;
+			}
 		}
 	}
+}
 </style>

+ 14 - 4
store/index.js

@@ -1,12 +1,23 @@
 import Vue from "vue";
 import Vuex from "vuex";
+import createPersistedState from "vuex-persistedstate";
 
 Vue.use(Vuex);
 const files = require.context("./modules", false, /\.js$/);
 let modules = {
-	state: {},
-	mutations: {},
-	actions: {}
+  state: {},
+  mutations: {},
+  actions: {},
+  plugins: [
+    createPersistedState({
+      paths: ["token", "userInfo", "system_code", "system_Name"],
+      storage: {
+        getItem: (key) => uni.getStorageSync(key),
+        setItem: (key, value) => uni.setStorageSync(key, value),
+        removeItem: (key) => uni.removeStorageSync(key),
+      },
+    }),
+  ],
 };
 
 files.keys().forEach((key) => {
@@ -16,4 +27,3 @@ files.keys().forEach((key) => {
 });
 const store = new Vuex.Store(modules);
 export default store;
-