register.vue 9.2 KB

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