Commit ff4d4a1a authored by leiqingsong's avatar leiqingsong

Merge branch 'dev_lqs' into 'master'

修改

See merge request !45
parents c774d244 f4e958f3
......@@ -23,6 +23,10 @@ export default {
}
},
created() {
// const user = {
// userId: "1313123232"
// }
// localStorage.setItem('user', JSON.stringify(user));
console.log('和App开始交互');
getAuthToken().then(res => {
console.log('获取token成功', res);
......
......@@ -38,23 +38,35 @@ export function getAuthToken() {
console.log("ios");
return new Promise((resolve, reject) => {
console.log("调用1");
jsBridge.callhandler("getAuthToken", null, data => {
console.log("调用2");
localStorage.setItem("token", data);
console.log("--------------");
if (data) {
resolve(data)
getUserInfo().then(res => {
if (res.code === 0) {
localStorage.setItem("user", JSON.stringify(res.data));
}
})
} else {
console.log("调用失败");
reject("getAuthToken", data);
}
});
})
try {
window.webkit.messageHandlers.Location.postMessage(null); //调用OC方法“postMessage”
resolve('成功');
} catch (e) {
//TODO handle the exception
reject('异常');
console.log('ios, 异常');
}
//监听OC的方法
// function setLocation(data) {
// console.log('监听', data);
// }
// jsBridge.callhandler("getAuthToken", null, data => {
// console.log("调用2");
// localStorage.setItem("token", data);
// console.log("--------------");
// if (data) {
// resolve(data)
// getUserInfo().then(res => {
// if (res.code === 0) {
// localStorage.setItem("user", JSON.stringify(res.data));
// }
// })
// } else {
// console.log("调用失败");
// reject("getAuthToken", data);
// }
// });
})
}
}
......
......@@ -5,14 +5,12 @@ let loading = null;
const service = axios.create({
baseURL: "/shop-mall",
// baseURL: "http://192.168.204.152:8997/shop-mall",
timeout: 5000
});
service.interceptors.request.use(
config => {
const token = localStorage.getItem("token");
// config.headers["Authorization"] = "Bearer " + token;
config.headers["token"] = token;
if (!config.loading) {
loading = Toast.loading({
......
......@@ -108,6 +108,7 @@ export default {
},
getstatus() {
const userId = this.$userId;
console.log(userId);
const _this = this;
getForestStatus(userId).then(res => {
if (res.code === 0) {
......
......@@ -5,7 +5,6 @@
</template>
<script>
import { inviteCode } from "@/api/invite";
var userId = this.$userId;
export default {
data() {
return {
......@@ -22,7 +21,7 @@ export default {
forbidClick: true,
message: "加载中..."
});
inviteCode(userId).then(res => {
inviteCode(this.$userId).then(res => {
if (loading) _this.$toast.clear();
_this.imgSrc = _this.getUserPhoto(res);
});
......
......@@ -5,7 +5,7 @@
<van-cell is-link center title="头像" @click="onModefy">
<img
class="avatar-img"
src="@/assets/images/no_avatar.png"
src=""
alt="头像"
/>
</van-cell>
......@@ -46,7 +46,7 @@
</template>
<script>
import { getUserInfo } from "@/api/user";
// import { getUserInfo } from "@/api/user";
import { logoutToApp } from "@/utils/bridgeToAppFun";
import { logout } from "@/api/user";
import { fillInviteCode } from "@/api/user";
......@@ -56,28 +56,29 @@ export default {
name: "Settings",
data() {
return {
avatar: "",
fileList: [],
fillCode: "",
inviteeCode: "未填写",
inviteeCodeDialog: false
};
},
created() {
mounted() {
this.getUser()
},
methods: {
getUser() {
getUserInfo().then(res => {
if (res.code === 0) {
localStorage.setItem("user", JSON.stringify(res.data));
}
})
const user = JSON.parse(localStorage.getItem('user'));
console.log(user);
// getUserInfo().then(res => {
// if (res.code === 0) {
// localStorage.setItem("user", JSON.stringify(res.data));
// }
// })
},
logout() {
const params = {
token: "qwedskdljlkjlklkjlkjlkjl"
};
logout(params).then();
localStorage.removeItem('token');
logout().then();
logoutToApp();
},
jumpToInstructions() {
......
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