You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
5.8 KiB

<template>
<view class="page">
1 year ago
<image class="logo" src="@/static/image/logo.png" mode="widthFix"></image>
<view class="wrap">
1 year ago
<view class="hello">
{{ form.isTeam ? '或然科技城市合伙人,欢迎回来!' : form.isTeam === 0 ? '请认真填写您的姓名和意向开展业务的区域。创建成功后,我们将会有区域运营与您联系沟通后续事宜。' : '欢迎加入或然城市合伙人计划!请认真填写您的姓名和意向开展业务的区域。注册后,我们将会有区域运营与您联系沟通后续事宜。'}}
</view>
<view>
<uni-forms>
<uni-forms-item label="姓名">
2 years ago
<uni-easyinput type="text" v-model="form.userName" placeholder="请输入姓名" :disabled="exist" />
</uni-forms-item>
2 years ago
<uni-forms-item label="业务省份">
2 years ago
<view v-if="form.isTeam" class="location">{{ form.provinceName }}</view>
<uni-data-picker v-else placeholder="请选择省份" popup-title="请选择省份" preload :localdata="provinces" :map="{text: 'provinceName', value: 'provinceId'}" v-model="form.provinceId" @change="getCity"></uni-data-picker>
</uni-forms-item>
2 years ago
<uni-forms-item label="业务城市">
2 years ago
<view v-if="form.isTeam" class="location">{{ form.cityName }}</view>
<uni-data-picker v-else placeholder="请选择城市" popup-title="请选择城市" preload :localdata="cities" :map="{text: 'cityName', value: 'cityId'}" v-model="form.cityId"></uni-data-picker>
</uni-forms-item>
</uni-forms>
<view class="btns">
<button type="primary" @click="submit">{{ form.isTeam ? '登录' : form.isTeam === 0 ? '确定' : '注册' }}</button>
2 years ago
<button @click="back">取消</button>
</view>
</view>
</view>
</view>
</template>
<script>
import { queryPartnerAccount, queryProvince, queryCity, partnerAccountApplication, loginByOpenid, checkWorkNumOrAccount } from '@/apis/modules/user.js'
export default {
data() {
return {
isDy: uni.getSystemInfoSync().uniPlatform === 'mp-toutiao', // 抖音小程序标识
openid: '',
phone: '',
1 year ago
my: false,
form: {
userName: '',
provinceId: '',
cityId: '',
},
accountRepeat: false,
provinces: [],
2 years ago
cities: [],
exist: false
}
},
onShow() {
const pages = getCurrentPages()
const { options } = pages[pages.length - 1]
this.openid = options.openid
this.phone = options.phone
1 year ago
this.my = options.my
this.getProvince()
this.checkLogin()
},
methods: {
// 检查登录状态
checkLogin() {
1 year ago
// 根据手机号获取是否注册过,如果有,则判断是否是队长(isTeam 1:队长,0:成员),如果没有返回team,则注册
queryPartnerAccount({
phone: this.phone,
openId: this.isDy ? '' : this.openid,
douYinOpenId: this.isDy ? this.openid : '',
}).then(({ team, username }) => {
1 year ago
if (team) {
team.teamId && uni.setStorageSync('teamId', team.teamId)
this.form.userName = team.userName
if (team) this.exist = true
if (team.isTeam) {
this.form = team
this.getCity()
} else {
this.form.isTeam = 0
if (team.userName) this.form.userName = team.userName
}
1 year ago
} else if (username) { // 没有团队,只有username
this.form.userName = username
}
}).catch(e => {})
},
// 获取省份
getProvince() {
queryProvince().then(({ list }) => {
this.provinces = list
}).catch(res => {})
},
// 获取城市
getCity(val) {
if (this.form.provinceId) {
queryCity({
provinceId: this.form.provinceId
}).then(({ list }) => {
this.cities = list
}).catch(res => {})
} else {
this.cities = []
}
if (val) this.form.cityId = ''
},
// 提交
async submit() {
const { form } = this
if (!form.userName) return this.$util.errMsg('请输入姓名!')
if (!form.provinceId) return this.$util.errMsg('请选择意向省份!')
if (!form.cityId) return this.$util.errMsg('请选择意向城市!')
form.phone = this.phone
form[this.isDy ? 'douYinOpenId' : 'appOpenId'] = this.openid
form.uniqueIdentification = Date.now()
if (form.isTeam) { // 队长,直接登录
const { data } = await loginByOpenid(this.openid)
uni.setStorageSync('token', data.token)
this.toIndex()
} else { // 新用户,注册。or 成员,创建自己的团队
const { token, teamId } = await partnerAccountApplication(form)
this.$util.sucMsg(form.isTeam === 0 ? '创建成功' : '注册成功')
// 如果返回了token,直接登录,并且把teamId存在缓存里,到了首页后直接选中该团队
if (token) {
teamId && uni.setStorageSync('teamId', teamId)
uni.setStorageSync('token', token)
setTimeout(() => {
this.toIndex()
}, 1500)
} else {
setTimeout(() => {
uni.redirectTo({
url: '../login/login'
})
}, 1500)
}
}
},
// 跳转到首页
toIndex() {
uni.reLaunch({
url: this.my ? '../person/person' : '../home/home'
})
2 years ago
},
// 返回
back() {
1 year ago
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.page {
min-height: 100%;
text-align: center;
background: url(@/static/image/login1.png) 0 0/175rpx auto no-repeat,
url(@/static/image/login2.png) bottom right/123rpx auto no-repeat;
.logo {
width: 393rpx;
margin: 100rpx 0 60rpx;
}
}
.wrap {
position: relative;
padding: 60rpx;
margin: 0 61rpx;
text-align: center;
border-radius: 8rpx;
background-color: #fff;
.hello {
margin-bottom: 30rpx;
font-size: 28rpx;
color: #333;
}
.btns {
display: flex;
button {
width: 200rpx;
font-size: 30rpx;
}
}
2 years ago
.location {
padding-left: 10px;
line-height: 38px;
font-size: 14px;
color: #D5D5D5;
border: 1px solid #e5e5e5;
background-color: #F7F6F6;
border-radius: 4px;
}
}
</style>