register.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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/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">
  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. <view><button type="green" @click="register" class="uni-button uni-button-green">{{$t('login.a7')}}</button>
  52. </view>
  53. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true"
  54. hover-class="none" @click="login">{{$t('login.a4')}}</button></view>
  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. store_name:''
  83. };
  84. },
  85. onLoad(option) {
  86. uni.setNavigationBarTitle({
  87. title: this.$t("login.a7"),
  88. });
  89. // #ifndef MP
  90. if (option.spread) {
  91. // 存储其他邀请人
  92. uni.setStorageSync('spread', option.spread);
  93. }
  94. // #endif
  95. // #ifdef MP
  96. if (option.scene) {
  97. // 存储小程序邀请人
  98. uni.setStorage({
  99. key: 'spread_code',
  100. data: option.scene
  101. });
  102. }
  103. // #endif
  104. // 获取扫码邀请人id
  105. this.spread = option.spread || uni.getStorageSync('spread') || '';
  106. },
  107. watch: {
  108. // 监听倒计时
  109. countDown(i) {
  110. if (i == 0) {
  111. clearInterval(this.time);
  112. }
  113. }
  114. },
  115. methods: {
  116. // #ifdef H5
  117. domApp(type) {
  118. const bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  119. if (bool) {
  120. uni.showModal({
  121. // title: '提示',
  122. title: this.$t("enter.a7"),
  123. // content: '无法在微信中下载,请用浏览器打开下载',
  124. content: this.$t("login.c2"),
  125. showCancel: false,
  126. });
  127. } else {
  128. if (type == 'apk') {
  129. getAppVersion().then((res) => {
  130. console.log(res, 'res');
  131. window.open(res.data.apk);
  132. }).catch((err) => {
  133. console.log(err, 'err');
  134. })
  135. return
  136. }
  137. if(type=="ios"){
  138. window.open("/index/dom/iosdom.mobileconfig");
  139. }
  140. }
  141. },
  142. // #endif
  143. checkAccount() {
  144. const regPhone = /^1[3|4|5|7|8][0-9]{9}$/;
  145. const regEmail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  146. this.isPhone = regPhone.test(this.account);
  147. },
  148. // 注册
  149. register() {
  150. let obj = this;
  151. if (obj.account == '') {
  152. obj.$api.msg(obj.$t("login.a1"));
  153. return;
  154. }
  155. if (this.isPhone) {
  156. if (!/^1[3|4|5|7|8][0-9]{9}$/.test(this.account)) {
  157. this.$api.msg(obj.$t("safe.b8"));
  158. return;
  159. }
  160. } else {
  161. if (!/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(this.account)) {
  162. this.$api.msg(obj.$t("login.b9"));
  163. return;
  164. }
  165. }
  166. if(!this.store_name){
  167. this.$api.msg("请输入商户名称");
  168. }
  169. if (obj.password == '') {
  170. obj.$api.msg(obj.$t("reg.a9"));
  171. return;
  172. }
  173. if (obj.trade_password == '') {
  174. obj.$api.msg(obj.$t("login.b3"));
  175. return;
  176. }
  177. register({
  178. account: obj.account, //账号
  179. captcha: obj.captcha, //验证码
  180. password: obj.password, //密码
  181. trade_password: obj.trade_password, // 交易密码
  182. spread: obj.spread ,//上级推广人
  183. store_name:obj.store_name
  184. }).then(function(e) {
  185. // uni.showToast({
  186. // title: obj.$t("reg.c5"),
  187. // duration: 2000,
  188. // position: 'top'
  189. // });
  190. uni.showModal({
  191. title: obj.$t("enter.a7"),
  192. content: obj.$t("login.c3"),
  193. cancelText: obj.$t("zy.b4"),
  194. confirmText: obj.$t("zy.b3"),
  195. success: res => {
  196. if(res.confirm){
  197. uni.navigateTo({
  198. url: '/pages/public/login'
  199. });
  200. }
  201. },
  202. fail: () => {},
  203. complete: () => {}
  204. });
  205. });
  206. //调用注册接口,成功跳转登录页
  207. },
  208. //发送验证码
  209. verification() {
  210. let obj = this;
  211. if (this.account == '') {
  212. this.$api.msg(obj.$t("login.a1"));
  213. return;
  214. }
  215. if (this.account.length < 11) {
  216. this.$api.msg(obj.$t("safe.b8"));
  217. return;
  218. }
  219. // 判断是否在倒计时
  220. if (obj.countDown > 0) {
  221. return false;
  222. } else {
  223. obj.countDown = 60;
  224. obj.time = setInterval(() => {
  225. obj.countDown--;
  226. }, 1000);
  227. //调用验证码接口
  228. verify({
  229. phone: obj.account,
  230. type: 'register'
  231. })
  232. .then(({
  233. data
  234. }) => {})
  235. .catch(err => {
  236. console.log(err);
  237. });
  238. }
  239. },
  240. login() {
  241. //返回登录
  242. uni.navigateTo({
  243. url: '/pages/public/login'
  244. });
  245. }
  246. }
  247. };
  248. </script>
  249. <style lang="scss">
  250. page {
  251. height: 100%;
  252. }
  253. .container {
  254. width: 100%;
  255. height: 100%;
  256. background-size: 100% 100%;
  257. background-image: url("../../static/img/loginBg.png");
  258. background-repeat: no-repeat;
  259. }
  260. .container_text {
  261. width: 100%;
  262. text-align: center;
  263. .banner-img {
  264. width: 144rpx;
  265. margin-top: 100rpx;
  266. }
  267. }
  268. .login_text {
  269. margin: auto 10rpx;
  270. position: relative;
  271. padding: 100rpx 72rpx;
  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: 100%;
  284. font-size: 28rpx !important;
  285. }
  286. .input-placeholder{
  287. color: #FFF;
  288. }
  289. .login_name {
  290. color: #FFFFFF;
  291. flex-grow: 1;
  292. margin-left: 20rpx;
  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: #1257FE;
  337. background-color: #FFF;
  338. margin: 40rpx 0rpx;
  339. border-radius: 10rpx;
  340. }
  341. .uni-button-green-plain {
  342. border: 1px solid #FFF;
  343. margin: 40rpx 0rpx;
  344. border-radius: 10rpx;
  345. color: #FFF;
  346. background-color: transparent;
  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: #FFF;
  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>