发送数据用于登录

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({ wx.login({
success: function (res) { success: function (res) {
if (res.code) { if (res.code) {
that.globalData.code = res.code
wx.getUserInfo({ wx.getUserInfo({
success: function (res) { success: function (res) {
that.globalData.userInfo = res.userInfo that.globalData.userInfo = res.userInfo
that.globalData.code = res.code
typeof cb == "function" && cb(that.globalData.userInfo) typeof cb == "function" && cb(that.globalData.userInfo)
} }
}) })

@ -5,7 +5,7 @@ const profile = require('../../utils/profile.js')
Page({ Page({
data: { data: {
needBindMobile: true, needBindMobile: true,
mobile: '',
userInfo: null, userInfo: null,
zichan_slides: [], zichan_slides: [],
xunZhang: 'https://bayewechat.oss-cn-shanghai.aliyuncs.com/rassets/revision/' + 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) { 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 var baye_rank = currentCustomer.baye_rank
that.setData({baye_rank: baye_rank}) that.setData({baye_rank: baye_rank})

@ -14,17 +14,20 @@
<view class="separate"></view> <view class="separate"></view>
<view wx:if="{{needBindMobile}}"> <view wx:if="{{needBindMobile}}">
<view class="check mobile"> <form bindsubmit="bindGetPassCode">
<text>绑定手机号:</text> <view class="check mobile">
<input></input> <text>绑定手机号:</text>
<button bindtap="bindGetPassCode">获取验证码</button> <input name="mobile"></input>
</view> <button formType="submit">获取验证码</button>
<view class="check code"> </view>
<text>输入验证码:</text> </form>
<input></input> <form bindsubmit="bindSubmitMobile">
<button bindtap="bindSubmitMobile">提交</button> <view class="check code">
</view> <text>输入验证码:</text>
<input name="code"></input>
<button formType="submit">提交</button>
</view>
</form>
</view> </view>
<view wx:else> <view wx:else>
<view class="zichan"> <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({ wx.request({
url: `${app.globalData.API_URL}/sessions/new`, url: `${app.globalData.API_URL}/sessions/new`,
header: { 'Content-Type': 'application/json'}, header: { 'Content-Type': 'application/json'},
data: { data: data,
code: app.globalData.code,
mobile: customerMobile,
name: app.globalData.userInfo.nickName
},
success: function(res) { success: function(res) {
app.globalData.currentCustomer = res.data.customer app.globalData.currentCustomer = res.data.customer
app.globalData.token = res.data.token app.globalData.token = res.data.token

Loading…
Cancel
Save