From ed38637a58dc1cbf67b62dea1a63ad9a6050d3df Mon Sep 17 00:00:00 2001 From: Ge Hao Date: Thu, 10 Nov 2016 17:03:21 +0800 Subject: [PATCH] sessions new staging test version --- app.js | 2 ++ pages/mine/mine.js | 39 ++++++++++++++++++++++++--------------- utils/profile.js | 3 +-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/app.js b/app.js index 5e6cdf5..3709681 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ App({ const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js') this.store = new(jsonApi.JsonApiDataStore) this.jsonModel = jsonApi.JsonApiDataStoreModel + this.globalData.code = wx.getStorageSync('code') }, getUserInfo: function (cb) { @@ -14,6 +15,7 @@ App({ success: function (res) { if (res.code) { that.globalData.code = res.code + wx.setStorageSync('code', res.code) wx.getUserInfo({ success: function (res) { that.globalData.userInfo = res.userInfo diff --git a/pages/mine/mine.js b/pages/mine/mine.js index 4367907..295530f 100644 --- a/pages/mine/mine.js +++ b/pages/mine/mine.js @@ -18,6 +18,12 @@ Page({ onLoad: function() { var that = this + var token = wx.getStorageSync('userToken') + if (token) { + that.setData({needBindMobile: false}) + var data = {token: token} + profile.getCustomerInfo(data, that.infoCallback) + } app.getUserInfo(function(userInfo){ that.setData({userInfo:userInfo}) }) @@ -25,25 +31,28 @@ Page({ bindGetPassCode: function(e) { this.setData({mobile: e.detail.value.mobile}) + profile.getPassCode(this.data.mobile) }, bindSubmitMobile: function(e) { - var mobile = this.data.mobile - var data = {mobile: this.data.mobile, mobile_code: e.detail.value.code} - - profile.getCustomerInfo(data, function(currentCustomer){ - var baye_rank = currentCustomer.baye_rank - that.setData({baye_rank: baye_rank}) - - profile.getZichanSlides(function(result) { - var data = getApp().store.sync(result.data) - that.setData({'zichan_slides': data}) - wx.setStorage({ - key:"zichan_slides", - data:data - }) + var data = {mobile: this.data.mobile, mobile_code: e.detail.value.code, name: app.globalData.userInfo.nickName} + profile.getCustomerInfo(data, this.infoCallback) + }, + + infoCallback: function(currentCustomer) { + var that = this + var baye_rank = currentCustomer.baye_rank + that.setData({baye_rank: baye_rank}) + + profile.getZichanSlides(function(result) { + debugger + var data = getApp().store.sync(result.data) + that.setData({'zichan_slides': data}) + wx.setStorage({ + key:"zichan_slides", + data:data }) }) - }, + } }) \ No newline at end of file diff --git a/utils/profile.js b/utils/profile.js index 52ac6af..24826ed 100644 --- a/utils/profile.js +++ b/utils/profile.js @@ -12,7 +12,6 @@ function getZichanSlides (resolve) { 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'}, @@ -33,7 +32,7 @@ function getCustomerInfo (data, cb) { function getPassCode (mobile) { wx.request({ - url: `${app.globalData.API_URL}/profile/send_pass_code`, + url: `${app.globalData.API_URL}/profiles/get_mobile_passcode`, header: { 'Content-Type': 'application/json'}, data: { mobile: mobile