Compare commits
merge into: APP:master
APP:account
APP:course
APP:dev
APP:devMac
APP:feat-230721
APP:gongyingshang
APP:master
APP:md0726
APP:organize
APP:privacy
APP:tid1509
APP:tid1731
APP:tid1867
APP:tid1878
APP:voice
APP:voice08
pull from: APP:account
APP:account
APP:course
APP:dev
APP:devMac
APP:feat-230721
APP:gongyingshang
APP:master
APP:md0726
APP:organize
APP:privacy
APP:tid1509
APP:tid1731
APP:tid1867
APP:tid1878
APP:voice
APP:voice08
2 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
|
e2bca46922 |
add author
|
4 years ago |
|
9cbee1e4e4 |
add account modal
|
4 years ago |
4 changed files with 526 additions and 210 deletions
-
184src/components/author_modal/author_modal.vue
-
9src/pages.json
-
408src/pages/index/index.vue
-
117src/pages/login_and_bind/login_and_bind.vue
@ -0,0 +1,184 @@ |
|||||
|
<template> |
||||
|
<view class="ox-dark-mask"> |
||||
|
<view class="ic-author-modal"> |
||||
|
<view class="iam-title">微信授权</view> |
||||
|
<view class="iam-tip">您的信息和数据将受到保护</view> |
||||
|
<image class="iam-pic" mode="aspectFit" src="/static/images/icon/author_modal.png"></image> |
||||
|
<view class="iam-btns"> |
||||
|
<button plain hover-class="hover-active" @click="cancelAuthor">取消</button> |
||||
|
|
||||
|
<button |
||||
|
v-if="isProfile" |
||||
|
plain |
||||
|
hover-class="hover-active" |
||||
|
@click="profileConfirm" |
||||
|
>授权并登录</button> |
||||
|
<button |
||||
|
v-else |
||||
|
plain |
||||
|
hover-class="hover-active" |
||||
|
open-type="getUserInfo" |
||||
|
lang="zh_CN" |
||||
|
@getuserinfo="confirmAuthor" |
||||
|
>授权并登录</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { API } from '../../js/api'; |
||||
|
import { servers } from '../../js/server'; |
||||
|
import util from '../../utils/util' |
||||
|
const uniLogin = util.promisify(uni.login); |
||||
|
const APPID = uni.getAccountInfoSync().miniProgram.appId; |
||||
|
const app = getApp(); |
||||
|
export default { |
||||
|
computed: { |
||||
|
isProfile: _=>util.isProfile(), |
||||
|
}, |
||||
|
methods: { |
||||
|
// 新获取用户信息 |
||||
|
profileConfirm(){ |
||||
|
uni.getUserProfile({ |
||||
|
lang: 'zh_CN', desc: '授权登陆', |
||||
|
success: res => { |
||||
|
this.confirmAuthor({detail: {...res}}); |
||||
|
}, |
||||
|
fail: function(err) { |
||||
|
util.showNone('获取用户信息失败!请重试'); |
||||
|
console.warn('getUserProfile Err', err) |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
getLoginQuery({ |
||||
|
userInfo, |
||||
|
loginRes |
||||
|
}){ |
||||
|
return { |
||||
|
appid: APPID, |
||||
|
code: loginRes.code, |
||||
|
encryptedData: userInfo.encryptedData, |
||||
|
// is_details: 1, |
||||
|
// 后端解密错误,直接传用户信息 |
||||
|
user_info: userInfo.userInfo, |
||||
|
user_raw_data: userInfo.rawData, |
||||
|
...userInfo.userInfo, |
||||
|
} |
||||
|
}, |
||||
|
async confirmAuthor(userRes){ |
||||
|
if(!userRes.detail.userInfo){ |
||||
|
// this.closeAuthor(); |
||||
|
return util.showNone('获取用户信息失败!请稍后重试'); |
||||
|
} |
||||
|
let loginRes = await uniLogin(); |
||||
|
|
||||
|
if(!loginRes.code){ |
||||
|
// this.closeAuthor(); |
||||
|
return util.showNone('获取登陆凭证失败!稍后重试'); |
||||
|
} |
||||
|
|
||||
|
servers.post({ |
||||
|
url: API.wechatMiniAppLoginAndSync, |
||||
|
data: this.getLoginQuery({ |
||||
|
userInfo: userRes.detail, |
||||
|
loginRes |
||||
|
}), |
||||
|
isDefaultGet: false, |
||||
|
}) |
||||
|
.then(res=>{ |
||||
|
util.hideLoad(); |
||||
|
let _data = res.data || {}; |
||||
|
if(_data.code == 0){ |
||||
|
if(_data.data == '')return util.routeTo(`/pages/login/login`,'rL'); |
||||
|
util.showNone(_data.message || '登陆成功!'); |
||||
|
// let _data = res.data.data; |
||||
|
// if(_data.user.role == '')return util.routeTo(`/pages/merchant_login/merchant_login`,'rL'); |
||||
|
|
||||
|
uni.setStorageSync('token',_data.data); |
||||
|
|
||||
|
setTimeout(_=>{ |
||||
|
this.$emit('success', _data); |
||||
|
// this.getIndexInfo(); |
||||
|
// this.closeAuthor(); |
||||
|
// this.loginStatus = app.isLogin(); |
||||
|
}, 1200); |
||||
|
}else{ |
||||
|
|
||||
|
util.showNone(_data.message || '后台登陆失败!'); |
||||
|
setTimeout(_=>{ |
||||
|
this.$emit('fail', _data); |
||||
|
}, 1200) |
||||
|
// setTimeout(_=>this.closeAuthor(), 1200); |
||||
|
} |
||||
|
|
||||
|
}).catch(err=>{ |
||||
|
util.hideLoad(); |
||||
|
setTimeout(_=>{ |
||||
|
this.$emit('fail', err); |
||||
|
}, 1200) |
||||
|
}) |
||||
|
|
||||
|
}, |
||||
|
cancelAuthor(){ |
||||
|
this.$emit('cancel') |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
@import "~style/public.scss"; |
||||
|
.ic-author-modal{ |
||||
|
position: absolute; |
||||
|
left: 50%; |
||||
|
top: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
padding-top: 60upx; |
||||
|
width: 662upx; |
||||
|
height: 884upx; |
||||
|
border-radius: 10upx; |
||||
|
background-color: #fff; |
||||
|
.iam-title{ |
||||
|
margin-bottom: 22upx; |
||||
|
text-align: center; |
||||
|
line-height: 60upx; |
||||
|
font-size: 44upx; |
||||
|
font-weight: 500; |
||||
|
color: #1a1a1a; |
||||
|
} |
||||
|
.iam-tip{ |
||||
|
margin-bottom: 52upx; |
||||
|
line-height: 40upx; |
||||
|
text-align: center; |
||||
|
font-size: 28upx; |
||||
|
color: #9c9c9f; |
||||
|
} |
||||
|
.iam-pic{ |
||||
|
margin: 0 auto 62upx; |
||||
|
display: block; |
||||
|
width: 488upx; |
||||
|
height: 416upx; |
||||
|
} |
||||
|
.iam-btns{ |
||||
|
@include centerFlex(center); |
||||
|
>button{ |
||||
|
margin: 0 20upx; |
||||
|
width: 240upx; |
||||
|
height: 92upx; |
||||
|
line-height: 88upx; |
||||
|
text-align: center; |
||||
|
border-radius: 46upx; |
||||
|
border: 2upx solid $themeColor; |
||||
|
font-size: 32upx; |
||||
|
color: $themeColor; |
||||
|
&+button{ |
||||
|
background-color: $themeColor; |
||||
|
color: #fff; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
</style> |
@ -0,0 +1,117 @@ |
|||||
|
<template> |
||||
|
<view class="login-and-bind"> |
||||
|
<view class="lab-header"> |
||||
|
<view class="lh-txt"><text>您好,\n\r欢迎使用商家助手</text></view> |
||||
|
</view> |
||||
|
<view class="lab-main"> |
||||
|
<view class="lm-bar"></view> |
||||
|
<view class="lm-logo"></view> |
||||
|
<view class="lm-ipt-ls"> |
||||
|
<view class="lil-item"> |
||||
|
<input placeholder="请输入密码" /> |
||||
|
<view class="li-tip">您输入的账号信息有误,请检查重新输入</view> |
||||
|
</view> |
||||
|
<view class="lil-item"><input placeholder="请输入密码" /></view> |
||||
|
<view class="lil-item"><input placeholder="请输入密码" /></view> |
||||
|
</view> |
||||
|
<view class="lm-btn">登录</view> |
||||
|
<view class="lm-tip">账号登录成功后即被激活且绑定微信号</view> |
||||
|
<view class="lm-help-link">使用帮助</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
|
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
@import '~style/public.scss'; |
||||
|
page{ |
||||
|
background-color: #fff; |
||||
|
} |
||||
|
.login-and-bind{ |
||||
|
padding-bottom: 0upx; |
||||
|
padding-bottom: calc( 0upx + constant(safe-area-inset-bottom)); /* 兼容 iOS < 11.2 */ |
||||
|
padding-bottom: calc( 0upx + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */ |
||||
|
} |
||||
|
.lab-header{ |
||||
|
padding: 88upx 40upx 0; |
||||
|
height: 300upx; |
||||
|
background-color: #17a181; |
||||
|
.lh-txt{ |
||||
|
font-size: 56upx; |
||||
|
line-height: 66upx; |
||||
|
font-weight: 500; |
||||
|
color: #fff; |
||||
|
} |
||||
|
} |
||||
|
.lab-main{ |
||||
|
position: relative; |
||||
|
.lm-bar{ |
||||
|
height: 160upx; |
||||
|
background-color: skyblue; |
||||
|
|
||||
|
} |
||||
|
.lm-logo{ |
||||
|
margin: -146upx auto 68upx; |
||||
|
width: 176upx; |
||||
|
height: 176upx; |
||||
|
border-radius: 50%; |
||||
|
background-color: $themeColor; |
||||
|
} |
||||
|
.lm-ipt-ls{ |
||||
|
padding: 68upx 74upx 10upx; |
||||
|
.lil-item{ |
||||
|
position: relative; |
||||
|
margin-bottom: 50upx; |
||||
|
padding: 0 40upx; |
||||
|
height: 108upx; |
||||
|
border-radius: 54upx; |
||||
|
border: 2upx solid #D8D8D8; |
||||
|
@include centerFlex(center); |
||||
|
>input{ |
||||
|
flex-grow: 1; |
||||
|
height: 100%; |
||||
|
font-size: 32upx; |
||||
|
color: #1a1a1a; |
||||
|
} |
||||
|
.li-tip{ |
||||
|
position: absolute; |
||||
|
right: 0; |
||||
|
bottom: -42upx; |
||||
|
padding: 0 40upx; |
||||
|
font-size: 28upx; |
||||
|
line-height: 40upx; |
||||
|
color: #EA5061; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.lm-btn{ |
||||
|
margin: 0 auto 20upx; |
||||
|
width: 610upx; |
||||
|
line-height: 108upx; |
||||
|
border-radius: 54upx; |
||||
|
text-align: center; |
||||
|
font-size: 32upx; |
||||
|
color: #fff; |
||||
|
background-color: $themeColor; |
||||
|
} |
||||
|
.lm-tip{ |
||||
|
margin-bottom: 122upx; |
||||
|
text-align: center; |
||||
|
line-height: 40upx; |
||||
|
font-size: 28upx; |
||||
|
color: #B2B2B2; |
||||
|
} |
||||
|
.lm-help-link{ |
||||
|
text-align: center; |
||||
|
font-size: 28upx; |
||||
|
line-height: 40upx; |
||||
|
color: $themeColor; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue