|
|
@@ -15,10 +15,10 @@
|
|
|
<image src="../../static/images/air.png" mode=""></image>
|
|
|
<text>共享空调</text>
|
|
|
</navigator>
|
|
|
- <!-- <navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
|
|
|
+ <navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
|
|
|
<image src="../../static/images/bus.png" mode=""></image>
|
|
|
<text>校车预约</text>
|
|
|
- </navigator> -->
|
|
|
+ </navigator>
|
|
|
<!-- <navigator :url="'/pagesClockIn/index/index'" open-type="navigate" class="menu_item">
|
|
|
<image src="../../static/images/clockIn.png" mode=""></image>
|
|
|
<text>校园打卡</text>
|
|
|
@@ -29,23 +29,32 @@
|
|
|
</navigator> -->
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="qr_code" v-if="showQR_code"><image :src="qr_code_url" 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()"
|
|
|
+ @success="login_success_callback"
|
|
|
+ @cancel="login_cancel_callback"
|
|
|
+ @fail="login_fail_callback"
|
|
|
/>
|
|
|
</view>
|
|
|
+ <Popup :showPopup="showPopup" @close="showPopup = false">
|
|
|
+ <view class="pupup-content">
|
|
|
+ <text class="pupup-title">请截屏,再识别二维码领取校园卡</text>
|
|
|
+ <image src="../../static/images/qr.jpg" mode="aspectFill" class="pupup-img"></image>
|
|
|
+ </view>
|
|
|
+ </Popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import Popup from '@/components/Popup.vue';
|
|
|
export default {
|
|
|
+ components: {
|
|
|
+ Popup
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
ceshi: 'code',
|
|
|
@@ -62,7 +71,7 @@ export default {
|
|
|
validation_times: 0, // 授权次数
|
|
|
from: 0, // 跳转参数
|
|
|
execed_onload: false,
|
|
|
- qr_code_url: this.$code_base_url + '/HotWaters/image/1.jpg'
|
|
|
+ showPopup: false
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -168,7 +177,7 @@ export default {
|
|
|
this.login_fail_callback()
|
|
|
} else {
|
|
|
try {
|
|
|
- uni.removeStorageSync('userinfo_storage_key')
|
|
|
+ // uni.removeStorageSync('userinfo_storage_key')
|
|
|
setTimeout(() => {
|
|
|
this.showLogin = false
|
|
|
this.userinfo = {}
|
|
|
@@ -187,12 +196,10 @@ export default {
|
|
|
* 授权登陆取消回调
|
|
|
*/
|
|
|
login_fail_callback() {
|
|
|
- this.userinfo = {}
|
|
|
- // setTimeout(() => {
|
|
|
- // this.validation_failed = true
|
|
|
- // }, 3000);
|
|
|
- if (!this.validation_failed) {
|
|
|
- this.validation_failed = false
|
|
|
+ var _this = this;
|
|
|
+ _this.userinfo = {}
|
|
|
+ if (!_this.validation_failed) {
|
|
|
+ _this.validation_failed = false
|
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
|
content: '授权:请先领取校园卡、并激活!',
|
|
|
@@ -200,34 +207,8 @@ export default {
|
|
|
confirmText: '领取',
|
|
|
success: res1 => {
|
|
|
if (res1.confirm) {
|
|
|
- uni.navigateTo({
|
|
|
- url: '../qr_code/qr_code'
|
|
|
- })
|
|
|
- // 出现二维码,用户扫描二维码添加校园卡、激活
|
|
|
- // uni.downloadFile({
|
|
|
- // url: 'https://chtech.ncjti.edu.cn/shuidian/HotWaters/image/1.jpg',
|
|
|
- // success: (res2) => {
|
|
|
- // // console.log(res2);
|
|
|
- // if (res2.statusCode == 200) {
|
|
|
- // uni.saveImageToPhotosAlbum({
|
|
|
- // filePath: res2
|
|
|
- // .tempFilePath,
|
|
|
- // success: function() {
|
|
|
- // uni.showToast({
|
|
|
- // title: "保存成功!请用微信扫码添加校园卡!",
|
|
|
- // icon: "none"
|
|
|
- // });
|
|
|
- // },
|
|
|
- // fail: function() {
|
|
|
- // uni.showToast({
|
|
|
- // title: "保存失败,请手动截图保存,再用微信扫二维码!",
|
|
|
- // icon: "none"
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
+ // 截屏,用户利用微信识别二维码添加校园卡、激活
|
|
|
+ _this.showPopup = true;
|
|
|
} else if (res1.cancel) {
|
|
|
// console.log('用户点击取消');
|
|
|
// uni.showToast({
|
|
|
@@ -263,7 +244,7 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
uni.hideLoading()
|
|
|
}, 1000)
|
|
|
-
|
|
|
+
|
|
|
// 通过wxcode换取access_token
|
|
|
this.get_access_token(wxcode)
|
|
|
},
|
|
|
@@ -310,14 +291,14 @@ export default {
|
|
|
data: {
|
|
|
access_token: param_access_token
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// console.log(res);
|
|
|
if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
|
|
|
try {
|
|
|
this.userinfo = res.data
|
|
|
- this.$store.state.userInfo = this.userinfo
|
|
|
-
|
|
|
+ this.$store.state.userInfo = res.data
|
|
|
+
|
|
|
// 获取code,然后去检查是否存在数据库中
|
|
|
this.getCode()
|
|
|
} catch (e) {
|
|
|
@@ -334,12 +315,13 @@ export default {
|
|
|
* 获得code
|
|
|
*/
|
|
|
getCode() {
|
|
|
+ var _this = this;
|
|
|
uni.login({
|
|
|
success: res => {
|
|
|
// console.log('reshui', res);
|
|
|
if (res.code) {
|
|
|
// 检查用户是否存在第三方库
|
|
|
- this.chk_user_is_in_db(res.code)
|
|
|
+ _this.chk_user_is_in_db(res.code)
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: res.errMsg,
|
|
|
@@ -353,16 +335,17 @@ export default {
|
|
|
* 检查数据库中是否有该用户信息
|
|
|
*/
|
|
|
async chk_user_is_in_db(param_code) {
|
|
|
- const res = await this.$myRequest({
|
|
|
+ var _this = this;
|
|
|
+ const res = await _this.$myRequest({
|
|
|
// host: 'local',
|
|
|
- host: this.ceshi,
|
|
|
+ host: _this.ceshi,
|
|
|
url: '/HotWaters/wpopenid.action',
|
|
|
method: 'POST',
|
|
|
header: {
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
},
|
|
|
data: {
|
|
|
- userinfo: JSON.stringify(this.userinfo),
|
|
|
+ userinfo: JSON.stringify(_this.userinfo),
|
|
|
code: param_code
|
|
|
}
|
|
|
})
|
|
|
@@ -370,14 +353,14 @@ export default {
|
|
|
// console.log(res);
|
|
|
if (res.data.code == 0 || res.data.code == 100) {
|
|
|
// 存储用户信息
|
|
|
- uni.setStorageSync('userinfo_storage_key', this.userinfo)
|
|
|
+ uni.setStorageSync('userinfo_storage_key', _this.userinfo)
|
|
|
// 提示授权成功
|
|
|
uni.showToast({
|
|
|
icon: 'success',
|
|
|
title: '授权成功',
|
|
|
duration: 800,
|
|
|
success: res => {
|
|
|
- if (this.from != 0 || this.from != '0') {
|
|
|
+ if (_this.from != 0 || _this.from != '0') {
|
|
|
uni.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
@@ -469,16 +452,21 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- .qr_code {
|
|
|
+
|
|
|
+ .pupup-content {
|
|
|
display: flex;
|
|
|
+ flex-direction: column;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
- width: 750rpx;
|
|
|
height: 100%;
|
|
|
- position: fixed;
|
|
|
- left: 0;
|
|
|
- top: 0;
|
|
|
- background-color: #ffffff;
|
|
|
+
|
|
|
+ .pupup-title {
|
|
|
+ padding-bottom: 20rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pupup-img {
|
|
|
+ height: 90%;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|