xuxy
2024-06-28 b07d5f16634fc4a695fa8e6f6b18c33806f2b05a
sub_pages/supplier/supplier-reg/supplier-reg.vue
文件名从 sub_pages/farmer/farmer-reg/farmer-reg.vue 修改
@@ -1,7 +1,9 @@
<template>
   <view class="main-container login-container img100 relative" style="margin-top: 0rpx;">
      <image class="component-bg" src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a5/a54508de179a4942918ecb2c5a4aa9f5bg.png" mode="scaleToFill" />
      <image class="component-bg"
         src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a5/a54508de179a4942918ecb2c5a4aa9f5bg.png"
         mode="scaleToFill" />
      <view class="t-login top-bg">
         <view class="nav-title">注册</view>
@@ -9,17 +11,17 @@
            <form class="cl">
               <view class="t-a titles-top">
                  <view class="title-1">HELLO</view>
                  <view class="title-2">欢迎注册<span class="title-3">花满芜</span></view>
                  <view class="title-2">欢迎入住<span class="title-3">花满芜</span></view>
               </view>
               <view class="t-a input" v-if="loginType=='code'">
                  <input type="text" name="userName" placeholder="请输入手机号" v-model="phoneNumber" />
                  <view class="get-code" :style="{'color':getCodeBtnColor}" @click.stop="getCode()">
                     {{getCodeText}}
                  </view>
                  <input type="text" name="userName" placeholder="请输入手机号" v-model="phoneNumber" />
               </view>
@@ -33,6 +35,14 @@
               <view class="flex">
                  <view class="topic-font m-l-a m-r-0" @click="toLogin">前往登录</view>
               </view>
               <view class="flex flex-wrap-normal" style="position: fixed;bottom: 40rpx;left: 40rpx;right: 40rpx;">
                  <view :style="{'margin-top': '8rpx','margin-right': '12rpx','font-size':'24rpx'}"
                  @click="protocal=!protocal"
                   class="component-radio" :class="[protocal?'cur':'']">
                  </view>
                  <view class="topic-gray" @click="toProtocol">请仔细阅读《花满芜合伙人供应商入口小程序隐私保护指引》如您同意该指引,请勾选开始使用本小程序</view>
               </view>
            </form>
         </view>
@@ -60,11 +70,17 @@
            getCodeText: '获取验证码',
            getCodeBtnColor: "#20613D",
            getCodeisWaiting: false,
            Timer: undefined
            Timer: undefined,
            protocal:false
         };
      },
      methods: {
         getCode() {
         toProtocol(){
            uni.navigateTo({
               url:'/sub_pages/supplier/protocol'
            })
         },
         async getCode() {
            uni.hideKeyboard() //隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。
            if (this.getCodeisWaiting) {
               return;
@@ -78,18 +94,30 @@
            }
            this.getCodeText = "发送中..." //发送验证码
            this.getCodeisWaiting = true;
            this.getCodeBtnColor = "rgba(255,255,255,0.5)" //追加样式,修改颜色
            this.getCodeBtnColor = "#000" //追加样式,修改颜色
            //示例用定时器模拟请求效果
            //setTimeout(()用于在指定的毫秒数后调用函数或计算表达式
            setTimeout(() => {
            const {
               code
            } = await this.$http.request('post', '/api/sms/send/code', {
               data: {
                  tel: this.phoneNumber,
                  userType: 'supplier'
               }
            })
            if (code == 0) {
               uni.showToast({
                  title: '验证码已发送',
                  icon: "none"
               }); //弹出提示框
               //示例默认1234,生产中请删除这一句。
               // this.code = '1234'; //发送验证码,进行填入
               });
               this.setTimer(); //调用定时器方法
            }, 1000)
            }
            // setTimeout(() => {
            //    //弹出提示框
            //    //示例默认1234,生产中请删除这一句。
            //    // this.code = '1234'; //发送验证码,进行填入
            // }, 1000)
         },
         //setTimer: 需要每隔一段时间执行一件事的的时候就需要使用SetTimer函数
         setTimer() {
@@ -111,7 +139,7 @@
         },
         toLogin() {
            uni.redirectTo({
               url: '/pages/login/farmer-login'
               url: '/pages/login/supplier-login'
            })
         },
@@ -123,9 +151,16 @@
               title: '登陆中'
            });
            var that = this;
            if (!that.userName) {
            if (!that.phoneNumber) {
               uni.showToast({
                  title: '请输入用户名',
                  title: '请输入手机号',
                  icon: 'none'
               });
               return;
            }
            if (!that.smsCode) {
               uni.showToast({
                  title: '请输入手机验证码',
                  icon: 'none'
               });
               return;
@@ -142,14 +177,15 @@
            //    return;
            // }
            let post = {
               username: this.userName,
               tel: this.phoneNumber,
               smsCode: this.smsCode,
               password: this.password,
               // openId: '123456789'
            }
            // const {
            // code
            // } = await this.$http.request('get', '/api/login/admin')
            const resp = await this.$store.dispatch('loginSupplier', post);
            const resp = await this.$store.dispatch('regSupplier', post);
            // uni.hideLoading()
            if (resp.code == 0) {
@@ -159,9 +195,13 @@
               // if (userRes.status) {
               //    myCache.cache("userInfo", JSON.stringify(userRes.data))
               // }
               // setTimeout(() => {
               //    uni.navigateBack();
               // }, 1000);
               uni.showToast({
                  title: '注册成功!',
                  icon: 'none'
               });
               setTimeout(() => {
                  this.toLogin()
               }, 1000);
            } else {
               uni.showToast({