Commit 276a8da8 by LiuJunYi

微信登陆和授权问题

parent b6337ef1
......@@ -16,9 +16,9 @@ Page({
detail: {},
user: {},
loading: false,
familyNum: 0,
phone: '',
formPhone:'',
nickname: '',
adultNum: 0,
childrenNum: 0,
......@@ -28,7 +28,9 @@ Page({
// 订单
order: {},
nums: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
sessionId: ''
sessionId: '',
visible: false,
errMsg:false
},
/**
* 生命周期函数--监听页面加载
......@@ -50,6 +52,84 @@ Page({
},
/**
* 保存手机号
*/
savePhone() {
//发送请求保存手机号
const phone = this.data.formPhone
api.getPhoneNumber({
phone: phone
}).then(res => {
if (!res.code) {
// 将刚拿到的手机号码放到全局数据中,否则phone数据只会是当前页面数据
if (app.globalData.userInfo) {
app.globalData.userInfo.phone = res.data.phone
}
this.setData({
phone: res.data.phone,
visible: false
})
if(res.is_relation){
$Toast({
content: '温馨提示:手机号授权成功,系统已自动关联您在其他平台购买的美行者VIP会员',
type: 'success'
});
}else{
$Toast({
content: '手机号授权成功',
type: 'success'
});
}
//在拉去一遍用户信息
this.getUserInfo();
} else {
this.setData({
'errMsg': true,
'errMessage': '*'+res.msg
})
}
})
},
//获取用户信息
// 获取个人资料
getUserInfo: function () {
api.me.info().then(res => {
if (!res.code) {
console.log(res.data);
app.globalData.userInfo = res.data
// 渲染数据
this.setData({
user: res.data,
})
}
})
},
/**
* 关闭手机号填写弹窗
*/
alertClose() {
this.setData({
visible: false
});
},
/**
* 打开手机号填写弹窗
*/
openAlert() {
this.setData({
visible: true
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
......@@ -241,6 +321,12 @@ Page({
})
},
handlePhone: function (event) {
this.setData({
formPhone: event.detail.detail.value
})
},
handleAdultNum: function(event) {
this.setData({
adultNum: parseInt(event.detail.value)
......
......@@ -2,11 +2,13 @@
"navigationBarTitleText": "立即报名",
"usingComponents": {
"i-input-number": "/iview/input-number/index",
"i-input": "/iview/input/index",
"i-row": "/iview/row/index",
"i-col": "/iview/col/index",
"i-button": "/iview/button/index",
"i-cell-group": "/iview/cell-group/index",
"i-cell": "/iview/cell/index",
"i-toast": "/iview/toast/index"
"i-toast": "/iview/toast/index",
"i-modal": "/iview/modal/index"
}
}
\ No newline at end of file
......@@ -44,7 +44,7 @@
</i-cell>
<i-cell title="手机号" i-class="cell-class">
<block wx:if="{{phone.length == 0}}">
<button slot="footer" bindgetphonenumber="handlePhoneAuth" type="info" open-type="getPhoneNumber" class="btn-auth-phone">授权手机号</button>
<button slot="footer" bindtap='openAlert' type="info" class="btn-auth-phone">填写手机号</button>
</block>
<block wx:else>
<text slot="footer">{{phone}}</text>
......@@ -82,4 +82,13 @@
</i-row>
</view>
<!-- 手机号授权框 -->
<i-modal title="填写手机号" visible="{{ visible }}" bind:ok="savePhone" bind:cancel="alertClose">
<i-input error="{{ errMsg }}" value="{{ value }}" type="number" bindchange='handlePhone' title="手机号" placeholder="请输入手机号" />
<view class="color-red">{{ errMessage }}</view>
</i-modal>
<!-- 弹窗 -->
<i-toast id="toast" />
\ No newline at end of file
......@@ -120,3 +120,10 @@ page {
.num-picker{
width: 100px;
}
.color-red{
color: #ed3f14;
text-align: left;
padding-top:20rpx;
padding-left: 60rpx;
}
\ No newline at end of file
......@@ -14,13 +14,17 @@ Page({
value2: 0.1,
visible2: false,
vip_price: 49.9,
order: {},
user: {},
phone:'',
formPhone:'',
name: '',
address: '',
wx_number: '',
sessionId: ''
sessionId: '',
visible: false,
errMsg: false,
errMessage:''
},
handleChange1({
......@@ -333,5 +337,73 @@ Page({
api.me.vipOrderSendTemplate(params).then(res => {
typeof callback == "function" && callback(res)
})
},
/**
* 保存手机号
*/
savePhone() {
//发送请求保存手机号
const phone = this.data.formPhone
api.getPhoneNumber({
phone: phone
}).then(res => {
if (!res.code) {
// 将刚拿到的手机号码放到全局数据中,否则phone数据只会是当前页面数据
if (app.globalData.userInfo) {
app.globalData.userInfo.phone = res.data.phone
}
this.setData({
phone: res.data.phone,
visible: false
})
if (res.is_relation) {
$Toast({
content: '温馨提示:手机号授权成功,系统已自动关联您在其他平台购买的美行者VIP会员',
type: 'success'
});
} else {
$Toast({
content: '手机号授权成功',
type: 'success'
});
}
//在拉去一遍用户信息
this.getUserInfo();
} else {
this.setData({
'errMsg': true,
'errMessage': '*' + res.msg
})
}
})
},
/**
* 关闭手机号填写弹窗
*/
alertClose() {
this.setData({
visible: false
});
},
/**
* 打开手机号填写弹窗
*/
openAlert() {
this.setData({
visible: true
})
},
handlePhone: function (event) {
this.setData({
formPhone: event.detail.detail.value
})
},
})
\ No newline at end of file
......@@ -26,7 +26,7 @@
<view class='phoneGive' wx:if="{{!user.phone}}">
<text>手机号</text>
<button bindgetphonenumber="handlePhoneAuth" open-type="getPhoneNumber">授权</button>
<button bindtap='openAlert'>填写手机号</button>
</view>
<i-input wx:else title="手机号" type="text" right="true" value="{{ user.phone }}" placeholder="请输入手机号" disabled/>
......@@ -42,8 +42,13 @@
</i-row>
<!-- toast弹窗 -->
<i-toast id="toast" />
<i-toast id="toast" class="alert-index" />
<i-modal visible="{{ visible2 }}" bind:ok="modelCancel" title="温馨提示" show-cancel="{{false}}">
<!-- <i-modal visible="{{ visible2 }}" bind:ok="modelCancel" title="温馨提示" show-cancel="{{false}}">
<view class="modelCancel">系统已自动关联您在其他平台购买的美行者VIP会员,请点击确定查看详情</view>
</i-modal> -->
<!-- 手机号授权框 -->
<i-modal title="填写手机号" visible="{{ visible }}" bind:ok="savePhone" bind:cancel="alertClose">
<i-input error="{{ errMsg }}" value="{{ value }}" type="number" bindchange='handlePhone' title="手机号" placeholder="请输入手机号" />
<view class="color-red">{{ errMessage }}</view>
</i-modal>
\ No newline at end of file
......@@ -124,3 +124,11 @@ page {
width: 90%;
margin: auto;
}
.color-red{
color: #ed3f14;
text-align: left;
padding-top:20rpx;
padding-left: 60rpx;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
......
......@@ -15,7 +15,7 @@ export const shareTicket = params => {
}
export const getPhoneNumber = params => {
return req.post('user/getPhoneNumber2', params).then(res => res.data)
return req.post('user/savePhone', params).then(res => res.data)
}
export const getSessionKey = params => {
......
//正式
export const Config = {
apiPath: "https://wxapp.maveler.com/api/",
mobPath: "https://wxapp.maveler.com/mob/",
shopJoinPath: "https://wxapp.maveler.com/mob/Index/shopjoin"
}
// //测试
// export const Config = {
// apiPath: "https://meixzz.usa1.utools.club/api/",
// mobPath: "https://meixzz.usa1.utools.club/mob/",
// shopJoinPath: "https://meixzz.usa1.utools.club/mob/Index/shopjoin"
// }
export default Config
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment