App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. uni.removeStorageSync('parent_member_id');
  20. //用户分享用户绑定
  21. let shareUserId = uni.getStorageSync('shareUserId')
  22. if (shareUserId) {
  23. that.$api.scanCode({
  24. openId: res.data.data.userInfo.otherId,
  25. memberId: shareUserId
  26. }).then(res => {
  27. console.log('用户分享用户绑定成功', res)
  28. uni.removeStorageSync('shareUserId');
  29. })
  30. }
  31. //拓客端或者技师端扫码用户绑定
  32. let expandParam = uni.getStorageSync('expandParam')
  33. if (expandParam) {
  34. //用户扫码拓客端进入小程序
  35. that.$api.userBindMember(
  36. {
  37. ...expandParam,
  38. memberId: res.data.data.userInfo.id
  39. }
  40. ).then(res1 => {
  41. console.log('拓客端推广用户绑定成功!')
  42. uni.removeStorageSync('expandParam');
  43. })
  44. }
  45. //用户扫码技师端进入小程序 暂无操作
  46. let promotionParam = uni.getStorageSync('promotionParam')
  47. })
  48. },
  49. })
  50. },
  51. onHide: function () {
  52. console.log('App Hide')
  53. }
  54. }
  55. </script>