| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <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) {
- if (expandParam.isUse != 1){
- console.log('获取到的拓客端参数',expandParam)
- if (new Date().getTime() <= expandParam.timestamp){
- if (isNew){
- //登录成功,且是新用户,触发首页的自定义事件
- uni.$emit("loginSuccess")
- }else {
- that.$api.addRecordForAttach({
- ...expandParam,
- isNew:0,
- isBindSuccess:0,
- }).then(res=>{
- expandParam.isUse = 1
- uni.setStorageSync('expandParam', expandParam)
- 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('用户点击取消');
- }
- }
- });
- expandParam.isUse = 1
- uni.setStorageSync('expandParam', expandParam)
- // uni.removeStorageSync('expandParam');
- }
- }
- }
- //用户扫码技师端进入小程序,携带的参数。 暂无操作
- let promotionParam = uni.getStorageSync('promotionParam')
- })
- },
- })
- },
- onHide: function () {
- console.log('App Hide')
- }
- }
- </script>
|