register.vue 13 KB

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