register.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. phone: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. this.$Router.replaceAll({name:'index'})
  162. // #endif
  163. }else{
  164. this.$tip.alert(res.data.message);
  165. }
  166. }).catch((err) => {
  167. let msg = err.data.message || "请求出现错误,请稍后再试"
  168. this.loading=false;
  169. this.$tip.alert(msg);
  170. }).finally(()=>{
  171. this.loading=false;
  172. })
  173. },
  174. saveClientId(){
  175. var info = plus.push.getClientInfo();
  176. var cid = info.clientid;
  177. this.$http.get("/sys/user/saveClientId",{params:{clientId:cid}}).then(res=>{
  178. console.log("res::saveClientId>",res)
  179. this.$tip.success('登录成功!')
  180. this.$Router.replaceAll({name:'index'})
  181. })
  182. },
  183. changePassword() {
  184. this.showPassword = !this.showPassword;
  185. },
  186. changePassword1() {
  187. this.showPassword1 = !this.showPassword1;
  188. },
  189. onSMSSend() {
  190. // let smsParams = {};
  191. // smsParams.phone=this.phoneNo;
  192. // smsParams.smsmode="0";
  193. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  194. if(!this.phoneNo || this.phoneNo.length==0){
  195. this.$tip.toast('请输入手机号');
  196. return false
  197. }
  198. if(!checkPhone.test(this.phoneNo)){
  199. this.$tip.toast('请输入正确的手机号');
  200. return false
  201. }
  202. this.$http.get("/merchant/app/sendMsg",{params:{phone:this.phoneNo}}).then(res=>{
  203. if(res.data.success){
  204. this.smsCountDown = 60;
  205. this.startSMSTimer();
  206. }else{
  207. this.smsCountDown = 0;
  208. this.$tip.toast(res.data.message);
  209. }
  210. });
  211. },
  212. startSMSTimer() {
  213. this.smsCountInterval = setInterval(() => {
  214. this.smsCountDown--;
  215. if (this.smsCountDown <= 0) {
  216. clearInterval(this.smsCountInterval);
  217. }
  218. }, 1000);
  219. },
  220. onSMSLogin() {
  221. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  222. if(!this.phoneNo || this.phoneNo.length==0){
  223. this.$tip.toast('请填写手机号');
  224. return;
  225. }
  226. if(!checkPhone.test(this.phoneNo)){
  227. this.$tip.toast('请输入正确的手机号');
  228. return false
  229. }
  230. if(!this.smsCode || this.smsCode.length==0){
  231. this.$tip.toast('请填短信验证码');
  232. return;
  233. }
  234. if(this.password !== this.password1){
  235. this.$tip.toast('请确定密码是否一致');
  236. return;
  237. }
  238. if(!this.checked || this.checked.length==0){
  239. this.$tip.toast('请阅读后勾选并同意《平台协议》及《隐私协议》政策');
  240. return;
  241. }
  242. this.$http.get("/merchant/app/checkCode",{params:{phone:this.phoneNo, code:this.smsCode}}).then(res=>{
  243. if(res.data.success){
  244. // this.nav('settled')
  245. uni.setStorageSync('phone', this.phoneNo)
  246. uni.setStorageSync('password', this.password)
  247. uni.navigateTo({
  248. url: '/pages/login/settled'
  249. });
  250. // this.$tip.success('登录成功!')
  251. // this.$Router.replaceAll({name:'index'})
  252. }else{
  253. this.$tip.error(res.data.message);
  254. }
  255. }).catch((err) => {
  256. let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  257. this.$tip.error(msg);
  258. });
  259. // this.PhoneLogin(loginParams).then((res) => {
  260. // console.log("res====》",res)
  261. // if(res.data.success){
  262. // // this.$tip.success('登录成功!')
  263. // // this.$Router.replaceAll({name:'index'})
  264. // }else{
  265. // this.$tip.error(res.data.message);
  266. // }
  267. // }).catch((err) => {
  268. // let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  269. // this.$tip.error(msg);
  270. // });
  271. },
  272. loginSuccess() {
  273. // 登陆成功,重定向到主页
  274. this.$Router.replace({name:'index'})
  275. },
  276. requestFailed(err) {
  277. this.$message.warning("登录失败")
  278. },
  279. },
  280. beforeDestroy() {
  281. if (this.smsCountInterval) {
  282. clearInterval(this.smsCountInterval);
  283. }
  284. },
  285. }
  286. </script>
  287. <style scoped lang="scss">
  288. page{
  289. background: #FFFFFF;
  290. height: 100%;
  291. }
  292. .uni-data-checklist{
  293. flex:none;
  294. /deep/.checklist-group .checklist-box{
  295. margin-right: 0 !important;
  296. }
  297. }
  298. .footer{
  299. position: fixed;
  300. bottom: 54upx;
  301. font-size: 12px;
  302. color: #999999;
  303. left: 50%;
  304. transform: translateX(-50%);
  305. }
  306. .text-color {
  307. color: #449AFF ;
  308. margin: 0 5px;
  309. }
  310. .login-paddingtop {
  311. // padding-top: 100upx;
  312. padding: 100upx 32upx 0 32upx;
  313. }
  314. .zai-box {
  315. background: #FFFFFF;
  316. height: 100%;
  317. .zai-header{
  318. width: 100%;
  319. height: 432upx;
  320. background-image: url(../../static/login/bejing.png);
  321. background-size: cover;
  322. }
  323. // padding: 0 20upx;
  324. // padding-top: 100upx;
  325. // position: relative;
  326. }
  327. .zai-logo {
  328. width: 20px;
  329. height: 20px;
  330. }
  331. .box-user{
  332. min-height: 45px;
  333. border-bottom: 1px solid #EFEFEF;
  334. image{
  335. margin-right: 10px;
  336. }
  337. input{
  338. font-size: 14px;
  339. flex: 1;
  340. }
  341. }
  342. .zai-title {
  343. font-size: 58upx;
  344. color: #000000;
  345. text-align: center;
  346. }
  347. .input-placeholder, .zai-input {
  348. color: #94afce;
  349. }
  350. .zai-label {
  351. padding: 60upx 0;
  352. text-align: center;
  353. font-size: 30upx;
  354. color: #a7b6d0;
  355. }
  356. .zai-btn {
  357. background: #ff65a3;
  358. color: #fff;
  359. border: 0;
  360. border-radius: 100upx;
  361. font-size: 36upx;
  362. }
  363. .zai-btn:after {
  364. border: 0;
  365. }
  366. /*按钮点击效果*/
  367. .zai-btn.button-hover {
  368. transform: translate(1upx, 1upx);
  369. }
  370. </style>