You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
7.1 KiB

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