register.vue 11 KB

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