login.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="app">
  3. <view class="left-bottom-sign"></view>
  4. <view class="back-btn mix-icon icon-guanbi" @click="navBack"></view>
  5. <view class="right-top-sign"></view>
  6. <view class="agreement center">
  7. <text class="mix-icon icon-xuanzhong" :class="{active: agreement}" @click="checkAgreement"></text>
  8. <text @click="checkAgreement">请认真阅读并同意</text>
  9. <text class="tit" @click="navToAgreementDetail(1)">《用户服务协议》</text>
  10. <text class="tit" @click="navToAgreementDetail(2)">《隐私权政策》</text>
  11. </view>
  12. <view class="wrapper">
  13. <view class="left-top-sign">LOGIN</view>
  14. <view class="welcome">
  15. 欢迎回来!
  16. </view>
  17. <view class="input-content">
  18. <view class="input-item">
  19. <text class="tit">手机号码</text>
  20. <view class="row">
  21. <input
  22. v-model="username"
  23. type="number"
  24. maxlength="11"
  25. placeholder="请输入手机号码"
  26. placeholder-style="color: #909399"
  27. />
  28. </view>
  29. </view>
  30. <view class="input-item">
  31. <text class="tit">验证码</text>
  32. <view class="row">
  33. <input
  34. v-model="code"
  35. type="number"
  36. maxlength="6"
  37. placeholder="请输入手机验证码"
  38. placeholder-style="color: #909399"
  39. />
  40. <mix-code :mobile="username" templateCode="SMS_194050994"></mix-code>
  41. </view>
  42. </view>
  43. </view>
  44. <mix-button ref="confirmBtn" text="登录" marginTop="60rpx" @onConfirm="login"></mix-button>
  45. <!-- #ifdef APP-PLUS || MP-WEIXIN -->
  46. <view class="other-wrapper">
  47. <view class="line center">
  48. <text class="tit">快捷登录</text>
  49. </view>
  50. <view class="list row">
  51. <!-- #ifdef MP-WEIXIN -->
  52. <view class="item column center" @click="mpWxGetUserInfo">
  53. <image class="icon" src="/static/icon/login-wx.png"></image>
  54. </view>
  55. <!-- #endif -->
  56. <!-- #ifdef APP-PLUS -->
  57. <view v-if="canUseAppleLogin && false" class="item column center" style="width: 180rpx;" @click="loginByApple">
  58. <image class="icon" src="/static/icon/apple.png"></image>
  59. <text>Apple登录</text>
  60. </view>
  61. <view class="item column center" style="width: 180rpx;" @click="loginByWxApp">
  62. <image class="icon" src="/static/icon/login-wx.png"></image>
  63. <text>微信登录</text>
  64. </view>
  65. <!-- #endif -->
  66. </view>
  67. </view>
  68. <!-- #endif -->
  69. </view>
  70. <mix-loading v-if="isLoading"></mix-loading>
  71. </view>
  72. </template>
  73. <script>
  74. import {checkStr} from '@/common/js/util'
  75. import loginMpWx from './mixin/login-mp-wx.js'
  76. import loginAppWx from './mixin/login-app-wx.js'
  77. import loginApple from './mixin/login-apple.js'
  78. export default{
  79. mixins: [loginMpWx, loginAppWx, loginApple],
  80. data(){
  81. return {
  82. canUseAppleLogin: false,
  83. agreement: true,
  84. username: '',
  85. code: '',
  86. }
  87. },
  88. onLoad() {
  89. console.log(1);
  90. },
  91. methods: {
  92. loginSuccessCallBack(data){
  93. this.$util.msg('登陆成功');
  94. this.$store.commit('setToken', data);
  95. setTimeout(()=>{
  96. uni.navigateBack();
  97. }, 1000)
  98. },
  99. //手机号登录
  100. async login(){
  101. if(!this.agreement){
  102. this.$util.msg('请阅读并同意用户服务及隐私协议');
  103. this.$refs.confirmBtn.stop();
  104. return;
  105. }
  106. const {username, code} = this;
  107. if(!checkStr(username, 'mobile')){
  108. this.$util.msg('请输入正确的手机号码');
  109. this.$refs.confirmBtn.stop();
  110. return;
  111. }
  112. if(!checkStr(code, 'mobileCode')){
  113. this.$util.msg('验证码错误');
  114. this.$refs.confirmBtn.stop();
  115. return;
  116. }
  117. const res = await this.$request('user', 'login', {username,code});
  118. this.$refs.confirmBtn.stop();
  119. if(res.status === 1){
  120. this.loginSuccessCallBack(res.data);
  121. }else{
  122. this.$util.msg(res.msg);
  123. }
  124. },
  125. navBack(){
  126. uni.navigateBack();
  127. },
  128. //同意协议
  129. checkAgreement(){
  130. this.agreement = !this.agreement;
  131. },
  132. //打开协议
  133. navToAgreementDetail(type){
  134. this.navTo('/pages/public/article?param=' + JSON.stringify({
  135. module: 'article',
  136. operation: 'getAgreement',
  137. data: {
  138. type
  139. }
  140. }))
  141. },
  142. }
  143. }
  144. </script>
  145. <style>
  146. page{
  147. background: #fff;
  148. }
  149. </style>
  150. <style scoped lang='scss'>
  151. .app{
  152. padding-top: 15vh;
  153. position:relative;
  154. width: 100vw;
  155. height: 100vh;
  156. overflow: hidden;
  157. background: #fff;
  158. }
  159. .wrapper{
  160. position:relative;
  161. z-index: 90;
  162. padding-bottom: 40rpx;
  163. }
  164. .back-btn{
  165. position:absolute;
  166. left: 20rpx;
  167. top: calc(var(--status-bar-height) + 20rpx);
  168. z-index: 90;
  169. padding: 20rpx;
  170. font-size: 32rpx;
  171. color: #606266;
  172. }
  173. .left-top-sign{
  174. font-size: 120rpx;
  175. color: #f8f8f8;
  176. position:relative;
  177. left: -12rpx;
  178. }
  179. .right-top-sign{
  180. position:absolute;
  181. top: 80rpx;
  182. right: -30rpx;
  183. z-index: 95;
  184. &:before, &:after{
  185. display:block;
  186. content:"";
  187. width: 400rpx;
  188. height: 80rpx;
  189. background: #b4f3e2;
  190. }
  191. &:before{
  192. transform: rotate(50deg);
  193. border-top-right-radius: 50px;
  194. }
  195. &:after{
  196. position: absolute;
  197. right: -198rpx;
  198. top: 0;
  199. transform: rotate(-50deg);
  200. border-top-left-radius: 50px;
  201. }
  202. }
  203. .left-bottom-sign{
  204. position:absolute;
  205. left: -270rpx;
  206. bottom: -320rpx;
  207. border: 100rpx solid #d0d1fd;
  208. border-radius: 50%;
  209. padding: 180rpx;
  210. }
  211. .welcome{
  212. position:relative;
  213. left: 50rpx;
  214. top: -90rpx;
  215. font-size: 46rpx;
  216. color: #555;
  217. text-shadow: 1px 0px 1px rgba(0,0,0,.3);
  218. }
  219. .input-content{
  220. padding: 0 60rpx;
  221. }
  222. .input-item{
  223. display:flex;
  224. flex-direction: column;
  225. align-items:flex-start;
  226. justify-content: center;
  227. padding: 0 30rpx;
  228. background: #f8f6fc;
  229. height: 120rpx;
  230. border-radius: 4px;
  231. margin-bottom: 50rpx;
  232. &:last-child{
  233. margin-bottom: 0;
  234. }
  235. .row{
  236. width: 100%;
  237. }
  238. .tit{
  239. height: 50rpx;
  240. line-height: 56rpx;
  241. font-size: 26rpx;
  242. color: #606266;
  243. }
  244. input{
  245. flex: 1;
  246. height: 60rpx;
  247. font-size: 30rpx;
  248. color: #303133;
  249. width: 100%;
  250. }
  251. }
  252. /* 其他登录方式 */
  253. .other-wrapper{
  254. display: flex;
  255. flex-direction: column;
  256. align-items: center;
  257. padding-top: 20rpx;
  258. margin-top: 80rpx;
  259. .line{
  260. margin-bottom: 40rpx;
  261. .tit{
  262. margin: 0 32rpx;
  263. font-size: 24rpx;
  264. color: #606266;
  265. }
  266. &:before, &:after{
  267. content: '';
  268. width: 160rpx;
  269. height: 0;
  270. border-top: 1px solid #e0e0e0;
  271. }
  272. }
  273. .item{
  274. font-size: 24rpx;
  275. color: #606266;
  276. background-color: #fff;
  277. border: 0;
  278. &:after{
  279. border: 0;
  280. }
  281. }
  282. .icon{
  283. width: 90rpx;
  284. height: 90rpx;
  285. margin: 0 24rpx 16rpx;
  286. }
  287. }
  288. .agreement{
  289. position: absolute;
  290. left: 0;
  291. bottom: 6vh;
  292. z-index: 1;
  293. width: 750rpx;
  294. height: 90rpx;
  295. font-size: 24rpx;
  296. color: #999;
  297. .mix-icon{
  298. font-size: 36rpx;
  299. color: #ccc;
  300. margin-right: 8rpx;
  301. margin-top: 1px;
  302. &.active{
  303. color: $base-color;
  304. }
  305. }
  306. .tit{
  307. color: #40a2ff;
  308. }
  309. }
  310. </style>