register.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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/ze.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/ze2.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/ze2.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/ze2.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/ze.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. <!-- #ifdef H5 -->
  50. <view class="flex">
  51. <button class="uni-button loadapp" @click="domApp('apk')">APK下载</button>
  52. <button class="uni-button loadapp" @click="domApp('ios')">IOS下载</button>
  53. </view>
  54. <!-- #endif -->
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. register,
  61. verify
  62. } from '@/api/login.js';
  63. import {
  64. getAppVersion
  65. } from '@/api/index.js'
  66. export default {
  67. data() {
  68. return {
  69. // phone: '', //用户
  70. account: '', //用户
  71. password: '', //密码
  72. repassword: '',
  73. // invitation: '', //邀请码
  74. spread: '', //邀请码
  75. captcha: '', //验证码
  76. time: '', //保存倒计时对象
  77. countDown: 0, //倒计时
  78. trade_password: '', // 交易密码
  79. isPhone: true, //是否为手机号,默认为true
  80. };
  81. },
  82. onLoad(option) {
  83. // #ifndef MP
  84. if (option.spread) {
  85. // 存储其他邀请人
  86. uni.setStorageSync('spread', option.spread);
  87. }
  88. // #endif
  89. // #ifdef MP
  90. if (option.scene) {
  91. // 存储小程序邀请人
  92. uni.setStorage({
  93. key: 'spread_code',
  94. data: option.scene
  95. });
  96. }
  97. // #endif
  98. // 获取扫码邀请人id
  99. this.spread = option.spread || uni.getStorageSync('spread') || '';
  100. },
  101. watch: {
  102. // 监听倒计时
  103. countDown(i) {
  104. if (i == 0) {
  105. clearInterval(this.time);
  106. }
  107. }
  108. },
  109. methods: {
  110. // #ifdef H5
  111. domApp(type) {
  112. console.log('111');
  113. const bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  114. if (bool) {
  115. uni.showModal({
  116. title: '提示',
  117. content: '无法在微信中下载,请用浏览器打开下载',
  118. showCancel: false,
  119. });
  120. } else {
  121. if (type == 'apk') {
  122. getAppVersion().then((res) => {
  123. console.log(res, 'res');
  124. window.open(res.data.apk);
  125. }).catch((err) => {
  126. console.log(err, 'err');
  127. })
  128. return
  129. }
  130. if(type=="ios"){
  131. }
  132. }
  133. },
  134. // #endif
  135. checkAccount() {
  136. const regPhone = /^1[3|4|5|7|8][0-9]{9}$/;
  137. const regEmail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  138. this.isPhone = regPhone.test(this.account);
  139. },
  140. // 注册
  141. register() {
  142. let obj = this;
  143. if (obj.account == '') {
  144. obj.$api.msg(obj.$t("login.a1"));
  145. return;
  146. }
  147. if (this.isPhone) {
  148. if (!/^1[3|4|5|7|8][0-9]{9}$/.test(this.account)) {
  149. this.$api.msg(obj.$t("safe.b8"));
  150. return;
  151. }
  152. } else {
  153. if (!/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(this.account)) {
  154. this.$api.msg(obj.$t("login.b9"));
  155. return;
  156. }
  157. }
  158. // if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  159. // obj.$api.msg('请输入正确的手机号');
  160. // return;
  161. // }
  162. if (obj.password == '') {
  163. obj.$api.msg(obj.$t("reg.a9"));
  164. return;
  165. }
  166. if (obj.trade_password == '') {
  167. obj.$api.msg(obj.$t("login.b3"));
  168. return;
  169. }
  170. register({
  171. // account: obj.account, //账号
  172. account: obj.account, //账号
  173. captcha: obj.captcha, //验证码
  174. password: obj.password, //密码
  175. trade_password: obj.trade_password, // 交易密码
  176. spread: this.spread //上级推广人
  177. }).then(function(e) {
  178. uni.showToast({
  179. title: this.$t("reg.c5"),
  180. duration: 2000,
  181. position: 'top'
  182. });
  183. uni.showModal({
  184. title: '提示',
  185. content: '注册成功是否登录?',
  186. cancelText: '取消',
  187. confirmText: '登录',
  188. success: res => {
  189. if(res.confirm){
  190. uni.navigateTo({
  191. url: '/pages/public/login'
  192. });
  193. }
  194. },
  195. fail: () => {},
  196. complete: () => {}
  197. });
  198. });
  199. //调用注册接口,成功跳转登录页
  200. },
  201. //发送验证码
  202. verification() {
  203. let obj = this;
  204. if (this.account == '') {
  205. this.$api.msg(obj.$t("login.a1"));
  206. return;
  207. }
  208. if (this.account.length < 11) {
  209. this.$api.msg(obj.$t("safe.b8"));
  210. return;
  211. }
  212. // 判断是否在倒计时
  213. if (obj.countDown > 0) {
  214. return false;
  215. } else {
  216. obj.countDown = 60;
  217. obj.time = setInterval(() => {
  218. obj.countDown--;
  219. }, 1000);
  220. //调用验证码接口
  221. verify({
  222. phone: obj.account,
  223. type: 'register'
  224. })
  225. .then(({
  226. data
  227. }) => {})
  228. .catch(err => {
  229. console.log(err);
  230. });
  231. }
  232. },
  233. login() {
  234. //返回登录
  235. uni.navigateTo({
  236. url: '/pages/public/login'
  237. });
  238. }
  239. }
  240. };
  241. </script>
  242. <style lang="scss">
  243. page {
  244. height: 100%;
  245. }
  246. .container {
  247. width: 100%;
  248. height: 100%;
  249. background-size: 100%;
  250. background-color: #000000;
  251. }
  252. .container_text {
  253. width: 100%;
  254. height: 500rpx;
  255. top: 0rpx;
  256. .banner-img {
  257. width: 144rpx;
  258. height: 144rpx;
  259. margin-top: 100rpx;
  260. margin-left: 302rpx;
  261. }
  262. }
  263. .login_text {
  264. margin: auto 10rpx;
  265. position: relative;
  266. padding: 100rpx 102rpx;
  267. background-color: #000000;
  268. margin-top: -180rpx;
  269. border-radius: 20rpx;
  270. .login_input {
  271. border-bottom: 1px solid #f0f0f0;
  272. margin-bottom: 65rpx;
  273. .login_img image {
  274. height: 35rpx;
  275. width: 29rpx;
  276. // padding-right: 20rpx;
  277. }
  278. .uni-input {
  279. text-align: left;
  280. width: 470rpx;
  281. font-size: 28rpx !important;
  282. }
  283. .login_name {
  284. color: #FFFFFF;
  285. // width: 640rpx;
  286. // height: 99rpx;
  287. // background: #FFFFFF;
  288. // opacity: 0.1;
  289. // border-radius: 50rpx;
  290. }
  291. }
  292. .other {
  293. margin-top: 60rpx;
  294. .fenge {
  295. width: 30%;
  296. height: 2rpx;
  297. background-color: #eeeeee;
  298. }
  299. .qita {
  300. font-size: 28rpx;
  301. color: #999999;
  302. }
  303. }
  304. // .weixin {
  305. // width: 75rpx;
  306. // height: 75rpx;
  307. // margin: 25rpx auto;
  308. // }
  309. // .weixin image {
  310. // width: 100%;
  311. // height: 100%;
  312. // }
  313. // .weixin_text {
  314. // text-align: center;
  315. // font-size: 28rpx;
  316. // color: #999999;
  317. // }
  318. .forget {
  319. font-size: 28rpx;
  320. width: 100%;
  321. text-align: right;
  322. color: #999999;
  323. }
  324. .loadapp {
  325. border: 1px solid #feb041;
  326. background-color: transparent;
  327. color: #feb041;
  328. width: 45%;
  329. }
  330. .uni-button-green {
  331. color: #ffffff;
  332. background-color: #feb041;
  333. margin: 40rpx 10rpx;
  334. border-radius: 50rpx;
  335. }
  336. .uni-button-green-plain {
  337. border: 1px solid #feb041;
  338. margin: 40rpx 10rpx;
  339. border-radius: 50rpx;
  340. color: #feb041;
  341. background-color: #000000;
  342. }
  343. .uni-button {
  344. height: 85rpx;
  345. line-height: 85rpx;
  346. }
  347. }
  348. .loginTitle {
  349. position: absolute;
  350. top: 250rpx;
  351. width: 100%;
  352. text-align: center;
  353. color: #c6a674;
  354. font-size: 40rpx;
  355. }
  356. .forget {
  357. width: 100rpx;
  358. font-size: 24rpx;
  359. color: #ffffff;
  360. margin: 0px auto;
  361. border-bottom: 1px solid #ffffff;
  362. }
  363. .width {
  364. width: 325rpx !important;
  365. }
  366. .code {
  367. color: #feb041;
  368. font-size: 23rpx;
  369. border-left: 1px solid #eeeeee;
  370. width: 150rpx;
  371. flex-shrink: 0;
  372. text-align: center;
  373. }
  374. uni-button {
  375. height: 80rpx !important;
  376. line-height: 80rpx !important;
  377. }
  378. </style>