register.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="register">
  3. <view class="welcome">
  4. 欢迎您来到<br>香花畦商城
  5. </view>
  6. <view class="input-container">
  7. <view class="input-item flex">
  8. <view class="input-label flex normal">手机号</view>
  9. <u-input v-model="mobile" class="input" placeholder="请输入手机号码" />
  10. </view>
  11. <view class="input-item flex" v-if="appConfig.register_setting">
  12. <view class="input-label flex normal">短信验证码</view>
  13. <u-input v-model="smsCode" style="width: 300rpx" placeholder="请输入验证码" />
  14. <button class="bd-primary xs primary br60 flex row-center" hover-class="none" @click="sendSmsFun">
  15. <!-- 获取验证码 -->
  16. <u-verification-code unique-key="register" ref="uCode" @change="codeChange">
  17. </u-verification-code>
  18. <view class="xs">{{codeTips}}</view>
  19. </button>
  20. </view>
  21. <view class="input-item flex">
  22. <view class="input-label flex normal">设置密码</view>
  23. <u-input type="password" v-model="password" placeholder="6-20位数字+字母或符号组合" />
  24. </view>
  25. <view class="input-item flex">
  26. <view class="input-label flex normal">确认密码</view>
  27. <u-input type="password" v-model="passwordConfirm" placeholder="6-20位数字+字母或符号组合" />
  28. </view>
  29. <view class="input-item flex">
  30. <view class="input-label flex normal">邀请码</view>
  31. <u-input type="text" v-model="invitecode" placeholder="请输入邀请码" />
  32. </view>
  33. </view>
  34. <view class="btn white bg-primary br60 flex row-center" @click="registerFun">立即注册</view>
  35. <!-- #ifndef APP-PLUS -->
  36. <view class="btn btn-primary br60 flex row-center" @click="app_download">下载APP</view>
  37. <!-- #endif -->
  38. <view class="m-t-40 sm flex row-center">
  39. <u-checkbox v-model="isAgreement" shape="circle">
  40. <div class="flex">
  41. 已阅读并同意
  42. <router-link to="/bundle/pages/server_explan/server_explan?type=0">
  43. <view class="primary">《服务协议》</view>
  44. </router-link>
  45. <router-link to="/bundle/pages/server_explan/server_explan?type=1">
  46. <view class="primary">《隐私协议》</view>
  47. </router-link>
  48. </div>
  49. </u-checkbox>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. register,
  57. sendSms
  58. } from '@/api/app.js'
  59. import {
  60. ACCESS_TOKEN
  61. } from '@/config/app.js'
  62. import {
  63. SMSType
  64. } from '@/utils/type.js'
  65. import {
  66. mapMutations,
  67. mapGetters,
  68. mapActions,
  69. } from 'vuex'
  70. export default {
  71. name: 'register',
  72. created() {
  73. },
  74. data() {
  75. return {
  76. isAgreement: false,
  77. mobile: '',
  78. smsCode: '',
  79. password: '',
  80. passwordConfirm: "",
  81. canSendSms: true,
  82. codeTips: '',
  83. invitecode: ""
  84. }
  85. },
  86. onLoad(option) {
  87. console.log(option)
  88. if(option){
  89. this.invitecode = option.invite_code
  90. }
  91. },
  92. methods: {
  93. ...mapMutations(['login']),
  94. ...mapActions(['getUser']),
  95. codeChange(tip) {
  96. this.codeTips = tip
  97. },
  98. registerFun() {
  99. let {
  100. isAgreement,
  101. mobile,
  102. password,
  103. smsCode,
  104. passwordConfirm,
  105. invitecode
  106. } = this;
  107. if (!isAgreement) return this.$toast({
  108. title: '请先勾选\"已阅读并同意《服务协议》和《隐私协议》\"'
  109. })
  110. if (!mobile) {
  111. this.$toast({
  112. title: '请填写手机号'
  113. });
  114. return;
  115. }
  116. if (!password) {
  117. this.$toast({
  118. title: "请设置密码"
  119. })
  120. return;
  121. }
  122. if (password != passwordConfirm) {
  123. this.$toast({
  124. title: "两次密码输入不一致"
  125. })
  126. return;
  127. }
  128. let data = {
  129. mobile: mobile,
  130. password: password,
  131. code: smsCode,
  132. client: 2,
  133. invitecode: invitecode
  134. }
  135. register(data).then(res => {
  136. if (res.code == 1) {
  137. this.login(res.data)
  138. this.$toast({
  139. title: res.msg
  140. });
  141. // 跳转到首页
  142. setTimeout(() => {
  143. this.$Router.pushTab('/pages/index/index')
  144. }, 1000)
  145. }else{
  146. this.$toast({
  147. title: res.msg
  148. });
  149. }
  150. })
  151. },
  152. countDownFinish() {
  153. this.canSendSms = true;
  154. },
  155. sendSmsFun() {
  156. if (!this.$refs.uCode.canGetCode) return
  157. if (!this.mobile) {
  158. this.$toast({
  159. title: '请填写手机号信息~'
  160. })
  161. return;
  162. }
  163. sendSms({
  164. mobile: this.mobile,
  165. key: SMSType.REGISTER
  166. }).then(res => {
  167. if (res.code == 1) {
  168. this.$toast({
  169. title: res.msg
  170. });
  171. this.$refs.uCode.start();
  172. }
  173. })
  174. },
  175. // app下载
  176. app_download(){
  177. location.href = "/app.html";
  178. }
  179. },
  180. computed: {
  181. ...mapGetters(['appConfig']),
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. .btn-primary{
  187. border: 1px solid #FF2C3C;
  188. color: #FF2C3C;
  189. }
  190. page {
  191. background-color: white;
  192. }
  193. .register {
  194. padding: 460rpx 40rpx 0;
  195. min-height: 100vh;
  196. background: url('../../static/login/bg.jpg')no-repeat;
  197. background-size: 100%;
  198. position: relative;
  199. .welcome {
  200. position: absolute;
  201. left: 50rpx;
  202. top: 180rpx;
  203. color: #fff;
  204. font-size: 60rpx;
  205. text-align: left;
  206. font-weight: 500;
  207. }
  208. .input-container {
  209. .input-item {
  210. padding: 0 20rpx;
  211. height: 88rpx;
  212. margin-bottom: 30rpx;
  213. border-bottom: 1px solid #D7D7D7;
  214. .input-label {
  215. width: 180rpx;
  216. flex: none;
  217. }
  218. .bd-primary {
  219. height: 56rpx;
  220. width: 176rpx;
  221. flex: none;
  222. border: 1px solid $-color-primary;
  223. .seconds {
  224. color: $-color-primary;
  225. }
  226. }
  227. }
  228. }
  229. .btn {
  230. margin-top: 60rpx;
  231. padding: 20rpx 0;
  232. }
  233. }
  234. </style>