|
|
@@ -21,6 +21,9 @@
|
|
|
</navigator>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="qr_code" v-if="showQR_code">
|
|
|
+ <image src="https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg" mode="aspectFit"></image>
|
|
|
+ </view>
|
|
|
<view v-if="showLogin">
|
|
|
<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible"
|
|
|
@success="login_success_callback()" @cancel="login_cancel_callback()" @fail="login_fail_callback()" />
|
|
|
@@ -42,15 +45,13 @@
|
|
|
app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
|
|
|
my_display: false,
|
|
|
userinfo: '',
|
|
|
- wxcode: '',
|
|
|
- access_token: '',
|
|
|
- code: '',
|
|
|
+ showQR_code: false,
|
|
|
from: 0
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- console.log(options)
|
|
|
- if (options && JSON.stringify(options) != '{}' && typeof(options.from) != 'undefined') {
|
|
|
+ // console.log(options)
|
|
|
+ if (typeof(options.from) != 'undefined') {
|
|
|
this.from = options.from
|
|
|
}
|
|
|
// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
|
|
|
@@ -146,7 +147,7 @@
|
|
|
this.userinfo = {};
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '需要先授权,请点击右下角【重新授权】按钮'
|
|
|
+ title: '请先授权,点击右下角【重新授权】按钮'
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
@@ -156,32 +157,33 @@
|
|
|
this.userinfo = {};
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: '授权失败,请先领取校园卡、激活',
|
|
|
+ title: '授权失败,请先领取校园卡、再激活!',
|
|
|
duration: 3000,
|
|
|
success: (res) => {
|
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
|
content: '是否将校园卡二维码,保存到相册?',
|
|
|
- showCancel: false,
|
|
|
- success: res => {
|
|
|
- if (res.confirm) {
|
|
|
+ cancelText: '手动截图',
|
|
|
+ confirmText: '自动保存',
|
|
|
+ success: (res1) => {
|
|
|
+ if (res1.confirm) {
|
|
|
// 出现二维码,用户扫描二维码添加校园卡、激活
|
|
|
uni.downloadFile({
|
|
|
- url: 'https://www.ecjtuit.edu.cn/img/zs.jpg',
|
|
|
- success: (res) => {
|
|
|
- console.log(res);
|
|
|
- if (res.statusCode === 200) {
|
|
|
+ url: 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg',
|
|
|
+ success: (res2) => {
|
|
|
+ // console.log(res2);
|
|
|
+ if (res2.statusCode == 200) {
|
|
|
uni.saveImageToPhotosAlbum({
|
|
|
- filePath: res.tempFilePath,
|
|
|
+ filePath: res2.tempFilePath,
|
|
|
success: function() {
|
|
|
uni.showToast({
|
|
|
- title: "保存成功",
|
|
|
+ title: "保存成功!请用微信扫码添加校园卡!",
|
|
|
icon: "none"
|
|
|
});
|
|
|
},
|
|
|
fail: function() {
|
|
|
uni.showToast({
|
|
|
- title: "保存失败,请稍后重试",
|
|
|
+ title: "保存失败,请手动截图保存,再用微信扫二维码!",
|
|
|
icon: "none"
|
|
|
});
|
|
|
}
|
|
|
@@ -189,8 +191,9 @@
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- } else if (res.cancel) {
|
|
|
- console.log('用户点击取消');
|
|
|
+ } else if (res1.cancel) {
|
|
|
+ // console.log('用户点击取消');
|
|
|
+ this.showQR_code = true;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -207,16 +210,13 @@
|
|
|
wxcode = ""
|
|
|
} = detail
|
|
|
|
|
|
- // 获取wxcode
|
|
|
- this.wxcode = wxcode
|
|
|
-
|
|
|
// 通过wxcode换取access_token
|
|
|
- this.get_access_token()
|
|
|
+ this.get_access_token(wxcode)
|
|
|
},
|
|
|
/**
|
|
|
* 通过wxcode换取access_token
|
|
|
*/
|
|
|
- async get_access_token() {
|
|
|
+ async get_access_token(param_wxcode) {
|
|
|
const res = await this.$myRequest({
|
|
|
host: 'wecard',
|
|
|
url: '/connect/oauth2/token',
|
|
|
@@ -225,7 +225,7 @@
|
|
|
'content-type': 'application/json'
|
|
|
},
|
|
|
data: {
|
|
|
- 'wxcode': this.wxcode,
|
|
|
+ 'wxcode': param_wxcode,
|
|
|
'app_key': this.appkey,
|
|
|
'app_secret': this.app_secret,
|
|
|
'grant_type': 'authorization_code',
|
|
|
@@ -238,16 +238,14 @@
|
|
|
title: '未获得token'
|
|
|
});
|
|
|
} else {
|
|
|
- this.access_token = res.data.access_token;
|
|
|
-
|
|
|
// 通过access_token换取用户信息
|
|
|
- this.get_user_info();
|
|
|
+ this.get_user_info(res.data.access_token);
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
* 通过access_token换取用户信息
|
|
|
*/
|
|
|
- async get_user_info() {
|
|
|
+ async get_user_info(param_access_token) {
|
|
|
const res = await this.$myRequest({
|
|
|
host: 'wecard',
|
|
|
url: '/connect/oauth/get-user-info',
|
|
|
@@ -256,7 +254,7 @@
|
|
|
'content-type': 'application/json'
|
|
|
},
|
|
|
data: {
|
|
|
- "access_token": this.access_token
|
|
|
+ "access_token": param_access_token
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -265,7 +263,7 @@
|
|
|
this.userinfo = res.data
|
|
|
this.$store.state.userInfo = this.userinfo
|
|
|
|
|
|
- // 获得code,然后去检查是否存在数据库中
|
|
|
+ // 获取code,然后去检查是否存在数据库中
|
|
|
this.getCode()
|
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
|
@@ -285,10 +283,8 @@
|
|
|
success: (res) => {
|
|
|
// console.log('reshui', res);
|
|
|
if (res.code) {
|
|
|
- this.code = res.code
|
|
|
-
|
|
|
// 检查用户是否存在第三方库
|
|
|
- this.chk_user_is_in_db()
|
|
|
+ this.chk_user_is_in_db(res.code)
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: res.errMsg,
|
|
|
@@ -301,7 +297,7 @@
|
|
|
/**
|
|
|
* 检查数据库中是否有该用户信息
|
|
|
*/
|
|
|
- async chk_user_is_in_db() {
|
|
|
+ async chk_user_is_in_db(param_code) {
|
|
|
const res = await this.$myRequest({
|
|
|
// host: 'local',
|
|
|
host: this.ceshi,
|
|
|
@@ -312,7 +308,7 @@
|
|
|
},
|
|
|
data: {
|
|
|
"userinfo": JSON.stringify(this.userinfo),
|
|
|
- "code": this.code
|
|
|
+ "code": param_code
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -328,7 +324,7 @@
|
|
|
success: (res) => {
|
|
|
this.my_display = true
|
|
|
|
|
|
- if (this.from != 0) {
|
|
|
+ if (this.from != 0 || this.from != '0') {
|
|
|
uni.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
@@ -421,6 +417,17 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ .qr_code {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ width: 750rpx;
|
|
|
+ height: 100%;
|
|
|
+ position: fixed;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ background-color: #FFFFFF;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|