| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view style="position: relative;">
- <view class="back" @click="$back">
- <u-icon name="arrow-left" size="50" color="#919191"></u-icon>
- </view>
- <view class="content">
- <view class="bg"></view>
- <view class="bg1"></view>
- <view class="top">
- <view class="title">
- <text>注册联兑通账号</text>
- <text>请输入手机号进行注册</text>
- </view>
- </view>
-
- <view style="width: 76%;margin-top: 80rpx;">
- <u-form :model="form" ref="uForm" :rules="rules" :error-type="['message']">
- <u-form-item label="手机号" prop="phone" label-width="150">
- <u-input :border="false" placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
- </u-form-item>
- <u-form-item label="验证码" prop="code" label-width="150">
- <view class="flex">
- <u-input style="width: 100%;" :border="false" placeholder="请输入验证码" v-model="form.code" type="text"></u-input>
- <u-button shape="circle" slot="right" :custom-style="customStyle" size="mini" @click="getCode">{{codeTips}}</u-button>
- </view>
- </u-form-item>
- <u-form-item label="密码" prop="password" label-width="150">
- <u-input :border="false" placeholder="请设置登录密码" v-model="form.password" type="password"></u-input>
- </u-form-item>
- <u-form-item label="确认密码" prop="newPassword" label-width="150">
- <u-input :border="false" placeholder="请再次输入密码" v-model="form.newPassword" type="password"></u-input>
- </u-form-item>
- </u-form>
- </view>
-
- <view style="width: 86%;margin-top: 100rpx;">
- <view @click="next" class="btn cu-btn round" style="width:100%;height: 90rpx;font-size: 34rpx;">
- 确认
- </view>
- <!-- <view class="center" style="margin-top: 100rpx;">
- <text style="color: #949494;">确认注册即代表已阅读并同意</text>
- <text style="color: #0000ff;">《软件服务协议》</text>
- </view> -->
- </view>
- </view>
-
- <u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
- </view>
- </template>
- <script>
- import md5Libs from "uview-ui/libs/function/md5";
- export default {
- data() {
- return {
- customStyle:{
- 'backgroundColor':'#d18c42',
- 'color':'#ffffff'
- },
- codeTips: '',
- form:{
- phone:'',
- code:'',
- password:'',
- newPassword:''
- },
- rules: {
- phone: [{
- required: true,
- message: '请输入手机号',
- trigger: ['change', 'blur'],
-
- },{
- message: '手机号码不正确',
- trigger: ['change', 'blur'],
- validator: (rule, value, callback) => {
- return this.$u.test.mobile(value);
- },
- }],
- code: [{
- required: true,
- message: '请输入验证码',
- trigger: ['change', 'blur'],
- }],
- password: [{
- required: true,
- message: '请输入登录密码',
- trigger: ['change', 'blur'],
- }],
- newPassword: [{
- required: true,
- message: '请再次输入登录密码',
- trigger: ['change', 'blur'],
- },{
- message: '密码不一致',
- trigger: ['change', 'blur'],
- validator: (rule, value, callback) => {
- return this.form.password == value
- },
- }],
- }
- }
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- },
- methods: {
- next(){
- this.$refs.uForm.validate(valid => {
- if (valid) {
- this.register()
- }
- });
- },
- codeChange(text) {
- this.codeTips = text;
- },
- async register(){
- let p={
- phone:this.form.phone,
- secret:md5Libs.md5(this.form.password),
- smsId:this.$cache.get('smsId'),
- value:this.form.code,
- type:1
- }
- let res=await this.$api.accout.register(p)
- if (res.success) {
- this.$dialog.showModal('注册成功,请填写店铺资料',false).then(()=>{
- uni.navigateTo({
- url:"/pages/shop-info/shop-info?phone="+this.form.phone
- })
- })
- }
- },
- // 获取验证码
- getCode() {
- if (this.$isEmpty(this.form.phone)) {
- this.$u.toast('请输入手机号')
- return
- }
- if (this.$refs.uCode.canGetCode) {
- // 模拟向后端请求验证码
- uni.showLoading({
- title: '正在获取验证码',
- mask: true
- })
- setTimeout(() => {
- let params={
- phone:this.form.phone
- }
- let p=this.$u.queryParams(params)
- this.$api.sms.send(p).then(res=>{
- if (res.data.success) {
- this.$cache.put('smsId',res.data.id)
- this.$u.toast('验证码已发送');
- // 通知验证码组件内部开始倒计时
- }else{
- this.$u.toast(res.data);
- }
- this.$refs.uCode.start();
- })
- }, 200);
- } else {
- this.$u.toast('倒计时结束后再发送');
- }
- },
- }
- }
- </script>
- <style>
- page{
- background-color: #FFFFFF;
- }
- </style>
- <style lang="scss" scoped>
- $color:#d18c42;
-
- page{
- background-color: #FFFFFF;
- }
-
- .btn{
- background-color: $color;
- color:#FFFFFF;
- }
-
- .btn{
- background-color: $color;
- color:#FFFFFF;
- }
-
- .bg{
- z-index: 99;
- height: 400rpx;
- width: 400rpx;
- position: absolute;
- right: -240rpx;
- top: -240rpx;
- background-color: #d18c42;
- border-radius: 50%;
- box-shadow: 0rpx 0rpx 50rpx #c5803b;
- }
-
- .bg1{
- height: 460rpx;
- width: 460rpx;
- position: absolute;
- right: -240rpx;
- top: -240rpx;
- background-color: #d18c42;
- border-radius: 50%;
- box-shadow: #c6813b;
- }
-
- .back{
- position: absolute;
- top: var(--status-bar-height);
- left: 20rpx;
- padding-top: var(--status-bar-height);
- }
-
- .content{
- height: 96vh;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .top{
- width: 76%;
- display: flex;
- .title{
- margin-right: 20rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: flex-start;
- text-align: left;
-
- text:first-child{
- font-weight: 800;
- font-size: 50rpx;
- color: #000;
- margin-bottom: 20rpx;
- }
-
- text:last-child{
- font-size: 28rpx;
- color: #7f7f7f;
- }
- }
-
-
- }
- }
- </style>
|