Commit 276a8da8 by LiuJunYi

微信登陆和授权问题

parent b6337ef1
...@@ -16,9 +16,9 @@ Page({ ...@@ -16,9 +16,9 @@ Page({
detail: {}, detail: {},
user: {}, user: {},
loading: false, loading: false,
familyNum: 0, familyNum: 0,
phone: '', phone: '',
formPhone:'',
nickname: '', nickname: '',
adultNum: 0, adultNum: 0,
childrenNum: 0, childrenNum: 0,
...@@ -28,7 +28,9 @@ Page({ ...@@ -28,7 +28,9 @@ Page({
// 订单 // 订单
order: {}, order: {},
nums: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 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({ ...@@ -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() { onReady: function() {
...@@ -241,6 +321,12 @@ Page({ ...@@ -241,6 +321,12 @@ Page({
}) })
}, },
handlePhone: function (event) {
this.setData({
formPhone: event.detail.detail.value
})
},
handleAdultNum: function(event) { handleAdultNum: function(event) {
this.setData({ this.setData({
adultNum: parseInt(event.detail.value) adultNum: parseInt(event.detail.value)
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
"navigationBarTitleText": "立即报名", "navigationBarTitleText": "立即报名",
"usingComponents": { "usingComponents": {
"i-input-number": "/iview/input-number/index", "i-input-number": "/iview/input-number/index",
"i-input": "/iview/input/index",
"i-row": "/iview/row/index", "i-row": "/iview/row/index",
"i-col": "/iview/col/index", "i-col": "/iview/col/index",
"i-button": "/iview/button/index", "i-button": "/iview/button/index",
"i-cell-group": "/iview/cell-group/index", "i-cell-group": "/iview/cell-group/index",
"i-cell": "/iview/cell/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 @@ ...@@ -44,7 +44,7 @@
</i-cell> </i-cell>
<i-cell title="手机号" i-class="cell-class"> <i-cell title="手机号" i-class="cell-class">
<block wx:if="{{phone.length == 0}}"> <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>
<block wx:else> <block wx:else>
<text slot="footer">{{phone}}</text> <text slot="footer">{{phone}}</text>
...@@ -82,4 +82,13 @@ ...@@ -82,4 +82,13 @@
</i-row> </i-row>
</view> </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" /> <i-toast id="toast" />
\ No newline at end of file
...@@ -119,4 +119,11 @@ page { ...@@ -119,4 +119,11 @@ page {
.num-picker{ .num-picker{
width: 100px; 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({ ...@@ -14,13 +14,17 @@ Page({
value2: 0.1, value2: 0.1,
visible2: false, visible2: false,
vip_price: 49.9, vip_price: 49.9,
order: {}, order: {},
user: {}, user: {},
phone:'',
formPhone:'',
name: '', name: '',
address: '', address: '',
wx_number: '', wx_number: '',
sessionId: '' sessionId: '',
visible: false,
errMsg: false,
errMessage:''
}, },
handleChange1({ handleChange1({
...@@ -333,5 +337,73 @@ Page({ ...@@ -333,5 +337,73 @@ Page({
api.me.vipOrderSendTemplate(params).then(res => { api.me.vipOrderSendTemplate(params).then(res => {
typeof callback == "function" && callback(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 @@ ...@@ -26,7 +26,7 @@
<view class='phoneGive' wx:if="{{!user.phone}}"> <view class='phoneGive' wx:if="{{!user.phone}}">
<text>手机号</text> <text>手机号</text>
<button bindgetphonenumber="handlePhoneAuth" open-type="getPhoneNumber">授权</button> <button bindtap='openAlert'>填写手机号</button>
</view> </view>
<i-input wx:else title="手机号" type="text" right="true" value="{{ user.phone }}" placeholder="请输入手机号" disabled/> <i-input wx:else title="手机号" type="text" right="true" value="{{ user.phone }}" placeholder="请输入手机号" disabled/>
...@@ -42,8 +42,13 @@ ...@@ -42,8 +42,13 @@
</i-row> </i-row>
<!-- toast弹窗 --> <!-- 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> <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> </i-modal>
\ No newline at end of file
...@@ -124,3 +124,11 @@ page { ...@@ -124,3 +124,11 @@ page {
width: 90%; width: 90%;
margin: auto; 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 @@ ...@@ -4,7 +4,7 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": true, "urlCheck": false,
"es6": true, "es6": true,
"postcss": true, "postcss": true,
"minified": true, "minified": true,
......
...@@ -15,7 +15,7 @@ export const shareTicket = params => { ...@@ -15,7 +15,7 @@ export const shareTicket = params => {
} }
export const getPhoneNumber = 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 getSessionKey = params => {
......
//正式
export const Config = { export const Config = {
apiPath: "https://wxapp.maveler.com/api/", apiPath: "https://wxapp.maveler.com/api/",
mobPath: "https://wxapp.maveler.com/mob/", mobPath: "https://wxapp.maveler.com/mob/",
shopJoinPath: "https://wxapp.maveler.com/mob/Index/shopjoin" 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 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