App.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. console.log('获取到的拓客端参数',expandParam)
  35. if (new Date().getTime() <= expandParam.timestamp){
  36. //用户扫码拓客端进入小程序
  37. that.$api.userBindMember(
  38. {
  39. ...expandParam,
  40. memberId: res.data.data.userInfo.id
  41. }
  42. ).then(res1 => {
  43. console.log('拓客端推广用户绑定成功!')
  44. uni.removeStorageSync('expandParam');
  45. })
  46. }else {
  47. uni.showModal({
  48. title: '温馨提示',
  49. content: ' 当前二维码已过期,请重新扫码',
  50. showCancel:false,
  51. success: function (res) {
  52. if (res.confirm) {
  53. console.log('用户点击确定');
  54. } else if (res.cancel) {
  55. console.log('用户点击取消');
  56. }
  57. }
  58. });
  59. uni.removeStorageSync('expandParam');
  60. }
  61. }
  62. //用户扫码技师端进入小程序 暂无操作
  63. let promotionParam = uni.getStorageSync('promotionParam')
  64. })
  65. },
  66. })
  67. },
  68. onHide: function () {
  69. console.log('App Hide')
  70. }
  71. }
  72. </script>