浏览代码

修改部分消息接收通知功能

xiebaomin 2 年之前
父节点
当前提交
cf07dabbaf

+ 6 - 0
App.vue

@@ -1,5 +1,10 @@
 <script>
+import global from '@/mixins/global.js'
+
+
+
 export default {
+    mixins: [global],
     onLaunch: function() {
         const updateManager = uni.getUpdateManager()
         updateManager.onCheckForUpdate(function(res) {
@@ -18,6 +23,7 @@ export default {
         })
         
         this.$store.dispatch('app/initDevice')
+        this.initSetSystemInfo() // 初始化系统程序
     }
 }
 </script>

+ 1 - 1
main.js

@@ -9,7 +9,7 @@ import store from '@/store/index.js'
 
 Vue.config.productionTip = false
 App.mpType = 'app'
-
+// Vue.prototype.$Static = 'https://static.caimei365.com/app/img/'
 // 使用插件
 Vue.use(uniappApi)
 Vue.use(filters)

+ 50 - 0
mixins/global.js

@@ -18,6 +18,56 @@ export default {
                 3: `others/image-view?imageUrl=${encodeURIComponent(jumpImage)}`
             }
             this.$router.navigateTo(jumpMap[jumpType])
+        },
+        initSetSystemInfo() {
+            let self = this
+            uni.getSystemInfo({
+                success: function(e) {
+                    let modelmes = e.model
+                    console.log(e)
+                    if (modelmes.search('iPhone 11') !== -1 || modelmes.search('iPhone 11 Pro Max') !==
+                		-1 || modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
+                        self.$store.dispatch('setVariableFun', true)
+                    } else {
+                        self.$store.dispatch('setVariableFun', false)
+                    }
+                    // #ifndef MP
+                    Vue.prototype.StatusBar = e.statusBarHeight
+                    if (e.platform == 'android') {
+                        Vue.prototype.CustomBar = e.statusBarHeight + 50
+                        Vue.prototype.platformClass = true
+                    } else {
+                        Vue.prototype.CustomBar = e.statusBarHeight + 45
+                        Vue.prototype.platformClass = false
+                    };
+                    // #endif
+                    // #ifdef MP-WEIXIN || MP-QQ
+                    console.log(e.platform)
+                    if (e.platform == 'android') {
+                        Vue.prototype.platformClass = 'left'
+                        self.$store.dispatch('setVariableFun', false)
+                    } else {
+                        Vue.prototype.platformClass = 'center'
+                        self.$store.dispatch('setIsIphoneFun', true)
+                    }
+                    Vue.prototype.StatusBar = e.statusBarHeight
+                    Vue.prototype.fontSizeSetting = e.fontSizeSetting
+                    Vue.prototype.screenWidth = e.screenWidth
+                    let capsule = wx.getMenuButtonBoundingClientRect()
+                    Vue.prototype.capsule = capsule
+                    if (capsule) {
+                        Vue.prototype.Custom = capsule
+                        Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight
+                    } else {
+                        Vue.prototype.CustomBar = e.statusBarHeight + 50
+                    }
+                    // #endif		
+                    // #ifdef MP-ALIPAY
+                    Vue.prototype.StatusBar = e.statusBarHeight
+                    Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight
+                    // #endif
+                }
+            })
         }
     }
 }

+ 49 - 1
pages.json

@@ -45,7 +45,17 @@
             "navigationBarTitleText": "登录",
             "enablePullDownRefresh": false
         }
-    }],
+    }    ,{
+            "path" : "pages/tabBar/notice/notice",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "消息通知",
+                "enablePullDownRefresh": true
+                // "navigationStyle": "custom"
+            }
+            
+        }
+    ],
 
     // 分包加载配置
     "subPackages": [
@@ -253,6 +263,38 @@
                     "enablePullDownRefresh": false
                 }
             }]
+        }, {
+            "root": "pages/notice/",
+            "pages": [
+                {
+                	"path": "club/notice-order",
+                	"style": {
+                		"navigationBarTitleText": "交易物流",
+                		"enablePullDownRefresh": true
+                	}
+                },
+                {
+                	"path": "club/notice-users",
+                	"style": {
+                		"navigationBarTitleText": "账户通知",
+                		"enablePullDownRefresh": true
+                	}
+                },
+                {
+                	"path": "club/notice-server",
+                	"style": {
+                		"navigationBarTitleText": "服务通知",
+                		"enablePullDownRefresh": true
+                	}
+                },
+                {
+                	"path": "club/notice-coupon",
+                	"style": {
+                		"navigationBarTitleText": "优惠促销",
+                		"enablePullDownRefresh": true
+                	}
+                }
+            ]
         }
     ],
 
@@ -283,6 +325,12 @@
                 "selectedIconPath": "static/tabBar/icon-category-active@2x.png",
                 "text": "分类"
             },
+            {
+            	"pagePath": "pages/tabBar/notice/notice",
+            	"iconPath": "static/tabBar/notice.png",
+            	"selectedIconPath": "static/tabBar/notice_active.png",
+            	"text": "消息"
+            },
             {
                 "pagePath": "pages/tabBar/cart/cart",
                 "iconPath": "static/tabBar/icon-cart@2x.png",

+ 19 - 0
pages/notice/club/notice-coupon.vue

@@ -0,0 +1,19 @@
+<template>
+    <view>
+        优惠促销
+    </view>
+</template>
+
+<script>
+    export default {
+        data() {
+            return {
+                
+            };
+        }
+    }
+</script>
+
+<style lang="scss">
+
+</style>

+ 19 - 0
pages/notice/club/notice-order.vue

@@ -0,0 +1,19 @@
+<template>
+    <view>
+        交易物流
+    </view>
+</template>
+
+<script>
+    export default {
+        data() {
+            return {
+                
+            };
+        }
+    }
+</script>
+
+<style lang="scss">
+
+</style>

+ 19 - 0
pages/notice/club/notice-server.vue

@@ -0,0 +1,19 @@
+<template>
+    <view>
+        服务通知
+    </view>
+</template>
+
+<script>
+    export default {
+        data() {
+            return {
+                
+            };
+        }
+    }
+</script>
+
+<style lang="scss">
+
+</style>

+ 19 - 0
pages/notice/club/notice-users.vue

@@ -0,0 +1,19 @@
+<template>
+    <view>
+        账户通知
+    </view>
+</template>
+
+<script>
+    export default {
+        data() {
+            return {
+                
+            };
+        }
+    }
+</script>
+
+<style lang="scss">
+
+</style>

+ 232 - 0
pages/tabBar/notice/notice.vue

@@ -0,0 +1,232 @@
+<template>
+    <view class="notice clearfix" :style="{ paddingTop: CustomBar + 'px' }">
+        <tui-skeleton
+        	v-if="skeletonShow"
+        	backgroundColor="#fafafa"
+        	borderRadius="10rpx"
+        	:isLoading="true"
+        	:loadingType="5"
+        ></tui-skeleton>
+        <view v-else>
+            <view class="navbar-wrap" :style="{ height: CustomBar + 'px', paddingTop: StatusBar + 'px' }">
+            	<view
+            		class="navbar-text"
+            		:style="{ lineHeight: CustomBar - StatusBar + 'px;', fontSize: fontSizeSetting + 'px;' }"
+            	>
+            		消息 <image class="iconfont icon-qingli" @click="clearNews" src="@/static/tabBar/clean_notice.png"></image>
+            	</view>
+            </view>
+            <view class="container-notice">
+                <view class="notice-cell" @click="navigator('/pages/notice/club/notice-order?messageType=1')">
+                	<view class="notice-cell-icon">
+                		<image class="icon-image" src="@/static/tabBar/play_notice.png" mode=""></image>
+                	</view>
+                	<view class="notice-cell-text"> 交易物流 <text class="cell-text">官方</text> </view>
+                	<view class="notice-cell-badge" v-if="tradeCount > 0">
+                		<text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
+                			{{ tradeCount | BadgeType }}
+                		</text>
+                	</view>
+                </view>
+                <view class="notice-cell" @click="navigator('/pages/notice/club/notice-users?messageType=2')">
+                	<view class="notice-cell-icon">
+                		<image class="icon-image" src="@/static/tabBar/user_notice.png" mode=""></image>
+                	</view>
+                	<view class="notice-cell-text"> 账户通知 <text class="cell-text">官方</text> </view>
+                	<view class="notice-cell-badge" v-if="accountCount > 0">
+                		<text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
+                			{{ accountCount | BadgeType }}
+                		</text>
+                	</view>
+               </view>
+<!--                <view class="notice-cell" @click="navigator('/pages/notice/club/notice-serve?messageType=3')">
+                	<view class="notice-cell-icon">
+                		<image class="icon-image" src="@/" mode=""></image>
+                	</view>
+                	<view class="notice-cell-text"> 服务通知 <text class="cell-text">官方</text> </view>
+                	<view class="notice-cell-badge" v-if="notificationCount > 0">
+                		<text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
+                			{{ notificationCount | BadgeType }}
+                		</text>
+                	</view>
+                </view> -->
+                <view class="notice-cell" @click="navigator('/pages/notice/club/notice-coupon?messageType=4')">
+                	<view class="notice-cell-icon">
+                		<image class="icon-image" src="@/static/tabBar/preferential_notice.png" mode=""></image>
+                	</view>
+                	<view class="notice-cell-text"> 优惠促销 <text class="cell-text">官方</text> </view>
+                	<view class="notice-cell-badge" v-if="promotionCount > 0">
+                		<text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
+                			{{ promotionCount | BadgeType }}
+                		</text>
+                	</view>
+                </view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+    import { mapGetters, mapMutations } from 'vuex'
+    export default {
+        data() {
+            return {
+                skeletonShow: true,
+                // CustomBar: this.CustomBar,
+                // StatusBar: this.StatusBar,
+                // fontSizeSetting: this.fontSizeSetting,
+                CustomBar: '',
+                StatusBar: '',
+                fontSizeSetting: '',
+                StaticUrl: '',
+                clubId: 0,
+                allCount:0,
+                tradeCount: 0,
+                accountCount: 0,
+                notificationCount: 0,
+                promotionCount: 0
+            }
+        },
+        filters: {
+            BadgeType: (val) => (val && val >= 99 ? '99+' : val), // 红点的提示信息
+        },
+        computed: {
+            // ...mapGetters(['hasLogin'])
+        },
+        watch: {},
+        onPullDownRefresh() {
+            uni.stopPullDownRefresh()
+        },
+        onShow() {
+            if (!this.$store.getters.hasLogin) {
+            	this.initData()
+            } else {
+            	this.initLogin()
+            }
+        },
+        methods: {
+            initLogin() {
+                console.log(111)
+                uni.reLaunch({
+                    url: 'pages/tabBar/user/user'
+                })
+            },
+            initData() {
+                this.skeletonShow = false
+            },
+            getSystomInfo() {
+                uni.getSystemInfo({
+                    success: (e) => {
+                        console.log(e)
+                    }
+                })
+            },
+        },
+    }
+</script>
+
+<style lang="scss">
+.navbar-wrap {
+	position: fixed;
+	width: 100%;
+	top: 0;
+	z-index: 100000;
+	box-sizing: border-box;
+	background: #ffffff;
+	.navbar-text {
+		font-size: 30rpx;
+		color: #000000;
+		font-weight: 500;
+		text-align: center;
+		.iconfont {
+			display: inline-block;
+			width: 48rpx;
+			height: 48rpx;
+			border-radius: 50%;
+			background-color: #f5f5f5;
+			text-align: center;
+			line-height: 48rpx;
+			color: #666666;
+			font-size: 30rpx;
+			margin-left: 20rpx;
+		}
+	}
+}
+.container-notice {
+	width: 100%;
+	height: auto;
+	box-sizing: border-box;
+	padding: 0 24rpx;
+	padding-top: 20rpx;
+	.notice-cell {
+		width: 100%;
+		height: 130rpx;
+		box-sizing: border-box;
+		padding: 19rpx 0;
+		border-bottom: 1px solid #e1e1e1;
+		.notice-cell-icon {
+			width: 92rpx;
+			height: 92rpx;
+			float: left;
+			.icon-image {
+				width: 92rpx;
+				height: 92rpx;
+				display: block;
+			}
+		}
+		.notice-cell-text {
+			width: 400rpx;
+			height: 100%;
+			line-height: 92rpx;
+			font-size: 34rpx;
+			text-align: left;
+			margin-left: 24rpx;
+			float: left;
+			.cell-text {
+				display: inline-block;
+				height: 32rpx;
+				padding: 0 11rpx;
+				line-height: 32rpx;
+				border-radius: 20rpx;
+				text-align: center;
+				border: 1px solid #e15616;
+				font-size: 24rpx;
+				color: #e15616;
+				margin-left: 10rpx;
+			}
+		}
+		.notice-cell-badge {
+			width: 92rpx;
+			height: 92rpx;
+			float: right;
+			box-sizing: border-box;
+			padding: 25rpx 15rpx;
+			text-align: right;
+		}
+	}
+}
+.uni-badge--small {
+	-webkit-transform: scale(0.8);
+	-ms-transform: scale(0.8);
+	transform: scale(0.8);
+	-webkit-transform-origin: center center;
+	-ms-transform-origin: center center;
+	transform-origin: center center;
+}
+.uni-badge {
+	font-family: 'Helvetica Neue', Helvetica, sans-serif;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+	font-size: 12px;
+	line-height: 1;
+	display: inline-block;
+	padding: 3px 6px;
+	color: #333;
+	border-radius: 100px;
+	background-color: #f1f1f1;
+}
+.uni-badge-error {
+	color: #fff;
+	background-color: #ff2a2a;
+}
+</style>

+ 44 - 0
project.config.json

@@ -0,0 +1,44 @@
+{
+  "appid": "wx290030e37cfbff71",
+  "compileType": "miniprogram",
+  "libVersion": "2.31.0",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "urlCheck": true,
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "lazyloadPlaceholderEnable": false,
+    "preloadBackgroundData": false,
+    "minified": true,
+    "autoAudits": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "enhance": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmManually": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true,
+    "useStaticServer": true,
+    "showES6CompileOption": false,
+    "checkInvalidKey": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "disableUseStrict": false,
+    "useCompilerPlugins": false,
+    "minifyWXML": true
+  },
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  },
+  "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "simulatorPluginLibVersion": {}
+}

+ 7 - 0
project.private.config.json

@@ -0,0 +1,7 @@
+{
+  "projectname": "caimei-applets-store",
+  "setting": {
+    "compileHotReLoad": true
+  },
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
+}

二进制
static/tabBar/clean_notice.png


二进制
static/tabBar/delete_notice.png


二进制
static/tabBar/emtry_notice.png


二进制
static/tabBar/notice.png


二进制
static/tabBar/notice_active.png


二进制
static/tabBar/play_notice.png


二进制
static/tabBar/preferential_notice.png


二进制
static/tabBar/user_notice.png


+ 4 - 1
store/getters.js

@@ -13,7 +13,10 @@ const getters = {
     usedNum: state => state.coupon.usedNum,
     couponAlertType: state => state.coupon.couponAlertType,
     couponNoticeFlag: state => state.coupon.couponNoticeFlag,
-    kindCount: state => state.cart.kindCount
+    kindCount: state => state.cart.kindCount,
+    isIphoneX: state => state.app.isIphoneX,
+    isIphone: state => state.app.isIphone,
+    hasLogin: state => state.user.hasLogin,
 }
 
 export default getters

+ 16 - 2
store/modules/app.js

@@ -1,7 +1,9 @@
 const state = {
 	model: '',
 	safeArea: true,
-	systemInfo: {}
+    isIphoneX: '',
+	systemInfo: {},
+    isIphone: true,
 }
 
 const mutations = {
@@ -16,6 +18,12 @@ const mutations = {
 		console.log('safeArea', safeArea)
 		state.safeArea = safeArea
 	},
+    SET_CHANGE_VAR: (state, isIphoneX) => {
+        state.isIphoneX = isIphoneX
+    },
+    SET_IS_IPHONE: (state, isIphone) => {
+        state.isIphone = isIphone
+    },
 }
 
 const actions = {
@@ -28,7 +36,13 @@ const actions = {
 		if (reg.test(model) || model.indexOf('iphone') === -1) {
 			commit('SET_SAFE_AREA', false)
 		}
-	}
+	},
+    setVariableFun: function(context, vData) {
+        context.commit('SET_CHANGE_VAR', vData)
+    },
+    setIsIphoneFun: function(context, vData) {
+        context.commit('SET_IS_IPHONE', vData)
+    },
 }
 
 export default {

+ 13 - 1
store/modules/user.js

@@ -14,6 +14,7 @@ function initUserState() {
         userIdentity: -1, // 用户类型
         inviteUserId: '', // 分享者用户ID
         accessToken: '', // token
+        hasLogin: false, // 用户是否登录
     }
     const userInfo = getStorage('USER_INFO')
     if (userInfo) {
@@ -32,6 +33,7 @@ console.log(state)
 
 const mutations = {
     SET_USER_INFO: (state, userInfo) => {
+        state.hasLogin = true
         objAssign(state, userInfo)
     },
     SET_INVITE_USER_ID: (state, id) => {
@@ -39,7 +41,10 @@ const mutations = {
     },
     SET_ACCESS_TOKEN: (state, token) => {
         state.accessToken = token
-    }
+    },
+    SET_LOGINOUT: (state, logout) => {
+        state.hasLogin = logout
+    },
 }
 
 const actions = {
@@ -52,8 +57,11 @@ const actions = {
             commit('SET_USER_INFO', data)
             setStorage('USER_INFO', data)
             dispatch('getAccessToken') // 获取token
+            commit('SET_LOGINOUT', true)
         } catch (e) {
+            commit('SET_LOGINOUT', false)
             console.log(e)
+            
         }
     },
     // 手机号注册登录
@@ -63,7 +71,9 @@ const actions = {
             const data = JSON.parse(res.data)
             commit('SET_USER_INFO', data)
             setStorage('USER_INFO', data)
+            commit('SET_LOGINOUT', true)
         } catch (e) {
+            commit('SET_LOGINOUT', false)
             console.log(e)
         }
     },
@@ -73,7 +83,9 @@ const actions = {
             const res = await getAccessToken()
             commit('SET_ACCESS_TOKEN', res.data)
             setStorage('ACCESS_TOKEN', res.data)
+            commit('SET_LOGINOUT', true)
         } catch (e) {
+            commit('SET_LOGINOUT', false)
             console.log(e)
         }
     }