|
|
@ -26,6 +26,7 @@ |
|
|
<script> |
|
|
<script> |
|
|
import { mapState } from 'vuex' |
|
|
import { mapState } from 'vuex' |
|
|
import EmailPopup from './emailPopup.vue' |
|
|
import EmailPopup from './emailPopup.vue' |
|
|
|
|
|
import { subscribeBeforePublish } from '@/utils/subscribeMessage.js' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'CommentPublish', |
|
|
name: 'CommentPublish', |
|
|
@ -90,7 +91,7 @@ export default { |
|
|
|
|
|
|
|
|
// 执行提交评论 |
|
|
// 执行提交评论 |
|
|
async doSubmit() { |
|
|
async doSubmit() { |
|
|
await this.onSubscribeMessageTap() |
|
|
|
|
|
|
|
|
await subscribeBeforePublish() |
|
|
|
|
|
|
|
|
let data = { |
|
|
let data = { |
|
|
...this.form, |
|
|
...this.form, |
|
|
@ -140,39 +141,6 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
//订阅模版消息 |
|
|
|
|
|
onSubscribeMessageTap() { |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
let templateIds = [ |
|
|
|
|
|
'uXZnHWrjtcX9JHlnMpdlWmzgJp71sKxCRiMn3TrE-EE', |
|
|
|
|
|
'gTzGpOfJcYxtbvPG9OHnhbureKz5XLG8NPyECUGb2lw', |
|
|
|
|
|
]; |
|
|
|
|
|
wx.requestSubscribeMessage({ |
|
|
|
|
|
tmplIds: templateIds, // 需要订阅的模板ID列表 |
|
|
|
|
|
success(res) { |
|
|
|
|
|
resolve(res) |
|
|
|
|
|
console.log('订阅消息调用成功', res); |
|
|
|
|
|
// res[tmplId] 表示用户是否同意订阅该模板ID对应的消息 |
|
|
|
|
|
// 例如:res['your_template_id_1'] === 'accept' 表示用户同意订阅 |
|
|
|
|
|
templateIds.forEach(tmplId => { |
|
|
|
|
|
if (res[tmplId] === 'accept') { |
|
|
|
|
|
console.log(`用户同意订阅模板ID:${tmplId}`); |
|
|
|
|
|
// 这里可以添加用户同意后的逻辑,比如发送消息等(注意:发送消息需要在后端进行) |
|
|
|
|
|
} else if (res[tmplId] === 'reject') { |
|
|
|
|
|
console.log(`用户拒绝订阅模板ID:${tmplId}`); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log(`用户对该模板ID的订阅请求:${res[tmplId]}`); // 'ban' 表示用户被禁止订阅该模板 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
fail(err) { |
|
|
|
|
|
resolve(res) |
|
|
|
|
|
console.error('订阅消息调用失败', err); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|