register.vue 9.1 KB

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