From 07f4f8f3dde82821d95f926b7b5c8b5721cb2ff2 Mon Sep 17 00:00:00 2001 From: Ge Hao Date: Wed, 11 Jan 2017 10:24:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=B3=95=E8=8E=B7=E5=8F=96app?= =?UTF-8?q?=EF=BC=8C=E7=84=B6=E5=90=8E=E6=8F=90=E5=89=8Drequire=E4=BC=9A?= =?UTF-8?q?=E4=BD=BF=E5=85=B6=E4=BB=96=E5=87=BD=E6=95=B0=E7=94=A8=E7=9A=84?= =?UTF-8?q?app=E4=B9=9F=E6=98=AFundefined=EF=BC=8C=E6=89=80=E4=BB=A5?= =?UTF-8?q?=E5=88=86=E5=BC=80=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 17 +++++++++++++++-- utils/profile.js | 36 +++--------------------------------- 2 files changed, 18 insertions(+), 35 deletions(-) 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