password.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="register-box">
  3. <Navbar title='注册'></Navbar>
  4. <image class="logo" :src="static ? static + 'logo.png' : ''" mode="heightFix"></image>
  5. <view class="tip">设置密码</view>
  6. <viow class="sub-tip">欢迎注册账号</viow>
  7. <view class="phone-box input-box">
  8. <IconText :code="`\ue898`" color="#999" size="14"></IconText>
  9. <uni-easyinput type="password" :inputBorder="false" v-model="password" placeholder="输入密码"></uni-easyinput>
  10. </view>
  11. <view class="password-box input-box">
  12. <IconText :code="`\ue898`" color="#999" size="14"></IconText>
  13. <uni-easyinput type="password" :inputBorder="false" v-model="repassword" placeholder="再次输入密码">
  14. </uni-easyinput>
  15. </view>
  16. <view class="btn">
  17. 密码支持6-16位数字与字母的组合
  18. </view>
  19. <view class="register-btn" @click="handleRegister">注册</view>
  20. <!-- #ifndef H5 -->
  21. <!-- <view class="agree">
  22. 注册登录即表示接受<text @click="handleAgree"> 《用户协议》</text>
  23. </view> -->
  24. <!-- #endif -->
  25. <uni-popup ref="agreement" :safe-area="false">
  26. <scroll-view class="agreement-box" :scroll-y="true">
  27. <view class="title">{{ agreement.title }}</view>
  28. <view class="content-styl" v-html="agreement.content"></view>
  29. </scroll-view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script lang="ts">
  34. import {
  35. Component,
  36. Prop,
  37. Vue
  38. } from 'vue-property-decorator';
  39. import {
  40. OSS_STATIC
  41. } from '@/common/constants';
  42. import agreement from './agreement';
  43. import pubKey from './pubKey';
  44. import {
  45. types
  46. } from '@/common/store/index';
  47. // @ts-ignore
  48. import JSEncrypt from '@/common/jsencrypt.js';
  49. import {
  50. namespace
  51. } from 'vuex-class';
  52. const baseModule = namespace('base');
  53. @Component({})
  54. export default class Password extends Vue {
  55. @baseModule.Getter('_referrerId') referrerId: any;
  56. @baseModule.Mutation(types.SET_TOKEN) setToken: any;
  57. link: string = '';
  58. static: string = OSS_STATIC;
  59. password: any = null;
  60. repassword: any = null;
  61. agreement: {
  62. title: string;content: string
  63. } = agreement;
  64. handleAgree() {
  65. (this.$refs.agreement as any).open('bottom');
  66. }
  67. handleRegister() {
  68. if (!this.repassword || !this.password) {
  69. uni.showToast({
  70. title: '请输入密码',
  71. icon: 'none'
  72. })
  73. return;
  74. }
  75. if (this.password !== this.repassword) {
  76. uni.showToast({
  77. title: '您输入的密码不一致',
  78. icon: 'none'
  79. })
  80. return;
  81. }
  82. // uni.showLoading({
  83. // title: '加载中',
  84. // });
  85. let pass = this.rsa(this.password);
  86. this.$http
  87. .post({
  88. url: this.$api.register,
  89. data: {
  90. auth: {
  91. sid: 0,
  92. agent: 1,
  93. genre: 0,
  94. way: 2,
  95. env: 0,
  96. identity: this.$Route.query.phone,
  97. password: pass,
  98. sys: 0
  99. },
  100. // timeStamp: time,
  101. third: {
  102. smsToken: this.$Route.query.token,
  103. referrer: +uni.getStorageSync('referrerId') || 0,
  104. }
  105. },
  106. })
  107. .then((res: any) => {
  108. // uni.hideLoading();
  109. this.setToken(res.token);
  110. uni.setStorageSync('referrerId', '');
  111. // #ifdef H5
  112. this.$Router.replace({
  113. path: '/packages/login/register-success',
  114. query: {
  115. phone: this.$Route.query.phone
  116. }
  117. })
  118. // #endif
  119. // #ifndef H5
  120. // this.$Router.back(1);
  121. this.$Router.pushTab({
  122. path: '/pages/front/front'
  123. })
  124. // #endif
  125. }, (err: any) => {
  126. // uni.hideLoading();
  127. console.log(err);
  128. });
  129. }
  130. rsa(pass: string) {
  131. console.log('加密前', pass)
  132. var encryptor = new JSEncrypt() // 创建加密对象实例
  133. encryptor.setPublicKey(pubKey) //设置公钥
  134. return encryptor.encrypt(pass) || '加密失败'
  135. }
  136. }
  137. </script>
  138. <style>
  139. .uni-easyinput__content {
  140. background: transparent !important;
  141. }
  142. </style>
  143. <style lang="scss" scoped>
  144. .register-box {
  145. // padding: 0 vw(24);
  146. @include flex-y(flex-start, center);
  147. background: #fff;
  148. min-height: 100vh;
  149. box-sizing: border-box;
  150. .logo {
  151. // width: vw(90);
  152. height: vw(72);
  153. border-radius: vw(45);
  154. margin-top: vw(36);
  155. }
  156. .tip {
  157. margin-top: vw(10);
  158. @include word-vw(30, #333);
  159. }
  160. .sub-tip {
  161. margin-top: vw(6);
  162. @include word-vw(14, #999);
  163. }
  164. .input-box {
  165. height: vw(52);
  166. width: vw(335);
  167. background: #F5F5F5;
  168. border-radius: vw(10);
  169. margin-top: vw(16);
  170. @include flex-x(flex-start);
  171. padding: 0 vw(24);
  172. box-sizing: border-box;
  173. .uni-easyinput__content {
  174. background: #F5F5F5;
  175. }
  176. .code-btn {
  177. @include word-vw(14, $btn-color);
  178. }
  179. }
  180. .phone-box {
  181. margin-top: 25%;
  182. }
  183. .btn {
  184. margin-top: vw(18);
  185. @include word-vw(14, #999);
  186. margin-right: vw(24);
  187. }
  188. .register-btn {
  189. height: vw(48);
  190. width: vw(335);
  191. background: $btn-color;
  192. border-radius: vw(10);
  193. @include word-vw(18, #fff);
  194. @include flex-x(center);
  195. margin-top: vw(32);
  196. }
  197. .agree {
  198. // width: 100%;
  199. @include word-vw(14, #666);
  200. margin-top: vw(25);
  201. text-align: center;
  202. position: absolute;
  203. bottom: vw(36);
  204. text {
  205. color: #E6644E;
  206. }
  207. }
  208. //用户协议
  209. .agreement-box {
  210. overflow: hidden;
  211. // overflow-y: auto;
  212. height: vw(480);
  213. background: #fff;
  214. border-top-left-radius: vw(5);
  215. border-top-right-radius: vw(5);
  216. padding-bottom: vw(30);
  217. box-sizing: border-box;
  218. .title {
  219. margin: vw(24) 0 vw(30);
  220. text-align: center;
  221. @include word-vw(16, $gray3);
  222. }
  223. .content-styl {
  224. @include word-vw(14, $gray6);
  225. line-height: vw(24);
  226. padding: 0 vw(15);
  227. }
  228. }
  229. }
  230. </style>