unbind-weixin.js 818 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. const {
  2. preUnBind,
  3. postUnBind
  4. } = require('../../lib/utils/relate')
  5. const {
  6. LOG_TYPE, dbCmd
  7. } = require('../../common/constants')
  8. const {
  9. getWeixinPlatform
  10. } = require('../../lib/utils/weixin')
  11. /**
  12. * 解绑微信
  13. * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-weixin
  14. * @returns
  15. */
  16. module.exports = async function () {
  17. const { uid } = this.authInfo
  18. // const weixinPlatform = getWeixinPlatform.call(this)
  19. await preUnBind.call(this, {
  20. uid,
  21. unBindAccount: {
  22. wx_openid: dbCmd.exists(true),
  23. wx_unionid: dbCmd.exists(true)
  24. },
  25. logType: LOG_TYPE.UNBIND_WEIXIN
  26. })
  27. return await postUnBind.call(this, {
  28. uid,
  29. unBindAccount: {
  30. wx_openid: dbCmd.remove(),
  31. wx_unionid: dbCmd.remove()
  32. },
  33. logType: LOG_TYPE.UNBIND_WEIXIN
  34. })
  35. }