register.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <view class="app">
  3. <view class="top-view">
  4. <image class="bg" src="/static/img/login-bg.png"></image>
  5. <view class="inner">
  6. <view class="statusBar" :style="'height:' + statusBarHeight + 'px'"></view>
  7. <view class="inner-body fx-h fx-bc fx-ac">
  8. <view class="prv" @tap="utils.navigateBack()">
  9. <image src="/static/img/ic_back_white.png" class="icon-back"></image>
  10. </view>
  11. <view class="logo">
  12. <image src="/static/img/cbb_white.png"></image>
  13. </view>
  14. <view class="label-text">注册长城易趣拍</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="body">
  19. <view class="h120"></view>
  20. <view class="input-view">
  21. <view class="login-input fx-r">
  22. <view class="left fx-r fx-bc ">
  23. <view class="label">+86</view>
  24. <image class="loginv" src="/static/img/login-v.png"></image>
  25. </view>
  26. <input type="number" v-model="form.mobile" placeholder="请输入手机号" />
  27. </view>
  28. <view class="login-input yzm fx-r fx-bc">
  29. <view class="left fx-h fx-ac">
  30. <image class="icon" style="margin-left: 20rpx;" src="/static/img/login-password.png"></image>
  31. </view>
  32. <input type="text" v-model="form.verify" placeholder="请输入验证码" />
  33. <view class="line"></view>
  34. <view v-if="verifyCount <= 0" class="sbtn" @tap="getVcode">验证码</view>
  35. <view v-else class="no-sbtn">{{ verifyCount }} S</view>
  36. </view>
  37. <view class="login-input pass fx-r fx-bc">
  38. <view class="left fx-h fx-ac">
  39. <image class="icon" style="margin-left: 20rpx;" src="/static/img/login-password.png"></image>
  40. </view>
  41. <input type="text" v-model="form.password" password="*" placeholder="请输入密码" />
  42. <view class="fx-g1"></view>
  43. <image @tap="showPass = !showPass"
  44. :src="showPass ? '/static/img/mis_pass.png' : '/static/img/ck_pass.png' " class="miss-pass">
  45. </image>
  46. </view>
  47. <view class="login-input fx-r" v-if="showData">
  48. <view class="left fx-h fx-ac">
  49. <image class="icon" style="margin-left: 20rpx;" src="/static/img/login-password.png"></image>
  50. </view>
  51. <input type="text" v-model="form.code" placeholder="请输入邀请码(非必填)" />
  52. </view>
  53. <view class="btn ihover" @tap="tapSubmit">注册账号</view>
  54. <view class="agament fx-r fx-bc fx-ac">
  55. <view @tap="isRead = !isRead" class="fx-r fx-ac fx-bc">
  56. <image v-if="!isRead" src="/static/img/radio_buttons.png"></image>
  57. <image v-else src="/static/img/radio_buttons_btn.png"></image>
  58. 注册及同意
  59. </view>
  60. <text @tap="tapOpen" data-url="/pages/operation/user">《用户协议》</text>
  61. ,认真阅读<text @tap="tapOpen" data-url="/pages/operation/package">《长城易趣拍产品购买协议》</text>
  62. </view>
  63. <view id="captcha"></view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <style lang="scss">
  69. page {
  70. background: #fff;
  71. }
  72. .top-view {
  73. position: relative;
  74. width: 100vw;
  75. height: 62vw;
  76. .bg {
  77. width: 100vw;
  78. height: 62vw;
  79. }
  80. .inner {
  81. position: absolute;
  82. width: 100%;
  83. height: 100%;
  84. top: 0;
  85. left: 0;
  86. .inner-body {
  87. position: relative;
  88. .prv {
  89. position: absolute;
  90. left: 20rpx;
  91. top: 20rpx;
  92. .icon-back {
  93. width: 60rpx;
  94. height: 60rpx;
  95. }
  96. }
  97. .logo {
  98. width: 200rpx;
  99. height: 119rpx;
  100. margin-bottom: 40rpx;
  101. margin-top: 60rpx;
  102. image {
  103. width: 100%;
  104. height: 100%;
  105. }
  106. }
  107. .label-text {
  108. font-size: 42rpx;
  109. color: #FFFFFF;
  110. }
  111. }
  112. }
  113. }
  114. .body {
  115. position: relative;
  116. background: #fff;
  117. border-radius: 80rpx 80rpx 0px 0px;
  118. top: -120rpx;
  119. z-index: 9;
  120. height: 500px;
  121. .h120 {
  122. height: 100rpx;
  123. }
  124. .input-view {
  125. padding: 0px 60rpx;
  126. .login-input {
  127. border-radius: 70rpx;
  128. border: 1px solid #E0E0E0;
  129. padding: 30rpx 46rpx;
  130. margin-bottom: 50rpx;
  131. .left {
  132. .label {
  133. font-size: 28rpx;
  134. color: #DB292B;
  135. font-weight: bold;
  136. }
  137. .loginv {
  138. width: 15rpx;
  139. height: 12rpx;
  140. margin-left: 14rpx;
  141. }
  142. .icon {
  143. width: 30rpx;
  144. height: 33rpx;
  145. }
  146. width: 90rpx;
  147. }
  148. input {
  149. width: calc(100% - 90rpx);
  150. }
  151. &.yzm {
  152. input {
  153. width: calc(100% - 90rpx - 22rpx - 80rpx);
  154. }
  155. .line {
  156. width: 1px;
  157. height: 36rpx;
  158. background: #eee;
  159. margin-right: 20rpx;
  160. }
  161. .sbtn {
  162. font-size: 12px;
  163. color: #DB292B;
  164. }
  165. .no-sbtn {
  166. font-size: 12px;
  167. color: #999999;
  168. }
  169. }
  170. &.pass {
  171. input {
  172. width: calc(100% - 180rpx);
  173. }
  174. .miss-pass {
  175. width: 60rpx;
  176. height: 60rpx
  177. }
  178. }
  179. }
  180. }
  181. .btn {
  182. background: #DB292B;
  183. border-radius: 60rpx;
  184. text-align: center;
  185. font-weight: bold;
  186. font-size: 28rpx;
  187. padding: 30rpx 0;
  188. color: #FAFAFA;
  189. }
  190. .agament {
  191. margin-top: 40rpx;
  192. image {
  193. width: 36rpx;
  194. height: 36rpx;
  195. margin-right: 20rpx;
  196. }
  197. color: #999999;
  198. font-size:24rpx;
  199. text {
  200. color: #DB292B;
  201. }
  202. }
  203. }
  204. .miss-pass {
  205. width: 30px;
  206. height: 30px;
  207. }
  208. .mb-view {
  209. font-size: 14px;
  210. margin-top: 30px;
  211. padding: 0px 5px;
  212. }
  213. .mb-view .link {
  214. color: #DB292B;
  215. }
  216. </style>
  217. <script>
  218. import maoScroll from '@/components/mao-scroll/mao-scroll.vue';
  219. import customerWiget from '@/components/ui-public/customer-wiget.vue';
  220. import {
  221. mapState,
  222. mapMutations
  223. } from 'vuex';
  224. export default {
  225. components: {
  226. maoScroll,
  227. customerWiget
  228. },
  229. computed: {
  230. ...mapState(['showData']),
  231. getWebSocket() {
  232. // #ifdef APP-PLUS
  233. const webSocket = getApp().globalData.webSocket
  234. // #endif
  235. // #ifndef APP-PLUS
  236. const webSocket = this.webSocket
  237. // #endif
  238. return webSocket
  239. }
  240. },
  241. data() {
  242. return {
  243. statusBarHeight: 20,
  244. form: {
  245. mobile: "",
  246. password: "",
  247. verify: "",
  248. code: ""
  249. },
  250. isRead: false,
  251. verifyCount: 0,
  252. showPass: false,
  253. captchaIns: null,
  254. validate: "",
  255. }
  256. },
  257. onLoad() {
  258. this.initView();
  259. this.$nextTick(() => {
  260. this.initNeCaptcha();
  261. });
  262. },
  263. methods: {
  264. ...mapMutations(['setSys', 'setUser']),
  265. initView: function() {
  266. uni.getSystemInfo({
  267. success: (res) => {
  268. this.statusBarHeight = res.statusBarHeight;
  269. }
  270. });
  271. },
  272. initNeCaptcha() {
  273. // #ifdef H5
  274. const options = {
  275. captchaId: 'c6af8490405544f8a169504b11c86fdc',
  276. element: '#captcha',
  277. protocol: 'https',
  278. onVerify: (err, data) => {
  279. if (data != null || data != "") {
  280. this.validate = data.validate;
  281. this.getVcode2();
  282. }
  283. }
  284. }
  285. options.mode = 'popup';
  286. initNECaptcha({
  287. ...options
  288. }, ins => {
  289. this.captchaIns = ins
  290. })
  291. // #endif
  292. // #ifdef APP
  293. this.captchaIns = uni.requireNativePlugin('YD-Captcha')
  294. this.captchaIns.init({
  295. captcha_id: 'c6af8490405544f8a169504b11c86fdc',
  296. is_no_sense_mode: false
  297. });
  298. // #endif
  299. },
  300. /**
  301. * 注册
  302. */
  303. tapReg: function() {
  304. uni.navigateTo({
  305. url: "./register"
  306. });
  307. },
  308. getVcode: function() {
  309. if (this.verifyCount > 0) return;
  310. if (!this.utils.isPoneAvailable(this.form.mobile)) {
  311. return uni.showToast({
  312. title: '请输入正确的手机号码!',
  313. mask: true,
  314. icon: 'none'
  315. });
  316. }
  317. // #ifdef H5
  318. this.captchaIns.popUp();
  319. // #endif
  320. // #ifdef APP
  321. this.captchaIns.showCaptcha((data) => {
  322. var method = data.method;
  323. if (method == "onSuccess") {
  324. var data = data.data;
  325. this.validate = data.validate;
  326. this.getVcode2();
  327. }
  328. })
  329. // #endif
  330. },
  331. getVcode2: function() {
  332. uni.showLoading({
  333. title: "获取中..."
  334. });
  335. this
  336. .request
  337. .post("getYzm", {
  338. mobile: this.form.mobile,
  339. validate: this.validate
  340. })
  341. .then(res => {
  342. uni.hideLoading();
  343. if (res.code == 200) {
  344. if (res.data.status == 2) {
  345. this.utils.CountDowm(res.data.time, (e, s) => {
  346. this.verifyCount = e;
  347. });
  348. }
  349. if (res.data.status == 1) {
  350. this.utils.CountDowm(120, (e, s) => {
  351. this.verifyCount = e;
  352. });
  353. }
  354. } else {
  355. uni.showToast({
  356. title: res.msg,
  357. mask: true,
  358. icon: 'none'
  359. });
  360. }
  361. })
  362. .catch(err => {
  363. uni.showToast({
  364. title: '获取失败',
  365. mask: true,
  366. icon: 'none'
  367. });
  368. uni.hideLoading();
  369. });
  370. },
  371. /**
  372. * 打开Open
  373. * @param {Object} ev
  374. */
  375. tapOpen: function(ev) {
  376. let url = ev.currentTarget.dataset.url;
  377. this.utils.navigateTo(url);
  378. },
  379. /**
  380. * 提交数据
  381. */
  382. tapSubmit: function() {
  383. //手机号码
  384. if (this.form.mobile == "") {
  385. uni.showToast({
  386. title: "请输入手机号码",
  387. icon: "none",
  388. mask: true
  389. })
  390. return;
  391. }
  392. //手机验证号码
  393. //this.form.mobile
  394. if (!this.utils.isPoneAvailable(this.form.mobile)) {
  395. uni.showToast({
  396. title: "请输入正确的手机号码",
  397. icon: "none",
  398. mask: true
  399. })
  400. return;
  401. }
  402. if (this.form.password == '') {
  403. uni.showToast({
  404. title: '请输入密码',
  405. mask: true,
  406. icon: 'none'
  407. });
  408. return;
  409. }
  410. // if (this.form.code == '') {
  411. // uni.showToast({
  412. // title: '请填写推荐码',
  413. // mask: true,
  414. // icon: 'none'
  415. // });
  416. // return;
  417. // }
  418. if (!this.isRead) {
  419. uni.showToast({
  420. title: "请阅读并同意相关政策",
  421. icon: "none",
  422. mask: true
  423. })
  424. return;
  425. }
  426. uni.showLoading({
  427. title: '登录中..'
  428. });
  429. this.request
  430. .post("register", this.form)
  431. .then(res => {
  432. uni.hideLoading();
  433. if (res.code == 200) {
  434. this.setUser(res.data);
  435. this.getWebSocket.connect();
  436. uni.reLaunch({
  437. url: "../index/index"
  438. });
  439. } else {
  440. uni.showToast({
  441. title: res.msg,
  442. icon: "none",
  443. mask: true
  444. });
  445. }
  446. })
  447. .catch(res => {
  448. uni.hideLoading();
  449. uni.showModal({
  450. title: '系统提示',
  451. content: '加载失败,重新点击尝试!',
  452. showCancel: false
  453. });
  454. });
  455. }
  456. }
  457. }
  458. </script>