login.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. console.log(this.$Route.query.fullPath);
  68. if (this.$cache.get('phone')) {
  69. //免登录
  70. uni.switchTab({
  71. url:"/pages/index/index"
  72. })
  73. }
  74. },
  75. methods: {
  76. wxLogin(){
  77. this.$refs.uTips.show({
  78. title: '完成员工认证的用户才可以使用微信快速登陆',
  79. type: 'primary',
  80. duration: '2500'
  81. })
  82. },
  83. typeClick(index){
  84. this.typeIndex=index
  85. },
  86. getCode() {
  87. if(this.$refs.uCode.canGetCode) {
  88. // 模拟向后端请求验证码
  89. uni.showLoading({
  90. title: '正在获取验证码'
  91. })
  92. setTimeout(() => {
  93. uni.hideLoading();
  94. // 这里此提示会被this.start()方法中的提示覆盖
  95. this.$u.toast('验证码已发送');
  96. // 通知验证码组件内部开始倒计时
  97. this.$refs.uCode.start();
  98. }, 3000);
  99. } else {
  100. this.$u.toast('倒计时结束后再发送');
  101. }
  102. },
  103. checkboxChange(e){
  104. this.checked=e.value
  105. },
  106. codeChange(text) {
  107. this.tips = text;
  108. },
  109. end() {
  110. this.showText=true
  111. },
  112. start() {
  113. this.showText=false
  114. },
  115. //当前登录按钮操作
  116. login() {
  117. var that = this;
  118. if (!that.phone) {
  119. uni.showToast({ title: '请输入手机号', icon: 'none' });
  120. return;
  121. }
  122. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(that.phone)) {
  123. uni.showToast({ title: '请输入正确手机号', icon: 'none' });
  124. return;
  125. }
  126. if (!that.yzm) {
  127. uni.showToast({ title: '请输入验证码', icon: 'none' });
  128. return;
  129. }
  130. if (that.checked) {
  131. //七天内免登录
  132. that.$cache.put("phone",that.phone,1*24*60*60*7)
  133. }else{
  134. //三十分内钟免登录
  135. that.$cache.put("phone",that.phone,1*60*30)
  136. }
  137. //存储登陆的用户类型
  138. if (that.typeIndex==0) {
  139. //员工登陆
  140. that.$cache.put('loginType','employees')
  141. }else if(that.typeIndex==1){
  142. //企业登陆
  143. that.$cache.put('loginType','enterprise')
  144. }
  145. uni.showLoading({ title: '登陆中...' })
  146. setTimeout(()=>{
  147. uni.hideLoading()
  148. if (that.$isEmpty(that.$Route.query.fullPath)) {
  149. uni.switchTab({
  150. url:"/pages/index/index"
  151. })
  152. }else{
  153. uni.reLaunch({
  154. url:that.$Route.query.fullPath
  155. })
  156. }
  157. },1500)
  158. },
  159. }
  160. };
  161. </script>
  162. <style lang="scss" >
  163. page{
  164. background-color: #FFFFFF;
  165. }
  166. .checkbox{
  167. padding-bottom: 50rpx;
  168. padding-left: 20rpx;
  169. margin-top: -10rpx;
  170. }
  171. .img-a {
  172. position: absolute;
  173. width: 100%;
  174. top: -300rpx;
  175. right: -100rpx;
  176. }
  177. .img-b {
  178. position: absolute;
  179. width: 50%;
  180. bottom: 0;
  181. left: -50rpx;
  182. margin-bottom: -200rpx;
  183. }
  184. .t-login {
  185. width: 600rpx;
  186. margin: -200rpx auto;
  187. font-size: 28rpx;
  188. color: #000;
  189. }
  190. .t-login button {
  191. font-size: 28rpx;
  192. background: #5677fc;
  193. color: #fff;
  194. height: 90rpx;
  195. line-height: 90rpx;
  196. border-radius: 50rpx;
  197. box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  198. }
  199. .t-login input {
  200. padding: 0 20rpx 0 120rpx;
  201. height: 90rpx;
  202. line-height: 90rpx;
  203. margin-bottom: 50rpx;
  204. background: #f8f7fc;
  205. border: 1px solid #e9e9e9;
  206. font-size: 28rpx;
  207. border-radius: 50rpx;
  208. }
  209. .t-login .t-a {
  210. position: relative;
  211. }
  212. .t-login .t-a image {
  213. width: 40rpx;
  214. height: 42rpx;
  215. position: absolute;
  216. left: 20rpx;
  217. top: 28rpx;
  218. padding-right:4rpx;
  219. }
  220. .t-login .t-b {
  221. text-align: left;
  222. font-size: 46rpx;
  223. color: #000;
  224. padding: 300rpx 0 120rpx 0;
  225. font-weight: bold;
  226. }
  227. .t-login .t-c {
  228. position: absolute;
  229. right: 22rpx;
  230. top: 22rpx;
  231. background: #5677fc;
  232. color: #fff;
  233. font-size: 24rpx;
  234. border-radius: 50rpx;
  235. height: 50rpx;
  236. line-height: 50rpx;
  237. padding: 0 25rpx;
  238. z-index: 99999;
  239. }
  240. .t-login .t-d {
  241. text-align: center;
  242. color: #999;
  243. margin: 80rpx 0;
  244. }
  245. .t-login .t-e {
  246. text-align: center;
  247. width: 250rpx;
  248. margin: 80rpx auto;
  249. }
  250. .t-login .t-g {
  251. float: left;
  252. width: 50%;
  253. }
  254. .t-login .t-e image {
  255. width: 50rpx;
  256. height: 50rpx;
  257. }
  258. .t-login .t-f {
  259. text-align: center;
  260. margin: 100rpx 0 0 0;
  261. color: #666;
  262. }
  263. .t-login .t-f text {
  264. margin-left: 20rpx;
  265. color: #aaaaaa;
  266. font-size: 27rpx;
  267. }
  268. .t-login .uni-input-placeholder {
  269. color: #000;
  270. }
  271. .cl {
  272. zoom: 1;
  273. }
  274. .cl:after {
  275. clear: both;
  276. display: block;
  277. visibility: hidden;
  278. height: 0;
  279. content: '\20';
  280. }
  281. </style>