login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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="phoneNo"></input>
  18. </view>
  19. <view class="box-user flex align-center" :class="[shape=='round'?'round':'']">
  20. <image src="../../static/login/Frame (28).png" mode='aspectFit' class="zai-logo"></image>
  21. <input class="uni-input" placeholder="请输入验证码" v-model="smsCode"/>
  22. <view class="action">
  23. <text class="text-color" :disabled="!isSendSMSEnable" @click="onSMSSend"> {{ getSendBtnText }}</text>
  24. </view>
  25. </view>
  26. <!-- 注释掉密码登录 add by hxl 2025-07-16 -->
  27. <!--<view class="box-user flex align-center" :class="[shape == 'round' ? 'round' : '']">
  28. <image src="../../static/login/Frame (26).png" mode='aspectFit' class="zai-logo "></image>
  29. <input placeholder="请输入密码" :password="!showPassword" v-model="password"></input>
  30. <view class="action text-lg">
  31. <text :class="[showPassword ? 'cuIcon-attention' : 'cuIcon-attentionforbid']"
  32. @click="changePassword"></text>
  33. </view>
  34. </view>
  35. -->
  36. <view style="margin-top: 216upx;">
  37. <button class="cu-btn round lg bg-blue " style="display: flex;" :loading="loading"
  38. :class="[shape == 'round' ? 'round' : '']" @tap="onLogin"><text
  39. space="emsp">{{ loading ? "登录中..." : " 登录/注册"}}</text>
  40. </button>
  41. </view>
  42. <!-- 去掉注册和忘记密码 add by hxl 2025-07-16 -->
  43. <!--<view class="foote" style="display: flex;align-items: center;margin-top: 40rpx;justify-content: center;">
  44. <view class="text-color" @tap="nav('register')" style="margin-right: 53rpx;">去注册</view>
  45. <text style="" @tap="nav('resetpassword')">忘记密码</text>
  46. </view>
  47. -->
  48. <view class="flex align-center"
  49. style="margin-top:154rpx;color: #858585;font-size:26rpx;justify-content: center;">
  50. <uni-data-checkbox multiple :localdata="sex" v-model="checked" active-color="#FF852D "
  51. style="margin-top: 2px;transform: scale(0.7,0.7 );"></uni-data-checkbox>
  52. 请您阅读并同意<view> <text @tap="nav('xieyi')" class="text-color"> 用户协议</text> 和 <text class="text-color"
  53. @tap="nav('mimi')">隐私政策</text></view>
  54. </view>
  55. </block>
  56. <!-- #ifdef APP-PLUS -->
  57. <!-- <view class="padding flex flex-direction text-center">
  58. 当前版本:{{version}}
  59. </view> -->
  60. <!-- #endif -->
  61. </view>
  62. <!-- </scroll-view> -->
  63. <!-- 登录加载弹窗 -->
  64. <view class="cu-load load-modal" v-if="loading">
  65. <!-- <view class="cuIcon-emojifill text-orange"></view> -->
  66. <image src="https://static.jeecg.com/upload/test/login4_1595818039175.png" mode="aspectFit" class="round">
  67. </image>
  68. <view class="gray-text">登录中...</view>
  69. </view>
  70. <u-popup v-model="addShow" mode="center" :round="20" >
  71. <view class="popup-contents-add">
  72. <view class="tit-center">
  73. <text>{{msg}}</text>
  74. </view>
  75. <view class="tit tit-bottom">
  76. <u-line></u-line>
  77. <view>
  78. <u-button size="small" shape="square" class="cancel-btn"
  79. @click="closePage()">取消</u-button>
  80. <u-button size="small" shape="square" class="btn"
  81. @click="makePhoneCall()" v-if="type==='2'" >联系客服</u-button>
  82. <u-button size="small" shape="square" class="btn" @click="toLoginDown()" v-if="type==='1'">去注册</u-button>
  83. </view>
  84. </view>
  85. </view>
  86. </u-popup>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. ACCESS_TOKEN,
  92. USER_NAME,
  93. USER_INFO
  94. } from "@/common/util/constants"
  95. import {
  96. mapActions
  97. } from "vuex"
  98. import configService from '@/common/service/config.service.js';
  99. import appUpdate from "@/components/yzhua006-update/app-update.vue"; //app更新组件
  100. import eventBus from '@/common/util/event-bus.js';
  101. export default {
  102. components: {
  103. appUpdate
  104. },
  105. data() {
  106. return {
  107. msg:'',
  108. type:'',
  109. addShow:false,
  110. phoneMsg:'',//手机信息
  111. sex: [{
  112. text: '',
  113. value: 1
  114. }],
  115. checked: [],
  116. shape: '', //round 圆形
  117. loading: false,
  118. userName: '',
  119. password: '',
  120. phoneNo: '',
  121. smsCode: '',
  122. showPassword: false, //是否显示明文
  123. loginWay: 1, //1: 账密,2:验证码
  124. smsCountDown: 0,
  125. smsCountInterval: null,
  126. toggleDelay: false,
  127. version: '',
  128. //第三方登录相关信息
  129. thirdType: "",
  130. thirdLoginInfo: "",
  131. thirdLoginState: false,
  132. bindingPhoneModal: false,
  133. thirdUserUuid: '',
  134. url: {
  135. bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone'
  136. }
  137. };
  138. },
  139. onLoad: function() {
  140. // #ifdef APP-PLUS
  141. var that = this
  142. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  143. that.version = wgtinfo.version
  144. });
  145. // #endif
  146. eventBus.on('openPage', this.openPage);
  147. },
  148. onUnload() {
  149. eventBus.off('openPage', this.openPage);
  150. },
  151. beforeCreate() {
  152. setTimeout(() => {
  153. this.$refs.app_update.update(); //调用子组件检查更新方法
  154. setTimeout(() => {
  155. if (this.$refs.app_update.popup_show == true && this.$refs.app_update.force == true) {}
  156. }, 100)
  157. }, 500)
  158. },
  159. computed: {
  160. isSendSMSEnable() {
  161. return this.smsCountDown <= 0 && this.phoneNo.length > 4;
  162. },
  163. getSendBtnText() {
  164. if (this.smsCountDown > 0) {
  165. return this.smsCountDown + '秒后发送';
  166. } else {
  167. return '发送验证码';
  168. }
  169. },
  170. canSMSLogin() {
  171. return this.phoneNo.length > 4 && this.smsCode.length > 4;
  172. },
  173. canPwdLogin() {
  174. return this.phoneNo.length > 4 && this.password.length > 4;
  175. },
  176. },
  177. methods: {
  178. ...mapActions(["mLogin", "PhoneLogin", "ThirdLogin"]),
  179. nav(url) {
  180. this.$Router.push({
  181. name: url
  182. })
  183. // uni.navigateTo({
  184. // url: url
  185. // });
  186. },
  187. // 登录
  188. onLogin: function() {
  189. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  190. if (!this.phoneNo || this.phoneNo.length == 0) {
  191. this.$tip.toast('请输入手机号');
  192. return false
  193. }
  194. if (!checkPhone.test(this.phoneNo)) {
  195. this.$tip.toast('请输入正确的手机号');
  196. return false
  197. }
  198. if (!this.smsCode || this.smsCode.length == 0) {
  199. this.$tip.toast('请填写验证码');
  200. return;
  201. }
  202. if (!this.checked || this.checked.length == 0) {
  203. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私政策》');
  204. return;
  205. }
  206. let loginParams = {
  207. phone: this.phoneNo,
  208. code: this.smsCode,
  209. }
  210. //this.loading = true;
  211. this.mLogin(loginParams).then((res) => {
  212. this.loading = false;
  213. if (res.data.success) {
  214. // #ifdef APP-PLUS
  215. this.saveClientId()
  216. uni.switchTab({
  217. url: '/pages/index/index'
  218. })
  219. // #endif
  220. // #ifndef APP-PLUS
  221. this.$tip.success('登录成功!')
  222. this.$Router.replaceAll({
  223. name: 'index'
  224. })
  225. // uni.navigateTo({
  226. // url: '/pages/index/index'
  227. // })
  228. // #endif
  229. } else {
  230. this.$tip.alert(res.data.message);
  231. }
  232. }).catch((err) => {
  233. let msg = err.data.message || "请求出现错误,请稍后再试"
  234. this.loading = false;
  235. this.$tip.alert(msg);
  236. }).finally(() => {
  237. this.loading = false;
  238. })
  239. },
  240. saveClientId() {
  241. var randomNum = new Date().getTime();
  242. this.$http.get("/sys/user/saveClientId", {
  243. params: {
  244. clientId: randomNum
  245. }
  246. }).then(res => {
  247. console.log("res::saveClientId>", res)
  248. this.$tip.success('登录成功!')
  249. this.$Router.replaceAll({
  250. name: 'index'
  251. })
  252. })
  253. },
  254. changePassword() {
  255. this.showPassword = !this.showPassword;
  256. },
  257. onSMSSend() {
  258. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  259. if (!this.phoneNo || this.phoneNo.length == 0) {
  260. this.$tip.toast('请输入手机号');
  261. return false
  262. }
  263. if (!checkPhone.test(this.phoneNo)) {
  264. this.$tip.toast('请输入正确的手机号');
  265. return false
  266. }
  267. this.$http.get("/merchant/app/merLogin/send/code", {
  268. params: {
  269. phone: this.phoneNo
  270. }
  271. }).then(res => {
  272. if (res.data.success) {
  273. this.smsCountDown = 60;
  274. this.startSMSTimer();
  275. } else {
  276. this.smsCountDown = 0;
  277. this.$tip.toast(res.data.message);
  278. }
  279. });
  280. },
  281. startSMSTimer() {
  282. this.smsCountInterval = setInterval(() => {
  283. this.smsCountDown--;
  284. if (this.smsCountDown <= 0) {
  285. clearInterval(this.smsCountInterval);
  286. }
  287. }, 1000);
  288. },
  289. //关闭页面
  290. closePage(){
  291. this.loading = false;
  292. this.addShow = false;
  293. this.msg = "";
  294. this.type = "";
  295. },
  296. //打开页面
  297. openPage(data){
  298. this.loading = false;
  299. this.addShow = true;
  300. this.msg = data.msg;
  301. this.type = data.type;
  302. },
  303. //打电话
  304. makePhoneCall() {
  305. uni.makePhoneCall({
  306. phoneNumber: '40088888888',
  307. success: () => {
  308. console.log('拨打电话成功')
  309. },
  310. fail: (err) => {
  311. console.log('拨打电话失败', err)
  312. uni.showToast({
  313. title: '拨打电话失败',
  314. icon: 'none'
  315. })
  316. }
  317. })
  318. },
  319. //跳转到下载页面
  320. toLoginDown(){
  321. // #ifdef APP-PLUS
  322. uni.navigateTo({
  323. url: '/pages/download/index'
  324. });
  325. // #endif
  326. // #ifndef APP-PLUS
  327. window.location.href = configService.apiUrl + '/downloadApp/download.html';
  328. // #endif
  329. },
  330. },
  331. beforeDestroy() {
  332. if (this.smsCountInterval) {
  333. clearInterval(this.smsCountInterval);
  334. }
  335. },
  336. }
  337. </script>
  338. <style scoped lang="scss">
  339. page {
  340. background: #FFFFFF;
  341. height: 100%;
  342. }
  343. .uni-data-checklist {
  344. flex: none;
  345. ::v-deep.checklist-group .checklist-box {
  346. margin-right: 0 !important;
  347. }
  348. }
  349. .footer {
  350. position: fixed;
  351. bottom: 54upx;
  352. font-size: 12px;
  353. background: #FFFFFF;
  354. color: #999999;
  355. text-align: center;
  356. width: 100%;
  357. // left: 50%;
  358. // transform: translateX(-50%);
  359. }
  360. .text-color {
  361. color: #449AFF;
  362. margin: 0 10upx;
  363. }
  364. .login-paddingtop {
  365. // padding-top: 100upx;
  366. padding: 100upx 32upx 0 32upx;
  367. }
  368. .zai-box {
  369. background: #FFFFFF;
  370. height: 100%;
  371. .zai-header {
  372. width: 100%;
  373. height: 432upx;
  374. background-image: url(../../static/login/beijing.png);
  375. background-size: cover;
  376. }
  377. // padding: 0 20upx;
  378. // padding-top: 100upx;
  379. // position: relative;
  380. }
  381. .zai-logo {
  382. width: 20px;
  383. height: 20px;
  384. }
  385. .box-user {
  386. border-bottom: 1px solid #EFEFEF;
  387. min-height: 45px;
  388. image {
  389. margin-right: 10px;
  390. }
  391. input {
  392. font-size: 14px;
  393. flex: 1;
  394. }
  395. }
  396. .zai-title {
  397. font-size: 58upx;
  398. color: #000000;
  399. text-align: center;
  400. }
  401. .input-placeholder,
  402. .zai-input {
  403. color: #94afce;
  404. }
  405. .zai-label {
  406. padding: 60upx 0;
  407. text-align: center;
  408. font-size: 30upx;
  409. color: #a7b6d0;
  410. }
  411. .zai-btn {
  412. background: #ff65a3;
  413. color: #fff;
  414. border: 0;
  415. border-radius: 100upx;
  416. font-size: 36upx;
  417. }
  418. .zai-btn:after {
  419. border: 0;
  420. }
  421. /*按钮点击效果*/
  422. .zai-btn.button-hover {
  423. transform: translate(1upx, 1upx);
  424. }
  425. .popup-contents-add {
  426. width: 600rpx;
  427. height: 350rpx;
  428. display: flex;
  429. align-items: center;
  430. flex-direction: column;
  431. >view {
  432. width: 100%;
  433. }
  434. >view.tit {
  435. height: 100rpx;
  436. display: flex;
  437. align-items: center;
  438. flex-direction: column;
  439. justify-content: space-around;
  440. padding: 0 20rpx;
  441. box-sizing: border-box;
  442. text {
  443. padding-top: 20rpx;
  444. box-sizing: border-box;
  445. font-size: 40rpx;
  446. font-weight: 600;
  447. }
  448. }
  449. .tit-center {
  450. flex: 1;
  451. display: flex;
  452. flex-direction: column;
  453. align-items: center;
  454. justify-content: center;
  455. text {
  456. padding: 10rpx;
  457. box-sizing: border-box;
  458. font-size: 28rpx;
  459. font-weight: 400;
  460. }
  461. }
  462. .tit-bottom {
  463. >view {
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. gap: 16rpx;
  468. }
  469. }
  470. >view.tit-bottom {
  471. padding: 0;
  472. }
  473. }
  474. .btn {
  475. border-radius: 50rpx;
  476. width: 200rpx;
  477. background-color: #0081ff;
  478. color: #ffffff;
  479. padding: 10rpx 20rpx;
  480. text-align: center;
  481. box-sizing: border-box;
  482. }
  483. .cancel-btn {
  484. border-radius: 50rpx;
  485. width: 200rpx;
  486. padding: 10rpx 20rpx; // 上下左右内边距
  487. text-align: center; // 文字居中
  488. box-sizing: border-box; // 确保内边距不会增加按钮总尺寸
  489. }
  490. </style>