diff --git a/components/card.vue b/components/card.vue
index 491a970..1022aa1 100644
--- a/components/card.vue
+++ b/components/card.vue
@@ -83,7 +83,8 @@
lastOpacity: 0,
swipe: false, // 是否轮播,是否翻页
zIndex: 10
- }
+ },
+ id:''
}
},
computed: {
@@ -113,6 +114,28 @@
this.el = await getElSize('flipcard', this) // 卡片的位置对象,上下左右,宽高
console.log('----', this.el)
})
+ const that = this
+ // 获取匿名用户唯一标识
+ wx.login({
+ success(res){
+ console.log('code====',res.code);
+ wx.request({
+ url: 'https://api.weixin.qq.com/sns/jscode2session',
+ data:{
+ appid: 'wxab7dd0a14272badf',
+ secret: '1ff1d2119715e82db1adda4fe143eedb',
+ js_code: res.code,
+ grant_type:'authorization_code'
+ },
+ method:"GET",
+ success(res){
+ that.id = res.data.openid
+ console.log('openid=====',res.data.openid); // 得到openid
+ console.log('session_key====', res.data.session_key); // 得到 session_key
+ }
+ })
+ }
+ })
},
watch:{
'currentShow':{
@@ -124,7 +147,7 @@
// this.isVoteFlag = false
const params = {
rumorId:this.currentShow.id, // id
- votePerson:userinfo.phone ?userinfo.phone : new Date().getTime() // 用户唯一标识
+ votePerson:userinfo.phone ?userinfo.phone : this.id // 用户唯一标识
}
// 查询用户是否投票
isVote(params).then(res => {
@@ -139,10 +162,17 @@
methods: {
// 点击真假进行投票
vote(flag) {
+ // 已经投票
+ if(this.isVoteFlag) {
+ uni.$u.toast('您已投过票,自动跳转下一个')
+ this.next()
+ return
+ }
+ // 未投票
const userinfo = wx.getStorageSync('userInfoxj')
const params = {
rumorId:this.currentShow.id,
- votePerson:userinfo.phone ?userinfo.phone : new Date().getTime(), // 用户唯一标识
+ votePerson:userinfo.phone ?userinfo.phone : this.id, // 用户唯一标识
status: flag ? '1' : '0'
}
addVote(params).then(res => {
diff --git a/components/card.vue b/components/card.vue
index 491a970..1022aa1 100644
--- a/components/card.vue
+++ b/components/card.vue
@@ -83,7 +83,8 @@
lastOpacity: 0,
swipe: false, // 是否轮播,是否翻页
zIndex: 10
- }
+ },
+ id:''
}
},
computed: {
@@ -113,6 +114,28 @@
this.el = await getElSize('flipcard', this) // 卡片的位置对象,上下左右,宽高
console.log('----', this.el)
})
+ const that = this
+ // 获取匿名用户唯一标识
+ wx.login({
+ success(res){
+ console.log('code====',res.code);
+ wx.request({
+ url: 'https://api.weixin.qq.com/sns/jscode2session',
+ data:{
+ appid: 'wxab7dd0a14272badf',
+ secret: '1ff1d2119715e82db1adda4fe143eedb',
+ js_code: res.code,
+ grant_type:'authorization_code'
+ },
+ method:"GET",
+ success(res){
+ that.id = res.data.openid
+ console.log('openid=====',res.data.openid); // 得到openid
+ console.log('session_key====', res.data.session_key); // 得到 session_key
+ }
+ })
+ }
+ })
},
watch:{
'currentShow':{
@@ -124,7 +147,7 @@
// this.isVoteFlag = false
const params = {
rumorId:this.currentShow.id, // id
- votePerson:userinfo.phone ?userinfo.phone : new Date().getTime() // 用户唯一标识
+ votePerson:userinfo.phone ?userinfo.phone : this.id // 用户唯一标识
}
// 查询用户是否投票
isVote(params).then(res => {
@@ -139,10 +162,17 @@
methods: {
// 点击真假进行投票
vote(flag) {
+ // 已经投票
+ if(this.isVoteFlag) {
+ uni.$u.toast('您已投过票,自动跳转下一个')
+ this.next()
+ return
+ }
+ // 未投票
const userinfo = wx.getStorageSync('userInfoxj')
const params = {
rumorId:this.currentShow.id,
- votePerson:userinfo.phone ?userinfo.phone : new Date().getTime(), // 用户唯一标识
+ votePerson:userinfo.phone ?userinfo.phone : this.id, // 用户唯一标识
status: flag ? '1' : '0'
}
addVote(params).then(res => {
diff --git a/packageToolList/notice/notice.vue b/packageToolList/notice/notice.vue
index 47a888e..9073578 100644
--- a/packageToolList/notice/notice.vue
+++ b/packageToolList/notice/notice.vue
@@ -23,7 +23,7 @@
-
+
@@ -65,6 +65,7 @@
noticeList: [] ,// 列表数据
pageIndex: 1, // 请求第几页
loadingMoreStatus: 'loadmore', // 加载更多
+ keyword:''
}
},
mounted() {
@@ -105,7 +106,17 @@
},
deep: true,
// immediate: true,
- }
+ },
+ keyword: {
+ handler(val){
+ if(!val.length) {
+ this.fetchNoticeList()
+ }
+ },
+ deep: true,
+ // immediate: true,
+ },
+
},
// 监听滚动条位置
onPageScroll(e) {
@@ -114,7 +125,7 @@
methods: {
// 点击搜索
search() {
-
+ this.noticeList = this.noticeList.filter(item => item.title.indexOf(this.keyword) !== -1)
},
// 获取通知公告列表
fetchNoticeList() {