Commit 45e25d9d by weijiguang
parents ce63e9bd b7f497cd
......@@ -39,7 +39,8 @@
<h3>我的消息</h3>
<view class="dec">点击查看我的消息</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>
</view>
</view>
......@@ -59,6 +60,7 @@
<script>
import User from '@/request/user'
import Mine from '@/request/mine'
export default {
onLoad() {
......@@ -68,9 +70,15 @@ export default {
})
}
},
onShow() {
if(this.userms){
this.getMessageCount()
}
},
data() {
return {
loginInfo:""
loginInfo:"",
UnreadNumber:""
}
},
computed: {
......@@ -86,19 +94,24 @@ export default {
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo
User.getPhoneNumber(e);
User.getPhoneNumber(e,this.getMessageCount);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
goToPage(page) {
if (!this.userms) {
this.loginByPhoneNumber(page)
this.getPhoneNumber(page)
return
}
page == 'order' && uni.switchTab({ url: '/pages/order/order' })
page == 'coupon' && uni.showToast({ title: '功能未开放!', icon: 'none' });
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 {
&.two {
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 {
......
......@@ -20,4 +20,14 @@ export default {
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 {
const data = res.detail.encryptedData
wx.checkSession({
success: (res) => {
console.log('seeon未过期')
console.log('seeion未过期')
this.onLogin(loginInfo,iv,data,callback)
},
fail: (res) => {
console.log('seeon已过期')
console.log('seeion已过期')
this.wxLoginAndGetOpenid(true).then(loginInfo => {
this.onLogin(loginInfo,iv,data,callback)
})
}
})
// this.uniLogin(res.detail, callback);
},
onLogin(loginInfo,iv,data,callback) {
this.loginDecrypt({loginInfo:JSON.parse(loginInfo),iv,data}).then(res => {
......@@ -146,7 +145,7 @@ export default {
Store.commit('setUserInfo', data);
Store.commit('setAuthorization', token);
if(callback)
callback();
return callback();
}
}).catch((err) => {
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