Merge pull request '邓洁 : 登录功能及拦截' (#42) from dj into master

Reviewed-on: http://git.feashow.cn/odjbin/city-store-transfer/pulls/42
This commit is contained in:
odjbin
2023-11-15 04:51:56 +00:00
7 changed files with 393 additions and 100 deletions

View File

@@ -46,7 +46,9 @@
styleIsolation: 'shared', // 解除样式隔离
},
created() {
this.open()
if (this.type !== '0') {
this.open()
}
},
methods: {
getUserLocation() {

View File

@@ -3,24 +3,32 @@
<view class="tabbar-bug"></view>
<view class="tabbar-container">
<block>
<view class="tabbar-item" v-for="(item,index) in tabbarList" :class="[item.centerItem ? ' center-item' : '']"
@click="changeItem(item)">
<view class="item-top">
<image :src="currentItem==item.id?item.selectIcon:item.icon"></image>
<view class="tabbar-item" v-for="(item,index) in tabbarList" :class="[item.centerItem ? ' center-item' : '']"
@click="changeItem(item)">
<view class="item-top">
<image :src="currentItem==item.id?item.selectIcon:item.icon"></image>
</view>
<view class="item-bottom" :class="[currentItem==item.id ? 'item-active' : '']">
<text>{{item.text}}</text>
</view>
</view>
<view class="item-bottom" :class="[currentItem==item.id ? 'item-active' : '']">
<text>{{item.text}}</text>
</view>
</view>
</block>
<publishSlide v-if="slideVisit" @quitSlide="quitSlide"></publishSlide>
</block>
<publishSlide v-if="slideVisit" @quitSlide="quitSlide"></publishSlide>
</view>
<view>
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
props: {
currentPage: {
type: Number,
@@ -31,6 +39,7 @@
return {
slideVisit: false,
currentItem: 0,
isLoad: true,
tabbarList: [{
id: 0,
path: "/pages/index/index",
@@ -72,18 +81,37 @@
uni.hideTabBar();
},
methods: {
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
return
}
this.isLoad = true
if (this.isLoad) {
this.slideVisit = true
}
},
failToLoad() {
uni.reLaunch({
url: '/pages/index/index'
})
},
quitSlide() {
this.slideVisit = false;
},
changeItem(item) {
if (item.id == 2) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
return
}
this.isLoad = true
this.slideVisit = true
}
let _this = this;
uni.switchTab({
url: item.path
});
}
}
}
@@ -94,6 +122,7 @@
width: 100%;
height: 98rpx;
}
view {
padding: 0;
margin: 0;

View File

@@ -13,12 +13,12 @@
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "速配商铺",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
//导航栏取消
// "navigationStyle": "custom",
//是否开启下拉刷新
"enablePullDownRefresh": true
"enablePullDownRefresh": false
}
},
{
@@ -34,8 +34,8 @@
"path": "pages/shopTransfer/shopTransfer",
"style": {
"navigationBarTitleText": "店铺转让",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
},
@@ -43,8 +43,8 @@
"path": "pages/shopAddress/shopAddress",
"style": {
"navigationBarTitleText": "找店地址",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
},
@@ -52,47 +52,60 @@
"path": "pages/my/my",
"style": {
"navigationBarTitleText": "我的",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
},
{
"path": "pages/detail/detail",
"style": {
"navigationBarTitleText": "商品详情"
"navigationBarTitleText": "商品详情",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
}, {
"path": "pages/published/published",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": true
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
}, {
"path": "pages/publish/publishTransfer/publishTransfer",
"style": {
"navigationBarTitleText": "",
"navigationBarTitleText": "发布店铺转让",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
}, {
"path": "pages/publish/publishAddress/publishAddress",
"style": {
"navigationBarTitleText": "",
"navigationBarTitleText": "发布找店地址",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
}, {
"path": "pages/publish/publishRent/publishRent",
"style": {
"navigationBarTitleText": "",
"navigationBarTitleText": "发布店铺出租",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
}, {
"path": "pages/publish/publishInvestment/publishInvestment",
"style": {
"navigationBarTitleText": "",
"navigationBarTitleText": "发布项目招商",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
@@ -102,48 +115,52 @@
"path": "pages/Partnerships/Partnerships",
"style": {
"navigationBarTitleText": "成功合伙人",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#339967",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/index/NavBarPages/zrxx/zrxx",
"style" :
{
"navigationBarTitleText" : "转让信息",
"enablePullDownRefresh" : false
"path": "pages/index/NavBarPages/zrxx/zrxx",
"style": {
"navigationBarTitleText": "转让信息",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/index/NavBarPages/zdxx/zdxx",
"style" :
{
"navigationBarTitleText" : "找店信息",
"enablePullDownRefresh" : false
"path": "pages/index/NavBarPages/zdxx/zdxx",
"style": {
"navigationBarTitleText": "找店信息",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/index/NavBarPages/czxx/czxx",
"style" :
{
"navigationBarTitleText" : "出租信息",
"enablePullDownRefresh" : false
"path": "pages/index/NavBarPages/czxx/czxx",
"style": {
"navigationBarTitleText": "出租信息",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/index/NavBarPages/xmzs/xmzs",
"style" :
{
"navigationBarTitleText" : "项目招商",
"enablePullDownRefresh" : false
"path": "pages/index/NavBarPages/xmzs/xmzs",
"style": {
"navigationBarTitleText": "项目招商",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/index/NavBarPages/cjal/cjal",
"style" :
{
"navigationBarTitleText" : "成交案例",
"enablePullDownRefresh" : false
"path": "pages/index/NavBarPages/cjal/cjal",
"style": {
"navigationBarTitleText": "成交案例",
"enablePullDownRefresh": false
}
},
{
"path": "pages/my/login/login",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],

View File

@@ -6,13 +6,32 @@
<view class="grid-text">{{ item.text }}</view>
</u-grid-item>
</u-grid>
<u-modal :show="showM" showCancelButton closeOnClickOverlay="false" confirmText="是" cancelText="否"
@confirm="confirm" @cancel="cancel">
<view>
<view>{{mobile}}</view>
<text>是否拨打客服电话</text>
</view>
</u-modal>
<view>
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
showM: false,
mobile: '',
isLoad: true,
navItems: [{
icon: "/static/navbar/sy_icon_zrxx.png",
text: "转让信息",
@@ -46,7 +65,7 @@
{
icon: "/static/navbar/sy_icon_zmhb.png",
text: "招募合伙",
url:'/pages/Partnerships/Partnerships'
url: '/pages/Partnerships/Partnerships'
},
{
icon: "/static/navbar/sy_icon_lxwm.png",
@@ -56,21 +75,64 @@
]
};
},
created() {
this.getCsTel()
},
methods: {
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
return
}
this.isLoad = true
},
failToLoad() {
uni.reLaunch({
url: '/pages/index/index'
})
},
confirm() {
this.showM = false
let phone = this.mobile
phone = phone.toString()
uni.makePhoneCall({
phoneNumber: phone,
success: function() {
console.log('拨打电话成功');
},
fail() {
console.log('打电话失败了');
}
})
},
cancel() {
this.showM = false
},
getCsTel() {
this.$api.getCsTel().then(res => {
console.log(res.data);
if (res.data.data) {
this.mobile = res.data.data.kf_phone
}
}).finally(_ => {})
},
handleItemClick(index) {
// 跳转页面
if (index >= 0 && index <= 6) {
if (index == 4 || index == 6) {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
return
}
this.isLoad = true
}
uni.navigateTo({
url: this.navItems[index].url
})
}else if (index == 7) {
uni.makePhoneCall({
phoneNumber: '123456789',
success: (result) => {},
fail: (error) => {}
})
} else if (index == 7) {
this.showM = true
}
}
}
};

136
pages/my/login/login.vue Normal file
View File

@@ -0,0 +1,136 @@
<template>
<view class="login-content">
<view style="text-align: center;margin-bottom:30rpx;">
<text>{{loginText}}</text>
</view>
<view style="padding-left: 30rpx;padding-right: 30rpx;display: flex;">
<u-button type="info" :plain="true" size="nomal" @click="$emit('fail')">取消</u-button>
<u-button open-type="getPhoneNumber" size="nomal" color='#12CA64' @getphonenumber="getphonenumber">登录
</u-button>
</view>
</view>
</template>
<script>
import {
apiService,
loginSys
} from '@/service/request.js'
export default {
data() {
return {
loginText: '请登录后查看'
}
},
props: {
timoutText: {
type: String,
default: ''
}
},
created() {
if (this.timoutText == 1) {
this.loginText = "登录超时,请重新登录"
}
},
methods: {
login() {
var that = this
},
getphonenumber(e) {
var that = this
// console.log('getphonenumber', e)
if (e.detail.errMsg === 'getPhoneNumber:ok') {
//调用接口利用 e.detail.encryptedData, e.detail.iv 信息来解密手机号
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
success: function(event) {
const {
code
} = event
// console.log('code', code);
that.$api.login({
code: code
}).then(res => {
var data = res.data.data
console.log('res.da',res);
// console.log('登录code换取的信息', data);
uni.setStorageSync('loginToken', data.token);
uni.setStorageSync('avatar', data.avatar);
uni.setStorageSync('nickname', data.nickname);
uni.setStorageSync('account', data.sn);
uni.setStorageSync('mobile', data.mobile);
that.$toast.success('登录成功')
that.$emit('success')
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
const codeData = {
code: e.detail.code
}
that.$api.getMobile(codeData).then(res => {
console.log('code换手机号', res)
})
})
},
fail: function(err) {
// 登录授权失败
// err.code是错误码
that.$emit('fail')
}
})
} else {
// 拒绝授权
that.$emit('fail')
}
}
// getphonenumber(e) {
// const {
// phoneCode
// } = e.detail;
// console.log("手机code : ", phoneCode);
// uni.login({
// "provider": "weixin",
// "onlyAuthorize": true, // 微信登录仅请求授权认证
// success: function(event) {
// const {
// code
// } = event
// console.log("登录code", code);
// //客户端成功获取授权临时票据code,向业务服务器发起登录请求。
// // 调用登录接口 拿到token 传手机code,更新手机号码
// loginSys(code).then(res => {
// console.log(res);
// //登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
// //接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
// })
// },
// fail: function(err) {
// // 登录授权失败
// // err.code是错误码
// }
// })
// },
}
}
</script>
<style lang="less" scoped>
/deep/.u-button {
width: 40% !important;
}
.login-content {
width: 100%;
position: absolute;
top: 50%;
left: 50%;
padding: 50rpx 30rpx;
background-color: #fff;
transform: translate(-50%, -50%);
}
</style>

View File

@@ -1,56 +1,89 @@
<template>
<view>
<view class="my">
<view class="profile">
<image src="../../static/img/wo_bj_ll@2x.png" mode="aspectFit" class="profile-bgi"></image>
<view class="avator">
<u-avatar :src="src"></u-avatar>
<view class="profile">
<image src="../../static/img/wo_bj_ll@2x.png" mode="aspectFit" class="profile-bgi"></image>
<view class="avator">
<u-avatar :src="src"></u-avatar>
</view>
<view class="username">{{username}}</view>
<view class="account">账号:{{account}}</view>
</view>
<view class="username">{{username}}</view>
<view class="account">账号:{{account}}</view>
</view>
<view class="publish">
<u-cell-group>
<u-cell icon="/static/my/wo_icon_zr.png" title="发布的店铺转让" is-link="true" @click="topublished('发布的店铺转让')"></u-cell>
<u-cell icon="/static/my/wo_icon_xz.png" title="发布的找店选址" is-link="true" @click="topublished('发布的找店选址')"></u-cell>
<u-cell icon="/static/my/wo_icon_cc.png" title="发布的店铺出租" is-link="true" @click="topublished('发布的店铺出租')"></u-cell>
<u-cell icon="/static/my/wo_icon_zs.png" title="发布的项目招商" is-link="true" @click="topublished('发布的项目招商')"></u-cell>
<u-cell icon="/static/my/wo_icon_hh.png" title="成功合伙人" is-link="true" @click="topartner"></u-cell>
<view class="publish">
<u-cell-group>
<u-cell icon="/static/my/wo_icon_zr.png" title="发布的店铺转让" is-link="true"
@click="topublished('发布的店铺转让')"></u-cell>
<u-cell icon="/static/my/wo_icon_xz.png" title="发布的找店选址" is-link="true"
@click="topublished('发布的找店选址')"></u-cell>
<u-cell icon="/static/my/wo_icon_cc.png" title="发布的店铺出租" is-link="true"
@click="topublished('发布的店铺出租')"></u-cell>
<u-cell icon="/static/my/wo_icon_zs.png" title="发布的项目招商" is-link="true"
@click="topublished('发布的项目招商')"></u-cell>
<u-cell icon="/static/my/wo_icon_hh.png" title="成功合伙人" is-link="true" @click="topartner"></u-cell>
<u-cell icon="/static/my/wo_icon_pppp.png" title="我的匹配" is-link="true" @click="topublished('我的匹配')"></u-cell>
</u-cell-group>
</view>
</u-cell-group>
</view>
</view>
<TabBar :current-page="4"></TabBar>
<view>
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
src: 'https://cdn.uviewui.com/uview/album/2.jpg',
account:'123456',
username:'用户名',
account: '123456',
username: '用户名',
isLoad: true
}
},
onLoad() {
// this.getInfo()
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
return
}
this.isLoad = true
this.src = uni.getStorageSync('avatar')
this.username = uni.getStorageSync('nickname')
this.account = uni.getStorageSync('account')
},
methods: {
topublished(title){
uni.navigateTo({
url:'/pages/published/published?titletext='+title
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
return
}
this.isLoad = true
},
failToLoad() {
uni.reLaunch({
url: '/pages/index/index'
})
},
todetail(){
topublished(title) {
uni.navigateTo({
url:'/pages/detail/detail'
url: '/pages/published/published?titletext=' + title
})
},
topartner(){
todetail() {
uni.navigateTo({
url:'/pages/Partnerships/Partnerships'
url: '/pages/detail/detail'
})
},
topartner() {
uni.navigateTo({
url: '/pages/Partnerships/Partnerships'
})
}
//---------页面调用接口示例------------
@@ -64,7 +97,7 @@
</script>
<style lang="scss" scoped>
.profile{
.profile {
color: #fff;
display: flex;
width: 100%;
@@ -74,27 +107,27 @@
align-items: center;
flex-direction: column;
gap: 10rpx;
.profile-bgi{
.profile-bgi {
position: absolute;
width: 100%;
height: 500px;
z-index: -1;
}
.avator{
.avator {
margin-top: 20rpx;
}
.username{
.username {
font-size: 18px;
font-weight: 1rpx;
}
.account{
.account {
font-size: 15px;
font-weight: 1rpx;
}
}
</style>

View File

@@ -1,4 +1,4 @@
const serverHost = 'https://spsp.feashow.com/api/'//http://xx.xxx.xx
const serverHost = 'https://spsp.feashow.com/api/' //http://xx.xxx.xx
const service = {
get(url, data) {
@@ -131,11 +131,25 @@ const apiService = {
uploadImgUrl: serverHost + `/upload/image/`,
//登录接口
login(data) {
const url = `/login`
const url = '/login/mnpLogin'
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
//code换手机号
getMobile(data) {
const url = '/user/getMobileByMnp'
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
// 获取客服电话
getCsTel() {
const url = '/center/cfg?key=kf_phone'
return new Promise((resolve, reject) => {
resolve(service.get(url))
})
},
// 展示用户信息
getUserInfo() {
const url = '/user'