login.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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 " :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']"
  25. @click="changePassword"></text>
  26. </view>
  27. </view>
  28. <view style="margin-top: 216upx;">
  29. <button class="cu-btn round lg bg-blue " style="display: flex;" :loading="loading"
  30. :class="[shape == 'round' ? 'round' : '']" @tap="onLogin"><text space="emsp">{{ loading ? "登录中..." : " 登录"}}</text>
  31. </button>
  32. </view>
  33. <view class="flex align-center" style="margin-top:10px;color: #858585;font-size:11px">
  34. <uni-data-checkbox multiple :localdata="sex" v-model="checked" active-color="#FF852D "
  35. style="margin-top: 2px;transform: scale(0.7,0.7 );"></uni-data-checkbox>
  36. 请您阅读并同意<view> <text @tap="nav('xieyi')" class="text-color"> 用户协议</text> 和 <text class="text-color"
  37. @tap="nav('mimi')">隐私政策</text></view>
  38. </view>
  39. </block>
  40. <!-- #ifdef APP-PLUS -->
  41. <!-- <view class="padding flex flex-direction text-center">
  42. 当前版本:{{version}}
  43. </view> -->
  44. <!-- #endif -->
  45. </view>
  46. <view class="footer">
  47. <view class="text-color" @tap="nav('register')">去注册</view>
  48. <text style="margin-top: 5px;" @tap="nav('resetpassword')">忘记密码</text>
  49. </view>
  50. <!-- </scroll-view> -->
  51. <!-- 登录加载弹窗 -->
  52. <view class="cu-load load-modal" v-if="loading">
  53. <!-- <view class="cuIcon-emojifill text-orange"></view> -->
  54. <image src="https://static.jeecg.com/upload/test/login4_1595818039175.png" mode="aspectFit" class="round">
  55. </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: '',
  75. password: '',
  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. userType:'2'
  147. }
  148. this.loading = true;
  149. this.mLogin(loginParams).then((res) => {
  150. this.loading = false;
  151. if (res.data.success) {
  152. // #ifdef APP-PLUS
  153. this.saveClientId()
  154. // #endif
  155. // #ifndef APP-PLUS
  156. this.$tip.success('登录成功!')
  157. this.$Router.replaceAll({ name: 'index' })
  158. // #endif
  159. } else {
  160. this.$tip.alert(res.data.message);
  161. }
  162. }).catch((err) => {
  163. let msg = err.data.message || "请求出现错误,请稍后再试"
  164. this.loading = false;
  165. this.$tip.alert(msg);
  166. }).finally(() => {
  167. this.loading = false;
  168. })
  169. },
  170. saveClientId() {
  171. var info = plus.push.getClientInfo();
  172. var cid = info.clientid;
  173. this.$http.get("/sys/user/saveClientId", { params: { clientId: cid } }).then(res => {
  174. console.log("res::saveClientId>", res)
  175. this.$tip.success('登录成功!')
  176. this.$Router.replaceAll({ name: 'index' })
  177. })
  178. },
  179. changePassword() {
  180. this.showPassword = !this.showPassword;
  181. },
  182. onSMSSend() {
  183. // let smsParams = {};
  184. // smsParams.phone=this.phoneNo;
  185. // smsParams.smsmode="0";
  186. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  187. if (!this.phoneNo || this.phoneNo.length == 0) {
  188. this.$tip.toast('请输入手机号');
  189. return false
  190. }
  191. if (!checkPhone.test(this.phoneNo)) {
  192. this.$tip.toast('请输入正确的手机号');
  193. return false
  194. }
  195. this.$http.get("/merchant/app/sendMsg", { params: { phone: this.phoneNo } }).then(res => {
  196. if (res.data.success) {
  197. this.smsCountDown = 60;
  198. this.startSMSTimer();
  199. } else {
  200. this.smsCountDown = 0;
  201. this.$tip.toast(res.data.message);
  202. }
  203. });
  204. },
  205. startSMSTimer() {
  206. this.smsCountInterval = setInterval(() => {
  207. this.smsCountDown--;
  208. if (this.smsCountDown <= 0) {
  209. clearInterval(this.smsCountInterval);
  210. }
  211. }, 1000);
  212. },
  213. onSMSLogin() {
  214. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  215. if (!this.phoneNo || this.phoneNo.length == 0) {
  216. this.$tip.toast('请填写手机号');
  217. return;
  218. }
  219. if (!checkPhone.test(this.phoneNo)) {
  220. this.$tip.toast('请输入正确的手机号');
  221. return false
  222. }
  223. if (!this.smsCode || this.smsCode.length == 0) {
  224. this.$tip.toast('请填短信验证码');
  225. return;
  226. }
  227. if (!this.checked || this.checked.length == 0) {
  228. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私协议》政策');
  229. return;
  230. }
  231. let loginParams = {
  232. mobile: this.phoneNo,
  233. captcha: this.smsCode
  234. };
  235. this.$http.get("/merchant/app/checkCode", { params: { phone: this.phoneNo, code: this.smsCode } }).then(res => {
  236. if (res.data.success) {
  237. this.nav('settled')
  238. // this.$tip.success('登录成功!')
  239. // this.$Router.replaceAll({name:'index'})
  240. } else {
  241. this.$tip.error(res.data.message);
  242. }
  243. }).catch((err) => {
  244. let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  245. this.$tip.error(msg);
  246. });
  247. // this.PhoneLogin(loginParams).then((res) => {
  248. // console.log("res====》",res)
  249. // if(res.data.success){
  250. // // this.$tip.success('登录成功!')
  251. // // this.$Router.replaceAll({name:'index'})
  252. // }else{
  253. // this.$tip.error(res.data.message);
  254. // }
  255. // }).catch((err) => {
  256. // let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  257. // this.$tip.error(msg);
  258. // });
  259. },
  260. loginSuccess() {
  261. // 登陆成功,重定向到主页
  262. this.$Router.replace({ name: 'index' })
  263. },
  264. requestFailed(err) {
  265. this.$message.warning("登录失败")
  266. },
  267. },
  268. beforeDestroy() {
  269. if (this.smsCountInterval) {
  270. clearInterval(this.smsCountInterval);
  271. }
  272. },
  273. }
  274. </script>
  275. <style scoped lang="scss">
  276. page {
  277. background: #FFFFFF;
  278. height: 100%;
  279. }
  280. .uni-data-checklist {
  281. flex: none;
  282. /deep/.checklist-group .checklist-box {
  283. margin-right: 0 !important;
  284. }
  285. }
  286. .footer {
  287. position: fixed;
  288. bottom: 54upx;
  289. font-size: 12px;
  290. background: #FFFFFF;
  291. color: #999999;
  292. text-align: center;
  293. width: 100%;
  294. // left: 50%;
  295. // transform: translateX(-50%);
  296. }
  297. .text-color {
  298. color: #449AFF;
  299. margin: 0 10upx;
  300. }
  301. .login-paddingtop {
  302. // padding-top: 100upx;
  303. padding: 100upx 32upx 0 32upx;
  304. }
  305. .zai-box {
  306. background: #FFFFFF;
  307. height: 100%;
  308. .zai-header {
  309. width: 100%;
  310. height: 432upx;
  311. background-image: url(../../static/login/bejing.png);
  312. background-size: cover;
  313. }
  314. // padding: 0 20upx;
  315. // padding-top: 100upx;
  316. // position: relative;
  317. }
  318. .zai-logo {
  319. width: 20px;
  320. height: 20px;
  321. }
  322. .box-user {
  323. border-bottom: 1px solid #EFEFEF;
  324. min-height: 45px;
  325. image {
  326. margin-right: 10px;
  327. }
  328. input {
  329. font-size: 14px;
  330. flex: 1;
  331. }
  332. }
  333. .zai-title {
  334. font-size: 58upx;
  335. color: #000000;
  336. text-align: center;
  337. }
  338. .input-placeholder,
  339. .zai-input {
  340. color: #94afce;
  341. }
  342. .zai-label {
  343. padding: 60upx 0;
  344. text-align: center;
  345. font-size: 30upx;
  346. color: #a7b6d0;
  347. }
  348. .zai-btn {
  349. background: #ff65a3;
  350. color: #fff;
  351. border: 0;
  352. border-radius: 100upx;
  353. font-size: 36upx;
  354. }
  355. .zai-btn:after {
  356. border: 0;
  357. }
  358. /*按钮点击效果*/
  359. .zai-btn.button-hover {
  360. transform: translate(1upx, 1upx);
  361. }
  362. </style>