diff --git a/app.js b/app.js index 654aca5..5de24f6 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,5 @@ const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js') require('utils/polyfill.js') -var profileUtil = require('utils/profile.js') App({ onLaunch: function () { @@ -10,7 +9,7 @@ App({ this.globalData.code = wx.getStorageSync('code') this.getUserInfo(function() { - profileUtil.postEncryptedData(function(res){ + that.postEncryptedData(function(res){ that.globalData.wechatUserType = res.data.wechat_user_type }) }) @@ -126,6 +125,20 @@ App({ } }, + postEncryptedData: function (resolve) { + this.request({ + method: 'POST', + url: `${this.globalData.API_URL}/sessions/wechat_user_type`, + data: { + code: this.globalData.code, + encrypted: this.globalData.encrypted, + userInfo: this.globalData.userInfo + }, + success: resolve, + fail: function(res) {} + }) + }, + globalData:{ wechatUserType: 'normal', featureManager: {}, diff --git a/utils/profile.js b/utils/profile.js index 3c47be3..610ce5c 100644 --- a/utils/profile.js +++ b/utils/profile.js @@ -1,6 +1,6 @@ const app = getApp() -function getZichanSlides (resolve) { +export function getZichanSlides (resolve) { app.authRequest({ url: `${app.globalData.API_URL}/my_assets`, header: { 'Content-Type': 'application/json'}, @@ -9,7 +9,7 @@ function getZichanSlides (resolve) { }) } -function postCustomerInfo (data, cb) { +export function postCustomerInfo (data, cb) { data['code'] = app.globalData.code data['encrypted'] = app.globalData.encrypted app.request({ @@ -45,7 +45,7 @@ function postCustomerInfo (data, cb) { }) } -function getPassCode (mobile, cb) { +export function getPassCode (mobile, cb) { app.request({ url: `${app.globalData.API_URL}/send_validation_code/send_message`, header: { 'Content-Type': 'application/json'}, @@ -58,33 +58,3 @@ function getPassCode (mobile, cb) { }) } -function postEncryptedData (resolve) { - var app = getApp() - app.request({ - method: 'POST', - url: `${app.globalData.API_URL}/sessions/wechat_user_type`, - data: { - code: app.globalData.code, - encrypted: app.globalData.encrypted, - userInfo: app.globalData.userInfo - }, - success: resolve, - fail: function(res) {} - }) -} - -module.exports = { - getZichanSlides (resolve) { - return getZichanSlides(resolve) - }, - postCustomerInfo (data, resolve) { - return postCustomerInfo(data, resolve) - }, - getPassCode (mobile, cb) { - return getPassCode(mobile, cb) - }, - - postEncryptedData (resolve) { - return postEncryptedData(resolve) - } -} \ No newline at end of file