发送数据用于登录

wechat_user_type
Ge Hao 8 years ago
parent cde539f10f
commit b280843b54
  1. 2
      app.js
  2. 11
      pages/mine/mine.js
  3. 25
      pages/mine/mine.wxml
  4. 10
      utils/profile.js

@ -13,10 +13,10 @@ App({
wx.login({
success: function (res) {
if (res.code) {
that.globalData.code = res.code
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
that.globalData.code = res.code
typeof cb == "function" && cb(that.globalData.userInfo)
}
})

@ -5,7 +5,7 @@ const profile = require('../../utils/profile.js')
Page({
data: {
needBindMobile: true,
mobile: '',
userInfo: null,
zichan_slides: [],
xunZhang: 'https://bayewechat.oss-cn-shanghai.aliyuncs.com/rassets/revision/' +
@ -23,14 +23,15 @@ Page({
})
},
bindGetPassCode: function() {
bindGetPassCode: function(e) {
this.setData({mobile: e.detail.value.mobile})
},
bindSubmitMobile: function(e) {
var mobile = this.detail
var mobile = this.data.mobile
var data = {mobile_code: this.data.mobile, code: e.detail.value.code}
profile.getCustomerInfo(this.data.currentMobile, function(currentCustomer){
profile.getCustomerInfo(data, function(currentCustomer){
var baye_rank = currentCustomer.baye_rank
that.setData({baye_rank: baye_rank})

@ -14,17 +14,20 @@
<view class="separate"></view>
<view wx:if="{{needBindMobile}}">
<view class="check mobile">
<text>绑定手机号:</text>
<input></input>
<button bindtap="bindGetPassCode">获取验证码</button>
</view>
<view class="check code">
<text>输入验证码:</text>
<input></input>
<button bindtap="bindSubmitMobile">提交</button>
</view>
<form bindsubmit="bindGetPassCode">
<view class="check mobile">
<text>绑定手机号:</text>
<input name="mobile"></input>
<button formType="submit">获取验证码</button>
</view>
</form>
<form bindsubmit="bindSubmitMobile">
<view class="check code">
<text>输入验证码:</text>
<input name="code"></input>
<button formType="submit">提交</button>
</view>
</form>
</view>
<view wx:else>
<view class="zichan">

@ -10,15 +10,13 @@ function getZichanSlides (resolve) {
})
}
function getCustomerInfo (customerMobile, cb) {
function getCustomerInfo (data, cb) {
data['code'] = app.globalData.code
data['name'] = app.globalData.userInfo.nickName
wx.request({
url: `${app.globalData.API_URL}/sessions/new`,
header: { 'Content-Type': 'application/json'},
data: {
code: app.globalData.code,
mobile: customerMobile,
name: app.globalData.userInfo.nickName
},
data: data,
success: function(res) {
app.globalData.currentCustomer = res.data.customer
app.globalData.token = res.data.token

Loading…
Cancel
Save