App.vue 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. }).catch(err=>{
  46. uni.removeStorageSync('expandParam');
  47. })
  48. }else {
  49. uni.showModal({
  50. title: '温馨提示',
  51. content: ' 当前二维码已过期,请重新扫码',
  52. showCancel:false,
  53. success: function (res) {
  54. if (res.confirm) {
  55. console.log('用户点击确定');
  56. } else if (res.cancel) {
  57. console.log('用户点击取消');
  58. }
  59. }
  60. });
  61. uni.removeStorageSync('expandParam');
  62. }
  63. }
  64. //用户扫码技师端进入小程序 暂无操作
  65. let promotionParam = uni.getStorageSync('promotionParam')
  66. })
  67. },
  68. })
  69. },
  70. onHide: function () {
  71. console.log('App Hide')
  72. }
  73. }
  74. </script>