Commit 6fcd69df authored by 黄奎's avatar 黄奎

11

parent adea96d1
...@@ -214,6 +214,7 @@ ...@@ -214,6 +214,7 @@
b2bResult.customerInfoChildrenId=b2bData.customerInfoChildrenId; b2bResult.customerInfoChildrenId=b2bData.customerInfoChildrenId;
b2bResult.name = b2bData.name; b2bResult.name = b2bData.name;
b2bResult.customerName = b2bData.customerName; b2bResult.customerName = b2bData.customerName;
b2bResult.token=b2bData.token;
uni.setStorageSync('b2b_user', b2bResult) uni.setStorageSync('b2b_user', b2bResult)
} }
}, (error2) => { }, (error2) => {
......
import Md5 from "js-md5" import Md5 from "js-md5"
// import { get_xs } from '@/static/xhs.js' // import { get_xs } from '@/static/xhs.js'
const resolveRVHandler =(response)=>{ const resolveRVHandler = (response) => {
// if(response.header && response.header['r-v']){ // if(response.header && response.header['r-v']){
// uni.setStorageSync("r-v",response.header['r-v']) // uni.setStorageSync("r-v",response.header['r-v'])
// } // }
} }
const getRVHandler = (payload,token)=>{ const getRVHandler = (payload, token) => {
// if(uni.getStorageSync("r-v")){ // if(uni.getStorageSync("r-v")){
// let a1 =uni.getStorageSync("r-v") // let a1 =uni.getStorageSync("r-v")
// let xs = get_xs(payload, a1,token) // let xs = get_xs(payload, a1,token)
// if(xs && xs !=''){ // if(xs && xs !=''){
// console.log(xs) // console.log(xs)
// return xs // return xs
// } // }
// } // }
return '' return ''
} }
export default { export default {
install(Vue, options) { install(Vue, options) {
Vue.prototype.host = "https://wx.weibaoge.cn/web/index.php?_mall_id=1285" Vue.prototype.host = "https://wx.weibaoge.cn/web/index.php?_mall_id=1285"
Vue.prototype.host2 = "http://192.168.5.46:5004" Vue.prototype.host2 = "http://192.168.5.46:8200"
Vue.prototype.host3 = "http://192.168.5.46" Vue.prototype.host3 = "http://192.168.5.46:8501"
Vue.prototype.host2 = "https://erpmallapi.oytour.com" // Vue.prototype.host2 = "https://mallapi.oytour.com"
Vue.prototype.host3 = "https://reborn.oytour.com" // Vue.prototype.host3 = "https://reborn.oytour.com"
Vue.prototype.request = function(param, success, failed) { Vue.prototype.request = function(param, success, failed) {
//网络请求 //网络请求
uni.request({ uni.request({
url: this.host + "&r=" + param.data.r, url: this.host + "&r=" + param.data.r,
method: param.method || "GET", method: param.method || "GET",
header: param.header || { header: param.header || {
'content-type': "application/json" 'content-type': "application/json"
}, },
data: param.data, data: param.data,
success: res => { success: res => {
if (res.data.code != 0 && res.data.msg != "商品未上架") {} if (res.data.code != 0 && res.data.msg != "商品未上架") {}
typeof success == "function" && success(res.data); typeof success == "function" && success(res.data);
}, },
fail: (e) => { fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e)); console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({ uni.showModal({
content: "" + res.errMsg content: "" + res.errMsg
}); });
typeof failed == "function" && failed(res.data); typeof failed == "function" && failed(res.data);
} }
}); });
} }
Vue.prototype.request2 = function(param, success, failed) { Vue.prototype.request2 = function(param, success, failed) {
let data = { let data = {
MallBaseId: this.GetMiniAppId().MallBaseId, MallBaseId: this.GetMiniAppId().MallBaseId,
TenantId: this.GetMiniAppId().TenantId, TenantId: this.GetMiniAppId().TenantId,
OpenId: this.GetOpenId().OpenId, OpenId: this.GetOpenId().OpenId,
UserId: this.GetOpenId().UserId, UserId: this.GetOpenId().UserId,
SmallShopsId: this.GetOpenId().SmallShopsId, SmallShopsId: this.GetOpenId().SmallShopsId,
MiniAppId: this.GetMiniAppId().AppId, MiniAppId: this.GetMiniAppId().AppId,
msg: param.data, msg: param.data,
token: this.GetOpenId().token token: this.GetOpenId().token
} }
//['X-s'] //['X-s']
const sign = getRVHandler(data,this.GetOpenId().token) const sign = getRVHandler(data, this.GetOpenId().token)
//网络请求 //网络请求
uni.request({ uni.request({
url: this.host2 + param.url, url: this.host2 + param.url,
method: param.method || "Post", method: param.method || "Post",
header: param.header || { header: param.header || {
'content-type': "application/json", 'content-type': "application/json",
'x-sign':sign["X-s"], 'x-sign': sign["X-s"],
'x-ts':sign["X-t"] 'x-ts': sign["X-t"]
}, },
data, data,
success: res => { success: res => {
resolveRVHandler(res) resolveRVHandler(res)
if (res.data.resultCode == 10000) { if (res.data.resultCode == 10000) {
let u = uni.getStorageSync("mall_UserInfo"); let u = uni.getStorageSync("mall_UserInfo");
if (u) { if (u) {
this.getLogin_t(u) this.getLogin_t(u)
typeof failed == "function" && failed(res.data); typeof failed == "function" && failed(res.data);
} }
} else if (res.data.resultCode != 1) { } else if (res.data.resultCode != 1) {
if (res.data.message != '') { if (res.data.message != '') {
uni.showToast({ uni.showToast({
title: res.data.message, title: res.data.message,
icon: "none", icon: "none",
}); });
} }
typeof failed == "function" && failed(res.data); typeof failed == "function" && failed(res.data);
} else { } else {
typeof success == "function" && success(res.data); typeof success == "function" && success(res.data);
} }
}, },
fail: (e) => { fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e)); console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({ uni.showModal({
content: "" + res.errMsg content: "" + res.errMsg
}); });
typeof failed == "function" && failed(res.data); typeof failed == "function" && failed(res.data);
} }
}); });
} }
//请求app接口 //请求app接口
Vue.prototype.apipost = function(cmd, msg, success, failed) { Vue.prototype.apipost = function(cmd, msg, success, failed) {
var data = this.GetPostData(cmd, msg, ""); var data = this.GetPostData(cmd, msg, "");
//['X-s'] //['X-s']
const sign = getRVHandler(data,data.token) const sign = getRVHandler(data, data.token)
uni.request({ uni.request({
url: this.host3 + '/api/common/post', url: this.host3 + '/api/common/post',
method: "Post", method: "Post",
header: { header: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'x-sign':sign["X-s"], 'x-ts':sign["X-t"] },
}, data,
data, success: res => {
success: res => { resolveRVHandler(res)
resolveRVHandler(res) if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) { uni.removeStorageSync('b2b_user')
uni.removeStorageSync('b2b_user') uni.removeStorageSync('mall_UserInfo')
uni.removeStorageSync('mall_UserInfo') // uni.redirectTo({
// uni.redirectTo({ // url: '/pages/jiuzhai/login'
// url: '/pages/jiuzhai/login' // })
// }) uni.redirectTo({
uni.redirectTo({ url: '/pages/index/index'
url: '/pages/index/index' })
}) } else if (res.data.resultCode != 1) {
} else if (res.data.resultCode != 1) { if (!failed) {
if (!failed) { if (res.data.message != '') {
if (res.data.message != '') { uni.showToast({
uni.showToast({ title: res.data.message,
title: res.data.message, icon: "none",
icon: "none", });
}); }
} }
} typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); } else {
} else { typeof success == "function" && success(res.data);
typeof success == "function" && success(res.data); }
} },
}, fail: (e) => {
fail: (e) => { console.log("网络请求fail:" + JSON.stringify(e));
console.log("网络请求fail:" + JSON.stringify(e)); uni.showModal({
uni.showModal({ content: "" + res.errMsg
content: "" + res.errMsg });
}); typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); }
} })
}) },
}, Vue.prototype.javaApipost = function(cmd, msg, success, failed) {
Vue.prototype.javaApipost = function(cmd, msg, success, failed) { let b2bUser = uni.getStorageSync('b2b_user')
let b2bUser = uni.getStorageSync('b2b_user') let token = "";
let token = ""; let key = "";
let key = ""; let groupId = 0
let groupId = 0 let timestamp = (new Date()).valueOf();
let timestamp = (new Date()).valueOf(); var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); if (b2bUser && b2bUser.token) {
if (b2bUser && b2bUser.token) { token = b2bUser.token;
token = b2bUser.token; key = b2bUser.secretKey;
key = b2bUser.secretKey; groupId = b2bUser.groupId;
groupId = b2bUser.groupId; }
} var md5Str = Md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var md5Str = Md5(`msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`); var postData = {
var postData = { "groupId": groupId,
"groupId": groupId, "msg": msg,
"msg": msg, "timestamp": timestamp,
"timestamp": timestamp, "token": token,
"token": token, "sign": md5Str,
"sign": md5Str, }
}
uni.request({
uni.request({ url: 'https://efficient.oytour.com/api/' + cmd,
url: 'https://efficient.oytour.com/api/' + cmd, method: "Post",
method: "Post", header: {
header: { 'Content-Type': 'application/json'
'Content-Type': 'application/json' },
}, data: postData,
data: postData, success: res => {
success: res => { if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) { uni.removeStorageSync('b2b_user')
uni.removeStorageSync('b2b_user') uni.removeStorageSync('mall_UserInfo')
uni.removeStorageSync('mall_UserInfo') // uni.redirectTo({
// uni.redirectTo({ // url: '/pages/jiuzhai/login'
// url: '/pages/jiuzhai/login' // })
// }) uni.redirectTo({
uni.redirectTo({ url: '/pages/index/index'
url: '/pages/index/index' })
}) } else if (res.data.resultCode != 1) {
} else if (res.data.resultCode != 1) { if (res.data.message != '') {
if (res.data.message != '') { uni.showToast({
uni.showToast({ title: res.data.message,
title: res.data.message, icon: "none",
icon: "none", });
}); }
} typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); } else {
} else { typeof success == "function" && success(res.data);
typeof success == "function" && success(res.data); }
} },
}, fail: (e) => {
fail: (e) => { console.log("网络请求fail:" + JSON.stringify(e));
console.log("网络请求fail:" + JSON.stringify(e)); uni.showModal({
uni.showModal({ content: "" + res.errMsg
content: "" + res.errMsg });
}); typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); }
} })
}) },
}, Vue.prototype.apipostDownload = function(cmd, msg, success, failed) {
Vue.prototype.apipostDownload = function(cmd, msg, success, failed) { var postData = this.GetPostData(cmd, msg, "");
var postData = this.GetPostData(cmd, msg, ""); uni.request({
uni.request({ url: this.host3 + '/api/file/' + cmd,
url: this.host3 + '/api/file/' + cmd, method: "Post",
method: "Post", header: {
header: { 'Content-Type': 'application/json'
'Content-Type': 'application/json' },
}, data: postData,
data: postData, success: res => {
success: res => { if (res.data.resultCode == 10000) {
if (res.data.resultCode == 10000) { let u = uni.getStorageSync("mall_UserInfo");
let u = uni.getStorageSync("mall_UserInfo"); if (u) {
if (u) { this.getLogin_t(u)
this.getLogin_t(u) typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); }
} } else if (res.data.resultCode != 1) {
} else if (res.data.resultCode != 1) { if (res.data.message != '') {
if (res.data.message != '') { uni.showToast({
uni.showToast({ title: res.data.message,
title: res.data.message, icon: "none",
icon: "none", });
}); }
} typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); } else {
} else { typeof success == "function" && success(res.data);
typeof success == "function" && success(res.data); }
} },
}, fail: (e) => {
fail: (e) => { console.log("网络请求fail:" + JSON.stringify(e));
console.log("网络请求fail:" + JSON.stringify(e)); uni.showModal({
uni.showModal({ content: "" + res.errMsg
content: "" + res.errMsg });
}); typeof failed == "function" && failed(res.data);
typeof failed == "function" && failed(res.data); }
} })
}) },
},
//获取请求参数
//获取请求参数 Vue.prototype.GetPostData = function(cmd, msg) {
Vue.prototype.GetPostData = function(cmd, msg) { if (msg == null || msg == "") {
if (msg == null || msg == "") { msg = {}
msg = {} }
} let b2bUser = uni.getStorageSync('b2b_user')
let b2bUser = uni.getStorageSync('b2b_user') let token = b2bUser.token;
let token = '' let key = ""
let key = "" let groupId = ''
let groupId = '' let timestamp = (new Date()).valueOf();
let timestamp = (new Date()).valueOf(); if (b2bUser && b2bUser.token) {
if (b2bUser && b2bUser.token) { token = b2bUser.token
token = b2bUser.token key = b2bUser.secretKey
key = b2bUser.secretKey }
} if (b2bUser) {
if (b2bUser) { groupId = b2bUser.groupId
groupId = b2bUser.groupId }
} var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); var postData = {
var postData = { "groupId": groupId,
"groupId": groupId, "msg": msg,
"msg": msg, "cmd": cmd,
"cmd": cmd, "timestamp": timestamp,
"timestamp": timestamp, "token": token,
"token": token, "sign": '',
"sign": '', "locale": 'zh_CN',
"locale": 'zh_CN', "currencyCode": 'CNY',
"currencyCode": 'CNY', version: 'MiniProgram'
version: 'MiniProgram' }
} return postData
return postData },
}, // token失效再次登录接口
// token失效再次登录接口 Vue.prototype.getLogin_t = function(obj) {
Vue.prototype.getLogin_t = function(obj) { console.log('apijs', obj)
console.log('apijs', obj) let pid = uni.getStorageSync("pid") ? uni.getStorageSync("pid").pid : 0;
let pid = uni.getStorageSync("pid") ? uni.getStorageSync("pid").pid : 0; let Up = uni.getStorageSync("Up") ? uni.getStorageSync("Up").Up : 0;
let Up = uni.getStorageSync("Up") ? uni.getStorageSync("Up").Up : 0; let SmallShopId = uni.getStorageSync("SmallShopId") ? uni.getStorageSync("SmallShopId").SmallShopId : 0;
let SmallShopId = uni.getStorageSync("SmallShopId") ? uni.getStorageSync("SmallShopId").SmallShopId : 0; let CounponPassword = uni.getStorageSync("CounponPassword") ? uni.getStorageSync("CounponPassword").CounponPassword :
let CounponPassword = uni.getStorageSync("CounponPassword") ? uni.getStorageSync("CounponPassword").CounponPassword : 0;
0; let KeyWord = uni.getStorageSync("KeyWord") ? uni.getStorageSync("KeyWord").KeyWord : '';
let KeyWord = uni.getStorageSync("KeyWord") ? uni.getStorageSync("KeyWord").KeyWord : ''; this.request2({
this.request2({ url: '/api/AppletLogin/Login',
url: '/api/AppletLogin/Login', data: {
data: { Source: obj.Source,
Source: obj.Source, OpenId: obj.OpenId,
OpenId: obj.OpenId, Name: obj.Name,
Name: obj.Name, Photo: obj.Photo,
Photo: obj.Photo, Moblie: '',
Moblie: '', SuperiorId: pid,
SuperiorId: pid, SmallShopId: SmallShopId,
SmallShopId: SmallShopId, UserPageType: Up,
UserPageType: Up, CounponPassword: CounponPassword,
CounponPassword: CounponPassword, KeyWord: KeyWord,
KeyWord: KeyWord, }
} },
}, res => {
res => { if (res.resultCode == 1) {
if (res.resultCode == 1) { uni.setStorageSync('mall_UserInfo', res.data);
uni.setStorageSync('mall_UserInfo', res.data); uni.removeStorageSync('pid');
uni.removeStorageSync('pid'); uni.removeStorageSync('SmallShopId');
uni.removeStorageSync('SmallShopId'); uni.removeStorageSync("Up");
uni.removeStorageSync("Up"); uni.removeStorageSync("CounponPassword");
uni.removeStorageSync("CounponPassword"); uni.removeStorageSync("KeyWord");
uni.removeStorageSync("KeyWord"); }
} }
} );
); }
} // 获取小程序APPID
// 获取小程序APPID Vue.prototype.GetMiniAppId = function() {
Vue.prototype.GetMiniAppId = function() { let appObj = {};
let appObj = {}; let appType = 2;
let appType = 2; switch (appType) {
switch (appType) { case 1: //旅小友-支付宝
case 1: //旅小友-支付宝 appObj = {
appObj = { AppId: '2021002181604459',
AppId: '2021002181604459', TenantId: 12,
TenantId: 12, MallBaseId: 2,
MallBaseId: 2, };
}; break;
break; case 2: //旅小友-微信
case 2: //旅小友-微信 //wx5564525562e92ddb
//wx5564525562e92ddb //wxcf0727a7c78b501e
//wxcf0727a7c78b501e appObj = {
appObj = { AppId: 'wxcf0727a7c78b501e',
AppId: 'wxcf0727a7c78b501e', TenantId: 12,
TenantId: 12, MallBaseId: 2,
MallBaseId: 2, };
}; break;
break; }
} return appObj;
return appObj; }
} //获取OpenId
//获取OpenId Vue.prototype.GetOpenId = function() {
Vue.prototype.GetOpenId = function() { let mall_userinfo = wx.getStorageSync('mall_UserInfo')
let mall_userinfo = wx.getStorageSync('mall_UserInfo') var obj = {
var obj = { OpenId: '',
OpenId: '', UserId: 0,
UserId: 0, token: '',
token: '', SmallShopsId: 0,
SmallShopsId: 0, }
} if (mall_userinfo) {
if (mall_userinfo) { if (mall_userinfo.OpenId) {
if (mall_userinfo.OpenId) { obj.OpenId = mall_userinfo.OpenId;
obj.OpenId = mall_userinfo.OpenId; obj.UserId = mall_userinfo.UserId;
obj.UserId = mall_userinfo.UserId; obj.token = mall_userinfo.Token;
obj.token = mall_userinfo.Token; obj.SmallShopsId = mall_userinfo.UserSmallShopId;
obj.SmallShopsId = mall_userinfo.UserSmallShopId; }
} }
} return obj
return obj }
} //公用判断图片地址 判断是否包含http
//公用判断图片地址 判断是否包含http Vue.prototype.getIconLink = function(url) {
Vue.prototype.getIconLink = function(url) { let str = ''
let str = '' if (url && url != '') {
if (url && url != '') { if (url.indexOf('http') != -1) {
if (url.indexOf('http') != -1) { str = url
str = url } else {
} else { str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url;
str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url; }
} return str;
return str; }
} }
} //价格返回.00
//价格返回.00 Vue.prototype.getPrice = function(val) {
Vue.prototype.getPrice = function(val) { val = Number(val).toFixed(2);
val = Number(val).toFixed(2); return val
return val }
}
Vue.prototype.apiheader = function() {
Vue.prototype.apiheader = function() { return {
return { 'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr',
'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr', 'X-App-Platform': 'wxapp',
'X-App-Platform': 'wxapp', 'X-App-Version': '4.2.47',
'X-App-Version': '4.2.47', 'X-Form-Id-List': '[]',
'X-Form-Id-List': '[]', 'X-Requested-With': 'XMLHttpRequest',
'X-Requested-With': 'XMLHttpRequest', 'X-User-Id': '19992',
'X-User-Id': '19992', 'content-type': "application/json"
'content-type': "application/json" }
} }
} }
} }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment