login.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. window.location.href = configService.apiUrl + '/downloadApp/download.html';
  314. },
  315. },
  316. beforeDestroy() {
  317. if (this.smsCountInterval) {
  318. clearInterval(this.smsCountInterval);
  319. }
  320. },
  321. }
  322. </script>
  323. <style scoped lang="scss">
  324. page {
  325. background: #FFFFFF;
  326. height: 100%;
  327. }
  328. .uni-data-checklist {
  329. flex: none;
  330. ::v-deep.checklist-group .checklist-box {
  331. margin-right: 0 !important;
  332. }
  333. }
  334. .footer {
  335. position: fixed;
  336. bottom: 54upx;
  337. font-size: 12px;
  338. background: #FFFFFF;
  339. color: #999999;
  340. text-align: center;
  341. width: 100%;
  342. // left: 50%;
  343. // transform: translateX(-50%);
  344. }
  345. .text-color {
  346. color: #449AFF;
  347. margin: 0 10upx;
  348. }
  349. .login-paddingtop {
  350. // padding-top: 100upx;
  351. padding: 100upx 32upx 0 32upx;
  352. }
  353. .zai-box {
  354. background: #FFFFFF;
  355. height: 100%;
  356. .zai-header {
  357. width: 100%;
  358. height: 432upx;
  359. background-image: url(../../static/login/beijing.png);
  360. background-size: cover;
  361. }
  362. // padding: 0 20upx;
  363. // padding-top: 100upx;
  364. // position: relative;
  365. }
  366. .zai-logo {
  367. width: 20px;
  368. height: 20px;
  369. }
  370. .box-user {
  371. border-bottom: 1px solid #EFEFEF;
  372. min-height: 45px;
  373. image {
  374. margin-right: 10px;
  375. }
  376. input {
  377. font-size: 14px;
  378. flex: 1;
  379. }
  380. }
  381. .zai-title {
  382. font-size: 58upx;
  383. color: #000000;
  384. text-align: center;
  385. }
  386. .input-placeholder,
  387. .zai-input {
  388. color: #94afce;
  389. }
  390. .zai-label {
  391. padding: 60upx 0;
  392. text-align: center;
  393. font-size: 30upx;
  394. color: #a7b6d0;
  395. }
  396. .zai-btn {
  397. background: #ff65a3;
  398. color: #fff;
  399. border: 0;
  400. border-radius: 100upx;
  401. font-size: 36upx;
  402. }
  403. .zai-btn:after {
  404. border: 0;
  405. }
  406. /*按钮点击效果*/
  407. .zai-btn.button-hover {
  408. transform: translate(1upx, 1upx);
  409. }
  410. .popup-contents-add {
  411. width: 600rpx;
  412. height: 350rpx;
  413. display: flex;
  414. align-items: center;
  415. flex-direction: column;
  416. >view {
  417. width: 100%;
  418. }
  419. >view.tit {
  420. height: 100rpx;
  421. display: flex;
  422. align-items: center;
  423. flex-direction: column;
  424. justify-content: space-around;
  425. padding: 0 20rpx;
  426. box-sizing: border-box;
  427. text {
  428. padding-top: 20rpx;
  429. box-sizing: border-box;
  430. font-size: 40rpx;
  431. font-weight: 600;
  432. }
  433. }
  434. .tit-center {
  435. flex: 1;
  436. display: flex;
  437. flex-direction: column;
  438. align-items: center;
  439. justify-content: center;
  440. text {
  441. padding: 10rpx;
  442. box-sizing: border-box;
  443. font-size: 28rpx;
  444. font-weight: 400;
  445. }
  446. }
  447. .tit-bottom {
  448. >view {
  449. display: flex;
  450. align-items: center;
  451. justify-content: space-between;
  452. gap: 16rpx;
  453. }
  454. }
  455. >view.tit-bottom {
  456. padding: 0;
  457. }
  458. }
  459. .btn {
  460. border-radius: 50rpx;
  461. width: 200rpx;
  462. background-color: #0081ff;
  463. color: #ffffff;
  464. padding: 10rpx 20rpx;
  465. text-align: center;
  466. box-sizing: border-box;
  467. }
  468. .cancel-btn {
  469. border-radius: 50rpx;
  470. width: 200rpx;
  471. padding: 10rpx 20rpx; // 上下左右内边距
  472. text-align: center; // 文字居中
  473. box-sizing: border-box; // 确保内边距不会增加按钮总尺寸
  474. }
  475. </style>