RegisterByEmail.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="div container">
  3. <view class="div top-wrapper">
  4. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" v-model="username" placeholder="用户名" maxlength="25" /><label v-if="!username" class="tips">用户名为3-25位,可以包含英文与数字</label></view></flex-line>
  5. <!-- <flex-line v-if="config.captcha_status_register=='1'" class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" v-model="pictureCode" placeholder="请输入图片验证码" maxlength="6" /><image mode="aspectFit" @click="changePictureCode" :src="pictureCodeUrl" class="img countdown" ></view></flex-line> -->
  6. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="password" placeholder="设置密码" maxlength="20" /></view></flex-line>
  7. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="confirmPassword" placeholder="确认密码" maxlength="20" /><label v-if="!confirmPassword" class="tips">6-20位数字/字母/符号</label></view></flex-line>
  8. </view>
  9. <view class="div common-btn ds-button-large mt-10 mb-10" @click="onSubmit">注册</view>
  10. <view class="div link-wrapper">
  11. <text class="span left-text">点击注册表示同意</text>
  12. <text class="span right-text" @click="onAgreement">《用户协议》</text>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { urlencode } from '@/util/common'
  18. import { mapState, mapMutations, mapActions } from 'vuex'
  19. import { register } from '../../../api/memberRegister'
  20. import { getSmsCaptcha, checkPictureCaptcha } from '../../../api/common'
  21. import flexLine from '../../flexLine'
  22. import { env } from '../../../static/config'
  23. export default {
  24. name: 'RegisterByEmail',
  25. data () {
  26. return {
  27. pictureCodeUrl: '',
  28. pictureCode: '',
  29. pictureCodeValid: false,
  30. pictureCodeWait: false,
  31. username: '',
  32. password: '',
  33. confirmPassword: '',
  34. aggrementUrl: ''
  35. }
  36. },
  37. components: {
  38. flexLine
  39. },
  40. created: function () {
  41. this.fetchConfig({}).then(
  42. response => {
  43. },
  44. error => {
  45. uni.showToast({icon:'none',title: error.message})
  46. }
  47. )
  48. },
  49. computed: {
  50. ...mapState({
  51. inviter_id: state => state.member.inviterId,
  52. config: state => state.config.config
  53. })
  54. },
  55. mounted () {
  56. // this.changePictureCode()
  57. },
  58. methods: {
  59. ...mapMutations({
  60. saveAuthInfo: 'memberLogin'
  61. }),
  62. ...mapActions({
  63. fetchConfig: 'fetchConfig'
  64. }),
  65. changePictureCode () {
  66. this.pictureCodeUrl = env.API_HOST + '/Seccode/makecode?r=' + Math.random()
  67. },
  68. goBack () {
  69. uni.navigateBack({delta:1})
  70. },
  71. goProfile () {
  72. uni.navigateBack({delta:2})
  73. },
  74. goProfileAdd () {
  75. uni.navigateTo({ url: 'profileAdd' })
  76. },
  77. check () {
  78. let username = this.username
  79. let password = this.password
  80. let confirmPassword = this.confirmPassword
  81. if (username.length === 0) {
  82. uni.showToast({icon:'none',title: '请输入3-25个字符的用户名'})
  83. return false
  84. }
  85. if (username.length < 3 || username.length > 25) {
  86. uni.showToast({icon:'none',title: '请输入3-25个字符的用户名'})
  87. return false
  88. }
  89. if (password.length === 0) {
  90. uni.showToast({icon:'none',title: '请输入密码'})
  91. return false
  92. }
  93. if (password.length < 6 || password.length > 20) {
  94. uni.showToast({icon:'none',title: '请输入6-20个字符的密码'})
  95. return false
  96. }
  97. if (confirmPassword.length === 0) {
  98. uni.showToast({icon:'none',title: '请输入确认密码'})
  99. return false
  100. }
  101. if (password.length !== confirmPassword.length) {
  102. uni.showToast({icon:'none',title: '确认密码与输入密码不一致'})
  103. return false
  104. }
  105. if (password !== confirmPassword) {
  106. uni.showToast({icon:'none',title: '确认密码与输入密码不一致'})
  107. return false
  108. }
  109. return true
  110. },
  111. signup () {
  112. if (!this.check()) {
  113. return
  114. }
  115. uni.showLoading({ title: '加载中' })
  116. let inviterId = this.inviter_id // 获取邀请人id
  117. register(this.username, this.password, this.confirmPassword, inviterId, this.pictureCode).then(
  118. response => {
  119. uni.hideLoading()
  120. this.saveAuthInfo({ token: response.result.token, info: response.result.info })
  121. uni.navigateTo({ url: '/pages/member/index/Index' })
  122. },
  123. error => {
  124. uni.hideLoading()
  125. uni.showToast({icon:'none',title: error.message})
  126. }
  127. )
  128. },
  129. onSubmit () {
  130. this.signup()
  131. },
  132. onAgreement () {
  133. uni.navigateTo({ url: '/pages/home/article/Document'+'?'+urlencode( { type: '' })})
  134. }
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .flex-line /deep/ .right{max-width: 100%;}
  140. .ds-button-large{margin:0 $pageSpace}
  141. .container {
  142. display: flex;
  143. flex-direction: column;
  144. justify-content: flex-start;
  145. align-items: stretch;
  146. //background-color: $primaryColor;
  147. .input-wrapper {
  148. font-size:$subFontSize;
  149. display: flex;
  150. flex-direction: row;
  151. align-content: flex-start;
  152. align-items: center;
  153. background-color: #fff;
  154. height:2.2rem;
  155. padding-left:0.5rem;
  156. .img {
  157. height: 1.75rem;width: auto;
  158. margin: 0;
  159. padding: 0;
  160. }
  161. input {
  162. flex: 1;
  163. }
  164. .bottom-input {
  165. border-bottom-width: 0;
  166. }
  167. }
  168. .link-wrapper {
  169. display: flex;
  170. flex-direction: row;
  171. justify-content: center;
  172. align-items: stretch;
  173. .span {
  174. font-size:$subFontSize;
  175. display: flex;
  176. flex-direction: row;
  177. justify-content: center;
  178. align-items: center;
  179. }
  180. .left-text {
  181. color: $descTextColor;
  182. }
  183. .right-text {
  184. color: $primaryColor;
  185. }
  186. }
  187. }
  188. .top-wrapper {
  189. margin:0 $pageSpace;
  190. }
  191. .bottom-wrapper {
  192. margin-top:0.5rem;
  193. }
  194. .tips {
  195. color: $descTextColor;
  196. font-size:$fontSize;
  197. white-space: nowrap;
  198. position: absolute;
  199. right: 0;
  200. top:50%;
  201. margin-top:-.3rem;
  202. }
  203. .countdown {min-width:4rem;margin-right:0.5rem;}
  204. .field-line-right{position: relative;
  205. .field-input{
  206. text-align: left !important;
  207. }
  208. }
  209. </style>