Authored by 李奇

修改接口508

... ... @@ -2,433 +2,355 @@
import wx from './utils/wx';
import udid from './common/udid';
import event from './common/event';
import promisify from './common/promisify';
import objectAssign from './vendors/object-assign';
import {WeToast} from './vendors/toast/wetoast';
import config from './common/config';
import {GET, POST} from './common/request';
import {Encrypt,Decrypt} from './common/aes.js';
let crypto = require('./common/cryptojs/cryptojs.js').Crypto
import md5 from './vendors/md5';
var mta = require('./vendors/mta_analysis.js')
import { wechatLoginAction } from './utils/login';
import { isStringEmpty } from './utils/util';
import { logEvent,
YB_LAUNCH_APP,
YB_EXIT_APP,
YB_ENTER_FOREGROUND,
YB_ENTER_BACKGROUND,
YB_PAGE_OPEN_L,
YB_AWAKE_MP
} from './common/analytics.js';
import { appReport } from './common/appReport.js';
import {wechatLoginAction} from './utils/login';
import {isStringEmpty} from './utils/util';
App({
onLaunch: function (options) {
let that = this;
let res = wx.getSystemInfoSync();
if (!res.screenHeight) {
res.screenHeight = res.windowHeight;
}
if (!res.screenWidth) {
res.screenWidth = res.windowWidth;
}
this.globalData.systemInfo = res;
this.checkUDID();
that.getSimplePise()
this.checkNetworkType()
if (options && options.scene){
this.globalData.ch = options.scene
}
if (options && options.query && options.query.union_type){
this.globalData.union_type = options.query.union_type
}
wx.checkSession({
success: function () {
//登录态未过期
that.getWechatThirdSession();
that.getUserInfo();
that.getUnionID();
},
fail: function () {
//登录态过期
wx.setStorage({
key: "WXThird_session",
data: ''
});
wx.setStorage({
key: "userInfo",
data: {}
});
onLaunch: function (options) {
let that = this;
let res = wx.getSystemInfoSync();
if (!res.screenHeight) {
res.screenHeight = res.windowHeight;
}
if (!res.screenWidth) {
res.screenWidth = res.windowWidth;
}
wx.setStorage({
key: "unionID",
data: ""
this.globalData.systemInfo = res;
this.checkUDID();
that.getSimplePise();
this.checkNetworkType();
if (options && options.scene) {
this.globalData.ch = options.scene
}
if (options && options.query && options.query.union_type) {
this.globalData.union_type = options.query.union_type
}
wx.checkSession({
success: function () {
//登录态未过期
that.getWechatThirdSession();
that.getUserInfo();
that.getUnionID();
},
fail: function () {
//登录态过期
wx.setStorage({
key: "WXThird_session",
data: ''
});
wx.setStorage({
key: "userInfo",
data: {}
});
wx.setStorage({
key: "unionID",
data: ""
});
}
});
}
})
this.getSessionkey();
let timestamp = new Date().getTime() + ''
this.globalData.sid = md5(timestamp);
if (options){
let channel = options.query.channel;
let channelType = options.query.type;
let params = { 'CHANNEL': channel, 'TYPE': channelType };
logEvent(YB_LAUNCH_APP, params, this);
}
setTimeout(function () {
wechatLoginAction(function (response) {});}, 1000);
this.mtainit(options);
},
//当应用程序进入前台显示状态时触发
onShow(options) {
let that = this
let params = {};
logEvent(YB_ENTER_FOREGROUND, params, this)
if (that.globalData.hasReportAwakeAction==='false'){
let pathParam = ""
if(options && options.query) {
for (var Key in options.query) {
if (pathParam.length == 0) {
pathParam = Key + '=' + options.query[Key] + '';
} else {
pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
}
this.getSessionkey();
let timestamp = new Date().getTime() + '';
this.globalData.sid = md5(timestamp);
if (options) {
let channel = options.query.channel;
let channelType = options.query.type;
let params = {'CHANNEL': channel, 'TYPE': channelType};
}
setTimeout(function () {
wechatLoginAction(() => '');
}, 1000);
this.mtainit(options);
},
onShow() {},
onHide () {},
getUserInfo: function () {
try {
var value = wx.getStorageSync('userInfo')
if (value) {
this.globalData.userInfo = value;
}
} catch (e) {
// console.log(e)
}
}
let path
if(pathParam!==""){
path = options.path + "?" + pathParam
}else{
path = options.path
}
params = {
PAGE_PATH: path
};
logEvent(YB_AWAKE_MP, params, this);
that.globalData.hasReportAwakeAction = 'true'
}
appReport('start', "LIFECYCLE", "RESUME", {},this)
},
//当应用程序进入后台状态时触发
onHide () {
let params = {};
logEvent(YB_ENTER_BACKGROUND,params)
appReport('start', "LIFECYCLE", "STOP", {},this)
},
getUserInfo: function () {
try {
var value = wx.getStorageSync('userInfo')
if (value) {
this.globalData.userInfo = value;
}
} catch (e) {
// console.log(e)
}
},
getUnionID: function () {
try {
var value = wx.getStorageSync('unionID')
if (value) {
this.globalData.WXUnion_ID = value;
}
} catch (e) {
// console.log(e)
}
},
getWechatThirdSession: function () {
try {
var that = this
var value = this.globalData.WXThird_session
if (!isStringEmpty(value)) {
that.globalData.WXThird_session = value;
}else{
value = wx.getStorageSync('WXThird_session')
}
return value
} catch (e) {
// console.log(e)
}
},
setUserInfo: function (cb) {
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
},
setSessionkey: function (sessionkey) {
this.globalData.sessionkey = sessionkey;
wx.setStorage({
key: "sessionkey",
data: this.globalData.sessionkey
})
},
setWechatThirdSession: function (session) {
this.globalData.WXThird_session = session;
wx.setStorage({
key: "WXThird_session",
data: this.globalData.WXThird_session
})
},
setWXUnionID: function (unionID) {
this.globalData.WXUnion_ID = unionID;
wx.setStorage({
key: "unionID",
data: unionID
})
},
setOpenID:function(openID){
if(openID=='') return
this.globalData.openID = openID;
wx.setStorage({
key: "openID",
data: openID
})
},
getOpenID: function () {
let openid = ''
if (!isStringEmpty(this.globalData.openID)){
openid = this.globalData.openID
}else{
openid = wx.getStorageSync('openID')
this.globalData.openID = openid
}
return openid
},
updateUid: function (uid) {
this.getUserInfo();
this.globalData.userInfo.uid = uid;
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
},
globalData: {
selectedChannel: 'boy',
userInfo: {},
systemInfo: null,
WXThird_session: '',
WXUnion_ID: '',
openID:'',
p2SecretKey: '',
sessionkey: '',
sid: '',
udid:'',
cid:'1',
mobileRegisterState:'',
hasReportAwakeAction: 'false',
defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
miniapp_type: config.constants.MINI_APP_TYPE,
union_type:'',
ch:'',
networkType:'0',
deviceInfo:{},
},
isLogin: function () {
return this.globalData.userInfo != null &&
// this.globalData.userInfo.uid != undefined &&
// this.globalData.userInfo.uid != null &&
// this.globalData.userInfo.uid != '' &&
this.globalData.WXThird_session != '' &&
this.globalData.WXThird_session != null &&
this.globalData.WXThird_session != undefined;
},
getUid: function () {
let uid = this.globalData.userInfo.uid
if(!uid||uid===0){
this.getUserInfo();
uid = this.globalData.userInfo.uid
}
return uid;
},
getMiniappType:function(){
return config.constants.MINI_APP_TYPE
},
//获取加签的秘钥
getSimplePise: function () {
let that = this
let data = {
"udid": that.globalData.udid,
"method": 'resources.simple.pice'}
let method = "GET"
let header = {
'Content-Type': 'application/x-www-form-urlencoded'
}
wx.request({
url:config.constants.API_HOST,
data,
method,
header: header,
success: function (res) {
// console.log("res:", res)
if (res && res.data && res.data.data && res.data.data.sk){
that.globalData.p2SecretKey = res.data.data.sk;
wx.setStorage({
key: "p2SecretKey",
data: res.data.data.sk
});
},
getUnionID: function () {
try {
var value = wx.getStorageSync('unionID')
if (value) {
this.globalData.WXUnion_ID = value;
}
} catch (e) {
// console.log(e)
}
},
fail: function (err) {
// console.log("err:",err)
}
});
},
fastloginSwitch: function () {
let that = this
let param = {
method: 'app.passport.fastloginSwitch',
};
GET(config.constants.API_HOST, param)
.then(json => {
// if (!json || !json.code || json.code != 200 || !json.data) return;
// if (!json.data || !json.data.sk) return;
// let p2SecretKey = json.data.sk;
// if (!p2SecretKey) return;
// that.globalData.p2SecretKey = p2SecretKey;
// wx.setStorage({
// key: "p2SecretKey",
// data: p2SecretKey
// });
})
.catch(error => {
});
},
checkUDID:function(){
let that = this
try {
var value = wx.getStorageSync('udid')
if (value) {
that.globalData.udid = value;
}else{
let udidValue = md5(that.getUUID());
that.globalData.udid = udidValue;
},
getWechatThirdSession: function () {
try {
wx.setStorageSync('udid', udidValue)
var that = this
var value = this.globalData.WXThird_session
if (!isStringEmpty(value)) {
that.globalData.WXThird_session = value;
} else {
value = wx.getStorageSync('WXThird_session')
}
return value
} catch (e) {
// console.log(e)
}
}
//获取签名秘钥
} catch (e) {
// Do something when catch error
// console.log("checkUDID error: " + e)
}
},
checkNetworkType:function(){
let that = this;
let net = '';
wx.getNetworkType({
success: function (res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
if (networkType === 'wifi') {
net = '1';
} else if (networkType === '2g') {
net = '2';
} else if (networkType === '3g') {
net = '3';
} else if (networkType === '4g') {
net = '4';
},
setUserInfo: function (cb) {
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
},
setSessionkey: function (sessionkey) {
this.globalData.sessionkey = sessionkey;
wx.setStorage({
key: "sessionkey",
data: this.globalData.sessionkey
})
},
setWechatThirdSession: function (session) {
this.globalData.WXThird_session = session;
wx.setStorage({
key: "WXThird_session",
data: this.globalData.WXThird_session
})
},
setWXUnionID: function (unionID) {
this.globalData.WXUnion_ID = unionID;
wx.setStorage({
key: "unionID",
data: unionID
})
},
setOpenID: function (openID) {
if (openID == '') return
this.globalData.openID = openID;
wx.setStorage({
key: "openID",
data: openID
})
},
getOpenID: function () {
let openid = ''
if (!isStringEmpty(this.globalData.openID)) {
openid = this.globalData.openID
} else {
net = '0';
openid = wx.getStorageSync('openID')
this.globalData.openID = openid
}
return openid
},
updateUid: function (uid) {
this.getUserInfo();
this.globalData.userInfo.uid = uid;
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
},
globalData: {
selectedChannel: 'boy',
userInfo: {},
systemInfo: null,
WXThird_session: '',
WXUnion_ID: '',
openID: '',
p2SecretKey: '',
sessionkey: '',
sid: '',
udid: '',
cid: '1',
mobileRegisterState: '',
hasReportAwakeAction: 'false',
defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
miniapp_type: config.constants.MINI_APP_TYPE,
union_type: '',
ch: '',
networkType: '0',
deviceInfo: {}
},
isLogin: function () {
return this.globalData.userInfo != null &&
this.globalData.WXThird_session != '' &&
this.globalData.WXThird_session != null &&
this.globalData.WXThird_session != undefined;
},
getUid: function () {
let uid = this.globalData.userInfo.uid
if (!uid || uid === 0) {
this.getUserInfo();
uid = this.globalData.userInfo.uid
}
return uid;
},
getMiniappType: function () {
return config.constants.MINI_APP_TYPE
},
//获取加签的秘钥
getSimplePise: function () {
let that = this
let data = {
"udid": that.globalData.udid,
"method": 'resources.simple.pice'
}
// console.log("network:",net)
},
complete:function(res){
appReport('start', "LIFECYCLE", "START", {}, that)
}
})
that.globalData.networkType = net;
},
getUUID: function () {
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
return value;
},
loginCallBack: function (response) {
// console.log(response)
// if (response.code === 10001) {
// this.showRelaunchModal();
// }
},
showRelaunchModal: function () {
wx.showModal({
title: '提示',
content: '使用微信小程序需要微信授权,您已经拒绝了该请求,请删除小程序重新进入。',
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
})
let method = "GET"
let header = {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
})
},
getSessionkey: function () {
if (this.isLogin) {
try {
var value = wx.getStorageSync('sessionkey')
if (value) {
// console.log(value)
this.globalData.sessionkey = value;
wx.request({
url: config.constants.API_HOST,
data,
method,
header: header,
success: function (res) {
if (res && res.data && res.data.data && res.data.data.sk) {
that.globalData.p2SecretKey = res.data.data.sk;
wx.setStorage({
key: "p2SecretKey",
data: res.data.data.sk
});
}
},
fail: function (err) {
}
});
},
fastloginSwitch: function () {
let that = this
let param = {
method: 'app.passport.fastloginSwitch'
};
GET(config.constants.API_HOST, param)
.then(json => {
})
.catch(error => {
});
},
checkUDID: function () {
let that = this
try {
var value = wx.getStorageSync('udid')
if (value) {
that.globalData.udid = value;
} else {
let udidValue = md5(that.getUUID());
that.globalData.udid = udidValue;
try {
wx.setStorageSync('udid', udidValue)
} catch (e) {
}
}
//获取签名秘钥
} catch (e) {
}
},
checkNetworkType: function () {
let that = this;
let net = '';
wx.getNetworkType({
success: function (res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
if (networkType === 'wifi') {
net = '1';
} else if (networkType === '2g') {
net = '2';
} else if (networkType === '3g') {
net = '3';
} else if (networkType === '4g') {
net = '4';
} else {
net = '0';
}
// console.log("network:",net)
},
complete: function (res) {
}
})
that.globalData.networkType = net;
},
getUUID: function () {
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
return value;
},
loginCallBack: function (response) {
},
showRelaunchModal: function () {
wx.showModal({
title: '提示',
content: '使用微信小程序需要微信授权,您已经拒绝了该请求,请删除小程序重新进入。',
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
})
}
}
})
},
getSessionkey: function () {
if (this.isLogin) {
try {
var value = wx.getStorageSync('sessionkey')
if (value) {
this.globalData.sessionkey = value;
}
} catch (e) {
}
}
} catch (e) {
// console.log(e)
}
}
return undefined;
},
mtainit(e) {
mta.App.init({
"appID": "500570715",
"eventID": "500570797",
});
// console.log("init mta");
},
WeToast
return undefined;
},
mtainit(e) {},
WeToast
})
... ...
... ... @@ -11,12 +11,14 @@ const config = {
constants: {
LOG_EVENT_HOST: 'https://analysis.yohobuy.com/yas_mobile',
APP_REPORT_HOST: 'https://app.yoho.cn/collect/v3',
API_HOST: 'http://api-test1.yohops.com:9999',
// API_HOST: 'https://api.yoho.cn',
// SERVICE_HOST: 'https://api.yoho.cn',
API_HOST: 'http://api-test1.yohops.com:9999/',
SERVICE_HOST: 'http://api-test1.yohops.com:9999/',
MINI_APP_TYPE: '0',
PAYMENT_CODE: '45',
OS_VERSION: 'yohobuy:h5',
APP_VERSION: '2.2.1',
APP_VERSION: '6.4.0',
APP_BUILD: '1003',
PRIVATE_KEY: 'b43890b0a296ff3c7b8c260ca763980b',
CLIENT_TYPE: 'miniapp',
... ...
... ... @@ -9,87 +9,138 @@ let p1SecretKey = "yoho9646yoho9646"
let ClientInitConfigMehtod = "resources.simple.pice"
let ClientConfigHasRequested = 0
function request(method = 'GET') {
return function(url, params = {}) {
return new Promise(function(resolve, reject) {
let app = getApp();
if (params && !params.hasOwnProperty('uid')) {
let uid = app && app.globalData && app.globalData.userInfo && app.globalData.userInfo.uid ? app.globalData.userInfo.uid : 0;
params.uid = uid;
}
let sessionkey = app && app.globalData && app.globalData.sessionkey ? app.globalData.sessionkey : '';
params.session_key = sessionkey;
params.source_type="wechat";
params.client_type = "miniapp";
params.business_line= "miniapp";
params.user_source ="wechat"
if (params && !params.hasOwnProperty('udid')) {
let udid = app && app.globalData && app.globalData.udid ? app.globalData.udid : "";
if(udid.length==0){
udid=wx.getStorageSync('udid');
}
params.udid = udid;
}
function getPrivateKey(){
return new Promise(function(resolve,reject){
let app = getApp()
let p2SecretKey = app && app.globalData && app.globalData.p2SecretKey;
if (!p2SecretKey){
p2SecretKey = wx.getStorageSync("p2SecretKey")
}
let body = _createBody(params);
let queryStrigPair = _signParam(body,true);
let data = '';
if (p2SecretKey){
resolve(p2SecretKey)
}else{
if (method === 'GET' || method === 'HEAD' || method === 'DELETE') {
url = url + '?' + queryStrigPair;
}
if (method !== 'GET' && method !== 'HEAD') {
data = queryStrigPair;
}
//加签
let resultString = "";
if((params.hasOwnProperty("method") && params["method"] ===ClientInitConfigMehtod)){
}else{
let p2SecretKey = app && app.globalData && app.globalData.p2SecretKey ? app.globalData.p2SecretKey : '';
if (p2SecretKey == ''){
p2SecretKey = wx.getStorageSync("p2SecretKey")
}
// console.log("p2SecretKey:", p2SecretKey)
resultString = crypto.HMAC(crypto.SHA256,_signParam(body,false),p2SecretKey,"")
let data = {
"udid": app.globalData.udid,
"method": 'resources.simple.pice'
}
let method = "GET"
let header = {
'Content-Type': 'application/x-www-form-urlencoded',
'x-yoho-verify' : resultString,
'Cookies': 'JSESSIONID=' + sessionkey, }
'Content-Type': 'application/x-www-form-urlencoded'
}
wx.request({
url,
url: config.constants.API_HOST,
data,
method,
header: header,
success: function(res) {
let statusCode = res.statusCode,
errMsg = res.errMsg,
data = res.data;
if (statusCode == 200) {
if (data.code === 508 && ClientConfigHasRequested===0){
let app = getApp();
app.getSimplePise()
ClientConfigHasRequested =1
}
resolve(data);
} else {
let code = statusCode;
let message = res.errMsg ? res.errMsg : '';
reject({code, message});
success: function (res) {
// console.log("res:", res)
if (res && res.data && res.data.data && res.data.data.sk) {
app.globalData.p2SecretKey = res.data.data.sk;
wx.setStorage({
key: "p2SecretKey",
data: res.data.data.sk
});
resolve(app.globalData.p2SecretKey)
}
},
fail: function(err) {
let code = err.code ? err.code : 800;
let message = err.message ? err.message : '';
reject({code, message});
fail: function (err) {
reject(err)
// console.log("err:",err)
}
});
})
}
})
}
function request(method = 'GET') {
return function(url, params = {}) {
return getPrivateKey()
.then(key => {
return new Promise(function(resolve, reject) {
let app = getApp();
if (params && !params.hasOwnProperty('uid')) {
let uid = app && app.globalData && app.globalData.userInfo && app.globalData.userInfo.uid ? app.globalData.userInfo.uid : 0;
params.uid = uid;
}
let sessionkey = app && app.globalData && app.globalData.sessionkey ? app.globalData.sessionkey : '';
params.session_key = sessionkey;
params.source_type="wechat";
params.client_type = "miniapp";
params.business_line= "miniapp";
params.user_source ="wechat"
if (params && !params.hasOwnProperty('udid')) {
let udid = app && app.globalData && app.globalData.udid ? app.globalData.udid : "";
if(udid.length==0){
udid=wx.getStorageSync('udid');
}
params.udid = udid;
}
let body = _createBody(params);
let queryStrigPair = _signParam(body,true);
let data = '';
if (method === 'GET' || method === 'HEAD' || method === 'DELETE') {
url = url + '?' + queryStrigPair;
}
if (method !== 'GET' && method !== 'HEAD') {
data = queryStrigPair;
}
//加签
let resultString = "";
if((params.hasOwnProperty("method") && params["method"] ===ClientInitConfigMehtod)){
}else{
let p2SecretKey = app && app.globalData && app.globalData.p2SecretKey ? app.globalData.p2SecretKey : '';
if (p2SecretKey == ''){
p2SecretKey = wx.getStorageSync("p2SecretKey")
}
// console.log("p2SecretKey:", p2SecretKey)
resultString = crypto.HMAC(crypto.SHA256,_signParam(body,false),p2SecretKey,"")
}
let header = {
'Content-Type': 'application/x-www-form-urlencoded',
'x-yoho-verify' : resultString,
'Cookies': 'JSESSIONID=' + sessionkey, }
wx.request({
url,
data,
method,
header: header,
success: function(res) {
let statusCode = res.statusCode,
errMsg = res.errMsg,
data = res.data;
if (statusCode == 200) {
if (data.code === 508 && ClientConfigHasRequested===0){
let app = getApp();
app.getSimplePise()
ClientConfigHasRequested =1
}
resolve(data);
} else {
let code = statusCode;
let message = res.errMsg ? res.errMsg : '';
reject({code, message});
}
},
fail: function(err) {
let code = err.code ? err.code : 800;
let message = err.message ? err.message : '';
reject({code, message});
}
});
})
});
}
}
... ... @@ -149,23 +200,12 @@ function _publicParams() {
// Do something when catch error
}
// app_version = '5.6.0';
// os_version = '10.3';
// screen_size = '320x568';
// let uid = '0';
// let udid = 'acea1c6170ecca417c67979a406156950bcf4fe5';
// let physical_channel = 1;
return {
app_version,
os_version,
client_type,
screen_size,
// physical_channel,
// udid,
v,
// uid,
v
};
}
... ...
import api from '../../common/api';
export default {
/**
* 解析用户信息
* @param thirdSession
* @param encryptedData
* @param iv
* @returns {*}
*/
decodeUserInfo(thirdSession, encryptedData, iv) {
return api.post({
url: '/wechat/',
data: {
iv,
encryptedData,
srdSession: thirdSession,
method: 'wechat.smallProgram.decodeUserInfo'
}
});
},
/**
* 判断有货微信账户是否绑定手机号
* @param unionID
* @param nickName
* @returns {*}
*/
wechatUserIsBind(unionID, nickName) {
return api.get({
url: '',
data: {
method: 'app.passport.signinByOpenID',
openId: unionID,
source_type: 'wechat',
nickname: nickName,
}
});
},
/**
* 微信登录小程序
* @param code
* @returns {*}
*/
wechatMiniAppLogin(code) {
return api.get({
url: '/wechat/',
data: {
method: 'wechat.smallProgram.onLogin',
jsCode: code,
miniapp_type: '2'
}
});
},
/**
* 绑定小程序
* @param unionId
* @param mobile
* @param code
* @param area
* @returns {*}
*/
bindMiniapp(unionId, mobile, code, area = 86) {
return api.get({
url: '',
data: {
code,
mobile,
area,
open_id: unionId,
source_type: 'wechat',
method: 'app.passport.bindMiniapp'
}
});
},
/**
* 自动绑定小程序
* @param unionId
* @param mobile
* @param area
* @returns {*}
*/
bindMiniAppByAuto(unionId, mobile, area = 86) {
return api.get({
url: '',
data: {
mobile,
area,
open_id: unionId,
source_type: 'wechat',
method: 'app.passport.miniAppBindByAuto'
}
});
},
/**
* 自动登录
* @param mobile
* @param code
* @param area
* @returns {*}
*/
autoSignIn(mobile, code, area = 86) {
return api.get({
url: '',
data: {
code,
area,
profile: mobile,
source_type: 'wechat',
method: 'app.passport.autoSignin'
}
});
},
/**
* sessionKey是否失效验证
* @returns {*}
*/
verify() {
return api.get({
url: '',
data: {
method: 'app.passport.verify'
}
});
},
/**
* 获取用户信息
* @param uid 用户UID
* @returns {*}
*/
getProfile() {
return api.get({
url: '',
data: {
method: 'app.passport.profile'
}
});
},
/**
* 获取优惠券总数
* @returns {*}
*/
getCouponTotal() {
return api.get({
url: '/coupon/total.do',
data: {},
api: 'store'
});
},
/**
* 获取有货币总数
* @returns {*}
*/
getCoinTotal() {
return api.get({
url: '',
data: {
method: 'app.yohocoin.total'
}
});
},
/**
* 获取国家和地区
* @returns {*}
*/
getArea() {
return api.get({
url: '',
data: {
source_type: 'wechat',
method: 'app.passport.getArea'
}
});
},
/**
* 用户未授权-发送验证码
* @param area 国家码
* @param mobile 手机号
* @returns {*}
*/
sendSms(area, mobile) {
return api.get({
url: '',
data: {
area,
mobile,
source_type: 'wechat',
method: 'app.message.sendSms'
}
});
},
/**
* 用户已授权-发送验证码
* @param mobile 手机号
* @param area 国家码
* @returns {*}
*/
sendCodeByMiniApp(area, mobile, openId) {
return api.get({
url: '',
data: {
area,
mobile,
open_id: openId,
source_type: 'wechat',
method: 'app.bind.sendCodeByMiniApp'
}
});
}
};
... ...

1.11 KB | W: | H:

259 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

1.09 KB | W: | H:

214 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -129,12 +129,13 @@ function getUnionID(srd_session, callbackFunc) {
判断该微信用户是否已经绑定了有货账号,如果已绑定则返回uid等用户信息
*/
function wechatUserIsBind(unionID, nickName, callbackFunc) {
let app = getApp()
let app = getApp();
let param = {
method: 'app.passport.signinByOpenID',
openId: unionID,
nickname: nickName,
}
};
POST(config.constants.API_HOST, param)
.then(data => {
let responseData = data.data
... ... @@ -146,7 +147,6 @@ function wechatUserIsBind(unionID, nickName, callbackFunc) {
userInfo.ssouid = responseData.ssouid;
userInfo.uid = responseData.uid;
app.setUserInfo(userInfo);
app.setSessionkey(responseData.session_key);
trigger(true)
... ...