|
|
|
@ -31,79 +31,118 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on |
|
|
|
|
|
|
|
|
|
const handleGetUserPhone = (e: any) => { |
|
|
|
|
console.log(e.detail) |
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/register', |
|
|
|
|
method: 'POST', |
|
|
|
|
data: { |
|
|
|
|
MCODE: e.detail.code, |
|
|
|
|
channel: 'wusehua_mini', |
|
|
|
|
open_id: Taro.getStorageSync('LoginKey'), |
|
|
|
|
invite_code: inviteCode |
|
|
|
|
}, |
|
|
|
|
success: (res: any) => { |
|
|
|
|
console.log('用户注册信息=>',res) |
|
|
|
|
Taro.setStorageSync('UserAvatar', res.data.user.Avatar) |
|
|
|
|
Taro.setStorageSync('UserNickName', res.data.user.NickName) |
|
|
|
|
Taro.setStorageSync('UserPhoneNumber', res.data.user.Mobile) |
|
|
|
|
Taro.setStorageSync('UserInviteCode', res.data.user.InviteCode) |
|
|
|
|
Taro.setStorageSync('UserToken', res.data.token) |
|
|
|
|
|
|
|
|
|
if(scene){ |
|
|
|
|
|
|
|
|
|
const open_id = Taro.getStorageSync('LoginKey') |
|
|
|
|
if (open_id) { |
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/register', |
|
|
|
|
method: 'POST', |
|
|
|
|
data: { |
|
|
|
|
MCODE: e.detail.code, |
|
|
|
|
channel: 'wusehua_mini', |
|
|
|
|
open_id, |
|
|
|
|
invite_code: inviteCode |
|
|
|
|
}, |
|
|
|
|
success: (res: any) => { |
|
|
|
|
console.log('用户注册信息=>',res) |
|
|
|
|
Taro.setStorageSync('UserAvatar', res.data.user.Avatar) |
|
|
|
|
Taro.setStorageSync('UserNickName', res.data.user.NickName) |
|
|
|
|
Taro.setStorageSync('UserPhoneNumber', res.data.user.Mobile) |
|
|
|
|
Taro.setStorageSync('UserInviteCode', res.data.user.InviteCode) |
|
|
|
|
Taro.setStorageSync('UserToken', res.data.token) |
|
|
|
|
|
|
|
|
|
if(scene){ |
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/product/exchange', |
|
|
|
|
method: 'POST', |
|
|
|
|
header: { |
|
|
|
|
authorization: `bearer ${Taro.getStorageSync('UserToken')}` |
|
|
|
|
}, |
|
|
|
|
data: { |
|
|
|
|
timestamp: Date.now(), |
|
|
|
|
change_code: scene |
|
|
|
|
}, |
|
|
|
|
success: (s_res: any) => { |
|
|
|
|
console.log('兑换成功=>', s_res.data) |
|
|
|
|
if(s_res.data.state === '200'){ |
|
|
|
|
let modalContent = '' |
|
|
|
|
s_res.data.data.Subscribed.forEach(element => { |
|
|
|
|
modalContent += `兑换成功: ${element.PrdtTitle}\n` |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Taro.showModal({ |
|
|
|
|
title: '兑换成功', |
|
|
|
|
content: modalContent, |
|
|
|
|
showCancel: true, |
|
|
|
|
success: (modal_res) => { |
|
|
|
|
if (modal_res.confirm) { |
|
|
|
|
console.log('用户点击确定') |
|
|
|
|
Taro.navigateTo({ |
|
|
|
|
url: '/pages/CollectionDetail/index?id=' + s_res.data.data.Subscribed[0].PrdtId |
|
|
|
|
}) |
|
|
|
|
} else if (modal_res.cancel) { |
|
|
|
|
console.log('用户点击取消') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else if(s_res.data.state === '207'){ |
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '兑换码已使用', |
|
|
|
|
icon: 'error' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('兑换失败=>', err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//注册成功
|
|
|
|
|
onClose(true) |
|
|
|
|
//关闭弹窗
|
|
|
|
|
onModalClose() |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('用户注册失败=>',err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
// 如果没有openId,则先调登录
|
|
|
|
|
Taro.login({ |
|
|
|
|
success:function(res) { |
|
|
|
|
console.log('微信登录成功', res.code) |
|
|
|
|
|
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/product/exchange', |
|
|
|
|
method: 'POST', |
|
|
|
|
header: { |
|
|
|
|
authorization: `bearer ${Taro.getStorageSync('UserToken')}` |
|
|
|
|
}, |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/login', |
|
|
|
|
data: { |
|
|
|
|
timestamp: Date.now(), |
|
|
|
|
change_code: scene |
|
|
|
|
CODE: res.code, |
|
|
|
|
channel: 'wusehua_mini', |
|
|
|
|
}, |
|
|
|
|
success: (s_res: any) => { |
|
|
|
|
console.log('兑换成功=>', s_res.data) |
|
|
|
|
if(s_res.data.state === '200'){ |
|
|
|
|
let modalContent = '' |
|
|
|
|
s_res.data.data.Subscribed.forEach(element => { |
|
|
|
|
modalContent += `兑换成功: ${element.PrdtTitle}\n` |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Taro.showModal({ |
|
|
|
|
title: '兑换成功', |
|
|
|
|
content: modalContent, |
|
|
|
|
showCancel: true, |
|
|
|
|
success: (modal_res) => { |
|
|
|
|
if (modal_res.confirm) { |
|
|
|
|
console.log('用户点击确定') |
|
|
|
|
Taro.navigateTo({ |
|
|
|
|
url: '/pages/CollectionDetail/index?id=' + s_res.data.data.Subscribed[0].PrdtId |
|
|
|
|
}) |
|
|
|
|
} else if (modal_res.cancel) { |
|
|
|
|
console.log('用户点击取消') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else if(s_res.data.state === '207'){ |
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '兑换码已使用', |
|
|
|
|
icon: 'error' |
|
|
|
|
}) |
|
|
|
|
success: function(sres) { |
|
|
|
|
console.log('静默授权登录成功', sres.data) |
|
|
|
|
|
|
|
|
|
if(sres.data.state === 200){ |
|
|
|
|
Taro.setStorageSync('UserAvatar', sres.data.data.user.Avatar) |
|
|
|
|
Taro.setStorageSync('UserNickName', sres.data.data.user.NickName) |
|
|
|
|
Taro.setStorageSync('UserPhoneNumber', sres.data.data.user.Mobile) |
|
|
|
|
Taro.setStorageSync('UserInviteCode', sres.data.data.user.InviteCode) |
|
|
|
|
Taro.setStorageSync('UserToken', sres.data.token) |
|
|
|
|
|
|
|
|
|
//注册成功
|
|
|
|
|
onClose(true) |
|
|
|
|
//关闭弹窗
|
|
|
|
|
onModalClose() |
|
|
|
|
}else{ |
|
|
|
|
//注册key
|
|
|
|
|
Taro.setStorageSync('LoginKey', sres.data.open_id) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('兑换失败=>', err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//注册成功
|
|
|
|
|
onClose(true) |
|
|
|
|
//关闭弹窗
|
|
|
|
|
onModalClose() |
|
|
|
|
}, |
|
|
|
|
fail: (err: any) => { |
|
|
|
|
console.log('用户注册失败=>',err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
@ -121,18 +160,31 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on |
|
|
|
|
<View className='phone_modal'> |
|
|
|
|
|
|
|
|
|
<View className='phone_modal_logo'></View> |
|
|
|
|
<Button |
|
|
|
|
className='phone_modal_container' |
|
|
|
|
openType='getPhoneNumber' |
|
|
|
|
onGetPhoneNumber={handleGetUserPhone} |
|
|
|
|
> |
|
|
|
|
{/* <View className='phone_modal_icon'></View> */} |
|
|
|
|
<View |
|
|
|
|
className='phone_modal_title' |
|
|
|
|
> |
|
|
|
|
手机号快捷登录 |
|
|
|
|
</View> |
|
|
|
|
</Button> |
|
|
|
|
{ |
|
|
|
|
Taro.getStorageSync('LoginKey') ? |
|
|
|
|
<Button |
|
|
|
|
className='phone_modal_container' |
|
|
|
|
openType='getPhoneNumber' |
|
|
|
|
onGetPhoneNumber={handleGetUserPhone} |
|
|
|
|
> |
|
|
|
|
<View |
|
|
|
|
className='phone_modal_title' |
|
|
|
|
> |
|
|
|
|
手机号快捷登录 |
|
|
|
|
</View> |
|
|
|
|
</Button> : |
|
|
|
|
<Button |
|
|
|
|
className='phone_modal_container' |
|
|
|
|
onClick={handleGetUserPhone} |
|
|
|
|
> |
|
|
|
|
<View |
|
|
|
|
className='phone_modal_title' |
|
|
|
|
> |
|
|
|
|
快捷登录 |
|
|
|
|
</View> |
|
|
|
|
</Button> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<Text |
|
|
|
|
className='phone_modal_desc' |
|
|
|
|
onClick={handleOverlayClick} |
|
|
|
|