sessions new staging test version

wechat_user_type
Ge Hao 8 years ago
parent 942a4cda8d
commit ed38637a58
  1. 2
      app.js
  2. 39
      pages/mine/mine.js
  3. 3
      utils/profile.js

@ -3,6 +3,7 @@ App({
const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js') const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js')
this.store = new(jsonApi.JsonApiDataStore) this.store = new(jsonApi.JsonApiDataStore)
this.jsonModel = jsonApi.JsonApiDataStoreModel this.jsonModel = jsonApi.JsonApiDataStoreModel
this.globalData.code = wx.getStorageSync('code')
}, },
getUserInfo: function (cb) { getUserInfo: function (cb) {
@ -14,6 +15,7 @@ App({
success: function (res) { success: function (res) {
if (res.code) { if (res.code) {
that.globalData.code = res.code that.globalData.code = res.code
wx.setStorageSync('code', res.code)
wx.getUserInfo({ wx.getUserInfo({
success: function (res) { success: function (res) {
that.globalData.userInfo = res.userInfo that.globalData.userInfo = res.userInfo

@ -18,6 +18,12 @@ Page({
onLoad: function() { onLoad: function() {
var that = this 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){ app.getUserInfo(function(userInfo){
that.setData({userInfo:userInfo}) that.setData({userInfo:userInfo})
}) })
@ -25,25 +31,28 @@ Page({
bindGetPassCode: function(e) { bindGetPassCode: function(e) {
this.setData({mobile: e.detail.value.mobile}) this.setData({mobile: e.detail.value.mobile})
profile.getPassCode(this.data.mobile)
}, },
bindSubmitMobile: function(e) { bindSubmitMobile: function(e) {
var mobile = this.data.mobile var data = {mobile: this.data.mobile, mobile_code: e.detail.value.code, name: app.globalData.userInfo.nickName}
var data = {mobile: this.data.mobile, mobile_code: e.detail.value.code} profile.getCustomerInfo(data, this.infoCallback)
},
profile.getCustomerInfo(data, function(currentCustomer){
var baye_rank = currentCustomer.baye_rank infoCallback: function(currentCustomer) {
that.setData({baye_rank: baye_rank}) var that = this
var baye_rank = currentCustomer.baye_rank
profile.getZichanSlides(function(result) { that.setData({baye_rank: baye_rank})
var data = getApp().store.sync(result.data)
that.setData({'zichan_slides': data}) profile.getZichanSlides(function(result) {
wx.setStorage({ debugger
key:"zichan_slides", var data = getApp().store.sync(result.data)
data:data that.setData({'zichan_slides': data})
}) wx.setStorage({
key:"zichan_slides",
data:data
}) })
}) })
}, }
}) })

@ -12,7 +12,6 @@ function getZichanSlides (resolve) {
function getCustomerInfo (data, cb) { function getCustomerInfo (data, cb) {
data['code'] = app.globalData.code 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'},
@ -33,7 +32,7 @@ function getCustomerInfo (data, cb) {
function getPassCode (mobile) { function getPassCode (mobile) {
wx.request({ 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'}, header: { 'Content-Type': 'application/json'},
data: { data: {
mobile: mobile mobile: mobile

Loading…
Cancel
Save