Commit 45e25d9d by weijiguang
parents ce63e9bd b7f497cd
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
<h3>我的消息</h3> <h3>我的消息</h3>
<view class="dec">点击查看我的消息</view> <view class="dec">点击查看我的消息</view>
</view> </view>
<view @click="goToPage('msg')" class="right"> <view @click="goToPage('msg')" class="right msg">
<div class="unread_number" v-if="UnreadNumber">{{UnreadNumber}}</div>
<image class="right_img" src="../../static/imgs/myMail.png"></image> <image class="right_img" src="../../static/imgs/myMail.png"></image>
</view> </view>
</view> </view>
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
<script> <script>
import User from '@/request/user' import User from '@/request/user'
import Mine from '@/request/mine'
export default { export default {
onLoad() { onLoad() {
...@@ -68,9 +70,15 @@ export default { ...@@ -68,9 +70,15 @@ export default {
}) })
} }
}, },
onShow() {
if(this.userms){
this.getMessageCount()
}
},
data() { data() {
return { return {
loginInfo:"" loginInfo:"",
UnreadNumber:""
} }
}, },
computed: { computed: {
...@@ -86,19 +94,24 @@ export default { ...@@ -86,19 +94,24 @@ export default {
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo
User.getPhoneNumber(e); User.getPhoneNumber(e,this.getMessageCount);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' }) uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
} }
}, },
goToPage(page) { goToPage(page) {
if (!this.userms) { if (!this.userms) {
this.loginByPhoneNumber(page) this.getPhoneNumber(page)
return return
} }
page == 'order' && uni.switchTab({ url: '/pages/order/order' }) page == 'order' && uni.switchTab({ url: '/pages/order/order' })
page == 'coupon' && uni.showToast({ title: '功能未开放!', icon: 'none' }); page == 'coupon' && uni.showToast({ title: '功能未开放!', icon: 'none' });
page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' }) page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' })
},
async getMessageCount() {
const {data} = await Mine.getMessageCount()
const num = data&&Number(data.data)!=0?data.data:''
this.UnreadNumber = num
} }
} }
} }
...@@ -237,6 +250,24 @@ export default { ...@@ -237,6 +250,24 @@ export default {
&.two { &.two {
margin-top: 15rpx; margin-top: 15rpx;
.msg{
position: relative;
.unread_number{
background-color: #ff73bf;
width: 25rpx;
height: 25rpx;
font-size: 15rpx;
color: white;
line-height: 25rpx;
text-align: center;
border-radius: 25rpx;
font-weight: bolder;
position: absolute;
right: -10rpx;
top: -10rpx;
}
}
} }
.left { .left {
......
...@@ -20,4 +20,14 @@ export default { ...@@ -20,4 +20,14 @@ export default {
uni.showToast({ title: '服务器错误', icon: 'none' }); uni.showToast({ title: '服务器错误', icon: 'none' });
}); });
}, },
getMessageCount() {
return uni.$u.http
.get('/app/getMessageCount', {})
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({ title: '服务器错误', icon: 'none' });
});
}
}; };
...@@ -123,17 +123,16 @@ export default { ...@@ -123,17 +123,16 @@ export default {
const data = res.detail.encryptedData const data = res.detail.encryptedData
wx.checkSession({ wx.checkSession({
success: (res) => { success: (res) => {
console.log('seeon未过期') console.log('seeion未过期')
this.onLogin(loginInfo,iv,data,callback) this.onLogin(loginInfo,iv,data,callback)
}, },
fail: (res) => { fail: (res) => {
console.log('seeon已过期') console.log('seeion已过期')
this.wxLoginAndGetOpenid(true).then(loginInfo => { this.wxLoginAndGetOpenid(true).then(loginInfo => {
this.onLogin(loginInfo,iv,data,callback) this.onLogin(loginInfo,iv,data,callback)
}) })
} }
}) })
// this.uniLogin(res.detail, callback);
}, },
onLogin(loginInfo,iv,data,callback) { onLogin(loginInfo,iv,data,callback) {
this.loginDecrypt({loginInfo:JSON.parse(loginInfo),iv,data}).then(res => { this.loginDecrypt({loginInfo:JSON.parse(loginInfo),iv,data}).then(res => {
...@@ -146,7 +145,7 @@ export default { ...@@ -146,7 +145,7 @@ export default {
Store.commit('setUserInfo', data); Store.commit('setUserInfo', data);
Store.commit('setAuthorization', token); Store.commit('setAuthorization', token);
if(callback) if(callback)
callback(); return callback();
} }
}).catch((err) => { }).catch((err) => {
uni.showToast({ uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment