register.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/shouye1.png" mode="scaleToFill"></image>
  5. </view>
  6. <view class="loginTitle"><text>{{$t('login.a0')}}</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" @input="checkAccount" v-model="account" focus
  13. :placeholder="$t('login.a1')" /></view>
  14. </view>
  15. <view class="login_input flex">
  16. <view class="login_img">
  17. <image src="/static/icon/img04.png"></image>
  18. </view>
  19. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus
  20. :placeholder="$t('login.a3')" /></view>
  21. </view>
  22. <view class="login_input flex">
  23. <view class="login_img">
  24. <image src="/static/icon/img04.png"></image>
  25. </view>
  26. <view class="login_name"><input class="uni-input" type="password" v-model="trade_password" focus
  27. :placeholder="$t('login.b3')" /></view>
  28. </view>
  29. <view class="login_input flex">
  30. <view class="login_img">
  31. <image src="/static/icon/img07.png"></image>
  32. </view>
  33. <view class="login_name"><input class="uni-input" type="text" v-model="spread" focus
  34. :placeholder="$t('login.b4')" /></view>
  35. </view>
  36. <view class="login_input flex">
  37. <view class="login_img">
  38. <image src="/static/icon/img06.png"></image>
  39. </view>
  40. <view class="login_name flex">
  41. <input class="uni-input width" v-model="captcha" focus :placeholder="$t('login.b6')" />
  42. <view class="code" @click="verification">{{ countDown == 0 ? $t('login.b5') : countDown }}</view>
  43. </view>
  44. </view>
  45. <view><button type="green" @click="register" class="uni-button uni-button-green">{{$t('login.a7')}}</button>
  46. </view>
  47. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true"
  48. hover-class="none" @click="login">{{$t('login.a4')}}</button></view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. register,
  55. verify
  56. } from '@/api/login.js';
  57. export default {
  58. data() {
  59. return {
  60. // phone: '', //用户
  61. account: '', //用户
  62. password: '', //密码
  63. repassword: '',
  64. // invitation: '', //邀请码
  65. spread: '', //邀请码
  66. captcha: '', //验证码
  67. time: '', //保存倒计时对象
  68. countDown: 0, //倒计时
  69. trade_password: '', // 交易密码
  70. isPhone: true, //是否为手机号,默认为true
  71. };
  72. },
  73. onLoad(option) {
  74. // #ifndef MP
  75. if (option.spread) {
  76. // 存储其他邀请人
  77. uni.setStorageSync('spread', option.spread);
  78. }
  79. // #endif
  80. // #ifdef MP
  81. if (option.scene) {
  82. // 存储小程序邀请人
  83. uni.setStorage({
  84. key: 'spread_code',
  85. data: option.scene
  86. });
  87. }
  88. // #endif
  89. // 获取扫码邀请人id
  90. this.spread = option.spread||uni.getStorageSync('spread') || '';
  91. },
  92. watch: {
  93. // 监听倒计时
  94. countDown(i) {
  95. if (i == 0) {
  96. clearInterval(this.time);
  97. }
  98. }
  99. },
  100. methods: {
  101. checkAccount() {
  102. const regPhone = /^1[3|4|5|7|8][0-9]{9}$/;
  103. const regEmail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  104. this.isPhone = regPhone.test(this.account);
  105. },
  106. // 注册
  107. register() {
  108. let obj = this;
  109. if (obj.account == '') {
  110. obj.$api.msg('请输入手机号/邮箱');
  111. return;
  112. }
  113. if (this.isPhone) {
  114. if (!/^1[3|4|5|7|8][0-9]{9}$/.test(this.account)) {
  115. this.$api.msg('请输入正确的手机号');
  116. return;
  117. }
  118. } else {
  119. if (!/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(this.account)) {
  120. this.$api.msg('请输入正确的邮箱地址');
  121. return;
  122. }
  123. }
  124. // if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  125. // obj.$api.msg('请输入正确的手机号');
  126. // return;
  127. // }
  128. if (obj.password == '') {
  129. obj.$api.msg('请输入密码');
  130. return;
  131. }
  132. if (obj.trade_password == '') {
  133. obj.$api.msg('请输入交易密码');
  134. return;
  135. }
  136. register({
  137. // account: obj.account, //账号
  138. account: obj.account, //账号
  139. captcha: obj.captcha, //验证码
  140. password: obj.password, //密码
  141. trade_password: obj.trade_password, // 交易密码
  142. spread: this.spread //上级推广人
  143. }).then(function(e) {
  144. uni.showToast({
  145. title: '注册成功',
  146. duration: 2000,
  147. position: 'top'
  148. });
  149. setTimeout(function() {
  150. uni.navigateTo({
  151. url: '/pages/public/login'
  152. });
  153. }, 1000)
  154. });
  155. //调用注册接口,成功跳转登录页
  156. },
  157. //发送验证码
  158. verification() {
  159. let obj = this;
  160. if (this.account == '') {
  161. this.$api.msg(obj.$t("login.a1"));
  162. return;
  163. }
  164. if (this.account.length < 11) {
  165. this.$api.msg(obj.$t("safe.b8"));
  166. return;
  167. }
  168. // 判断是否在倒计时
  169. if (obj.countDown > 0) {
  170. return false;
  171. } else {
  172. obj.countDown = 60;
  173. obj.time = setInterval(() => {
  174. obj.countDown--;
  175. }, 1000);
  176. //调用验证码接口
  177. verify({
  178. phone: obj.account,
  179. type: 'register'
  180. })
  181. .then(({
  182. data
  183. }) => {})
  184. .catch(err => {
  185. console.log(err);
  186. });
  187. }
  188. },
  189. login() {
  190. //返回登录
  191. uni.navigateTo({
  192. url: '/pages/public/login'
  193. });
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss">
  199. page {
  200. height: 100%;
  201. }
  202. .container {
  203. width: 100%;
  204. height: 100%;
  205. background-size: 100%;
  206. background-color: #000000;
  207. }
  208. .container_text {
  209. width: 100%;
  210. height: 500rpx;
  211. top: 0rpx;
  212. .banner-img {
  213. width: 144rpx;
  214. height: 144rpx;
  215. margin-top: 100rpx;
  216. margin-left: 302rpx;
  217. }
  218. }
  219. .login_text {
  220. margin: auto 30rpx;
  221. position: relative;
  222. padding: 100rpx 102rpx;
  223. background-color: #000000;
  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: #FFFFFF;
  241. // width: 640rpx;
  242. // height: 99rpx;
  243. // background: #FFFFFF;
  244. // opacity: 0.1;
  245. // border-radius: 50rpx;
  246. }
  247. }
  248. .other {
  249. margin-top: 60rpx;
  250. .fenge {
  251. width: 30%;
  252. height: 2rpx;
  253. background-color: #eeeeee;
  254. }
  255. .qita {
  256. font-size: 28rpx;
  257. color: #999999;
  258. }
  259. }
  260. .weixin {
  261. width: 75rpx;
  262. height: 75rpx;
  263. margin: 25rpx auto;
  264. }
  265. .weixin image {
  266. width: 100%;
  267. height: 100%;
  268. }
  269. .weixin_text {
  270. text-align: center;
  271. font-size: 28rpx;
  272. color: #999999;
  273. }
  274. .forget {
  275. font-size: 28rpx;
  276. width: 100%;
  277. text-align: right;
  278. color: #999999;
  279. }
  280. .uni-button-green {
  281. color: #ffffff;
  282. background-color: #feb041;
  283. margin: 40rpx 10rpx;
  284. border-radius: 50rpx;
  285. }
  286. .uni-button-green-plain {
  287. border: 1px solid #feb041;
  288. margin: 40rpx 10rpx;
  289. border-radius: 50rpx;
  290. color: #feb041;
  291. background-color: #000000;
  292. }
  293. .uni-button {
  294. height: 85rpx;
  295. line-height: 85rpx;
  296. }
  297. }
  298. .loginTitle {
  299. position: absolute;
  300. top: 250rpx;
  301. width: 100%;
  302. text-align: center;
  303. color: #c6a674;
  304. font-size: 40rpx;
  305. }
  306. .forget {
  307. width: 100rpx;
  308. font-size: 24rpx;
  309. color: #ffffff;
  310. margin: 0px auto;
  311. border-bottom: 1px solid #ffffff;
  312. }
  313. .width {
  314. width: 325rpx !important;
  315. }
  316. .code {
  317. color: #feb041;
  318. font-size: 23rpx;
  319. border-left: 1px solid #eeeeee;
  320. width: 150rpx;
  321. flex-shrink: 0;
  322. text-align: center;
  323. }
  324. uni-button {
  325. height: 80rpx !important;
  326. line-height: 80rpx !important;
  327. }
  328. </style>