register.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <view style="position: relative;">
  3. <back></back>
  4. <view class="content">
  5. <view class="bg"></view>
  6. <view class="bg1"></view>
  7. <view class="top">
  8. <view class="title">
  9. <text>注册联兑通账号</text>
  10. <text>请输入手机号进行注册</text>
  11. </view>
  12. </view>
  13. <view style="width: 76%;margin-top: 80rpx;">
  14. <u-form :model="form" ref="uForm" :rules="rules" :error-type="['message']">
  15. <u-form-item label="手机号" prop="phone" label-width="150">
  16. <u-input :border="false" placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
  17. </u-form-item>
  18. <u-form-item label="验证码" prop="code" label-width="150">
  19. <view class="flex">
  20. <u-input style="width: 100%;" :border="false" placeholder="请输入验证码" v-model="form.code"
  21. type="text"></u-input>
  22. <u-button shape="circle" slot="right" :custom-style="customStyle" size="mini"
  23. @click="getCode">{{codeTips}}</u-button>
  24. </view>
  25. </u-form-item>
  26. <u-form-item label="密码" prop="password" label-width="150">
  27. <u-input :border="false" placeholder="请设置登录密码" v-model="form.password" type="password">
  28. </u-input>
  29. </u-form-item>
  30. <u-form-item label="确认密码" prop="newPassword" label-width="150">
  31. <u-input :border="false" placeholder="请再次输入密码" v-model="form.newPassword" type="password">
  32. </u-input>
  33. </u-form-item>
  34. </u-form>
  35. </view>
  36. <view style="width: 86%;margin-top: 100rpx;">
  37. <view @click="next" class="btn cu-btn round" style="width:100%;height: 90rpx;font-size: 34rpx;">
  38. 确认
  39. </view>
  40. <!-- <view class="center" style="margin-top: 100rpx;">
  41. <text style="color: #949494;">确认注册即代表已阅读并同意</text>
  42. <text style="color: #0000ff;">《软件服务协议》</text>
  43. </view> -->
  44. </view>
  45. </view>
  46. <toast ref="toast" ></toast>
  47. <loading ref="loading" type="3"/>
  48. <u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
  49. </view>
  50. </template>
  51. <script>
  52. import md5Libs from "uview-ui/libs/function/md5";
  53. import back from "@/components/back.vue"
  54. export default {
  55. components:{
  56. back
  57. },
  58. data() {
  59. return {
  60. customStyle: {
  61. 'backgroundColor': '#EF9944',
  62. 'color': '#ffffff'
  63. },
  64. codeTips: '',
  65. form: {
  66. phone: '',
  67. code: '',
  68. password: '',
  69. newPassword: ''
  70. },
  71. rules: {
  72. phone: [{
  73. required: true,
  74. message: '请输入手机号',
  75. trigger: ['change', 'blur'],
  76. }, {
  77. message: '手机号码不正确',
  78. trigger: ['change', 'blur'],
  79. validator: (rule, value, callback) => {
  80. return this.$u.test.mobile(value);
  81. },
  82. }],
  83. code: [{
  84. required: true,
  85. message: '请输入验证码',
  86. trigger: ['change', 'blur'],
  87. }],
  88. password: [{
  89. required: true,
  90. message: '请输入登录密码',
  91. trigger: ['change', 'blur'],
  92. }],
  93. newPassword: [{
  94. required: true,
  95. message: '请再次输入登录密码',
  96. trigger: ['change', 'blur'],
  97. }, {
  98. message: '密码不一致',
  99. trigger: ['change', 'blur'],
  100. validator: (rule, value, callback) => {
  101. return this.form.password == value
  102. },
  103. }],
  104. }
  105. }
  106. },
  107. onReady() {
  108. this.$refs.uForm.setRules(this.rules);
  109. },
  110. onLoad(options) {
  111. if (options != null) {
  112. if (this.$isNotEmpty(options.q)) {
  113. //获取普通二维码的参数
  114. let params= this.$util.getUrlParams(options.q)
  115. this.$cache.put('promotionCode', params.promotionCode)
  116. return
  117. }
  118. if (this.$isNotEmpty(options.scene)) {
  119. let salesmanId=decodeURIComponent(options.scene)
  120. salesmanId && this.$cache.put('salesmanId',salesmanId)
  121. }
  122. }
  123. },
  124. methods: {
  125. back() {
  126. uni.navigateTo({
  127. url: "account-login"
  128. })
  129. },
  130. next() {
  131. this.$refs.uForm.validate(valid => {
  132. if (valid) {
  133. this.register()
  134. }
  135. });
  136. },
  137. codeChange(text) {
  138. this.codeTips = text;
  139. },
  140. async register() {
  141. let params = {
  142. phone: this.form.phone,
  143. secret: md5Libs.md5(this.form.password),
  144. smsId: this.$cache.get('smsId'),
  145. value: this.form.code,
  146. }
  147. if (this.$cache.get('promotionCode')) {
  148. params.agentId=this.$cache.get('promotionCode')
  149. }
  150. if (this.$cache.get('salesmanId')) {
  151. params.salesmanId=this.$cache.get('salesmanId')
  152. }
  153. this.$api.accout.register(params).then(res => {
  154. if (res.success) {
  155. this.$dialog.showModal('注册成功,请登录',false).then(()=>{
  156. this.$cache.remove('promotionCode')
  157. this.$cache.remove('salesmanId')
  158. uni.reLaunch({
  159. url:"/pages/login/account-login?phone="+this.form.phone,
  160. })
  161. })
  162. }
  163. })
  164. },
  165. // 获取验证码
  166. getCode() {
  167. if (this.$isEmpty(this.form.phone)) {
  168. this.$refs.toast.info('请输入手机号')
  169. return
  170. }
  171. if (this.$refs.uCode.canGetCode) {
  172. // 模拟向后端请求验证码
  173. let params = {
  174. phone: this.form.phone
  175. }
  176. let p = this.$u.queryParams(params)
  177. this.$api.sms.send(p).then(res => {
  178. if (res.data.success) {
  179. this.$cache.put('smsId', res.data.id)
  180. this.$refs.toast.info('验证码已发送')
  181. // 通知验证码组件内部开始倒计时
  182. } else {
  183. this.$u.toast(res.data);
  184. }
  185. this.$refs.uCode.start();
  186. })
  187. } else {
  188. this.$refs.toast.info('倒计时结束后再发送')
  189. }
  190. },
  191. }
  192. }
  193. </script>
  194. <style>
  195. page {
  196. background-color: #FFFFFF;
  197. }
  198. </style>
  199. <style lang="scss" scoped>
  200. page {
  201. background-color: #FFFFFF;
  202. }
  203. .btn {
  204. background-color: $color;
  205. color: #FFFFFF;
  206. }
  207. .btn {
  208. background-color: $color;
  209. color: #FFFFFF;
  210. }
  211. .bg {
  212. overflow: hidden;
  213. z-index: 99;
  214. height: 400rpx;
  215. width: 400rpx;
  216. position: absolute;
  217. right: -240rpx;
  218. top: -240rpx;
  219. background-color: $color;
  220. border-radius: 50%;
  221. box-shadow: 0rpx 0rpx 50rpx #e28e3f;
  222. }
  223. .bg1 {
  224. overflow: hidden;
  225. height: 460rpx;
  226. width: 460rpx;
  227. position: absolute;
  228. right: -240rpx;
  229. top: -240rpx;
  230. background-color: $color;
  231. border-radius: 50%;
  232. box-shadow: #c6813b;
  233. }
  234. .back {
  235. position: absolute;
  236. top: var(--status-bar-height);
  237. left: 20rpx;
  238. padding-top: var(--status-bar-height);
  239. }
  240. .content {
  241. height: 96vh;
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: center;
  245. align-items: center;
  246. .top {
  247. width: 76%;
  248. display: flex;
  249. .title {
  250. margin-right: 20rpx;
  251. display: flex;
  252. flex-direction: column;
  253. justify-content: center;
  254. align-items: flex-start;
  255. text-align: left;
  256. text:first-child {
  257. font-weight: 800;
  258. font-size: 50rpx;
  259. color: #000;
  260. margin-bottom: 20rpx;
  261. }
  262. text:last-child {
  263. font-size: 28rpx;
  264. color: #7f7f7f;
  265. }
  266. }
  267. }
  268. }
  269. </style>