129 lines
3.1 KiB
Vue
129 lines
3.1 KiB
Vue
<template>
|
||
<view class="loginBox">
|
||
<view class="title">设置登录密码</view>
|
||
<view class="desc">设置密码后,您可以使用密码登录</view>
|
||
|
||
<view class="twoBox">
|
||
<view class="row">
|
||
<up-input v-model="password" placeholder="请输入6-16位密码,支持数字及符号" clearable :type="Type1 ? 'password' : 'text'">
|
||
<template #suffix>
|
||
<view @click="Type1 = !Type1">
|
||
<up-icon v-if="Type1" name="eye-off" color="#666" size="20"></up-icon>
|
||
<up-icon v-else name="eye-fill" color="#666" size="20"></up-icon>
|
||
</view>
|
||
</template>
|
||
</up-input>
|
||
</view>
|
||
<view class="row">
|
||
<up-input v-model="password_again" placeholder="请再一次输入密码" clearable :type="Type2 ? 'password' : 'text'">
|
||
<template #suffix>
|
||
<view @click="Type2 = !Type2">
|
||
<up-icon v-if="Type2" name="eye-off" color="#666" size="20"></up-icon>
|
||
<up-icon v-else name="eye-fill" color="#666" size="20"></up-icon>
|
||
</view>
|
||
</template>
|
||
</up-input>
|
||
</view>
|
||
<view class="btn" @click="toCommit">确认</view>
|
||
</view>
|
||
</view>
|
||
|
||
</template>
|
||
|
||
<script>
|
||
import { ref, reactive, toRefs } from 'vue'
|
||
import { post } from '@/api/request.js'
|
||
import { showToast } from '@/components/common.js'
|
||
|
||
export default {
|
||
setup() {
|
||
const data = reactive({
|
||
Color: uni.getStorageSync('theme_color'),
|
||
password: '',
|
||
password_again: '',
|
||
Type1: true,
|
||
Type2: true
|
||
})
|
||
|
||
function toCommit() {
|
||
if(!data.password) {
|
||
return showToast('请输入密码')
|
||
} else if(!data.password_again) {
|
||
return showToast('请输入确认密码')
|
||
}
|
||
uni.showLoading({
|
||
title: '加载中...',
|
||
mask: true
|
||
})
|
||
let params = {
|
||
password: data.password,
|
||
password_again: data.password_again
|
||
}
|
||
post('/api/app/login/mobile/code/validate', params).then(async(res) => {
|
||
if(res.data.from == 'mini-app') { // 已经注册过小程序
|
||
await unionidLogin('abcdefg', res.data.shop_id, res.data.unionid_open)
|
||
uni.hideLoading()
|
||
} else {
|
||
uni.setStorageSync('avatar', res.data.avatar)
|
||
uni.setStorageSync('nickname', res.data.nickname)
|
||
uni.setStorageSync('shop_id', res.data.shop_id)
|
||
uni.setStorageSync('login_type', res.data.from)
|
||
uni.setStorageSync('unionid_open', res.data.unionid_open)
|
||
uni.hideLoading()
|
||
uni.reLaunch({
|
||
url: '/pages/index/index'
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
return {
|
||
...toRefs(data),
|
||
toCommit
|
||
}
|
||
},
|
||
async onLoad(options) {
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.loginBox{
|
||
padding: 80rpx 30px 0;
|
||
width: 100%;
|
||
height: 100vh;
|
||
overflow: hidden;
|
||
box-sizing: border-box;
|
||
background-color: #fff;
|
||
.title{
|
||
font-size: 50rpx;
|
||
color: #333;
|
||
font-weight: 600;
|
||
}
|
||
.desc{
|
||
font-size: 28rpx;
|
||
color: #888;
|
||
margin: 20rpx 0 100rpx;
|
||
}
|
||
.twoBox{
|
||
.row{
|
||
margin-bottom: 15px;
|
||
|
||
}
|
||
.btn{
|
||
width: 100%;
|
||
height: 80rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
background-color: v-bind('Color');
|
||
color: #fff;
|
||
border-radius: 80rpx;
|
||
margin: 24rpx auto;
|
||
|
||
}
|
||
}
|
||
}
|
||
</style>
|