index.vue 7.7 KB

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