Commit deb17f7b by 程默

fix request

parent c778fc2b
...@@ -2,7 +2,6 @@ import {requestPOST,requestGET} from "@/utils/request.js"; ...@@ -2,7 +2,6 @@ import {requestPOST,requestGET} from "@/utils/request.js";
export default { export default {
//登录
getShopInfo(){ getShopInfo(){
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`) return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`)
} }
......
<template> <template>
<div @click="clickHandle"> <div @click="clickHandle">
加载中。。。
<web-view :src="link+page+params" @message="getMessage"></web-view> <web-view :src="link+page+params" @message="getMessage"></web-view>
<!-- <div class="userinfo" @click="bindViewTap"> <!-- <div class="userinfo" @click="bindViewTap">
<img class="userinfo-avatar" v-if="userInfo.avatarUrl" :src="userInfo.avatarUrl" background-size="cover" /> <img class="userinfo-avatar" v-if="userInfo.avatarUrl" :src="userInfo.avatarUrl" background-size="cover" />
...@@ -40,8 +39,8 @@ export default { ...@@ -40,8 +39,8 @@ export default {
return { return {
options: {}, options: {},
session_key: "", session_key: "",
link: "http://test-m-shop.mayi888.cn", // link: "http://test-m-shop.mayi888.cn",
// link: "http://localhost:3000", link: "http://localhost:3000",
page: "/", page: "/",
params: "?mixid=dev001", params: "?mixid=dev001",
motto: "Hello miniprograme", motto: "Hello miniprograme",
......
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
e.mp.detail.encryptedData, e.mp.detail.encryptedData,
e.mp.detail.iv e.mp.detail.iv
); );
this.unionId = data.unionId | ""; this.unionId = data.unionId || "";
this.userInfo = JSON.parse(e.target.rawData); this.userInfo = JSON.parse(e.target.rawData);
console.log("data", data, this.unionId); console.log("data", data, this.unionId);
} }
......
let shopMixid= "dev001"; let shopMixid = "dev001";
let sessionid="eedbbdaf-844c-4fcc-8970-1fb92346441c"; let sessionid = "eedbbdaf-844c-4fcc-8970-1fb92346441c";
console.log('----------------------------',process.env.sessionid) console.log('----------------------------', process.env.sessionid);
export function requestGET(url, options) {
// wx.getStore
export async function requestGET(url, options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
url: url, url: url,
...@@ -9,7 +12,6 @@ export function requestGET(url, options) { ...@@ -9,7 +12,6 @@ export function requestGET(url, options) {
method: "GET", method: "GET",
header: { header: {
"Shop-Mixid": shopMixid, "Shop-Mixid": shopMixid,
Authorization: sessionid
}, },
success: function (res) { success: function (res) {
resolve(res) resolve(res)
...@@ -21,7 +23,7 @@ export function requestGET(url, options) { ...@@ -21,7 +23,7 @@ export function requestGET(url, options) {
}) })
} }
export function requestPOST(url, options) { export async function requestPOST(url, options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
url: url, url: url,
...@@ -29,7 +31,6 @@ export function requestPOST(url, options) { ...@@ -29,7 +31,6 @@ export function requestPOST(url, options) {
method: "POST", method: "POST",
header: { header: {
"Shop-Mixid": shopMixid, "Shop-Mixid": shopMixid,
Authorization: sessionid
}, },
success: function (res) { success: function (res) {
resolve(res) resolve(res)
...@@ -41,17 +42,14 @@ export function requestPOST(url, options) { ...@@ -41,17 +42,14 @@ export function requestPOST(url, options) {
}) })
} }
export async function requestPOST1(url, options) { export function requestPOST1(url, options) {
let header=getHeader();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
url: url, url: url,
data: options, data: options,
method: "POST", method: "POST",
header: { header: header,
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": shopMixid,
Authorization: sessionid
},
success: function (res) { success: function (res) {
resolve(res) resolve(res)
}, },
...@@ -61,3 +59,16 @@ export async function requestPOST1(url, options) { ...@@ -61,3 +59,16 @@ export async function requestPOST1(url, options) {
}) })
}) })
} }
function getHeader() {
let sessionid = wx.getStorageSync('sessionid');
let header = {
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": shopMixid,
Authorization: sessionid
};
// if (!sessionid) {
// delete header.Authorization
// }
return header
}
\ No newline at end of file
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