Commit deb17f7b by 程默

fix request

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