|
@@ -16,12 +16,12 @@
|
|
</view>
|
|
</view>
|
|
<view class="item" @click="getmsg">
|
|
<view class="item" @click="getmsg">
|
|
<image src="/static/icon/wechart.png" mode="scaleToFill"></image>
|
|
<image src="/static/icon/wechart.png" mode="scaleToFill"></image>
|
|
- <text v-if="!isLoginOff">微信登录</text>
|
|
|
|
- <text v-if="isLoginOff">授权登录</text>
|
|
|
|
|
|
+ <text>微信登录</text>
|
|
|
|
+ <!-- <text v-if="isLoginOff">授权登录</text> -->
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
- <u-modal @close="closeMask" closeOnClickOverlay="true" :show="modal.show" :title="modal.title"
|
|
|
|
|
|
+ <!-- <u-modal @close="closeMask" closeOnClickOverlay="true" :show="modal.show" :title="modal.title"
|
|
:show-confirm-button="false">
|
|
:show-confirm-button="false">
|
|
<view>
|
|
<view>
|
|
<button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
|
|
<button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
|
|
@@ -32,8 +32,35 @@
|
|
@change="handleChangeNickname">
|
|
@change="handleChangeNickname">
|
|
<button class="confirm" @click="handleConfirmWechatUserInfo">提交</button>
|
|
<button class="confirm" @click="handleConfirmWechatUserInfo">提交</button>
|
|
</view>
|
|
</view>
|
|
- </u-modal>
|
|
|
|
|
|
+ </u-modal> -->
|
|
|
|
+ <u-popup :show="modal.show" :round="10" mode="bottom" @close="close">
|
|
|
|
+ <view class="popup-login">
|
|
|
|
+ <view class="popup-login-top">
|
|
|
|
+ <image style="width: 56rpx; height: 56rpx; margin-right: 20rpx; "
|
|
|
|
+ src="https://t9.9026.com/imgs/loginLogo1.png" mode=""></image>
|
|
|
|
+ <text>登录后体验更多功能</text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="popup-login-main">
|
|
|
|
+ <button class="avatar" open-type="chooseAvatar" @chooseavatar="handleChooseAvatar">
|
|
|
|
+ <image class="user-avatar" style="height: 176rpx;width: 176rpx;border-radius: 50%;"
|
|
|
|
+ :src="modal.avatar?modal.avatar:'https://t9.9026.com/imgs/loginAvatar.png'" />
|
|
|
|
+ </button>
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
+ <view class="popup-login-ipt">
|
|
|
|
+ <input class="avatar" type="nickname" :value="modal.nickname" placeholder="输入昵称"
|
|
|
|
+ @change="handleChangeNickname">
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <view class="popup-login-btn" @click="handleConfirmWechatUserInfo">
|
|
|
|
+ <button class="confirm">完成</button>
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <view class="popup-login-text">
|
|
|
|
+ <view>登录即代表已阅读并同意<text style="color: #FF6200;">服务协议、隐私协议</text></view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </u-popup>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -42,7 +69,7 @@
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- imgBase64:'',
|
|
|
|
|
|
+ imgBase64: '',
|
|
isLoginOff: false,
|
|
isLoginOff: false,
|
|
modal: {
|
|
modal: {
|
|
show: false,
|
|
show: false,
|
|
@@ -60,30 +87,33 @@
|
|
this.isLoginOff = this.$store.getters.userInfo
|
|
this.isLoginOff = this.$store.getters.userInfo
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
-
|
|
|
|
|
|
+
|
|
getPageUrl() {
|
|
getPageUrl() {
|
|
const pages = getCurrentPages();
|
|
const pages = getCurrentPages();
|
|
- console.log(pages,'--------->pages')
|
|
|
|
- if(pages.length==1){
|
|
|
|
|
|
+ console.log(pages, '--------->pages')
|
|
|
|
+ if (pages.length == 1) {
|
|
const currentPage = pages[0];
|
|
const currentPage = pages[0];
|
|
let pageUrl = `${currentPage.$page.fullPath}`;
|
|
let pageUrl = `${currentPage.$page.fullPath}`;
|
|
console.log('当前页面url1:', pageUrl);
|
|
console.log('当前页面url1:', pageUrl);
|
|
return pageUrl
|
|
return pageUrl
|
|
-
|
|
|
|
- }else{
|
|
|
|
|
|
+
|
|
|
|
+ } else {
|
|
const currentPage = pages[pages.length - 2];
|
|
const currentPage = pages[pages.length - 2];
|
|
let pageUrl = `${currentPage.$page.fullPath}`;
|
|
let pageUrl = `${currentPage.$page.fullPath}`;
|
|
console.log('当前页面url2:', pageUrl);
|
|
console.log('当前页面url2:', pageUrl);
|
|
return pageUrl
|
|
return pageUrl
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//关闭遮罩层
|
|
//关闭遮罩层
|
|
closeMask() {
|
|
closeMask() {
|
|
this.modal.show = false
|
|
this.modal.show = false
|
|
},
|
|
},
|
|
|
|
+ close() {
|
|
|
|
+ this.modal.show = false
|
|
|
|
+ },
|
|
//提交
|
|
//提交
|
|
handleConfirmWechatUserInfo() {
|
|
handleConfirmWechatUserInfo() {
|
|
if (!this.modal.avatar) {
|
|
if (!this.modal.avatar) {
|
|
@@ -102,14 +132,14 @@
|
|
this.$hideLoading()
|
|
this.$hideLoading()
|
|
this.$store.dispatch('user/info', res.data)
|
|
this.$store.dispatch('user/info', res.data)
|
|
this.modal.show = false
|
|
this.modal.show = false
|
|
-
|
|
|
|
|
|
+
|
|
//获取登录页前地址
|
|
//获取登录页前地址
|
|
let pages = this.getPageUrl()
|
|
let pages = this.getPageUrl()
|
|
- if(pages){
|
|
|
|
|
|
+ if (pages != '/pages/login/login') {
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|
|
- url:pages
|
|
|
|
|
|
+ url: pages,
|
|
})
|
|
})
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
uni.switchTab({
|
|
uni.switchTab({
|
|
url: '/pages/my/my'
|
|
url: '/pages/my/my'
|
|
})
|
|
})
|
|
@@ -120,31 +150,37 @@
|
|
this.modal.show = true
|
|
this.modal.show = true
|
|
},
|
|
},
|
|
// 获取头像
|
|
// 获取头像
|
|
- handleChooseAvatar({detail}) {
|
|
|
|
|
|
+ handleChooseAvatar({
|
|
|
|
+ detail
|
|
|
|
+ }) {
|
|
let _this = this
|
|
let _this = this
|
|
// this.modal.avatar = detail.avatarUrl
|
|
// this.modal.avatar = detail.avatarUrl
|
|
uni.getFileSystemManager().readFile({
|
|
uni.getFileSystemManager().readFile({
|
|
- filePath:detail.avatarUrl, // 选择图片返回的相对路径
|
|
|
|
- encoding: 'base64', // 编码格式
|
|
|
|
- success: res => { // 成功的回调
|
|
|
|
- uni.uploadFile({
|
|
|
|
- url: _this.$setting.BASE_URL + '/v1/user/uploadFile',
|
|
|
|
- // filePath: 'data:image/png;base64,' + res.data,
|
|
|
|
- filePath: detail.avatarUrl,
|
|
|
|
- name: 'file',
|
|
|
|
- success({ data }) {
|
|
|
|
- const res = JSON.parse(data)
|
|
|
|
- const { url } = res.data
|
|
|
|
- _this.modal.avatar = url
|
|
|
|
- console.log('-->data', _this.modal.avatar)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // this.modal.avatar = detail.avatarUrl
|
|
|
|
- // console.log('data:image/png;base64,' + res.data)
|
|
|
|
- }
|
|
|
|
|
|
+ filePath: detail.avatarUrl, // 选择图片返回的相对路径
|
|
|
|
+ encoding: 'base64', // 编码格式
|
|
|
|
+ success: res => { // 成功的回调
|
|
|
|
+ uni.uploadFile({
|
|
|
|
+ url: _this.$setting.BASE_URL + '/v1/user/uploadFile',
|
|
|
|
+ // filePath: 'data:image/png;base64,' + res.data,
|
|
|
|
+ filePath: detail.avatarUrl,
|
|
|
|
+ name: 'file',
|
|
|
|
+ success({
|
|
|
|
+ data
|
|
|
|
+ }) {
|
|
|
|
+ const res = JSON.parse(data)
|
|
|
|
+ const {
|
|
|
|
+ url
|
|
|
|
+ } = res.data
|
|
|
|
+ _this.modal.avatar = url
|
|
|
|
+ console.log('-->data', _this.modal.avatar)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // this.modal.avatar = detail.avatarUrl
|
|
|
|
+ // console.log('data:image/png;base64,' + res.data)
|
|
|
|
+ }
|
|
})
|
|
})
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
},
|
|
},
|
|
//获取昵称
|
|
//获取昵称
|
|
handleChangeNickname(res) {
|
|
handleChangeNickname(res) {
|
|
@@ -169,41 +205,34 @@
|
|
},
|
|
},
|
|
//获取微信登录的code码
|
|
//获取微信登录的code码
|
|
getmsg() {
|
|
getmsg() {
|
|
- if (this.isLoginOff) {
|
|
|
|
- uni.switchTab({
|
|
|
|
- url: '/pages/my/my'
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- uni.login({
|
|
|
|
- provider: uni.$u.platform,
|
|
|
|
- success: res => {
|
|
|
|
- this.getCode().then((data) => {
|
|
|
|
- const params = {
|
|
|
|
- code: res.code,
|
|
|
|
- iv: data.iv,
|
|
|
|
- encryptData: data.encryptData
|
|
|
|
|
|
+ uni.login({
|
|
|
|
+ provider: uni.$u.platform,
|
|
|
|
+ success: res => {
|
|
|
|
+ this.getCode().then((data) => {
|
|
|
|
+ const params = {
|
|
|
|
+ code: res.code,
|
|
|
|
+ iv: data.iv,
|
|
|
|
+ encryptData: data.encryptData
|
|
|
|
+ }
|
|
|
|
+ console.log(params);
|
|
|
|
+ this.$api.my.myLogin(params).then(res => {
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
+ let {
|
|
|
|
+ token
|
|
|
|
+ } = res.data
|
|
|
|
+ this.handleGetWechatUserInfo()
|
|
|
|
+ // this.handleConfirmWechatUserInfo()
|
|
|
|
+ this.$store.dispatch('user/token', token)
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ icon: 'none',
|
|
|
|
+ title: res.msg
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- console.log(params);
|
|
|
|
- this.$api.my.myLogin(params).then(res => {
|
|
|
|
- if(res.code == 0){
|
|
|
|
- let {
|
|
|
|
- token
|
|
|
|
- } = res.data
|
|
|
|
- this.$store.dispatch('user/token', token)
|
|
|
|
- this.handleGetWechatUserInfo()
|
|
|
|
- this.handleConfirmWechatUserInfo()
|
|
|
|
- }else{
|
|
|
|
- uni.showToast({
|
|
|
|
- icon:'none',
|
|
|
|
- title:res.msg
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
})
|
|
})
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
}
|
|
}
|
|
@@ -220,16 +249,7 @@
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
|
|
|
|
- .avatar {
|
|
|
|
- width: 176rpx;
|
|
|
|
- height: 176rpx;
|
|
|
|
- border-radius: 50%;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- .user-avatar {
|
|
|
|
- object-fit: cover;
|
|
|
|
- object-position: center;
|
|
|
|
- }
|
|
|
|
|
|
|
|
.userinfo {
|
|
.userinfo {
|
|
position: absolute;
|
|
position: absolute;
|
|
@@ -332,4 +352,102 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //登录弹框
|
|
|
|
+ .popup-login {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 706rpx;
|
|
|
|
+ background: #FFFFFF;
|
|
|
|
+ box-shadow: 0rpx -10rpx 32rpx 0px rgba(0, 0, 0, 0.04);
|
|
|
|
+ border-radius: 16rpx 16rpx 0px 0px;
|
|
|
|
+ padding: 40rpx 64rpx 92rpx;
|
|
|
|
+
|
|
|
|
+ .popup-login-top {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
+ font-size: 30rpx;
|
|
|
|
+ font-weight: bold;
|
|
|
|
+ color: #000000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .popup-login-main {
|
|
|
|
+ width: 100%;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ margin-top: 62rpx;
|
|
|
|
+
|
|
|
|
+ .avatar {
|
|
|
|
+ width: 176rpx;
|
|
|
|
+ height: 176rpx;
|
|
|
|
+ border-radius: 50%;
|
|
|
|
+ border: 0;
|
|
|
|
+ background: transparent;
|
|
|
|
+
|
|
|
|
+ &::after {
|
|
|
|
+ border: none;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .user-avatar {
|
|
|
|
+ object-fit: cover;
|
|
|
|
+ object-position: center;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .popup-login-ipt {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 88rpx;
|
|
|
|
+ background: #F6F6F6;
|
|
|
|
+ border-radius: 44rpx;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ margin-top: 48rpx;
|
|
|
|
+
|
|
|
|
+ .avatar {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ text-align: center;
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
+ font-weight: bold;
|
|
|
|
+ color: #999999;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .popup-login-btn {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 88rpx;
|
|
|
|
+ background: #1AAC1B;
|
|
|
|
+ border-radius: 38rpx;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ margin-top: 32rpx;
|
|
|
|
+
|
|
|
|
+ .confirm {
|
|
|
|
+ border: 0;
|
|
|
|
+ background: transparent;
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
+ font-weight: bold;
|
|
|
|
+ color: #FFFFFF;
|
|
|
|
+
|
|
|
|
+ &::after {
|
|
|
|
+ border: none;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .popup-login-text {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ margin-top: 32rpx;
|
|
|
|
+ font-weight: bold;
|
|
|
|
+ color: #999999;
|
|
|
|
+ font-size: 22rpx;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|