| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <style lang="scss">
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
- @import "uview-ui/index.scss";
- </style>
- <script>
- export default {
- onLaunch: function () {
- console.log('App Launch')
- },
- onShow: function () {
- console.log('App Show 小程序显示了+++++++++++++++++++++++')
- let that = this;
- wx.login({
- success(re) {
- that.$api.wxLogin({code: re.code}).then(res => {
- console.log('++++++++++登录返回了++++++++++++++++', res)
- uni.setStorageSync('userInfo', res.data.data.userInfo)
- uni.setStorageSync('accessToken', res.data.data.access_token)
- let isNew = res.data.data.isNew
- uni.removeStorageSync('parent_member_id');
- //用户点击用户分享进入小程序,进行绑定操作
- let shareUserId = uni.getStorageSync('shareUserId')
- if (shareUserId) {
- that.$api.scanCode({
- openId: res.data.data.userInfo.otherId,
- memberId: shareUserId
- }).then(res => {
- console.log('用户分享用户绑定成功', res)
- uni.removeStorageSync('shareUserId');
- })
- }
- //用户扫码拓客端进入小程序,携带的参数,进行绑定操作
- let expandParam = uni.getStorageSync('expandParam')
- if (expandParam) {
- console.log('获取到的拓客端参数',expandParam)
- if (new Date().getTime() <= expandParam.timestamp){
- if (isNew){
- //登录成功,且是新用户,触发首页的自定义事件
- uni.$emit("loginSuccess")
- //用户扫码拓客端进入小程序
- // that.$api.userBindMember(
- // {
- // ...expandParam,
- // memberId: res.data.data.userInfo.id
- // }
- // ).then(res1 => {
- // console.log('拓客端推广用户绑定成功!')
- //
- // that.$api.addRecordForAttach({
- // ...expandParam,
- // isNew:1,
- // isBindSuccess:1,
- // }).then(res=>{
- // console.log('+++++++++新用户,扫码推广成功记录!++++++++++++++++')
- // })
- //
- // uni.removeStorageSync('expandParam');
- // }).catch(err=>{
- //
- // that.$api.addRecordForAttach({
- // ...expandParam,
- // isNew:1,
- // isBindSuccess:0,
- // }).then(res=>{
- // console.log('+++++++++新用户,扫码推广失败记录!++++++++++++++++')
- // })
- //
- // uni.removeStorageSync('expandParam');
- // })
- }else {
- that.$api.addRecordForAttach({
- ...expandParam,
- isNew:0,
- isBindSuccess:0,
- }).then(res=>{
- console.log('+++++++++老用户,扫码推广失败记录!++++++++++++++++')
- })
- uni.removeStorageSync('expandParam');
- }
- }else {
- uni.showModal({
- title: '温馨提示',
- content: ' 当前二维码已过期,请重新扫码',
- showCancel:false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- uni.removeStorageSync('expandParam');
- }
- }
- //用户扫码技师端进入小程序,携带的参数。 暂无操作
- let promotionParam = uni.getStorageSync('promotionParam')
- })
- },
- })
- },
- onHide: function () {
- console.log('App Hide')
- }
- }
- </script>
|