| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <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)
- 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){
- //用户扫码拓客端进入小程序
- that.$api.userBindMember(
- {
- ...expandParam,
- memberId: res.data.data.userInfo.id
- }
- ).then(res1 => {
- console.log('拓客端推广用户绑定成功!')
- uni.removeStorageSync('expandParam');
- }).catch(err=>{
- 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>
|