login.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <!-- 蓝色简洁登录页面 -->
  2. <template>
  3. <view class="">
  4. <view class="t-login">
  5. <u-top-tips ref="uTips"></u-top-tips>
  6. <u-toast ref="uToast"></u-toast>
  7. <!-- 页面装饰图片 -->
  8. <!-- <image class="img-a" src="@/static/login/2.png"></image> -->
  9. <!-- <image class="img-b" src="@/static/login/3.png"></image> -->
  10. <!-- 标题 -->
  11. <view class="t-b">{{ title }}</view>
  12. <form class="cl">
  13. <view class="t-a">
  14. <image src="@/static/login/sj.png"></image>
  15. <input type="number" name="phone" placeholder="请输入手机号" maxlength="11" v-model="phone" />
  16. </view>
  17. <view class="t-a">
  18. <image src="@/static/login/yz.png"></image>
  19. <input type="number" name="code" maxlength="6" placeholder="请输入验证码" v-model="yzm" />
  20. <view :style="showText?'':'background-color: #A7A7A7;'" class="t-c" @click="getCode()">{{tips}}</view>
  21. </view>
  22. <view @click="typeShow=true" class="flex padding-bottom-50" style="text-align: left">
  23. <view style="border: 1px solid #e9e9e9;background-color: #f8f7fc;" class="cu-btn df round">
  24. <text class="text-black">{{typeList[typeIndex].text}}登陆</text>
  25. <text class="text-black cuIcon-triangledownfill " style="font-size: 40rpx;padding-left: 4rpx;"></text>
  26. </view>
  27. </view>
  28. <view class="checkbox">
  29. <u-checkbox
  30. @change="checkboxChange"
  31. v-model="checked"
  32. >七天内免登录</u-checkbox>
  33. </view>
  34. <button @tap="login()">登 录</button>
  35. </form>
  36. <view v-if="typeIndex==0">
  37. <view class="t-f">
  38. <u-divider color="#aaa" border-color="#aaa">微信快速登陆</u-divider>
  39. </view>
  40. <!-- <view class="t-f"><text>————— 微信快速登录 —————</text></view> -->
  41. <view style="display: flex;justify-content: center;padding-top: 50rpx;">
  42. <view @tap="wxLogin()"><image style="width: 88rpx;height: 88rpx;" src="@/static/login/wx.png"></image></view>
  43. </view>
  44. </view>
  45. <u-action-sheet @click="typeClick" :list="typeList" v-model="typeShow"></u-action-sheet>
  46. <u-verification-code seconds="60" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. let that
  52. export default {
  53. data() {
  54. return {
  55. typeList:[{text:'员工',value:'0'},{text:'企业',value:'1'}],
  56. typeShow:false,
  57. typeIndex:0,
  58. checked:false,//七天免登录
  59. title: '欢迎回来!',
  60. tips: '',
  61. showText:true,
  62. phone: '', //手机号码
  63. yzm: '' //验证码
  64. };
  65. },
  66. onLoad() {
  67. if (this.$cache.get('phone')) {
  68. //免登录
  69. uni.switchTab({
  70. url:"../index/index"
  71. })
  72. }
  73. },
  74. methods: {
  75. wxLogin(){
  76. this.$refs.uTips.show({
  77. title: '完成员工认证的用户才可以使用微信快速登陆',
  78. type: 'primary',
  79. duration: '2500'
  80. })
  81. },
  82. typeClick(index){
  83. this.typeIndex=index
  84. },
  85. getCode() {
  86. if(this.$refs.uCode.canGetCode) {
  87. // 模拟向后端请求验证码
  88. uni.showLoading({
  89. title: '正在获取验证码'
  90. })
  91. setTimeout(() => {
  92. uni.hideLoading();
  93. // 这里此提示会被this.start()方法中的提示覆盖
  94. this.$u.toast('验证码已发送');
  95. // 通知验证码组件内部开始倒计时
  96. this.$refs.uCode.start();
  97. }, 3000);
  98. } else {
  99. this.$u.toast('倒计时结束后再发送');
  100. }
  101. },
  102. checkboxChange(e){
  103. this.checked=e.value
  104. },
  105. codeChange(text) {
  106. this.tips = text;
  107. },
  108. end() {
  109. this.showText=true
  110. },
  111. start() {
  112. this.showText=false
  113. },
  114. //当前登录按钮操作
  115. login() {
  116. var that = this;
  117. if (!that.phone) {
  118. uni.showToast({ title: '请输入手机号', icon: 'none' });
  119. return;
  120. }
  121. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(that.phone)) {
  122. uni.showToast({ title: '请输入正确手机号', icon: 'none' });
  123. return;
  124. }
  125. if (!that.yzm) {
  126. uni.showToast({ title: '请输入验证码', icon: 'none' });
  127. return;
  128. }
  129. if (that.checked) {
  130. //七天内免登录
  131. that.$cache.put("phone",that.phone,1*24*60*60*7)
  132. }else{
  133. //三十分内钟免登录
  134. that.$cache.put("phone",that.phone,1*60*30)
  135. }
  136. //存储登陆的用户类型
  137. if (that.typeIndex==0) {
  138. //员工登陆
  139. that.$cache.put('loginType','employees')
  140. }else if(that.typeIndex==1){
  141. //企业登陆
  142. that.$cache.put('loginType','enterprise')
  143. }
  144. uni.showLoading({ title: '登陆中...' })
  145. setTimeout(()=>{
  146. uni.hideLoading()
  147. uni.switchTab({
  148. url:"../index/index"
  149. })
  150. },1500)
  151. },
  152. }
  153. };
  154. </script>
  155. <style lang="scss" >
  156. page{
  157. background-color: #FFFFFF;
  158. }
  159. .checkbox{
  160. padding-bottom: 50rpx;
  161. padding-left: 20rpx;
  162. margin-top: -10rpx;
  163. }
  164. .img-a {
  165. position: absolute;
  166. width: 100%;
  167. top: -300rpx;
  168. right: -100rpx;
  169. }
  170. .img-b {
  171. position: absolute;
  172. width: 50%;
  173. bottom: 0;
  174. left: -50rpx;
  175. margin-bottom: -200rpx;
  176. }
  177. .t-login {
  178. width: 600rpx;
  179. margin: -200rpx auto;
  180. font-size: 28rpx;
  181. color: #000;
  182. }
  183. .t-login button {
  184. font-size: 28rpx;
  185. background: #5677fc;
  186. color: #fff;
  187. height: 90rpx;
  188. line-height: 90rpx;
  189. border-radius: 50rpx;
  190. box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  191. }
  192. .t-login input {
  193. padding: 0 20rpx 0 120rpx;
  194. height: 90rpx;
  195. line-height: 90rpx;
  196. margin-bottom: 50rpx;
  197. background: #f8f7fc;
  198. border: 1px solid #e9e9e9;
  199. font-size: 28rpx;
  200. border-radius: 50rpx;
  201. }
  202. .t-login .t-a {
  203. position: relative;
  204. }
  205. .t-login .t-a image {
  206. width: 40rpx;
  207. height: 42rpx;
  208. position: absolute;
  209. left: 20rpx;
  210. top: 28rpx;
  211. padding-right:4rpx;
  212. }
  213. .t-login .t-b {
  214. text-align: left;
  215. font-size: 46rpx;
  216. color: #000;
  217. padding: 300rpx 0 120rpx 0;
  218. font-weight: bold;
  219. }
  220. .t-login .t-c {
  221. position: absolute;
  222. right: 22rpx;
  223. top: 22rpx;
  224. background: #5677fc;
  225. color: #fff;
  226. font-size: 24rpx;
  227. border-radius: 50rpx;
  228. height: 50rpx;
  229. line-height: 50rpx;
  230. padding: 0 25rpx;
  231. z-index: 99999;
  232. }
  233. .t-login .t-d {
  234. text-align: center;
  235. color: #999;
  236. margin: 80rpx 0;
  237. }
  238. .t-login .t-e {
  239. text-align: center;
  240. width: 250rpx;
  241. margin: 80rpx auto;
  242. }
  243. .t-login .t-g {
  244. float: left;
  245. width: 50%;
  246. }
  247. .t-login .t-e image {
  248. width: 50rpx;
  249. height: 50rpx;
  250. }
  251. .t-login .t-f {
  252. text-align: center;
  253. margin: 100rpx 0 0 0;
  254. color: #666;
  255. }
  256. .t-login .t-f text {
  257. margin-left: 20rpx;
  258. color: #aaaaaa;
  259. font-size: 27rpx;
  260. }
  261. .t-login .uni-input-placeholder {
  262. color: #000;
  263. }
  264. .cl {
  265. zoom: 1;
  266. }
  267. .cl:after {
  268. clear: both;
  269. display: block;
  270. visibility: hidden;
  271. height: 0;
  272. content: '\20';
  273. }
  274. </style>