login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <view class="zai-box">
  3. <!-- <scroll-view scroll-y class="page"> -->
  4. <!-- <view class="text-center" :style="[{animation: 'show ' + 0.4+ 's 1'}]"> -->
  5. <!-- <image src="../../static/login/bejing.png" mode='aspectFit' class="zai-header "></image> -->
  6. <view class="zai-header"></view>
  7. <!-- <view class="text-center" >
  8. <image src="https://static.jeecg.com/upload/test/login4_1595818039175.png" mode='aspectFit' class="zai-logo "></image>
  9. <view class="zai-title text-shadow ">本地生活 </view>
  10. </view> -->
  11. <view class="box padding-lr-xl login-paddingtop" >
  12. <block >
  13. <view class="box-user flex align-center " style="border-bottom: 1px solid #EFEFEF;" :class="[shape=='round'?'round':'']">
  14. <!-- <view class="title"><text class="cuIcon-people margin-right-xs"></text>手机号:</view> -->
  15. <image src="../../static/login/Frame (27).png" mode='aspectFit' class="zai-logo "></image>
  16. <input placeholder="请输入手机号" name="input" v-model="userName"></input>
  17. </view>
  18. <view class="box-user flex align-center" :class="[shape=='round'?'round':'']">
  19. <!-- <view class="title"><text class="cuIcon-lock margin-right-xs"></text>密码:</view>
  20. <input class="uni-input" placeholder="请输入密码" :password="!showPassword" v-model="password" /> -->
  21. <image src="../../static/login/Frame (26).png" mode='aspectFit' class="zai-logo "></image>
  22. <input placeholder="请输入密码" :password="!showPassword" v-model="password" ></input>
  23. <view class="action text-lg">
  24. <text :class="[showPassword ? 'cuIcon-attention' : 'cuIcon-attentionforbid']" @click="changePassword"></text>
  25. </view>
  26. </view>
  27. <view style="margin-top:30%">
  28. <button class="cu-btn round lg bg-blue " style="display: flex;" :loading="loading" :class="[shape=='round'?'round':'']"
  29. @tap="onLogin"><text space="emsp">{{loading ? "登录中...":" 登录 "}}</text>
  30. </button>
  31. <!-- <button class="cu-btn line-blue lg margin-left shadow" :loading="loading" :class="[shape=='round'?'round':'']"
  32. @tap="loginWay=3-loginWay">注册
  33. </button> -->
  34. </view>
  35. <view class="flex align-center" style="margin-top:10px;color: #858585;font-size:11px">
  36. <uni-data-checkbox multiple :localdata="sex" v-model="checked" active-color="#FF852D "></uni-data-checkbox>
  37. 请您阅读并同意<view> <text @tap="nav('xieyi')" class="text-color"> 用户协议</text> 和 <text
  38. class="text-color" @tap="nav('mimi')">隐私政策</text></view>
  39. </view>
  40. <view class="footer">
  41. <view class="text-color" @tap="nav('register')">去注册</view>
  42. <text style="margin-top: 5px;" @tap="nav('resetpassword')">忘记密码</text>
  43. </view>
  44. </block>
  45. <!-- #ifdef APP-PLUS -->
  46. <view class="padding flex flex-direction text-center">
  47. 当前版本:{{version}}
  48. </view>
  49. <!-- #endif -->
  50. </view>
  51. <!-- </scroll-view> -->
  52. <!-- 登录加载弹窗 -->
  53. <view class="cu-load load-modal" v-if="loading">
  54. <!-- <view class="cuIcon-emojifill text-orange"></view> -->
  55. <image src="https://static.jeecg.com/upload/test/login4_1595818039175.png" mode="aspectFit" class="round"></image>
  56. <view class="gray-text">登录中...</view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import { ACCESS_TOKEN,USER_NAME,USER_INFO } from "@/common/util/constants"
  62. import { mapActions } from "vuex"
  63. import configService from '@/common/service/config.service.js';
  64. export default {
  65. data() {
  66. return {
  67. sex: [{
  68. text: '',
  69. value: 1
  70. }],
  71. checked:[],
  72. shape:'',//round 圆形
  73. loading: false,
  74. userName: '18956455265',
  75. password: '123456',
  76. phoneNo: '',
  77. smsCode: '',
  78. showPassword: false, //是否显示明文
  79. loginWay: 1, //1: 账密,2:验证码
  80. smsCountDown: 0,
  81. smsCountInterval: null,
  82. toggleDelay: false,
  83. version:'',
  84. //第三方登录相关信息
  85. thirdType:"",
  86. thirdLoginInfo:"",
  87. thirdLoginState:false,
  88. bindingPhoneModal:false,
  89. thirdUserUuid:'',
  90. url: {
  91. bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone'
  92. }
  93. };
  94. },
  95. onLoad:function(){
  96. // #ifdef APP-PLUS
  97. var that=this
  98. plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
  99. that.version=wgtinfo.version
  100. });
  101. // #endif
  102. },
  103. computed: {
  104. isSendSMSEnable() {
  105. return this.smsCountDown <= 0 && this.phoneNo.length > 4;
  106. },
  107. getSendBtnText() {
  108. if (this.smsCountDown > 0) {
  109. return this.smsCountDown + '秒后发送';
  110. } else {
  111. return '发送验证码';
  112. }
  113. },
  114. canSMSLogin() {
  115. return this.userName.length > 4 && this.smsCode.length > 4;
  116. },
  117. canPwdLogin() {
  118. return this.userName.length > 4 && this.password.length > 4;
  119. },
  120. },
  121. methods: {
  122. ...mapActions([ "mLogin","PhoneLogin","ThirdLogin" ]),
  123. nav(url) {
  124. this.$Router.push({name:url})
  125. // uni.navigateTo({
  126. // url: url
  127. // });
  128. },
  129. // 登录
  130. onLogin: function (){
  131. if(!this.checked || this.checked.length==0){
  132. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私协议》政策');
  133. return;
  134. }
  135. if(!this.userName || this.userName.length==0){
  136. this.$tip.toast('请填写手机号');
  137. return;
  138. }
  139. if(!this.password || this.password.length==0){
  140. this.$tip.toast('请填写密码');
  141. return;
  142. }
  143. let loginParams = {
  144. phone:this.userName,
  145. passWord:this.password
  146. }
  147. this.loading=true;
  148. this.mLogin(loginParams).then((res) => {
  149. this.loading=false;
  150. if(res.data.success){
  151. // #ifdef APP-PLUS
  152. this.saveClientId()
  153. // #endif
  154. // #ifndef APP-PLUS
  155. this.$tip.success('登录成功!')
  156. this.$Router.replaceAll({name:'index'})
  157. // #endif
  158. }else{
  159. this.$tip.alert(res.data.message);
  160. }
  161. }).catch((err) => {
  162. let msg = err.data.message || "请求出现错误,请稍后再试"
  163. this.loading=false;
  164. this.$tip.alert(msg);
  165. }).finally(()=>{
  166. this.loading=false;
  167. })
  168. },
  169. saveClientId(){
  170. var info = plus.push.getClientInfo();
  171. var cid = info.clientid;
  172. this.$http.get("/sys/user/saveClientId",{params:{clientId:cid}}).then(res=>{
  173. console.log("res::saveClientId>",res)
  174. this.$tip.success('登录成功!')
  175. this.$Router.replaceAll({name:'index'})
  176. })
  177. },
  178. changePassword() {
  179. this.showPassword = !this.showPassword;
  180. },
  181. onSMSSend() {
  182. // let smsParams = {};
  183. // smsParams.phone=this.phoneNo;
  184. // smsParams.smsmode="0";
  185. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  186. if(!this.phoneNo || this.phoneNo.length==0){
  187. this.$tip.toast('请输入手机号');
  188. return false
  189. }
  190. if(!checkPhone.test(this.phoneNo)){
  191. this.$tip.toast('请输入正确的手机号');
  192. return false
  193. }
  194. this.$http.get("/merchant/app/sendMsg",{params:{phone:this.phoneNo}}).then(res=>{
  195. if(res.data.success){
  196. this.smsCountDown = 60;
  197. this.startSMSTimer();
  198. }else{
  199. this.smsCountDown = 0;
  200. this.$tip.toast(res.data.message);
  201. }
  202. });
  203. },
  204. startSMSTimer() {
  205. this.smsCountInterval = setInterval(() => {
  206. this.smsCountDown--;
  207. if (this.smsCountDown <= 0) {
  208. clearInterval(this.smsCountInterval);
  209. }
  210. }, 1000);
  211. },
  212. onSMSLogin() {
  213. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  214. if(!this.phoneNo || this.phoneNo.length==0){
  215. this.$tip.toast('请填写手机号');
  216. return;
  217. }
  218. if(!checkPhone.test(this.phoneNo)){
  219. this.$tip.toast('请输入正确的手机号');
  220. return false
  221. }
  222. if(!this.smsCode || this.smsCode.length==0){
  223. this.$tip.toast('请填短信验证码');
  224. return;
  225. }
  226. if(!this.checked || this.checked.length==0){
  227. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私协议》政策');
  228. return;
  229. }
  230. let loginParams = {
  231. mobile:this.phoneNo,
  232. captcha:this.smsCode
  233. };
  234. this.$http.get("/merchant/app/checkCode",{params:{phone:this.phoneNo, code:this.smsCode}}).then(res=>{
  235. if(res.data.success){
  236. this.nav('settled')
  237. // this.$tip.success('登录成功!')
  238. // this.$Router.replaceAll({name:'index'})
  239. }else{
  240. this.$tip.error(res.data.message);
  241. }
  242. }).catch((err) => {
  243. let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  244. this.$tip.error(msg);
  245. });
  246. // this.PhoneLogin(loginParams).then((res) => {
  247. // console.log("res====》",res)
  248. // if(res.data.success){
  249. // // this.$tip.success('登录成功!')
  250. // // this.$Router.replaceAll({name:'index'})
  251. // }else{
  252. // this.$tip.error(res.data.message);
  253. // }
  254. // }).catch((err) => {
  255. // let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  256. // this.$tip.error(msg);
  257. // });
  258. },
  259. loginSuccess() {
  260. // 登陆成功,重定向到主页
  261. this.$Router.replace({name:'index'})
  262. },
  263. requestFailed(err) {
  264. this.$message.warning("登录失败")
  265. },
  266. },
  267. beforeDestroy() {
  268. if (this.smsCountInterval) {
  269. clearInterval(this.smsCountInterval);
  270. }
  271. },
  272. }
  273. </script>
  274. <style scoped lang="scss">
  275. page{
  276. background: #FFFFFF;
  277. height: 100%;
  278. }
  279. .uni-data-checklist{
  280. flex:none;
  281. /deep/.checklist-group .checklist-box{
  282. margin-right: 0 !important;
  283. }
  284. }
  285. .footer{
  286. position: fixed;
  287. bottom: 20px;
  288. font-size: 14px;
  289. color: #999999;
  290. left: 50%;
  291. transform: translateX(-50%);
  292. }
  293. .text-color {
  294. color: #449AFF ;
  295. margin: 0 5px;
  296. }
  297. .login-paddingtop {
  298. // padding-top: 100upx;
  299. padding: 50px 17px 28px 17px;
  300. }
  301. .zai-box {
  302. background: #FFFFFF;
  303. height: 100%;
  304. .zai-header{
  305. width: 100%;
  306. height: 225px;
  307. background-image: url(../../static/login/bejing.png);
  308. background-size: cover;
  309. }
  310. // padding: 0 20upx;
  311. // padding-top: 100upx;
  312. // position: relative;
  313. }
  314. .zai-logo {
  315. width: 20px;
  316. height: 20px;
  317. }
  318. .box-user{
  319. min-height: 45px;
  320. image{
  321. margin-right: 10px;
  322. }
  323. input{
  324. font-size: 14px;
  325. flex: 1;
  326. }
  327. }
  328. .zai-title {
  329. font-size: 58upx;
  330. color: #000000;
  331. text-align: center;
  332. }
  333. .input-placeholder, .zai-input {
  334. color: #94afce;
  335. }
  336. .zai-label {
  337. padding: 60upx 0;
  338. text-align: center;
  339. font-size: 30upx;
  340. color: #a7b6d0;
  341. }
  342. .zai-btn {
  343. background: #ff65a3;
  344. color: #fff;
  345. border: 0;
  346. border-radius: 100upx;
  347. font-size: 36upx;
  348. }
  349. .zai-btn:after {
  350. border: 0;
  351. }
  352. /*按钮点击效果*/
  353. .zai-btn.button-hover {
  354. transform: translate(1upx, 1upx);
  355. }
  356. </style>