register.vue 9.3 KB

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