register.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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" 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. };
  71. },
  72. onLoad(option) {
  73. // #ifndef MP
  74. if (option.spread) {
  75. // 存储其他邀请人
  76. uni.setStorageSync('spread', option.spread);
  77. }
  78. // #endif
  79. // #ifdef MP
  80. if (option.scene) {
  81. // 存储小程序邀请人
  82. uni.setStorage({
  83. key: 'spread_code',
  84. data: option.scene
  85. });
  86. }
  87. // #endif
  88. // 获取扫码邀请人id
  89. this.spread = option.spread||uni.getStorageSync('spread') || '';
  90. },
  91. watch: {
  92. // 监听倒计时
  93. countDown(i) {
  94. if (i == 0) {
  95. clearInterval(this.time);
  96. }
  97. }
  98. },
  99. methods: {
  100. // 注册
  101. register() {
  102. let obj = this;
  103. if (obj.account == '') {
  104. obj.$api.msg('请输入电话号码');
  105. return;
  106. }
  107. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  108. obj.$api.msg('请输入正确的手机号');
  109. return;
  110. }
  111. if (obj.password == '') {
  112. obj.$api.msg('请输入密码');
  113. return;
  114. }
  115. if (obj.trade_password == '') {
  116. obj.$api.msg('请输入交易密码');
  117. return;
  118. }
  119. register({
  120. account: obj.account, //账号
  121. captcha: obj.captcha, //验证码
  122. password: obj.password, //密码
  123. trade_password: obj.trade_password, // 交易密码
  124. spread: this.spread //上级推广人
  125. }).then(function(e) {
  126. uni.showToast({
  127. title: '注册成功',
  128. duration: 2000,
  129. position: 'top'
  130. });
  131. setTimeout(function() {
  132. uni.navigateTo({
  133. url: '/pages/public/login'
  134. });
  135. }, 1000)
  136. });
  137. //调用注册接口,成功跳转登录页
  138. },
  139. //发送验证码
  140. verification() {
  141. let obj = this;
  142. if (this.account == '') {
  143. this.$api.msg(obj.$t("login.a1"));
  144. return;
  145. }
  146. if (this.account.length < 11) {
  147. this.$api.msg(obj.$t("safe.b8"));
  148. return;
  149. }
  150. // 判断是否在倒计时
  151. if (obj.countDown > 0) {
  152. return false;
  153. } else {
  154. obj.countDown = 60;
  155. obj.time = setInterval(() => {
  156. obj.countDown--;
  157. }, 1000);
  158. //调用验证码接口
  159. verify({
  160. phone: obj.account,
  161. type: 'register'
  162. })
  163. .then(({
  164. data
  165. }) => {})
  166. .catch(err => {
  167. console.log(err);
  168. });
  169. }
  170. },
  171. login() {
  172. //返回登录
  173. uni.navigateTo({
  174. url: '/pages/public/login'
  175. });
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page {
  182. height: 100%;
  183. }
  184. .container {
  185. width: 100%;
  186. height: 100%;
  187. background-size: 100%;
  188. background-color: #000000;
  189. }
  190. .container_text {
  191. width: 100%;
  192. height: 500rpx;
  193. top: 0rpx;
  194. .banner-img {
  195. width: 144rpx;
  196. height: 144rpx;
  197. margin-top: 100rpx;
  198. margin-left: 302rpx;
  199. }
  200. }
  201. .login_text {
  202. margin: auto 30rpx;
  203. position: relative;
  204. padding: 100rpx 102rpx;
  205. background-color: #000000;
  206. margin-top: -180rpx;
  207. border-radius: 20rpx;
  208. .login_input {
  209. border-bottom: 1px solid #f0f0f0;
  210. margin-bottom: 65rpx;
  211. .login_img image {
  212. height: 35rpx;
  213. width: 29rpx;
  214. margin-right: 20rpx;
  215. }
  216. .uni-input {
  217. text-align: left;
  218. width: 470rpx;
  219. font-size: 28rpx !important;
  220. }
  221. .login_name {
  222. color: #FFFFFF;
  223. // width: 640rpx;
  224. // height: 99rpx;
  225. // background: #FFFFFF;
  226. // opacity: 0.1;
  227. // border-radius: 50rpx;
  228. }
  229. }
  230. .other {
  231. margin-top: 60rpx;
  232. .fenge {
  233. width: 30%;
  234. height: 2rpx;
  235. background-color: #eeeeee;
  236. }
  237. .qita {
  238. font-size: 28rpx;
  239. color: #999999;
  240. }
  241. }
  242. .weixin {
  243. width: 75rpx;
  244. height: 75rpx;
  245. margin: 25rpx auto;
  246. }
  247. .weixin image {
  248. width: 100%;
  249. height: 100%;
  250. }
  251. .weixin_text {
  252. text-align: center;
  253. font-size: 28rpx;
  254. color: #999999;
  255. }
  256. .forget {
  257. font-size: 28rpx;
  258. width: 100%;
  259. text-align: right;
  260. color: #999999;
  261. }
  262. .uni-button-green {
  263. color: #ffffff;
  264. background-color: #feb041;
  265. margin: 40rpx 10rpx;
  266. border-radius: 50rpx;
  267. }
  268. .uni-button-green-plain {
  269. border: 1px solid #feb041;
  270. margin: 40rpx 10rpx;
  271. border-radius: 50rpx;
  272. color: #feb041;
  273. background-color: #000000;
  274. }
  275. .uni-button {
  276. height: 85rpx;
  277. line-height: 85rpx;
  278. }
  279. }
  280. .loginTitle {
  281. position: absolute;
  282. top: 250rpx;
  283. width: 100%;
  284. text-align: center;
  285. color: #c6a674;
  286. font-size: 40rpx;
  287. }
  288. .forget {
  289. width: 100rpx;
  290. font-size: 24rpx;
  291. color: #ffffff;
  292. margin: 0px auto;
  293. border-bottom: 1px solid #ffffff;
  294. }
  295. .width {
  296. width: 325rpx !important;
  297. }
  298. .code {
  299. color: #feb041;
  300. font-size: 23rpx;
  301. border-left: 1px solid #eeeeee;
  302. width: 150rpx;
  303. flex-shrink: 0;
  304. text-align: center;
  305. }
  306. uni-button {
  307. height: 80rpx !important;
  308. line-height: 80rpx !important;
  309. }
  310. </style>