index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="content">
  3. <view class="top_bg">
  4. <image class="top_close" @click="$navTo('/pages/my/index','tabbar')" src="/static/image/login/close_icon.png" mode="scaleToFill" />
  5. <view class="top_text">
  6. <view>欢迎来到众酬帮</view>
  7. <image
  8. class="top_icon"
  9. src="/static//image/login/dot_icon.png"
  10. mode="scaleToFill"
  11. />
  12. </view>
  13. </view>
  14. <view class="w pdx-40 main">
  15. <u--input class="h-112" v-model="loginParam.phone" placeholder="请输入手机号码" border="bottom"
  16. clearable></u--input>
  17. <u--input v-if="loginParam.loginWay === 'password'" class="h-112 mgt-16" v-model="loginParam.password"
  18. :password="!isViewPassword" placeholder="请输入密码" border="bottom" clearable>
  19. <template slot="suffix">
  20. <u-icon @click="isViewPassword = !isViewPassword" :name="isViewPassword ? 'eye-fill' : 'eye-off'"
  21. color="#303030" size="24"></u-icon>
  22. </template>
  23. </u--input>
  24. <u--input v-else class="h-112 mgt-16" v-model="loginParam.code" placeholder="请输入验证码" border="bottom"
  25. clearable>
  26. <template slot="suffix">
  27. <u-code :seconds="seconds" @end="end" @start="start" change-text="xs" ref="uCode"
  28. :keep-running="true" @change="codeChange"></u-code>
  29. <u-button :disabled="!isShowCode" @tap="sliderVerify" class="code_btn">{{ tips }}</u-button>
  30. </template>
  31. </u--input>
  32. <view class="flex jc_between mgt-32">
  33. <view v-if="loginParam.loginWay === 'password'" @click="loginParam.loginWay = 'code'"
  34. class="text-24 text-500 text-303030">验证码登录</view>
  35. <view v-else @click="loginParam.loginWay = 'password'" class="text-24 text-500 text-303030">密码登录</view>
  36. <view class="text-24 text-500 text-303030" @click="$navTo('/pages/login/register')">注册</view>
  37. </view>
  38. <button class="login" @tap="submit">登录</button>
  39. <view class="mgt-32 text-24 text-500 text-303030 text-center" @click="$navTo('/pages/login/forget')">忘记密码</view>
  40. <view class="mgt-130">
  41. <u-divider text="快捷登录"></u-divider>
  42. </view>
  43. <view class="w flex jc_center mgt-30">
  44. <image class="w-80 h-80 " src="/static/image/login/weinxin_icon.png" mode="scaleToFill" />
  45. </view>
  46. <view class="mgt-72 text-24 text-7E7E7E text-500">
  47. 登录即代表同意
  48. <text class="text-303030">《用户协议》</text>和
  49. <text class="text-303030">《隐私政策》</text>
  50. </view>
  51. </view>
  52. <zmm-slider-verify ref="sliderVerify" @success="successHandle" @error="errorHandle"
  53. @close="closeHandle"></zmm-slider-verify>
  54. </view>
  55. </template>
  56. <script>
  57. import { isValidPhone, isValidPassword } from '@/utils/index'
  58. export default {
  59. data() {
  60. return {
  61. isViewPassword: false,
  62. isCode: false,//验证码按钮状态
  63. tips: '',// 验证码提示文字
  64. seconds: 60,//验证码秒数
  65. loginParam: {
  66. phone: undefined,
  67. password: undefined,
  68. code: undefined,
  69. loginWay: 'password'
  70. },
  71. }
  72. },
  73. computed: {
  74. isShowCode() {
  75. return this.loginParam.phone && !this.isCode
  76. }
  77. },
  78. watch: {
  79. },
  80. onLoad() {
  81. },
  82. methods: {
  83. //显示验证组件
  84. sliderVerify() {
  85. if(isValidPhone(this.loginParam.phone)) {
  86. this.$refs['sliderVerify'].show()
  87. } else {
  88. uni.$u.toast('请输入正确手机号');
  89. }
  90. },
  91. //验证通过回调
  92. successHandle(e) {
  93. console.log(e)
  94. this.getCode()
  95. },
  96. //验证失败回调
  97. errorHandle(e) {
  98. console.log(e)
  99. },
  100. //组件关闭回调
  101. closeHandle(e) {
  102. console.log(e)
  103. },
  104. codeChange(text) {
  105. this.tips = text;
  106. },
  107. getCode() {
  108. if (this.$refs.uCode.canGetCode) {
  109. // 模拟向后端请求验证码
  110. uni.showLoading({
  111. title: '正在获取验证码'
  112. })
  113. setTimeout(() => {
  114. uni.hideLoading();
  115. // 这里此提示会被this.start()方法中的提示覆盖
  116. uni.$u.toast('验证码已发送');
  117. // 通知验证码组件内部开始倒计时
  118. this.$refs.uCode.start();
  119. }, 2000);
  120. } else {
  121. uni.$u.toast('倒计时结束后再发送');
  122. }
  123. },
  124. end() {
  125. // uni.$u.toast('倒计时结束');
  126. this.isCode = false
  127. },
  128. start() {
  129. // uni.$u.toast('倒计时开始');
  130. this.isCode = true
  131. },
  132. submit() {
  133. console.log('提交参数 :===>>', this.loginParam);
  134. //todo 请求后端接口
  135. // 通过后跳转到个人中心
  136. this.$navTo('/pages/my/index','redirect')
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. .content {
  143. width: 100vw;
  144. height: 100vh;
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. position: relative;
  149. }
  150. .top_bg {
  151. position: relative;
  152. width: 100vw;
  153. height: 568rpx;
  154. flex-shrink: 0;
  155. background: linear-gradient(to bottom, #ffd8bf, #ffffff);
  156. .top_close {
  157. position: absolute;
  158. top: 128rpx;
  159. left: 40rpx;
  160. width: 48rpx;
  161. height: 48rpx;
  162. }
  163. .top_text {
  164. position: absolute;
  165. top: 224rpx;
  166. left: 64rpx;
  167. display: flex;
  168. color: #070602;
  169. font-family: "MiSans VF";
  170. font-size: 52rpx;
  171. font-style: normal;
  172. font-weight: 600;
  173. line-height: normal;
  174. letter-spacing: 0.66rpx;
  175. text-transform: uppercase;
  176. }
  177. .top_icon {
  178. margin-top: -10rpx;
  179. margin-left: 8rpx;
  180. width: 24rpx;
  181. height: 24rpx;
  182. }
  183. }
  184. .main {
  185. margin-top: -72rpx;
  186. .login {
  187. margin-top: 136rpx;
  188. height: 96rpx;
  189. width: 100%;
  190. flex-shrink: 0;
  191. border-radius: 64rpx;
  192. background: #FE6505;
  193. color: #ffffff;
  194. text-align: center;
  195. font-family: "MiSans VF";
  196. font-size: 36rpx;
  197. font-style: normal;
  198. font-weight: 500;
  199. }
  200. .code_btn {
  201. padding: 0rpx 24rpx;
  202. height: 60rpx;
  203. border-radius: 32rpx;
  204. font-size: 24rpx;
  205. color: #fff;
  206. font-weight: 400;
  207. background: linear-gradient(0deg, #FE6505 0%, #FE6505 100%), #141111;
  208. }
  209. .code_btn_off {
  210. background: #fe65054d;
  211. }
  212. }
  213. </style>