register.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="register">
  3. <div class="header">
  4. <navbar ref="navbar" backColor="#fff" :config="config"></navbar>
  5. <view class="register-title">邀请注册</view>
  6. <view class="register-code">邀请人:{{code}}</view>
  7. </div>
  8. <div class="body">
  9. <form @submit="formSubmit">
  10. <view class="item">
  11. <!-- <view class="top">
  12. 手机号注册
  13. </view> -->
  14. <view class="phone">
  15. <view class="name">
  16. 手机号
  17. </view>
  18. <input type="number" name="phone" @input="onPhone" placeholder="请输入手机号" maxlength="11"
  19. placeholder-style="color:#cccccc;" />
  20. </view>
  21. <view class="verification">
  22. <view class="name">
  23. 验证码
  24. </view>
  25. <input type="number" class="adjustment" value="" name="code" maxlength="6" placeholder="请输入验证码"
  26. placeholder-style="color:#cccccc;width:200rpx;" />
  27. <button class="obtain" :disabled="disabled" :class="isPhone?'active':''" @click="obtainCode">
  28. {{verification}}
  29. <!-- {{time}} -->
  30. </button>
  31. </view>
  32. <!-- <view class="invitation">
  33. <view class="name">
  34. 邀请码
  35. </view>
  36. <input type="text" :value="code" name="invitation" placeholder="请输入邀请码" maxlength="8"
  37. @input="invitationCode" placeholder-style="color:#cccccc;" />
  38. </view> -->
  39. <view class="password">
  40. <view class="name">
  41. 登录密码
  42. </view>
  43. <input type="password" name="password" value="" @input="onPass" placeholder="请输入登录密码" maxlength="11"
  44. placeholder-style="color:#cccccc;" />
  45. </view>
  46. </view>
  47. <!-- 协议问题 -->
  48. <view class="choice">
  49. <view class="whole">
  50. <view class="top" v-if="flag" @click="onFlag">
  51. <icon type="success" color="#FF0000" size="17"></icon>
  52. </view>
  53. <view v-else style="width: 34rpx;height: 34rpx;border-radius: 50%;border: #ccc solid 1rpx;" @click="onFlag">
  54. </view>
  55. </view>
  56. <view class="agree">
  57. 已阅读并同意<text @click="goToAgreement">《用户隐私协议》</text>
  58. </view>
  59. </view>
  60. <!-- 按钮 -->
  61. <view class="button">
  62. <button class="agree-register" form-type="submit">
  63. 确认提交
  64. </button>
  65. <view class="go-to-login" @click="goToLogin()">
  66. 去登录
  67. </view>
  68. <view class="go-to-login" @click="goToDownload()">
  69. 已注册,去下载
  70. </view>
  71. </view>
  72. </form>
  73. </div>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. // 头部导航
  81. config: {
  82. back: false, //false是tolbar页面 是则不写
  83. title: '',
  84. color: '#fff',
  85. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  86. backgroundColor: [1, "transparent"],
  87. statusBarFontColor: '#1A1A1A',
  88. },
  89. phone: "", //手机号
  90. disabled: false, //按钮
  91. isPhone: false, //手机号正则
  92. password: "",
  93. invitation: "",
  94. time: 60, //倒计时
  95. verification: "获取验证码",
  96. active: null,
  97. flag: false,
  98. code: null,
  99. }
  100. },
  101. onLoad(options) {
  102. console.log(options)
  103. this.code = options.code
  104. },
  105. methods: {
  106. //跳转协议{
  107. goToAgreement() {
  108. uni.navigateTo({
  109. url: "./agreement"
  110. })
  111. },
  112. //跳转下载
  113. goToDownload() {
  114. uni.navigateTo({
  115. url: "./down"
  116. })
  117. },
  118. //跳转到登录页
  119. goToLogin() {
  120. // window.location.href = "lida://&pageType=4";
  121. window.location.href = "lmzc://&pageType=4";
  122. // window.location.href = "hbuilder://&pageType=4";
  123. setTimeout(() => {
  124. uni.showModal({
  125. title: "该应用尚未下载,是否下载?",
  126. success(res) {
  127. if (res.confirm) {
  128. uni.navigateTo({
  129. url: "./down"
  130. })
  131. }
  132. }
  133. })
  134. }, 500)
  135. },
  136. //倒计时
  137. countDown() {
  138. var that = this
  139. if (that.time <= 0) {
  140. that.disabled = false;
  141. that.verification = "重新获取";
  142. that.isPhone = true;
  143. that.time = 60
  144. clearInterval(that.clear);
  145. } else {
  146. --that.time;
  147. that.verification = this.time + "s";
  148. }
  149. },
  150. //获取验证码
  151. async obtainCode() {
  152. if (this.isPhone) {
  153. this.$http.get("/account/verify-mobile/" + this.phone, ).then(res => {
  154. if (res && res.code == 200) {
  155. if (res.data == true) {
  156. this.$mUtil.toast("该手机号已被注册")
  157. } else if (res.data == false) {
  158. let res = this.$http.post('/common/account/getVerfityCode', this.phone).then(
  159. res => {
  160. if (res && res.code == 200) {
  161. this.disabled = false;
  162. this.isPhone = false;
  163. this.verification = this.time + 's';
  164. this.clear = setInterval(this.countDown, 1000);
  165. this.$mUtil.toast("发送成功")
  166. } else {
  167. this.$mUtil.toast(res.msg)
  168. }
  169. })
  170. }
  171. }
  172. })
  173. }
  174. },
  175. beforeDestroy() {
  176. clearInterval(this.clear)
  177. },
  178. //邀请码
  179. invitationCode(e) {
  180. let invitationCode = e.detail.value
  181. this.invitation = invitationCode
  182. console.log(this.invitation)
  183. },
  184. // 手机号
  185. onPhone(e) {
  186. let onPhone = e.detail.value
  187. this.phone = onPhone
  188. if (onPhone.match(this.$mConfig.telRegex)) {
  189. if (this.verification == '获取验证码' || this.verification == '重新获取') {
  190. this.isPhone = true
  191. }
  192. } else {
  193. this.isPhone = false
  194. }
  195. },
  196. onPass(e) {
  197. let onPass = e.detail.value
  198. this.password = onPass
  199. },
  200. //同意并注册
  201. formSubmit(e) {
  202. let target = e.detail.value;
  203. if (!target.phone) {
  204. this.$mUtil.toast('请输入手机号')
  205. return false
  206. }
  207. if (!(target.phone.match(this.$mConfig.telRegex))) {
  208. this.$mUtil.toast('请输入正确手机号')
  209. return false
  210. }
  211. if (!target.code) {
  212. this.$mUtil.toast("请输入验证码")
  213. return false
  214. }
  215. // if (!target.invitation) {
  216. // this.$mUtil.toast("请输入邀请码")
  217. // return false
  218. // }
  219. if (!target.password) {
  220. this.$mUtil.toast("请输入登录密码")
  221. return false
  222. }
  223. if (!this.flag) {
  224. this.$mUtil.toast('请先同意协议')
  225. return false
  226. }
  227. let param = {
  228. mobile: target.phone,
  229. captcha: target.code,
  230. // invitation_code: target.invitation,
  231. invitation_code: this.code,
  232. password: target.password,
  233. }
  234. this.$http.post("/account/app/register", param)
  235. .then(res => {
  236. console.log(res)
  237. if (res && res.code == 200) {
  238. this.$mUtil.toast("注册成功")
  239. setTimeout(() => {
  240. uni.navigateTo({
  241. url: '/pages/down'
  242. })
  243. }, 1000)
  244. }
  245. })
  246. },
  247. // 协议
  248. onFlag() {
  249. this.flag = !this.flag
  250. },
  251. radioChange(index) {
  252. if (this.active == index) {
  253. this.active == null;
  254. } else {
  255. this.active = index
  256. }
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .button {
  263. margin: 70rpx 50rpx;
  264. .agree-register {
  265. color: #FFFFFF;
  266. font-weight: Regular;
  267. font-size: 32rpx;
  268. // padding: 22rpx 0rpx;
  269. width: 100%;
  270. text-align: center;
  271. background-color: #3D93FC;
  272. border-radius: 45rpx;
  273. }
  274. .go-to-login {
  275. color: #3D93FC;
  276. font-weight: Regular;
  277. font-size: 32rpx;
  278. padding: 17rpx 0;
  279. width: 100%;
  280. text-align: center;
  281. margin-top: 24rpx;
  282. border: 1rpx solid #3775F6;
  283. border-radius: 45rpx;
  284. background: #e7eefc;
  285. }
  286. }
  287. .agree {
  288. font-size: 28rpx;
  289. color: #999999;
  290. font-weight: Regular;
  291. margin-left: 10rpx;
  292. text {
  293. color: #0047B1;
  294. }
  295. }
  296. .choice {
  297. margin: 0 50rpx;
  298. display: flex;
  299. justify-content: center;
  300. .whole {
  301. display: flex;
  302. .top {
  303. display: flex;
  304. }
  305. }
  306. }
  307. .password {
  308. display: flex;
  309. align-items: center;
  310. padding: 40rpx 0 40rpx 0;
  311. border-bottom: 1rpx solid #E6E6E6;
  312. .name {
  313. font-size: 28rpx;
  314. font-weight: 500;
  315. color: #333333;
  316. margin-right: 40rpx;
  317. flex-shrink: 0;
  318. }
  319. }
  320. .invitation {
  321. display: flex;
  322. align-items: center;
  323. padding: 40rpx 0 40rpx 0;
  324. border-bottom: 1rpx solid #E6E6E6;
  325. .name {
  326. font-size: 28rpx;
  327. font-weight: Medium;
  328. color: #333333;
  329. margin-right: 40rpx;
  330. flex-shrink: 0;
  331. }
  332. }
  333. .verification {
  334. display: flex;
  335. flex-wrap: nowrap;
  336. padding: 40rpx 0 34rpx 0;
  337. align-items: center;
  338. border-bottom: 1rpx solid #E6E6E6;
  339. .name {
  340. font-size: 28rpx;
  341. color: #333333;
  342. line-height: 28rpx;
  343. font-weight: 500;
  344. margin-right: 40rpx;
  345. }
  346. .adjustment {
  347. flex: 1;
  348. }
  349. .obtain {
  350. // padding: 14rpx 30rpx;
  351. padding: 0 30rpx;
  352. color: #999;
  353. font-size: 28rpx;
  354. font-weight: Regular;
  355. border: 1rpx solid #B3B3B3;
  356. border-radius: 36rpx;
  357. }
  358. .active {
  359. background-color: #e7eefc;
  360. color: #3775F6;
  361. border: 1rpx solid #3775F6;
  362. }
  363. }
  364. .register {
  365. .header {
  366. position: relative;
  367. height: 506rpx;
  368. background: url('@/static/login/register-heder-bg.png');
  369. background-size: cover;
  370. text-align: center;
  371. color: #fff;
  372. /deep/ .hx-navbar__icon {
  373. color: #fff !important;
  374. }
  375. .register-title {
  376. margin-top: 67rpx;
  377. font-size: 48rpx;
  378. font-weight: normal;
  379. }
  380. .register-code {
  381. margin-top: 17rpx;
  382. font-size: 32rpx;
  383. font-weight: normal;
  384. }
  385. }
  386. .body {
  387. // position: absolute;
  388. background-color: #fff;
  389. // z-index: 9;
  390. // top: 406rpx;
  391. // background: url('@/static/login/register-bg.png');
  392. background-size: cover;
  393. }
  394. .item {
  395. margin: 118rpx 50rpx 40rpx 50rpx;
  396. .top {
  397. font-size: 38rpx;
  398. font-weight: Bold;
  399. color: #333333;
  400. line-height: 28rpx;
  401. }
  402. .phone {
  403. display: flex;
  404. align-items: center;
  405. padding: 40rpx 0 34rpx 0;
  406. border-bottom: 1rpx solid #E6E6E6;
  407. .name {
  408. margin-right: 40rpx;
  409. flex-shrink: 0;
  410. }
  411. }
  412. }
  413. }
  414. </style>