passwordLogin.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view>
  3. <view style="height: 90rpx;"></view>
  4. <view style="padding-left: 30rpx;">
  5. <u-icon name="close" color="#666" size="24" @click="backto()"
  6. style="width: 40rpx;height: 40rpx;"></u-icon>
  7. </view>
  8. <view style="height: 260rpx;"></view>
  9. <view class="detext">登录即可体验完整功能</view>
  10. <veiw class="log">
  11. <view class="form-items">
  12. <u-icon name="account" color="#666" size="24" ></u-icon>
  13. <input
  14. type="number"
  15. style="flex: 1;margin-left: 16rpx;"
  16. v-model="phone"
  17. placeholder="请输入手机"
  18. maxlength="11"/>
  19. </view>
  20. <view class="form-items">
  21. <u-icon name="lock" color="#666" size="24" ></u-icon>
  22. <input
  23. type="password"
  24. style="flex: 1;margin-left: 16rpx;"
  25. v-model="password"
  26. placeholder="请输入密码"
  27. maxlength="11"/>
  28. </view>
  29. <view class="submitlog" @click="submit()">登录</view>
  30. <view class="forget">
  31. <view @click="navTo('/pages/auth/register')">注册账号</view>
  32. <view @click="navTo('/pages/auth/forgetPassword')">忘记密码</view>
  33. </view>
  34. </veiw>
  35. <view class="tips">
  36. <checkbox :checked="isAgreement" @click="handleAgreement()" color='#fff'
  37. activeBackgroundColor='#018C39 ' borderColor='#EDEEEF' activeBorderColor='#EDEEEF'/>
  38. <view @click="handleAgreement()">您同意并接受</view>
  39. <view class="btn" @click="openH5('/h5/userAgreement')">《用户协议》</view>
  40. <view class="btn" @click="openH5('/h5/privacyPolicy')">《隐私保护》</view>
  41. </view>
  42. <!-- 第三方登录 -->
  43. <view @click="handleWechatLogin()" class="wechat-btn">
  44. <image src="/static/images/wechat.png" style="width: 80rpx; height: 80rpx;"></image>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {login} from '@/api/user.js'
  50. export default {
  51. data() {
  52. return {
  53. phone:'',
  54. password:'',
  55. isAgreement:false,
  56. loginType:1
  57. }
  58. },
  59. methods: {
  60. // 校验手机号
  61. validatePhone() {
  62. return /^1[3-9]\d{9}$/.test(this.phone);
  63. },
  64. // 跳转页面
  65. navTo(url){
  66. uni.navigateTo({
  67. url: url
  68. })
  69. },
  70. backto(){
  71. uni.navigateBack({
  72. url:-1
  73. })
  74. },
  75. handleAgreement(){
  76. this.isAgreement=!this.isAgreement;
  77. },
  78. openH5(url){
  79. var requestPath = uni.getStorageSync('requestPath');
  80. uni.setStorageSync('url',requestPath+url);
  81. uni.navigateTo({
  82. url: '../home/h5'
  83. })
  84. },
  85. handleWechatLogin(){
  86. //微信登录
  87. this.$showLoginPage("weixin");
  88. },
  89. submit(){
  90. if (!this.phone) {
  91. uni.showToast({ title: '请输入手机号', icon: 'none' });
  92. return;
  93. }
  94. if (!this.validatePhone()) {
  95. uni.showToast({ title: '手机号格式错误', icon: 'none' });
  96. return;
  97. }
  98. if (!this.password) {
  99. uni.showToast({ title: '请输入密码', icon: 'none' });
  100. return;
  101. }
  102. if(!this.isAgreement){
  103. uni.showToast({
  104. icon:'none',
  105. title: "请先同意协议后再登录",
  106. });
  107. return false;
  108. }
  109. const data={
  110. phone:this.phone,
  111. password:this.password,
  112. loginType:this.loginType
  113. }
  114. login(data).then(res=>{
  115. if(res.code==200){
  116. uni.switchTab({
  117. url:'/pages/home/index'
  118. })
  119. uni.showToast({
  120. icon:'none',
  121. title: '登录成功',
  122. });
  123. uni.setStorageSync('userInfo',res.user)
  124. }else{
  125. uni.showToast({
  126. icon:'none',
  127. title: res.msg,
  128. });
  129. }
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .detext{
  137. font-size: 40rpx;
  138. font-weight: bold;
  139. text-align: center;
  140. margin-bottom: 40rpx;
  141. }
  142. .log{
  143. background: #fff ;
  144. width: calc(100% - 20rpx);
  145. margin: 10rpx ;
  146. padding: 20rpx 0;
  147. border-radius: 20rpx;
  148. display: flex;
  149. flex-direction: column;
  150. .form-items{
  151. background: #fff ;
  152. display: flex;
  153. justify-content: flex-start;
  154. align-items: center;
  155. padding: 28rpx 0;
  156. margin: 0 20rpx;
  157. border-bottom: #eee solid 2rpx;
  158. }
  159. }
  160. .submitlog{
  161. background: linear-gradient(135deg, #38e663 0%, #018C39 100%);
  162. border-radius: 80rpx;
  163. color: #fff;
  164. margin: 0 auto;
  165. width: 80%;
  166. padding: 20rpx 0;
  167. text-align: center;
  168. margin-top: 40rpx;
  169. }
  170. .forget{
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. padding: 0 20rpx;
  175. font-size: 24rpx;
  176. color: #38e663 ;
  177. margin: 20rpx 0;
  178. }
  179. .tips{
  180. margin-top: 30rpx;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. font-size: 28rpx;
  185. color: #000;
  186. .btn{
  187. color: #018C39;
  188. }
  189. }
  190. /deep/ .uni-checkbox-input {
  191. border-radius: 50% !important;
  192. }
  193. .wechat-btn {
  194. margin-top: 100rpx !important;
  195. margin: 0 auto;
  196. width: fit-content;
  197. padding: 16rpx;
  198. display: flex;
  199. align-items: center;
  200. border-radius: 50%;
  201. border: 2rpx solid #28c445;
  202. }
  203. </style>