login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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. if (!this.checked || this.checked.length == 0) {
  190. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私协议》政策');
  191. return;
  192. }
  193. if (!this.phoneNo || this.phoneNo.length == 0) {
  194. this.$tip.toast('请填写手机号');
  195. return;
  196. }
  197. if (!this.smsCode || this.smsCode.length == 0) {
  198. this.$tip.toast('请填写验证码');
  199. return;
  200. }
  201. let loginParams = {
  202. phone: this.phoneNo,
  203. code: this.smsCode,
  204. }
  205. //this.loading = true;
  206. this.mLogin(loginParams).then((res) => {
  207. this.loading = false;
  208. if (res.data.success) {
  209. // #ifdef APP-PLUS
  210. this.saveClientId()
  211. // #endif
  212. // #ifndef APP-PLUS
  213. this.$tip.success('登录成功!')
  214. this.$Router.replaceAll({
  215. name: 'index'
  216. })
  217. // uni.navigateTo({
  218. // url: '/pages/index/index'
  219. // })
  220. // #endif
  221. } else {
  222. this.$tip.alert(res.data.message);
  223. }
  224. }).catch((err) => {
  225. let msg = err.data.message || "请求出现错误,请稍后再试"
  226. this.loading = false;
  227. this.$tip.alert(msg);
  228. }).finally(() => {
  229. this.loading = false;
  230. })
  231. },
  232. saveClientId() {
  233. var randomNum = new Date().getTime();
  234. this.$http.get("/sys/user/saveClientId", {
  235. params: {
  236. clientId: randomNum
  237. }
  238. }).then(res => {
  239. console.log("res::saveClientId>", res)
  240. this.$tip.success('登录成功!')
  241. this.$Router.replaceAll({
  242. name: 'index'
  243. })
  244. })
  245. },
  246. changePassword() {
  247. this.showPassword = !this.showPassword;
  248. },
  249. onSMSSend() {
  250. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  251. if (!this.phoneNo || this.phoneNo.length == 0) {
  252. this.$tip.toast('请输入手机号');
  253. return false
  254. }
  255. if (!checkPhone.test(this.phoneNo)) {
  256. this.$tip.toast('请输入正确的手机号');
  257. return false
  258. }
  259. this.$http.get("/merchant/app/merLogin/send/code", {
  260. params: {
  261. phone: this.phoneNo
  262. }
  263. }).then(res => {
  264. if (res.data.success) {
  265. this.smsCountDown = 60;
  266. this.startSMSTimer();
  267. } else {
  268. this.smsCountDown = 0;
  269. this.$tip.toast(res.data.message);
  270. }
  271. });
  272. },
  273. startSMSTimer() {
  274. this.smsCountInterval = setInterval(() => {
  275. this.smsCountDown--;
  276. if (this.smsCountDown <= 0) {
  277. clearInterval(this.smsCountInterval);
  278. }
  279. }, 1000);
  280. },
  281. //关闭页面
  282. closePage(){
  283. this.loading = false;
  284. this.addShow = false;
  285. this.msg = "";
  286. this.type = "";
  287. },
  288. //打开页面
  289. openPage(data){
  290. this.loading = false;
  291. this.addShow = true;
  292. this.msg = data.msg;
  293. this.type = data.type;
  294. },
  295. //打电话
  296. makePhoneCall() {
  297. uni.makePhoneCall({
  298. phoneNumber: '40088888888',
  299. success: () => {
  300. console.log('拨打电话成功')
  301. },
  302. fail: (err) => {
  303. console.log('拨打电话失败', err)
  304. uni.showToast({
  305. title: '拨打电话失败',
  306. icon: 'none'
  307. })
  308. }
  309. })
  310. },
  311. //跳转到下载页面
  312. toLoginDown(){
  313. // #ifdef APP-PLUS
  314. uni.navigateTo({
  315. url: '/pages/download/index'
  316. });
  317. // #endif
  318. // #ifndef APP-PLUS
  319. window.location.href = configService.apiUrl + '/downloadApp/download.html';
  320. // #endif
  321. },
  322. },
  323. beforeDestroy() {
  324. if (this.smsCountInterval) {
  325. clearInterval(this.smsCountInterval);
  326. }
  327. },
  328. }
  329. </script>
  330. <style scoped lang="scss">
  331. page {
  332. background: #FFFFFF;
  333. height: 100%;
  334. }
  335. .uni-data-checklist {
  336. flex: none;
  337. ::v-deep.checklist-group .checklist-box {
  338. margin-right: 0 !important;
  339. }
  340. }
  341. .footer {
  342. position: fixed;
  343. bottom: 54upx;
  344. font-size: 12px;
  345. background: #FFFFFF;
  346. color: #999999;
  347. text-align: center;
  348. width: 100%;
  349. // left: 50%;
  350. // transform: translateX(-50%);
  351. }
  352. .text-color {
  353. color: #449AFF;
  354. margin: 0 10upx;
  355. }
  356. .login-paddingtop {
  357. // padding-top: 100upx;
  358. padding: 100upx 32upx 0 32upx;
  359. }
  360. .zai-box {
  361. background: #FFFFFF;
  362. height: 100%;
  363. .zai-header {
  364. width: 100%;
  365. height: 432upx;
  366. background-image: url(../../static/login/beijing.png);
  367. background-size: cover;
  368. }
  369. // padding: 0 20upx;
  370. // padding-top: 100upx;
  371. // position: relative;
  372. }
  373. .zai-logo {
  374. width: 20px;
  375. height: 20px;
  376. }
  377. .box-user {
  378. border-bottom: 1px solid #EFEFEF;
  379. min-height: 45px;
  380. image {
  381. margin-right: 10px;
  382. }
  383. input {
  384. font-size: 14px;
  385. flex: 1;
  386. }
  387. }
  388. .zai-title {
  389. font-size: 58upx;
  390. color: #000000;
  391. text-align: center;
  392. }
  393. .input-placeholder,
  394. .zai-input {
  395. color: #94afce;
  396. }
  397. .zai-label {
  398. padding: 60upx 0;
  399. text-align: center;
  400. font-size: 30upx;
  401. color: #a7b6d0;
  402. }
  403. .zai-btn {
  404. background: #ff65a3;
  405. color: #fff;
  406. border: 0;
  407. border-radius: 100upx;
  408. font-size: 36upx;
  409. }
  410. .zai-btn:after {
  411. border: 0;
  412. }
  413. /*按钮点击效果*/
  414. .zai-btn.button-hover {
  415. transform: translate(1upx, 1upx);
  416. }
  417. .popup-contents-add {
  418. width: 600rpx;
  419. height: 350rpx;
  420. display: flex;
  421. align-items: center;
  422. flex-direction: column;
  423. >view {
  424. width: 100%;
  425. }
  426. >view.tit {
  427. height: 100rpx;
  428. display: flex;
  429. align-items: center;
  430. flex-direction: column;
  431. justify-content: space-around;
  432. padding: 0 20rpx;
  433. box-sizing: border-box;
  434. text {
  435. padding-top: 20rpx;
  436. box-sizing: border-box;
  437. font-size: 40rpx;
  438. font-weight: 600;
  439. }
  440. }
  441. .tit-center {
  442. flex: 1;
  443. display: flex;
  444. flex-direction: column;
  445. align-items: center;
  446. justify-content: center;
  447. text {
  448. padding: 10rpx;
  449. box-sizing: border-box;
  450. font-size: 28rpx;
  451. font-weight: 400;
  452. }
  453. }
  454. .tit-bottom {
  455. >view {
  456. display: flex;
  457. align-items: center;
  458. justify-content: space-between;
  459. gap: 16rpx;
  460. }
  461. }
  462. >view.tit-bottom {
  463. padding: 0;
  464. }
  465. }
  466. .btn {
  467. border-radius: 50rpx;
  468. width: 200rpx;
  469. background-color: #0081ff;
  470. color: #ffffff;
  471. padding: 10rpx 20rpx;
  472. text-align: center;
  473. box-sizing: border-box;
  474. }
  475. .cancel-btn {
  476. border-radius: 50rpx;
  477. width: 200rpx;
  478. padding: 10rpx 20rpx; // 上下左右内边距
  479. text-align: center; // 文字居中
  480. box-sizing: border-box; // 确保内边距不会增加按钮总尺寸
  481. }
  482. </style>