没法获取app,然后提前require会使其他函数用的app也是undefined,所以分开吧

wechat_user_type
Ge Hao 7 years ago
parent 3192286227
commit 07f4f8f3dd
  1. 17
      app.js
  2. 36
      utils/profile.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: {},

@ -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)
}
}
Loading…
Cancel
Save