register.vue 12 KB

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