login.vue 11 KB

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