register.vue 8.6 KB

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