Commit bcad63e4 authored by zhengke's avatar zhengke

修改

parent 65aa4c6c
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.0.110:8200"
Vue.prototype.host2 = "http://192.168.0.110:8200" Vue.prototype.host2 = "http://192.168.0.110:8200"
//Vue.prototype.host2 = "https://mallApi.oytour.com"
//Vue.prototype.host2 = "http://mallapi.oytour.com"
Vue.prototype.request = function(param, success, failed) {
//网络请求
uni.request({
url: this.host + "&r=" + param.data.r,
method: param.method || "GET",
header: param.header || {
'content-type': "application/json"
},
data: param.data,
success: res => {
if (res.data.code != 0 && res.data.msg != "商品未上架") {
// wx.showModal({
// content: '网络开小差了,刷新页面重新加载吧',
// showCancel: false
// })
console.group("发生了异常情况");
console.error(res.data.msg);
console.groupEnd();
}
typeof success == "function" && success(res.data);
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
Vue.prototype.request2 = function(param, success, failed) { //Vue.prototype.host2 = "http://mallapi.oytour.com"
//网络请求 Vue.prototype.request = function(param, success, failed) {
uni.request({ //网络请求
url: this.host2 + param.url, uni.request({
method: param.method || "Post", url: this.host + "&r=" + param.data.r,
header: param.header || { method: param.method || "GET",
'content-type': "application/json" header: param.header || {
}, 'content-type': "application/json"
data: { },
MallBaseId: 1, data: param.data,
TenantId: 1, success: res => {
OpenId: this.GetOpenId().OpenId, if (res.data.code != 0 && res.data.msg != "商品未上架") {
UserId: this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(),
msg: param.data,
token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODg5MDg5MjkuMCwiZXhwIjoxNTkxNTAwOTI5LjAsIm1hbGxfdXNlckluZm8iOnsidWlkIjoiMyIsInJlcXVlc3RGcm9tIjoyfX0.wvWlZWUmi-sqoCaxB6C9kdQSvyYyMzvgleFLLRW71Sw'
},
success: res => {
if (res.data.resultCode != 1) {
// wx.showModal({
// content: '网络开小差了,刷新页面重新加载吧',
// showCancel: false
// })
console.group("发生了异常情况");
console.error(res.data.msg);
console.groupEnd();
} else {
typeof success == "function" && success(res.data);
}
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
// 获取小程序APPID
Vue.prototype.GetMiniAppId = function() {
return 'wxacd9f8cc3480d29e'
}
//获取OpenId
Vue.prototype.GetOpenId = function() {
let mall_userinfo =wx.getStorageSync('mall_UserInfo')
var obj = {
OpenId: '',
UserId: 0
}
if(mall_userinfo){
if(mall_userinfo.OpenId){
obj.OpenId=mall_userinfo.OpenId;
obj.UserId=mall_userinfo.UserId;
} }
typeof success == "function" && success(res.data);
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
} }
return obj });
} }
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url;
}
return str;
}
}
//价格返回.00
Vue.prototype.getPrice = function(val) {
val = Number(val).toFixed(2);
return val
}
Vue.prototype.apiheader = function() { Vue.prototype.request2 = function(param, success, failed) {
return { //网络请求
'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr', uni.request({
'X-App-Platform': 'wxapp', url: this.host2 + param.url,
'X-App-Version': '4.2.47', method: param.method || "Post",
'X-Form-Id-List': '[]', header: param.header || {
'X-Requested-With': 'XMLHttpRequest', 'content-type': "application/json"
'X-User-Id': '19992', },
'content-type': "application/json" data: {
} MallBaseId: 1,
} TenantId: 1,
OpenId: this.GetOpenId().OpenId,
UserId: this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(),
msg: param.data,
token: this.GetOpenId().token
},
success: res => {
if (res.data.resultCode != 1) {
} else {
typeof success == "function" && success(res.data);
}
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
// Vue.prototype.post = function(obj, success, failed) { // 获取小程序APPID
// this.sendRequest(obj.url, 'POST', obj.data, success, failed) Vue.prototype.GetMiniAppId = function() {
// } return 'wxacd9f8cc3480d29e'
}
//获取OpenId
Vue.prototype.GetOpenId = function() {
let mall_userinfo = wx.getStorageSync('mall_UserInfo')
var obj = {
OpenId: '',
UserId: 0,
token:''
}
if (mall_userinfo) {
if (mall_userinfo.OpenId) {
obj.OpenId = mall_userinfo.OpenId;
obj.UserId = mall_userinfo.UserId;
obj.token = mall_userinfo.Token;
}
}
return obj
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url;
}
return str;
}
}
//价格返回.00
Vue.prototype.getPrice = function(val) {
val = Number(val).toFixed(2);
return val
}
// Vue.prototype.get = function(obj, success, failed) { Vue.prototype.apiheader = function() {
// this.sendRequest(obj.url, 'GET', obj.data, success, failed) return {
// } 'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr',
} 'X-App-Platform': 'wxapp',
} 'X-App-Version': '4.2.47',
\ No newline at end of file 'X-Form-Id-List': '[]',
'X-Requested-With': 'XMLHttpRequest',
'X-User-Id': '19992',
'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