Commit b07d364a authored by leiqingsong's avatar leiqingsong

提现修改

parent 272a85fa
VUE_APP_BASE_URL = "http://8.131.244.76:81/" VUE_APP_BASE_URL = "http://8.131.244.76:81"
\ No newline at end of file \ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
</template> </template>
<script> <script>
import { getAuthToken } from "@/utils/bridgeToAppFun";
import BaseNavBar from "./components/BaseNavBar.vue"; import BaseNavBar from "./components/BaseNavBar.vue";
export default { export default {
components: { components: {
...@@ -29,7 +28,7 @@ export default { ...@@ -29,7 +28,7 @@ export default {
// localStorage.setItem('user', JSON.stringify(user)); // localStorage.setItem('user', JSON.stringify(user));
console.log("和App开始交互"); console.log("和App开始交互");
// showBottomBar(false); // showBottomBar(false);
getAuthToken() this.$bridgeToAppFun.getAuthToken()
.then(res => { .then(res => {
console.log("获取token成功", res); console.log("获取token成功", res);
}) })
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</template> </template>
<script> <script>
// import { navigateBack } from "@/utils/bridgeToAppFun"; import { navigateBack } from "@/utils/bridgeToAppFun";
export default { export default {
name: "BaseNavBar", name: "BaseNavBar",
props: { props: {
...@@ -21,14 +21,22 @@ export default { ...@@ -21,14 +21,22 @@ export default {
}, },
methods: { methods: {
onClickLeft() { onClickLeft() {
// console.log(this.$router); const currentPage = this.$router.currentRoute.name;
// const currentPage = this.$router.currentRoute; console.log('router', currentPage);
// if (whiteList.indexof(currentPage) > -1) { const whiteList = ['MyStatus', 'Publish', 'FastestProgress',
// navigateBack(); 'MonthAward', 'Instructions', 'Settings', 'Grade',
// } else { 'AirDrop', 'Invite', 'AboutUs', 'customerService'
// this.$router.go(-1); ]
// } if (whiteList.indexOf(currentPage) > -1) {
try {
navigateBack();
} catch {
console.log('不能交互');
}
} else {
this.$router.go(-1); this.$router.go(-1);
}
// this.$router.go(-1);
}, },
onClickRight() { onClickRight() {
console.log("right"); console.log("right");
......
...@@ -11,6 +11,9 @@ import Vconsole from "vconsole"; ...@@ -11,6 +11,9 @@ import Vconsole from "vconsole";
import { getUserId } from "./utils/localGetter"; import { getUserId } from "./utils/localGetter";
Vue.prototype.$userId = getUserId(); Vue.prototype.$userId = getUserId();
import bridgeToAppFun from "@/utils/bridgeToAppFun";
Vue.prototype.$bridgeToAppFun = new bridgeToAppFun();
Vue.prototype.$vConsole = new Vconsole(); Vue.prototype.$vConsole = new Vconsole();
Vue.use(MiniRefreshTools); Vue.use(MiniRefreshTools);
Vue.config.productionTip = false; Vue.config.productionTip = false;
......
...@@ -2,7 +2,19 @@ ...@@ -2,7 +2,19 @@
import jsBridge from "./bridge"; import jsBridge from "./bridge";
import { getUserInfo } from "@/api/user"; import { getUserInfo } from "@/api/user";
function saveUser(data) { class bridgeToAppFun {
constructor() {
this.userAgent = null;
console.log(navigator.userAgent);
if (navigator.userAgent.indexOf("Android") > -1 || navigator.userAgent.indexOf("Adr") > -1) {
this.userAgent = 'android';
} else if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
this.userAgent = 'ios';
} else {
this.userAgent = 'web';
}
}
saveUser(data) {
localStorage.setItem("token", data); localStorage.setItem("token", data);
if (data) { if (data) {
getUserInfo().then(res => { getUserInfo().then(res => {
...@@ -16,26 +28,29 @@ function saveUser(data) { ...@@ -16,26 +28,29 @@ function saveUser(data) {
} else { } else {
console.log("调用失败"); console.log("调用失败");
} }
} }
// 获取Token
// 获取Token getAuthToken() {
export function getAuthToken() { console.log("ua", this.userAgent);
const userAgent = navigator.userAgent; if (this.userAgent === 'android') {
console.log("ua", userAgent);
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
// android // android
console.log("android, 和安卓交互"); console.log("android, 和安卓交互");
const token = window.android.getAuthToken(); let token = null;
try {
token = window.android.getAuthToken();
} catch {
console.log('token获取失败');
}
console.log("an-token", token); console.log("an-token", token);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (token) { if (token) {
saveUser(token); this.saveUser(token);
resolve(token); resolve(token);
} else { } else {
reject("失败"); reject("失败");
} }
}); });
} else if (userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) { } else if (this.userAgent === 'ios') {
// ios // ios
console.log("ios"); console.log("ios");
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -58,38 +73,36 @@ export function getAuthToken() { ...@@ -58,38 +73,36 @@ export function getAuthToken() {
}); });
}); });
} }
} }
// 退出
// 退出 logoutToApp() {
export function logoutToApp() {
console.log("退出登录"); console.log("退出登录");
const userAgent = navigator.userAgent; if (this.userAgent === 'android') {
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an"); console.log("an");
window.android.logout(); window.android.logout();
} else { } else {
jsBridge.callhandler("logout"); jsBridge.callhandler("logout");
} }
} }
navigateBack() {
export function navigateBack() {
console.log("返回"); console.log("返回");
const userAgent = navigator.userAgent; if (this.userAgent === 'android') {
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an"); console.log("an");
window.android.navigateBack(); window.android.navigateBack();
} else { } else {
jsBridge.callhandler("navigateBack"); jsBridge.callhandler("navigateBack");
} }
} }
showBottomBar(params) {
export function showBottomBar(params) {
console.log("隐藏底部"); console.log("隐藏底部");
const userAgent = navigator.userAgent; if (this.userAgent === 'android') {
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an"); console.log("an");
window.android.showBottomBar(params); window.android.showBottomBar(params);
} else { } else {
jsBridge.callhandler("showBottomBar", params); jsBridge.callhandler("showBottomBar", params);
} }
}
} }
export default bridgeToAppFun;
\ No newline at end of file
// H5 去调用App的方法
import jsBridge from "./bridge";
import { getUserInfo } from "@/api/user";
function saveUser(data) {
localStorage.setItem("token", data);
if (data) {
getUserInfo().then(res => {
console.log("存用户信息");
console.log(res);
console.log("----");
if (res.code == 0) {
localStorage.setItem("user", JSON.stringify(res.data));
}
});
} else {
console.log("调用失败");
}
}
// 获取Token
export function getAuthToken() {
const userAgent = navigator.userAgent;
console.log("ua", userAgent);
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
// android
console.log("android, 和安卓交互");
const token = window.android.getAuthToken();
console.log("an-token", token);
return new Promise((resolve, reject) => {
if (token) {
saveUser(token);
resolve(token);
} else {
reject("失败");
}
});
} else if (userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
// ios
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);
}
});
});
}
}
// 退出
export function logoutToApp() {
console.log("退出登录");
const userAgent = navigator.userAgent;
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an");
window.android.logout();
} else {
jsBridge.callhandler("logout");
}
}
export function navigateBack() {
console.log("返回");
const userAgent = navigator.userAgent;
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an");
window.android.navigateBack();
} else {
jsBridge.callhandler("navigateBack");
}
}
export function showBottomBar(params) {
console.log("隐藏底部");
const userAgent = navigator.userAgent;
if (userAgent.indexOf("Android") > -1 || userAgent.indexOf("Adr") > -1) {
console.log("an");
window.android.showBottomBar(params);
} else {
jsBridge.callhandler("showBottomBar", params);
}
}
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
</van-cell-group> </van-cell-group>
<div class="detail"> <div class="detail">
<p style="font-size: 24px">提现金额</p> <p style="font-size: 24px">提现金额</p>
<van-field v-model="money" type="number" label="¥" class="money" /> <van-field v-model="money" type="number" label="¥" class="money" @blur="onFillMoneyBlur"/>
<div class="remain"> <div class="remain">
<span style="color: #666666" <span style="color: #666666"
>可提现金额{{ remainMoney.toFixed(2) }}</span >可提现金额{{ remainMoney.toFixed(2) }}</span
> >
<span class="all" @click="allIn">全部提现</span> <span v-if="remainMoney > 0" class="all" @click="allIn">全部提现</span>
</div> </div>
<div class="real"> <div class="real">
<p class="real-item"> <p class="real-item">
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
</template> </template>
<script> <script>
import { getWithdrawalAmount } from "@/api/wallet";
import { getUserBankInfo, sendSms, cashOut } from "@/api/bank"; import { getUserBankInfo, sendSms, cashOut } from "@/api/bank";
import BaseDialog from "@/components/BaseDialog.vue"; import BaseDialog from "@/components/BaseDialog.vue";
export default { export default {
...@@ -97,8 +98,28 @@ export default { ...@@ -97,8 +98,28 @@ export default {
}, },
created() { created() {
this.getUserInfo(); this.getUserInfo();
this.canCashOut();
}, },
methods: { methods: {
onFillMoneyBlur(e) {
if (e.target.value > this.remainMoney) {
this.$toast.fail('输入超过可提现金额,请重新输入')
return false
}
},
canCashOut() {
const params = {
userId: this.$userId
};
getWithdrawalAmount(params).then(res => {
if (res.code === 0) {
this.remainMoney = res.data.currentMoneyCan;
} else {
this.remainMoney = 100;
}
});
getWithdrawalAmount
},
jumpToBank() { jumpToBank() {
console.log("1"); console.log("1");
this.$router.push("/bank"); this.$router.push("/bank");
...@@ -113,7 +134,10 @@ export default { ...@@ -113,7 +134,10 @@ export default {
this.$toast.fail("未输入提现金额"); this.$toast.fail("未输入提现金额");
return; return;
} }
if (this.money > this.remainMoney) {
this.$toast.fail('输入超过可提现金额,请重新输入');
return
}
const params = { const params = {
userId: this.$userId userId: this.$userId
}; };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
> >
<van-button type="primary">上传新头像</van-button> <van-button type="primary">上传新头像</van-button>
</van-uploader> </van-uploader>
<van-button type="primary" plain @click="checkBtn">确定</van-button> <van-button type="primary" :class="!canSubmit && 'deactive-btn'" plain @click="checkBtn">确定</van-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -21,13 +21,21 @@ export default { ...@@ -21,13 +21,21 @@ export default {
name: "ModefyAvatar", name: "ModefyAvatar",
data() { data() {
return { return {
canSubmit: false,
avatar: "", avatar: "",
imageUrl: "" imageUrl: ""
}; };
}, },
mounted() { mounted() {
console.log("123"); console.log("123");
if (!this.avatar) { // if (!this.avatar) {
// this.avatar = require("@/assets/images/no_avatar.png");
// }
console.log(this.$route.query);
const headImage = this.$route.query.headImage;
if (headImage) {
this.avatar = process.env.VUE_APP_BASE_URL + headImage;
} else {
this.avatar = require("@/assets/images/no_avatar.png"); this.avatar = require("@/assets/images/no_avatar.png");
} }
}, },
...@@ -55,6 +63,7 @@ export default { ...@@ -55,6 +63,7 @@ export default {
uploadImage(params, fd).then(res => { uploadImage(params, fd).then(res => {
console.log(res); console.log(res);
this.imageUrl = res.zxUrl; this.imageUrl = res.zxUrl;
this.canSubmit = true;
}); });
}, },
onDeleteAvatar(file, detail) { onDeleteAvatar(file, detail) {
...@@ -90,14 +99,33 @@ export default { ...@@ -90,14 +99,33 @@ export default {
margin-bottom: 52px; margin-bottom: 52px;
border-radius: 4px; border-radius: 4px;
} }
.van-uploader {
font-size: 0;
}
.btn { .btn {
box-sizing: border-box;
display: flex; display: flex;
justify-content: space-around; justify-content: space-between;
align-content: center;
width: 345px;
height: 44px;
margin: 0 auto;
.van-uploader {
.van-button {
position: absolute;
top: 0;
left: 0;
}
::v-deep input {
width: 165px;
height: 44px;
}
}
.van-button { .van-button {
width: 165px; width: 165px;
} }
.deactive-btn {
color: #969595e9;
background-color: #dcd6d6;
border-color: #dcd6d6;
}
} }
</style> </style>
...@@ -46,13 +46,35 @@ export default { ...@@ -46,13 +46,35 @@ export default {
prizeVos: [] prizeVos: []
}; };
}, },
beforeRouteEnter(to, from, next) {
console.log('路由前');
try {
showBottomBar(false);
} catch {
console.log('无法请求App');
next()
}
},
beforeRouteLeave(to, form, next) {
console.log("离开");
try {
showBottomBar(true);
} catch {
console.log('未能和App交互');
next();
}
},
mounted() { mounted() {
this.getProgressPrizes(); this.getProgressPrizes();
}, },
methods: { methods: {
handlerBack() { handlerBack() {
try {
navigateBack(); navigateBack();
showBottomBar(true); } catch {
console.log('不能和App交互');
this.$router.go(-1);
}
}, },
getProgressPrizes() { getProgressPrizes() {
const _this = this; const _this = this;
......
...@@ -76,7 +76,7 @@ export default { ...@@ -76,7 +76,7 @@ export default {
localStorage.setItem("user", JSON.stringify(res)); localStorage.setItem("user", JSON.stringify(res));
this.$nextTick(() => { this.$nextTick(() => {
this.inviteeCode = res.inviteCode; this.inviteeCode = res.inviteCode;
this.avatar = "http://8.131.244.76:81" + res.headImage; this.avatar = process.env.VUE_APP_BASE_URL + res.headImage;
}) })
} }
}); });
...@@ -90,7 +90,12 @@ export default { ...@@ -90,7 +90,12 @@ export default {
this.$router.push("/instructions"); this.$router.push("/instructions");
}, },
onModefy() { onModefy() {
this.$router.push("/modefy-avatar"); this.$router.push({
path: "/modefy-avatar",
query: {
headImage: this.avatar
}
});
}, },
onCloseDialog() { onCloseDialog() {
this.inviteeCodeDialog = false; this.inviteeCodeDialog = false;
......
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