From b280843b546d531380a6974dd694481bb0f4b2d3 Mon Sep 17 00:00:00 2001 From: Ge Hao Date: Tue, 8 Nov 2016 15:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=95=B0=E6=8D=AE=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- pages/mine/mine.js | 11 ++++++----- pages/mine/mine.wxml | 25 ++++++++++++++----------- utils/profile.js | 10 ++++------ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 7562555..5e6cdf5 100644 --- a/app.js +++ b/app.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) } }) diff --git a/pages/mine/mine.js b/pages/mine/mine.js index b7ddcc3..3bfc9c2 100644 --- a/pages/mine/mine.js +++ b/pages/mine/mine.js @@ -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}) diff --git a/pages/mine/mine.wxml b/pages/mine/mine.wxml index fc9ad7c..d7ce40b 100644 --- a/pages/mine/mine.wxml +++ b/pages/mine/mine.wxml @@ -14,17 +14,20 @@ - - 绑定手机号: - - - - - 输入验证码: - - - - +
+ + 绑定手机号: + + + +
+
+ + 输入验证码: + + + +
diff --git a/utils/profile.js b/utils/profile.js index 1abe833..43c545c 100644 --- a/utils/profile.js +++ b/utils/profile.js @@ -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