register.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="page">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <view class="dis j-end a-c">
  6. <image src="../../static/image/login/3.png" mode=""
  7. style="height:260px;width: calc(100% - 16px);margin-top: 120px;">
  8. </image>
  9. </view>
  10. <view class="input-data1">
  11. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change"
  12. style="background: transparent;margin-bottom: 10px;"></u-tabs>
  13. <view class="input-data">
  14. <view class="phone d-flex">
  15. <image src="../../static/image/login/shoujihao.png" mode="" style="width: 18px;height: 18px;">
  16. </image>
  17. <input placeholder="请输入手机号" v-model="phone" maxlength="11" />
  18. </view>
  19. <view class="phone d-flex">
  20. <image src="../../static/image/login/name.png" mode="" style="width: 18px;height: 18px;">
  21. </image>
  22. <input placeholder="请输入真实姓名" v-model="name" />
  23. </view>
  24. <view class="password d-flex">
  25. <image src="../../static/image/login/mima.png" mode="" style="width: 18px;height: 18px;">
  26. </image>
  27. <input placeholder="请输入密码" v-model="password" :password='isHidePassword' maxlength="15"
  28. style="padding-right: 200rpx;" />
  29. <view class=" position-absolute top-0 right-0 d-flex a-center j-center"
  30. style="width: 200rpx;height: 100%;">
  31. <image
  32. :src="isHidePassword?'../../static/image/login/biyan.png':'../../static/image/login/zhengyan.png'"
  33. @tap="isHidePassword = !isHidePassword" mode="" style="width: 18px;height: 18px;">
  34. </view>
  35. </view>
  36. <view class="code d-flex">
  37. <image src="../../static/image/login/yanzhengma.png" mode="" style="width: 18px;height: 18px;">
  38. </image>
  39. <input placeholder="请输入验证码" v-model="code" maxlength="4" style="padding-right: 200rpx;" />
  40. <view class="d-flex a-center j-center login-font-color yanzhengma" @tap="getCheckNum">
  41. <view class="d-flex a-center j-center"
  42. :class="!codetime?'yanzhengma1 text-color':'yanzhengma2'">
  43. {{!codetime?'获取验证码':codetime+' s'}}
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="mx-3 mt-3" v-if="showRecommend">
  49. <view class=" mas-title dis j-start a-c">
  50. <image src="../../static/image/login/1.png" mode=""
  51. style="width: 18px;height: 18px;margin-right: 10px;">
  52. </image>
  53. <text>请确认推荐人信息,注册后,推荐人将不可修改</text>
  54. </view>
  55. <view class="recommendInfo">
  56. <view class="dis a-c j-start">
  57. <image src="/static/bigLogo.png" style="width: 21px;height: 20px;"></image>
  58. <text style="color: rgba(35,40,50,0.8);">推荐人姓名:</text>
  59. <text style="color: #232832;">{{recommendername}}</text>
  60. </view>
  61. <view class="dis a-c">
  62. <text style="color: rgba(35,40,50,0.8);">推荐人会员号:</text>
  63. <text style="color: #232832;">{{recommenderid}}</text>
  64. </view>
  65. </view>
  66. <button class="my-3 mt-4 d-flex a-center j-center font-weight bg-color" :loading="loading"
  67. :class="{'bg-hover-color':disabled}" type="primary" @tap="submit" :disabled="disabled"
  68. style="letter-spacing: 20rpx;">注册</button>
  69. <!-- <view class="d-flex a-center j-center my-3">
  70. 已有帐号?<view class="text-color" @tap="navigate({url:'/pages/login/login'},'reLaunch')">去登录</view>
  71. </view> -->
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. pathToBase64,
  79. base64ToPath
  80. } from '@/common/image-tools-base64.js';
  81. import {
  82. mapMutations
  83. } from "vuex"
  84. export default {
  85. data() {
  86. return {
  87. list: [{
  88. name: '出单员注册'
  89. }],
  90. current: 0,
  91. name: "",
  92. phone: "",
  93. password: "",
  94. code: "",
  95. isHidePassword: true,
  96. disabled: true,
  97. loading: false,
  98. codetime: 0,
  99. showRecommend: false,
  100. recommendername: "",
  101. recommenderid: ""
  102. }
  103. },
  104. async onLoad(params) {
  105. // // #ifdef H5
  106. // document.getElementsByTagName('uni-page-head')[0].style.display = 'none'
  107. // // #endif
  108. if (params.id) {
  109. this.recommenderid = params.id;
  110. // 查询推荐人信息
  111. let res = await this.$http.get('/user/findById?id=' + params.id);
  112. if ((res.code == '200') && (res.data != null)) {
  113. this.recommendername = res.data.name;
  114. this.showRecommend = true;
  115. } else {
  116. uni.showToast({
  117. title: res.msg,
  118. icon: "success",
  119. duration: 2000
  120. });
  121. this.showRecommend = false;
  122. // if(this.$base.baseUrl.indexOf("test")>-1){
  123. // this.recommenderid="99140109M01D01001";
  124. // this.recommendername = "耿陈杰";
  125. // this.showRecommend = false;
  126. // }else{
  127. // this.recommenderid="99140109M03D01001";
  128. // this.recommendername = "掌柜老王";
  129. // this.showRecommend = false;
  130. // }
  131. }
  132. }
  133. // else{
  134. // if(this.$base.baseUrl.indexOf("test")>-1){
  135. // this.recommenderid="99140109M01D01001";
  136. // this.recommendername = "耿陈杰";
  137. // this.showRecommend = false;
  138. // }else{
  139. // this.recommenderid="99140109M03D01001";
  140. // this.recommendername = "掌柜老王";
  141. // this.showRecommend = false;
  142. // }
  143. // }
  144. },
  145. watch: {
  146. name() {
  147. this.OnBtnChange();
  148. },
  149. phone(val) {
  150. this.OnBtnChange();
  151. },
  152. password(val) {
  153. this.OnBtnChange();
  154. },
  155. code(val) {
  156. this.OnBtnChange();
  157. }
  158. },
  159. methods: {
  160. ...mapMutations(['setUserModules']),
  161. change(index) {
  162. this.current = index;
  163. },
  164. // 改变按钮状态
  165. OnBtnChange() {
  166. if (this.phone && this.password && this.code && this.name) {
  167. this.disabled = false;
  168. return;
  169. }
  170. this.disabled = true;
  171. },
  172. isPwdRules() {
  173. let mPattern = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
  174. return mPattern.test(this.password);
  175. },
  176. // 获取验证码
  177. async getCheckNum() {
  178. uni.hideKeyboard();
  179. if (this.codetime > 0) return;
  180. // 验证手机号合法性
  181. if (!this.phone) {
  182. return uni.showToast({
  183. title: '请输入手机号',
  184. icon: 'none'
  185. });
  186. }
  187. if (!this.$base.phoneRegular.test(this.phone)) {
  188. return uni.showToast({
  189. title: '请输入正确的手机号码',
  190. icon: 'none'
  191. });
  192. }
  193. // 请求服务器,发送验证码
  194. let res = await this.$http.get('/sendMsg', {
  195. phone: this.phone,
  196. type: "1"
  197. });
  198. // 请求失败处理
  199. if (res.code != 200) {
  200. return uni.showToast({
  201. title: res.data.msg,
  202. icon: "none"
  203. });
  204. } else {
  205. uni.showToast({
  206. title: "发送成功",
  207. icon: "none"
  208. });
  209. }
  210. // 发送成功,开启倒计时
  211. this.codetime = 60;
  212. let timer = setInterval(() => {
  213. this.codetime--;
  214. if (this.codetime < 1) {
  215. clearInterval(timer);
  216. this.codetime = 0;
  217. }
  218. }, 1000);
  219. },
  220. // 提交注册
  221. async submit() {
  222. if (!this.name) {
  223. return uni.showToast({
  224. title: '请输入姓名',
  225. icon: 'none'
  226. });
  227. }
  228. // 验证手机号合法性
  229. if (!this.$base.phoneRegular.test(this.phone)) {
  230. return uni.showToast({
  231. title: '请输入正确的手机号码',
  232. icon: 'none'
  233. });
  234. }
  235. // 验证密码合法性
  236. if (!this.$base.passwordRegular.test(this.password)) {
  237. return uni.showToast({
  238. title: '密码须6-15位数字与字母组合',
  239. icon: 'none'
  240. });
  241. }
  242. // 请求服务器,发送验证码
  243. let res = await this.$http.post('/user/agentRegist', {
  244. "name": this.name,
  245. "password": this.password,
  246. "mobile": this.phone,
  247. "mobileMsg": this.code,
  248. "referrerId": this.recommenderid,
  249. "referrerName": this.recommendername,
  250. "flag": 1,
  251. });
  252. // 请求失败处理
  253. // var newPhone= "";
  254. // newPhone = this.phone;
  255. // this.password="";
  256. // this.phone="";
  257. // this.code="";
  258. // this.name="";
  259. if ((res.code == 200) && (!!res.data)) {
  260. // #ifndef H5
  261. this.setUserModules({
  262. title: "userLoginId",
  263. data: res.data
  264. })
  265. uni.showToast({
  266. title: '注册成功',
  267. icon: "success",
  268. duration: 2000
  269. });
  270. setTimeout(() => {
  271. return uni.reLaunch({
  272. url: "/pages/login/login"
  273. })
  274. }, 2000);
  275. // #endif
  276. // #ifdef H5
  277. setTimeout(() => {
  278. return uni.reLaunch({
  279. url: "/pages/register/registerSuccess?id=" + res.data + '&phone=' + this
  280. .phone
  281. })
  282. }, 2000);
  283. // #endif
  284. } else {
  285. uni.showToast({
  286. title: res.msg,
  287. icon: "none",
  288. duration: 2000
  289. });
  290. }
  291. // else{
  292. // uni.showToast({ title: '已注册,重复注册', icon:"success",duration:2000 });
  293. // }
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. @import '@/style/mixin.scss';
  300. /deep/ {
  301. .u-tab-bar {
  302. background: linear-gradient(90deg, #0052FF 0%, rgba(0, 82, 255, 0) 100%) !important;
  303. border-radius: 4px 4px 4px 4px;
  304. }
  305. }
  306. .text-color {
  307. color: #0052FF;
  308. }
  309. .bg-color {
  310. background-color: #0052FF;
  311. border-radius: 20px;
  312. }
  313. .bg-hover-color {
  314. background-color: #0052FF;
  315. opacity: 0.65;
  316. border-radius: 20px;
  317. }
  318. .mas-title {
  319. width: 100%;
  320. height: 34px;
  321. background: rgba(0, 82, 255, 0.1);
  322. border-radius: 6px;
  323. padding: 6px;
  324. margin-bottom: 15px;
  325. }
  326. .input-data1 {
  327. position: relative;
  328. margin-top: -140px;
  329. }
  330. .input-data {
  331. width: calc(100% - 32px);
  332. height: auto;
  333. background: #FFFFFF;
  334. box-shadow: 0px 4px 10px 0px #DAE3F4;
  335. border-radius: 6px;
  336. margin: auto;
  337. padding: 0 10px;
  338. z-index: 999;
  339. }
  340. .idCardBefore {
  341. background: rgba($themeColor, 0.1) url('/static/image/user/identy2.png') center center no-repeat;
  342. background-size: auto 70%;
  343. padding: 10upx;
  344. }
  345. .page {
  346. background: #F8FAFE;
  347. height: 100vh;
  348. width: 100%;
  349. position: absolute;
  350. }
  351. .phone,
  352. .password,
  353. .code {
  354. position: relative;
  355. height: 95rpx;
  356. display: flex;
  357. align-items: center;
  358. border-bottom: 1px solid #f2f2f2;
  359. }
  360. .phone .title,
  361. .password .title,
  362. .code .title {
  363. width: 160upx;
  364. flex-shrink: 0;
  365. color: #666;
  366. }
  367. .phone input,
  368. .password input,
  369. .code input {
  370. width: 350upx;
  371. font-size: 28upx;
  372. margin-left: 13px;
  373. }
  374. .yanzhengma {
  375. width: 150upx;
  376. position: absolute;
  377. right: 30upx;
  378. }
  379. .yanzhengma1 {
  380. font-size: 26upx;
  381. background: #FFFFFF;
  382. border-radius: 10rpx;
  383. width: 150rpx;
  384. padding: 5rpx 0;
  385. }
  386. .yanzhengma2 {
  387. background: #FFFFFF;
  388. font-size: 26upx;
  389. color: #B2B2B2;
  390. border-radius: 10rpx;
  391. width: 150rpx;
  392. padding: 5rpx 0;
  393. }
  394. .recommendInfo {
  395. background: #FFFFFF;
  396. width: 100%;
  397. height: 72;
  398. background: #FFFFFF;
  399. border-radius: 6px;
  400. border: 1px solid #0052FF;
  401. padding: 0 10px;
  402. >view {
  403. padding: 6px;
  404. font-size: 13px;
  405. }
  406. >view:nth-child(1) {
  407. border-bottom: 1px solid #f2f2f2;
  408. }
  409. }
  410. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(1) {
  411. width: 150upx;
  412. height: 150upx;
  413. border-radius: 50%;
  414. }
  415. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(1)>image {
  416. width: 100%;
  417. height: 100%;
  418. }
  419. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(2) {
  420. padding: 20upx;
  421. }
  422. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(2)>view {
  423. height: 55upx;
  424. }
  425. .recommendInfo>view:nth-of-type(2) {
  426. line-height: 50upx;
  427. }
  428. </style>