调整授权登录接口

static-project
chen 2022-05-27 10:21:12 +08:00
parent 3401446e65
commit d9a876a4ce
6 changed files with 86 additions and 121 deletions

21
App.vue
View File

@ -4,11 +4,28 @@
projectname:'', //
lat:'', //
lng:'' ,//
hostapi:'https://www.baidu.com' //
hostapi:'http://caimall.scdxtc.cn' //
},
// show
onLaunch: function() {
uni.login({
success: (res) => {
uni.request({
url: this.globalData.hostapi +'/api/user/login',
data:{code:res.code},
success: (result) => {
console.log(result);
uni.setStorageSync('userId',result.data.account_id);
uni.setStorageSync('token',result.data.data.token);//token
uni.setStorageSync('openid',result.data.data.openid);//openid
uni.setStorageSync('expire',result.data.data.expire);//
uni.setStorageSync('phone_active',result.data.data.phone_active);//
uni.setStorageSync('is_active',result.data.data.is_active);//
uni.setStorageSync('invite_code',result.data.data.invite_code);//
}
})
}
})
},
onShow: function() {
if(uni.getStorageSync('token')){

View File

@ -109,7 +109,7 @@
if(index==0){
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
} else {
// if(!this.$toolAll.tools.judgeAuth()) {
if(this.$toolAll.tools.judgeAuth()) {
//
switch (index){
case 1:
@ -122,12 +122,7 @@
uni.reLaunch({url:'/pages/tabbar/my/my'})
break;
}
// } else {
// //
// uni.navigateTo({
// url:'/pages/login/login'
// })
// }
}
}
}
}

View File

@ -383,10 +383,11 @@ const tools = {
judgeAuth(){
let auth = false;
clearTimeout(this.authTimer);
console.log(uni.getStorageSync('token'),1234);
if(!uni.getStorageSync('token')) {
this.showToast('请登录');
this.showToast('请授权登录');
this.authTimer = setTimeout(()=>{
uni.navigateTo({url:'/pages/login/login'});
uni.reLaunch({url:'/pagesB/login/login'});
},2000)
} else {
auth = true;

View File

@ -45,16 +45,16 @@
padt:uni.getSystemInfoSync().statusBarHeight + 50,
headHeight:'',//
list:[
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:60,iconHeight:60,title:'推荐套装'},
{url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:60,iconHeight:60,title:'喜糖组合'},
{url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:60,iconHeight:60,title:'喜盒自选'},
{url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:60,iconHeight:60,title:'喜糖自选'},
{url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:60,iconHeight:60,title:'迎宾糖散糖'},
{url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:60,iconHeight:60,title:'瓜子花生'},
{url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:60,iconHeight:60,title:'伴手礼'},
{url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:60,iconHeight:60,title:'购买须知'},
{url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:60,iconHeight:60,title:'商家简介'},
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:60,iconHeight:60,title:'其他推荐'},
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:48,iconHeight:50,title:'推荐套装'},
{url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:56,iconHeight:54,title:'喜糖组合'},
{url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:64,iconHeight:46,title:'喜盒自选'},
{url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:48,iconHeight:48,title:'喜糖自选'},
{url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:56,iconHeight:58,title:'迎宾糖散糖'},
{url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:58,iconHeight:52,title:'瓜子花生'},
{url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:48,iconHeight:54,title:'伴手礼'},
{url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:44,iconHeight:56,title:'购买须知'},
{url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:54,iconHeight:50,title:'商家简介'},
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:52,iconHeight:52,title:'其他推荐'},
],
keyword:'',
isplay:false,

View File

@ -1,15 +1,15 @@
<template>
<view>
<status-nav :titleVal="'登录'" :tabcolor="'rgba(244, 244, 244,1)'" :whereCome="1*1" :statusTitle="true" :backgroudColor="'rgba(244, 244, 244,1)'"></status-nav>
<!-- <view class='login-header'>
<image class="infoImg" :style="{boxShadow: '0px 0px 20px '+ publicColor}" mode="aspectFit" :src="userInfo.avatarUrl || imgSrc"></image>
<view class="logo-name">恒美植发</view>
<view class='login-header'>
<image class="infoImg" :style="{boxShadow: '0px 0px 20px rgba(0,0,0,.8)'}" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
<view class="logo-name">{{appletName}}</view>
</view>
<view class="login-box">
<button class='login-btn' :style="{background:publicColor}" type='primary' @click="bindGetUserInfo"></button>
<button class='login-btn' :style="{background:publicColor || 'linear-gradient(to right, #ff3772 0%,#fd5548 100%)'}" type='primary' @click="bindGetUserInfo"></button>
<view class="xie-box">登录代表您已同意<text @tap="goXie" class="xieCon">用户服务协议</text></view>
</view>
<view v-if="isShowP" class="disjcac posAll">
<!-- <view v-if="isShowP" class="disjcac posAll">
<view class="bacf radius20 width100 tank-box">
<view class="tc tank-box-itemone">请授权绑定手机号</view>
<view class="fon28 colf pad-x30 pad-zy30 tc disjb">
@ -21,13 +21,13 @@
</view>
</view>
</view> -->
<view class='login-header'>
<image class="infoImg" :style="{boxShadow: '0px 0px 20px '+ publicColor}" mode="aspectFit" :src="userInfo.avatarUrl || imgSrc"></image>
<!-- <view class='login-header'>
<image class="infoImg" :style="{boxShadow: '0px 0px 20px rgba(0,0,0,.8)'}" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
<view class="logo-name">{{appletName}}</view>
</view>
<view class="login-box">
<view @tap="setMiniColor">
<button class='login-btn' open-type="getPhoneNumber" @getphonenumber="getphonenumber" :style="{background:publicColor}" type='primary'>手机号授权登录</button>
<view>
<button class='login-btn' open-type="getPhoneNumber" @getphonenumber="getphonenumber" :style="{background:publicColor || 'linear-gradient(to right, #ff3772 0%,#fd5548 100%)'}" type='primary'>手机号授权登录</button>
</view>
<view class="xie-box">登录代表您已同意<text @tap="goXie" class="xieCon">用户服务协议</text></view>
</view>
@ -42,7 +42,7 @@
</view>
</view>
</view>
</view>
</view> -->
</view>
</template>
<script>
@ -51,37 +51,16 @@
return {
userInfo: {},//
canIGetUserProfile: false,
imgSrc: '/static/public/logo.png',//logo
appletName:'恒美植发',//
imgSrc: 'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',//logo
appletName:'商城小程序',//
isShowP:false,
};
},
computed: {
//
publicColor() {
return this.$store.state.publicColor
}
},
onLoad(options) {
//
this.$toolAll.tools.currentContext();
this.setLogo();
this.$toolAll.tools.isVedio();
// let ya = this;
// // ,
// if (options && options.q) {
// let arr = decodeURIComponent(options.q).split('?')[1].split('&')
// let obj = {}
// arr.forEach(item => {
// let brr = item.split('=')
// obj[brr[0]] = brr[1]
// })
// // console.log(obj) //
// ya.invite_code = obj.invite_code
// }
onLoad() {
if (uni.getUserProfile) {
this.canIGetUserProfile = true;
}
// this.setLogo();
},
methods: {
// logo
@ -96,18 +75,11 @@
this.$toolAll.tools.showToast('登录成功','success')
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
},
//
setMiniColor(){
this.$requst.get(`index/mini-program-setting`).then(res=>{
this.publicColor = res.data.mainColor;
uni.setStorageSync('publicColor', res.data.mainColor) //#3875F6 #2E8B57
})
},
getphonenumber(e){//
let ya = this;
wx.login({
success:(res)=>{
this.$requst.post('user/login',{code:res.code}).then(result => {
this.$requst.post('/api/user/login',{code:res.code}).then(result => {
if(e.detail.errMsg=="getPhoneNumber:ok"){
this.$requst.post('user/bind-phone',{openid: result.data.openid,session_key:result.data.session_key, iv:e.detail.iv,encryptedData:e.detail.encryptedData}).then(res=>{
console.log('手机号信息:',res);
@ -128,7 +100,7 @@
},
goXie(){
uni.navigateTo({
url:'/pages/login/xiey'
url:'/pagesB/login/xiey'
})
},
//
@ -176,30 +148,24 @@
language:ya.userInfo.language,//
is_active:1
}
this.$requst.post('user/login',params).then(res => {
this.$requst.post('/api/user/login',params).then(res => {
if(res.data.token!=''){
uni.setStorageSync('params',params)
uni.setStorageSync('userId',res.data.account_id)
uni.setStorageSync('token',res.data.token)//token
uni.setStorageSync('openid',res.data.openid)//openid
uni.setStorageSync('expire',res.data.expire)//
uni.setStorageSync('phone_active',res.data.phone_active)//
uni.setStorageSync('is_active',res.data.is_active)//
uni.setStorageSync('invite_code',res.data.invite_code)
uni.hideToast()
// if(res.data.phone_active!=1){
// this.isShowP = true;
// } else {
if(uni.getStorageSync('urlparams')) {
uni.reLaunch({ //
url:uni.getStorageSync('urlparams')
})
} else {
uni.reLaunch({
url:'/pages/tabbar/pagehome/pagehome'
})
}
// }
uni.setStorageSync('phone_active',res.data.phone_active)//
uni.setStorageSync('is_active',res.data.is_active)//
uni.setStorageSync('invite_code',res.data.invite_code)//
if(uni.getStorageSync('page-path-options')) {
uni.reLaunch({ //
url:uni.getStorageSync('page-path-options')
})
} else {
uni.reLaunch({
url:'/pages/tabbar/pagehome/pagehome'
})
}
}
},error => {})
}
@ -211,9 +177,9 @@
@tcolorp:#3875F6;
.login-header {display: flex;justify-content: center;align-items: center;flex-direction: column;margin-top: 40%;}
.infoImg {width: 192rpx;height: 192rpx;border-radius: 100%;}
.logo-name {font-size: 30rpx;font-weight: bold;margin-top: 20rpx;color: @tcolor;}
.logo-name {font-size: 30rpx;font-weight: bold;margin-top: 30rpx;color: @tcolor;}
.login-box {margin-top: 60rpx;text-align: center;}
.login-btn {width: 80%;margin-top: 50%;}
.login-btn {width: 80%;margin-top: 50%;box-shadow: 0rpx 6rpx 10rpx rgba(255, 55, 114, .6);}
.xie-box{display: flex;justify-content: center;align-items: center;color: @tcolor;margin-top: 30rpx;}
.xieCon{color: @tcolorp;}
</style>

View File

@ -1,49 +1,35 @@
<template>
<view>
<status-nav :titleVal="'用户协议及隐私声明'" :statusTitle="true"></status-nav>
<view :style="{paddingTop: statusHeight+'px'}" class="mar20 line-h50 fon30">
<!-- <rich-text :nodes="content"></rich-text> -->
<view class="text2">本协议为您与本小程序管理者之间所订立的契约具有合同的法律效力请您仔细阅读</view>
<view>本协议内容生效变更本协议内容包括协议正文及所有本小程序已经发布的或将来可能发布的各类规则所有规则为本协议不可分割的组成部分与协议正文具有同等法律效力如您对协议有任何疑问应向本小程序咨询您在同意所有协议条款并完成注册程序才能成为本站的正式用户您登录即代表同意用户服务协议本协议即生效对双方产生约束力只要您使用本小程序平台服务则本协议即对您产生约束届时您不应以未阅读本协议的内容或者未获得本小程序对您问询的解答等理由主张本协议无效或要求撤销本协议您确认本协议条款是处理双方权利义务的契约始终有效法律另有强制性规定或双方另有特别约定的依其规定 您承诺接受并遵守本协议的约定如果您不同意本协议的约定您应立即停止注册程序或停止使用本小程序平台服务本小程序有权根据需要不定期地制订修改本协议及/或各类规则并在本小程序平台公示不再另行单独通知用户变更后的协议和规则一经在网站公布立即生效如您不同意相关变更应当立即停止使用本小程序平台服务您继续使用本小程序平台服务的即表明您接受修订后的协议和规则</view>
<view>注册资格用户须具有法定的相应权利能力和行为能力的自然人法人或其他组织能够独立承担法律责任您完成注册程序或其他本小程序平台同意的方式实际使用本平台服务时即视为您确认自己具备主体资格能够独立承担法律责任若因您不具备主体资格而导致的一切后果由您及您的监护人自行承担</view>
<view class="text2">
<view class="text2">2.1用户应自行诚信向本站提供注册资料用户同意其提供的注册资料真实准确完整合法有效用户注册资料如有变动的应及时更新其注册资料如果用户提供的注册资料不合法不真实不准确不详尽的用户需承担因此引起的相应责任及后果并且本小程序保留终止用户使用本平台各项服务的权利</view>
<view class="text2">2.2用户在本站进行浏览等活动时涉及用户真实姓名/名称通信地址联系电话电子邮箱等隐私信息的本站将予以严格保密除非得到用户的授权或法律另有规定本站不会向外界披露用户隐私信息为完成创建账号用户需提供以下信息用户的微信昵称性别姓名手机号等信息用户提供的上述信息将在用户使用本服务期间持续授权我们使用在用户注销账号时我们将停止使用并删除上述信息上述信息将存储于中华人民共和国境内如需跨境传输我们将会单独征得用户的授权同意</view>
<status-container titlet="用户服务协议" :ifCustomer='false'>
<view slot="content">
<rich-text :nodes="richText" class="fon30 line-h50" style="color: #8c8c9b;"></rich-text>
</view>
<view>账户</view>
<view>
<view class="text2">3.1您注册成功后即成为本小程序平台的用户将持有本小程序平台唯一编号的账户信息</view>
<view class="text2">3.2您设置的姓名为真实姓名不得侵犯或涉嫌侵犯他人合法权益否则本小程序有权终止向您提供服务注销您的账户</view>
<view class="text2">3.3您应谨慎合理的保存使用您的会员名和密码应对通过您的会员名和密码实施的行为负责除非有法律规定或司法裁定且征得本小程序的同意否则会员名和密码不得以任何方式转让赠与或继承与账户相关的财产权益除外</view>
<view class="text2">3.4用户不得将在本站注册获得的账户借给他人使用否则用户应承担由此产生的全部责任并与实际使用人承担连带责任</view>
<view class="text2">3.5如果发现任何非法使用等可能危及您的账户安全的情形时您应当立即以有效方式通知本小程序要求暂停相关服务并向公安机关报案您理解本小程序对您的请求采取行动需要合理时间本小程序对在采取行动前已经产生的后果包括但不限于您的任何损失不承担任何责任</view>
</view>
<view>用户信息的合理使用</view>
<view>
<view class="text2">4.1您同意本小程序平台拥有通过短信电话微信消息提醒等形式向在本站注册用户发送信息等告知信息的权利</view>
<view class="text2">4.2您了解并同意本小程序有权应国家司法行政等主管部门的要求向其提供您在本小程序平台填写的注册信息和交易记录等必要信息如您涉嫌侵犯他人知识产权则本小程序亦有权在初步判断涉嫌侵权行为存在的情况下向权利人提供您必要的身份信息</view>
<view class="text2">4.3用户同意本小程序有权使用用户的注册信息用户名密码等信息登陆进入用户的注册账户进行证据保全包括但不限于公证见证等</view>
</view>
<view>免责条款</view>
<view class="text2">5.1 本平台仅提供信息对接发生一切纠纷问题皆与本平台无关请通过仲裁部门维护各自权益</view>
</view>
</status-container>
</view>
</template>
<script>
export default {
data(){
data() {
return {
richText:'',
}
},
computed:{
statusHeight() {
return this.$store.state.statusHeight
}
},
onLoad() {
// this.$toolAll.tools.escape2Html(this.content)
methods: {
//
checkAboutUs(){
this.$requst.post('/api/index/about').then(res=>{
if(res.code==0){
this.lat = res.data.lat;
this.lng = res.data.lon;
this.richText = this.$toolAll.tools.escape2Html(res.data.content);
this.address = res.data.address;
} else {
this.$toolAll.tools.showToast(res.msg);
}
})
},
}
}
</script>