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