register.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/img01.png" mode="scaleToFill"></image>
  5. </view>
  6. <view class="loginTitle"><text>注册</text></view>
  7. <view class="login_text">
  8. <view class="login_input flex">
  9. <view class="login_img">
  10. <image src="/static/icon/img03.png"></image>
  11. </view>
  12. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  13. </view>
  14. <view class="login_input flex">
  15. <view class="login_img">
  16. <image src="/static/icon/img04.png"></image>
  17. </view>
  18. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus
  19. placeholder="请输入密码" /></view>
  20. </view>
  21. <view class="login_input flex">
  22. <view class="login_img">
  23. <image src="/static/icon/img04.png"></image>
  24. </view>
  25. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus
  26. placeholder="请重复输入密码" /></view>
  27. </view>
  28. <view class="login_input flex">
  29. <view class="login_img">
  30. <image src="/static/icon/img04.png"></image>
  31. </view>
  32. <view class="login_name"><input class="uni-input" type="password" v-model="payment_pas" focus
  33. placeholder="请输入支付密码" /></view>
  34. </view>
  35. <view class="login_input flex">
  36. <view class="login_img">
  37. <image src="/static/icon/img07.png"></image>
  38. </view>
  39. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus
  40. placeholder="请输入邀请码" /></view>
  41. </view>
  42. <view class="login_input flex">
  43. <view class="login_img">
  44. <image src="/static/icon/img06.png"></image>
  45. </view>
  46. <view class="login_name flex">
  47. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  48. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  49. </view>
  50. </view>
  51. <label class="two" @click="checkboxChange">
  52. <radio style="transform:scale(0.7)" color="#5dbc7c" :checked="istype" />
  53. 我已阅读并同意
  54. <text @click.stop="navTo('/pages/contract/agreement')">《用户协议》</text>
  55. &nbsp
  56. <text @click.stop="navTo('/pages/contract/privacy')">《隐私政策》</text>
  57. </label>
  58. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  59. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true"
  60. hover-class="none" @click="login">返回登录</button></view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. register,
  67. verify
  68. } from '@/api/login.js';
  69. export default {
  70. data() {
  71. return {
  72. istype: false,
  73. phone: '', //用户
  74. password: '', //密码
  75. repassword: '',
  76. invitation: '', //邀请码
  77. code: '', //验证码
  78. time: '', //保存倒计时对象
  79. countDown: 0, //倒计时
  80. payment_pas: '' //交易密码
  81. };
  82. },
  83. onLoad() {
  84. // 获取扫码邀请人id
  85. this.invitation = uni.getStorageSync('spread') || '';
  86. },
  87. watch: {
  88. // 监听倒计时
  89. countDown(i) {
  90. if (i == 0) {
  91. clearInterval(this.time);
  92. }
  93. }
  94. },
  95. methods: {
  96. checkboxChange() {
  97. this.istype = !this.istype;
  98. console.log(this.istype);
  99. },
  100. // 注册
  101. register() {
  102. let obj = this;
  103. if (obj.phone == '') {
  104. obj.$api.msg('请输入电话号码');
  105. return;
  106. }
  107. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.phone)) {
  108. obj.$api.msg('请输入正确的手机号');
  109. return;
  110. }
  111. if (obj.password == '') {
  112. obj.$api.msg('请输入密码');
  113. return;
  114. }
  115. if (obj.repassword == '') {
  116. obj.$api.msg('请再次输入密码');
  117. return;
  118. }
  119. if (obj.repassword != obj.password) {
  120. obj.$api.msg('两次密码不正确');
  121. return;
  122. }
  123. if (obj.payment_pas == '') {
  124. obj.$api.msg('请输入支付密码');
  125. return;
  126. }
  127. if (obj.invitation == '') {
  128. obj.$api.msg('请输入邀请码');
  129. return;
  130. }
  131. if (!obj.istype) {
  132. obj.$api.msg('请查看并同意用户协议和隐私政策');
  133. return;
  134. }
  135. // if (obj.code == '') {
  136. // obj.$api.msg('请输入验证码');
  137. // return;
  138. // }
  139. register({
  140. account: obj.phone, //账号
  141. captcha: obj.code, //验证码
  142. password: obj.password, //密码
  143. spread: obj.invitation, //上级推广人
  144. payment_pas: obj.payment_pas
  145. // pas: obj.payment_pas
  146. }).then(function(e) {
  147. uni.showToast({
  148. title: '注册成功',
  149. duration: 2000,
  150. position: 'top'
  151. });
  152. setTimeout(function() {
  153. uni.navigateTo({
  154. url: '/pages/public/login'
  155. });
  156. }, 1000)
  157. });
  158. //调用注册接口,成功跳转登录页
  159. },
  160. //发送验证码
  161. verification() {
  162. let obj = this;
  163. if (this.phone == '') {
  164. this.$api.msg('请输入电话号码');
  165. return;
  166. }
  167. if (this.phone.length < 11) {
  168. this.$api.msg('请输入正确的手机号');
  169. return;
  170. }
  171. // 判断是否在倒计时
  172. if (obj.countDown > 0) {
  173. return false;
  174. } else {
  175. obj.countDown = 60;
  176. obj.time = setInterval(() => {
  177. obj.countDown--;
  178. }, 1000);
  179. //调用验证码接口
  180. verify({
  181. phone: obj.phone,
  182. type: 'register'
  183. })
  184. .then(({
  185. data
  186. }) => {})
  187. .catch(err => {
  188. console.log(err);
  189. });
  190. }
  191. },
  192. login() {
  193. //返回登录
  194. uni.navigateTo({
  195. url: '/pages/public/login'
  196. });
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss">
  202. page {
  203. height: 100%;
  204. }
  205. .container {
  206. width: 100%;
  207. height: 100%;
  208. background-size: 100%;
  209. }
  210. .container_text {
  211. width: 100%;
  212. height: 500rpx;
  213. top: 0rpx;
  214. .banner-img {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. }
  219. .login_text {
  220. margin: auto 30rpx;
  221. position: relative;
  222. padding: 100rpx 102rpx;
  223. background-color: #ffffff;
  224. margin-top: -180rpx;
  225. border-radius: 20rpx;
  226. .login_input {
  227. border-bottom: 1px solid #f0f0f0;
  228. margin-bottom: 65rpx;
  229. .login_img image {
  230. height: 35rpx;
  231. width: 29rpx;
  232. margin-right: 20rpx;
  233. }
  234. .uni-input {
  235. text-align: left;
  236. width: 470rpx;
  237. font-size: 28rpx !important;
  238. }
  239. .login_name {
  240. color: #333333;
  241. }
  242. }
  243. .other {
  244. margin-top: 60rpx;
  245. .fenge {
  246. width: 30%;
  247. height: 2rpx;
  248. background-color: #eeeeee;
  249. }
  250. .qita {
  251. font-size: 28rpx;
  252. color: #999999;
  253. }
  254. }
  255. .weixin {
  256. width: 75rpx;
  257. height: 75rpx;
  258. margin: 25rpx auto;
  259. }
  260. .weixin image {
  261. width: 100%;
  262. height: 100%;
  263. }
  264. .weixin_text {
  265. text-align: center;
  266. font-size: 28rpx;
  267. color: #999999;
  268. }
  269. .forget {
  270. font-size: 28rpx;
  271. width: 100%;
  272. text-align: right;
  273. color: #999999;
  274. }
  275. .uni-button-green {
  276. color: #ffffff;
  277. background-color: #5dbc7c;
  278. margin: 40rpx 10rpx;
  279. border-radius: 50rpx;
  280. }
  281. .uni-button-green-plain {
  282. border: 1px solid #5dbc7c;
  283. margin: 40rpx 10rpx;
  284. border-radius: 50rpx;
  285. color: #5dbc7c;
  286. background-color: #ffffff;
  287. }
  288. .uni-button {
  289. height: 85rpx;
  290. line-height: 85rpx;
  291. }
  292. }
  293. .loginTitle {
  294. position: absolute;
  295. top: 250rpx;
  296. width: 100%;
  297. text-align: center;
  298. color: white;
  299. font-size: 40rpx;
  300. }
  301. .forget {
  302. width: 100rpx;
  303. font-size: 24rpx;
  304. color: #ffffff;
  305. margin: 0px auto;
  306. border-bottom: 1px solid #ffffff;
  307. }
  308. .width {
  309. width: 325rpx !important;
  310. }
  311. .code {
  312. color: #5dbc7c;
  313. font-size: 23rpx;
  314. border-left: 1px solid #eeeeee;
  315. width: 150rpx;
  316. flex-shrink: 0;
  317. text-align: center;
  318. }
  319. uni-button {
  320. height: 80rpx !important;
  321. line-height: 80rpx !important;
  322. }
  323. .two {
  324. margin: 20rpx 0;
  325. font-size: 28rpx;
  326. text-align: center;
  327. font-family: PingFang SC;
  328. font-weight: 500;
  329. color: #999999;
  330. text {
  331. color: #5dbc7c;
  332. }
  333. }
  334. </style>