Commit c95b648e authored by leiqingsong's avatar leiqingsong

安卓联调对接

parent 0bf3fdbf
# 生产环境 部署生产环境放开这个 # 生产环境 部署生产环境放开这个
# VUE_APP_BASE_URL = "http://app.xitiansen.com" VUE_APP_BASE_URL = "http://app.xitiansen.com"
# 测试环境 部署测试环境放开这个 # 测试环境 部署测试环境放开这个
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
...@@ -27,11 +27,12 @@ export default { ...@@ -27,11 +27,12 @@ export default {
this.$bridgeToAppFun this.$bridgeToAppFun
.getAuthToken() .getAuthToken()
.then(res => { .then(res => {
console.log("获取token成功", res); console.log("获取到token成功", res);
localStorage.setItem('token', res);
this.saveUser(res); this.saveUser(res);
}) })
.catch(err => { .catch(err => {
console.log("获取token失败", err); console.log("获取token失败123", err);
}); });
}, },
methods: { methods: {
......
...@@ -23,7 +23,6 @@ export default { ...@@ -23,7 +23,6 @@ export default {
const currentPage = this.$router.currentRoute.name; const currentPage = this.$router.currentRoute.name;
console.log("router", currentPage); console.log("router", currentPage);
const whiteList = [ const whiteList = [
"MyStatus",
"Publish", "Publish",
"FastestProgress", "FastestProgress",
"MonthAward", "MonthAward",
......
...@@ -18,30 +18,28 @@ class bridgeToAppFun { ...@@ -18,30 +18,28 @@ class bridgeToAppFun {
} }
// 获取Token // 获取Token
getAuthToken() { getAuthToken() {
console.log('系统:', this.userAgent); console.log("系统:", this.userAgent);
if (this.userAgent === "android") { if (this.userAgent === "android") {
// android // android
let token = null; let token = null;
try {
token = window.android.getAuthToken();
localStorage.setItem("token", token);
} catch {
console.log("token获取失败");
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (token) { console.log('版本', window.android.getAppVersion());
console.log('接收', window.android.getToken());
token = window.android.getToken();
console.log('token', token);
if(token) {
resolve(token); resolve(token);
} else { } else {
reject("失败"); reject('没有token');
} }
}); });
} else if (this.userAgent === "ios") { } else if (this.userAgent === "ios") {
// ios // ios
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log('调ios的方法'); console.log("调ios的方法");
jsBridge.callhandler("getAuthToken", null, data => { jsBridge.callhandler("getAuthToken", null, data => {
localStorage.setItem("token", data);
if (data) { if (data) {
// localStorage.setItem("token", data);
resolve(data); resolve(data);
} else { } else {
console.log("调用失败"); console.log("调用失败");
...@@ -66,9 +64,10 @@ class bridgeToAppFun { ...@@ -66,9 +64,10 @@ class bridgeToAppFun {
console.log("返回"); console.log("返回");
if (this.userAgent === "android") { if (this.userAgent === "android") {
try { try {
const home_url = // const home_url =
"https://shop92680967.youzan.com/v2/showcase/homepage?alias=6aFsQ4vCp7"; // "https://shop92680967.youzan.com/v2/showcase/homepage?alias=6aFsQ4vCp7";
location.href = home_url; // location.href = home_url;
window.android1.navigateBack();
} catch { } catch {
console.log("返回调用失败,都不行"); console.log("返回调用失败,都不行");
} }
...@@ -95,6 +94,20 @@ class bridgeToAppFun { ...@@ -95,6 +94,20 @@ class bridgeToAppFun {
jsBridge.callhandler("redirectToLogin"); jsBridge.callhandler("redirectToLogin");
} }
} }
// 保存图片
saveImage(url) {
console.log("调用App保存图片, 图片地址", url);
if (this.userAgent === "android") {
console.log("an");
window.android.appSaveImage(url);
} else {
jsBridge.callhandler("appSaveImage", url, response => {
if (response) {
console.log("保存成功");
}
});
}
}
} }
export default bridgeToAppFun; export default bridgeToAppFun;
...@@ -106,11 +106,15 @@ export default { ...@@ -106,11 +106,15 @@ export default {
this.$toast.fail("请输入身份证号"); this.$toast.fail("请输入身份证号");
return; return;
} }
if (!/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(this.form.idCardNo)) { if (
!/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(
this.form.idCardNo
)
) {
this.$toast.fail("请输入正确的身份证号"); this.$toast.fail("请输入正确的身份证号");
return; return;
} }
if(!/^[a-zA-Z\u4e00-\u9fa5]+$/.test(this.form.name)){ if (!/^[a-zA-Z\u4e00-\u9fa5]+$/.test(this.form.name)) {
this.$toast.fail("姓名仅支持中文或英文"); this.$toast.fail("姓名仅支持中文或英文");
return; return;
} }
......
...@@ -246,7 +246,7 @@ export default { ...@@ -246,7 +246,7 @@ export default {
const params = { const params = {
code: this.validCode, code: this.validCode,
money: this.money, money: this.money,
userId:JSON.parse(localStorage.getItem("user")).userId userId: JSON.parse(localStorage.getItem("user")).userId
}; };
cashOut(params) cashOut(params)
.then(res => { .then(res => {
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
<div class="save-code"> <div class="save-code">
<p>保存二维码</p> <p>保存二维码</p>
<p>打开微信扫一扫添加客服</p> <p>打开微信扫一扫添加客服</p>
<p>请截图保存!</p> <!-- <p>请截图保存!</p> -->
</div> </div>
<!-- <van-button>保存</van-button> --> <van-button @click="onSave">保存</van-button>
</div> </div>
</div> </div>
</div> </div>
...@@ -39,6 +39,10 @@ export default { ...@@ -39,6 +39,10 @@ export default {
}, },
mounted() {}, mounted() {},
methods: { methods: {
onSave() {
const url = this.imageUrl;
this.$bridgeToAppFun.saveImage(url);
},
handlerBack() { handlerBack() {
try { try {
this.$bridgeToAppFun.navigateBack(); this.$bridgeToAppFun.navigateBack();
......
...@@ -4,7 +4,7 @@ const name = "西田森App"; ...@@ -4,7 +4,7 @@ const name = "西田森App";
module.exports = { module.exports = {
publicPath: "/front", publicPath: "/front",
// outputDir: "front", outputDir: "front",
devServer: { devServer: {
proxy: { proxy: {
'/shop-mall': { '/shop-mall': {
......
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