register.vue 9.6 KB

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