App.vue 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "uview-ui/index.scss";
  4. </style>
  5. <script>
  6. export default {
  7. onLaunch: function () {
  8. console.log('App Launch')
  9. },
  10. onShow: function () {
  11. console.log('App Show 小程序显示了+++++++++++++++++++++++')
  12. let that = this;
  13. wx.login({
  14. success(re) {
  15. that.$api.wxLogin({code: re.code}).then(res => {
  16. console.log('++++++++++登录返回了++++++++++++++++', res)
  17. uni.setStorageSync('userInfo', res.data.data.userInfo)
  18. uni.setStorageSync('accessToken', res.data.data.access_token)
  19. let isNew = res.data.data.isNew
  20. uni.removeStorageSync('parent_member_id');
  21. //用户点击用户分享进入小程序,进行绑定操作
  22. let shareUserId = uni.getStorageSync('shareUserId')
  23. if (shareUserId) {
  24. that.$api.scanCode({
  25. openId: res.data.data.userInfo.otherId,
  26. memberId: shareUserId
  27. }).then(res => {
  28. console.log('用户分享用户绑定成功', res)
  29. uni.removeStorageSync('shareUserId');
  30. })
  31. }
  32. //用户扫码拓客端进入小程序,携带的参数,进行绑定操作
  33. let expandParam = uni.getStorageSync('expandParam')
  34. if (expandParam) {
  35. console.log('获取到的拓客端参数',expandParam)
  36. if (new Date().getTime() <= expandParam.timestamp){
  37. if (isNew){
  38. //用户扫码拓客端进入小程序
  39. that.$api.userBindMember(
  40. {
  41. ...expandParam,
  42. memberId: res.data.data.userInfo.id
  43. }
  44. ).then(res1 => {
  45. console.log('拓客端推广用户绑定成功!')
  46. uni.removeStorageSync('expandParam');
  47. }).catch(err=>{
  48. uni.removeStorageSync('expandParam');
  49. })
  50. }else {
  51. console.log("老用户,删除拓客端携带的参数")
  52. uni.removeStorageSync('expandParam');
  53. }
  54. }else {
  55. uni.showModal({
  56. title: '温馨提示',
  57. content: ' 当前二维码已过期,请重新扫码',
  58. showCancel:false,
  59. success: function (res) {
  60. if (res.confirm) {
  61. console.log('用户点击确定');
  62. } else if (res.cancel) {
  63. console.log('用户点击取消');
  64. }
  65. }
  66. });
  67. uni.removeStorageSync('expandParam');
  68. }
  69. }
  70. //用户扫码技师端进入小程序,携带的参数。 暂无操作
  71. let promotionParam = uni.getStorageSync('promotionParam')
  72. })
  73. },
  74. })
  75. },
  76. onHide: function () {
  77. console.log('App Hide')
  78. }
  79. }
  80. </script>