App.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. let that = this;
  9. wx.login({
  10. success(re) {
  11. that.$api.wxLogin({code: re.code}).then(res => {
  12. console.log('++++++++++登录返回了++++++++++++++++', res)
  13. uni.setStorageSync('userInfo', res.data.data.userInfo)
  14. uni.setStorageSync('accessToken', res.data.data.access_token)
  15. uni.removeStorageSync('parent_member_id');
  16. //用户分享用户绑定
  17. let shareUserId = uni.getStorageSync('shareUserId')
  18. if (shareUserId) {
  19. that.$api.scanCode({
  20. openId: res.data.data.userInfo.otherId,
  21. memberId: shareUserId
  22. }).then(res => {
  23. console.log('用户分享用户绑定成功', res)
  24. uni.removeStorageSync('shareUserId');
  25. })
  26. }
  27. //拓客端或者技师端扫码用户绑定
  28. let expandParam = uni.getStorageSync('expandParam')
  29. if (expandParam) {
  30. //用户扫码拓客端进入小程序
  31. that.$api.userBindMember(
  32. {
  33. ...expandParam,
  34. memberId: res.data.data.userInfo.id
  35. }
  36. ).then(res1 => {
  37. console.log('拓客端推广用户绑定成功!')
  38. uni.removeStorageSync('expandParam');
  39. })
  40. }
  41. //用户扫码技师端进入小程序 暂无操作
  42. let promotionParam = uni.getStorageSync('promotionParam')
  43. })
  44. },
  45. })
  46. console.log('App Launch')
  47. },
  48. onShow: function () {
  49. console.log('App Show')
  50. },
  51. onHide: function () {
  52. console.log('App Hide')
  53. }
  54. }
  55. </script>