register.vue 9.4 KB

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