register.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <!-- 注册 -->
  2. <template>
  3. <view class="container flex-items flex-column">
  4. <global-loading />
  5. <view class="login-logoBox">
  6. <image class="login-logo" src="../../static/images/origin/loginLogo.png"></image>
  7. </view>
  8. <view>
  9. <view class="iphoneNum-box flex-row-plus flex-items">
  10. <view>
  11. <image class="loginIcon" src="../../static/images/origin/phone.png"></image>
  12. </view>
  13. <view style="margin-left: 40rpx;">
  14. <input
  15. v-model="phone" class="iphoneNum-inputbox" placeholder-class="iphoneNum-input" type="number"
  16. maxlength="11" placeholder="请输入您的手机号"
  17. />
  18. </view>
  19. </view>
  20. <view class="flex-row-plus mar-top-20">
  21. <view class="code-box">
  22. <view>
  23. <image class="loginIcon" src="../../static/images/origin/code.png"></image>
  24. </view>
  25. <view style="margin-left: 40rpx;">
  26. <input
  27. v-model="RegisterQuery.code" :maxlength="4" class="codeNum-inputbox" placeholder-class="codeNum-input"
  28. placeholder="请输入验证码"
  29. />
  30. </view>
  31. </view>
  32. <view :class="disabled === true ? 'on' : ''" :disabled="disabled" class="getcode" @click="codede">
  33. {{ text }}
  34. </view>
  35. </view>
  36. </view>
  37. <view class="registerBut" @click="onregister">注册</view>
  38. <view class="flex-row-plus mar-top-30">
  39. <text class="font-color-C5AA7B">已有账号,</text>
  40. <view class="font-color-C5AA7B" @click="gologin">去登录</view>
  41. </view>
  42. <view class="agreement">
  43. <image v-if="!agreement" src="../../static/images/origin/none.png" mode="" @click="agreement = true"></image>
  44. <image v-else src="../../static/images/origin/solid.png" mode="" @click="agreement = false"></image>
  45. <text class="font-color-999">注册即代表同意</text>
  46. <text class="font-color-C5AA7B" @click="protocol('app_user_agreement')">《APP用户服务协议》</text>和
  47. <text class="font-color-C5AA7B" @click="protocol('app_privacy_agreement')">《APP个人隐私协议》</text>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import sendVerifyCode from '@/mixins/SendVerifyCode'
  53. const NET = require('../../utils/request')
  54. const API = require('../../config/api')
  55. export default {
  56. mixins: [ sendVerifyCode ],
  57. data() {
  58. return {
  59. getCodeisWaiting: false,
  60. // 注册
  61. phone: '',
  62. RegisterQuery: {
  63. account: '',
  64. code: ''
  65. },
  66. // 获取验证码
  67. VerifyQuery: {
  68. phone: '',
  69. type: ''
  70. },
  71. agreement: false
  72. }
  73. },
  74. onLoad() {
  75. },
  76. methods: {
  77. // 注册账号
  78. getRegister() {
  79. const phoneCodeVerification = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
  80. if (this.phone == '') {
  81. uni.showToast({
  82. title: '请输入手机号!',
  83. duration: 2000,
  84. icon: 'none'
  85. })
  86. } else if (!phoneCodeVerification.test(this.phone)) {
  87. uni.showToast({
  88. title: '请输入正确的手机号!',
  89. duration: 2000,
  90. icon: 'none'
  91. })
  92. } else if (this.RegisterQuery.code == '') {
  93. uni.showToast({
  94. title: '请获取验证码!',
  95. duration: 2000,
  96. icon: 'none'
  97. })
  98. } else if (!this.agreement) {
  99. uni.showToast({
  100. title: '请先阅读并同意《用户服务协议和个人隐私协议》',
  101. duration: 2000,
  102. icon: 'none'
  103. })
  104. } else {
  105. // uni.showLoading({
  106. // mask: true,
  107. // title: '正在注册...',
  108. // duration: 2000,
  109. // })
  110. NET.request(API.Login, {
  111. type: 1,
  112. phone: this.phone,
  113. verificationCode: this.RegisterQuery.code
  114. }, 'POST').then((res) => {
  115. uni.hideLoading()
  116. uni.showToast({
  117. title: '注册成功!',
  118. duration: 2000,
  119. icon: 'none'
  120. })
  121. const item = res.data
  122. uni.setStorageSync('storage_key', item)
  123. setTimeout(function () {
  124. uni.switchTab({
  125. url: '../../pages/tabbar/user/index'
  126. })
  127. }, 600)
  128. // uni.navigateTo({
  129. // url: 'accountLogin'
  130. // })
  131. })
  132. .catch((res) => {
  133. uni.showToast({
  134. title: res.data.message,
  135. duration: 2000,
  136. icon: 'none'
  137. })
  138. })
  139. }
  140. },
  141. // 获取验证码
  142. getVerify() {
  143. const phoneCodeVerification = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
  144. if (this.phone == '') {
  145. uni.showToast({
  146. title: '请输入手机号!',
  147. duration: 2000,
  148. icon: 'none'
  149. })
  150. } else if (!phoneCodeVerification.test(this.phone)) {
  151. uni.showToast({
  152. title: '请输入正确的手机号!',
  153. duration: 2000,
  154. icon: 'none'
  155. })
  156. } else {
  157. this.VerifyQuery.phone = this.phone
  158. NET.request(API.Verify, {
  159. phone: this.VerifyQuery.phone
  160. }, 'GET').then((res) => {
  161. this.sendCode()
  162. })
  163. .catch((res) => {
  164. uni.showToast({
  165. title: res.data.message,
  166. icon: 'none',
  167. duration: 1000
  168. })
  169. })
  170. }
  171. },
  172. // 注册
  173. onregister() {
  174. this.getRegister()
  175. },
  176. // 获取验证码
  177. codede() {
  178. this.getVerify()
  179. },
  180. getCode() {
  181. uni.hideKeyboard()
  182. if (this.getCodeisWaiting) {
  183. return
  184. }
  185. if (this.phone == '' || this.phone == null) {
  186. uni.showToast({
  187. title: '手机号不能为空',
  188. icon: 'none'
  189. })
  190. return false
  191. } else if (!/^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(this.phone)) {
  192. uni.showToast({
  193. title: '输入的手机号错误',
  194. icon: 'none'
  195. })
  196. return false
  197. }
  198. this.getCodeisWaiting = true
  199. },
  200. // 跳转登录
  201. gologin() {
  202. uni.navigateTo({
  203. url: 'login'
  204. })
  205. },
  206. // 多商户用户协议
  207. protocol(type) {
  208. uni.navigateTo({
  209. url: 'protocol?type=' + type
  210. })
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .container {
  217. background-color: #FFFFFF;
  218. .login-logoBox {
  219. margin: 100rpx 0;
  220. .login-logo {
  221. width: 200rpx;
  222. height: 166rpx;
  223. }
  224. }
  225. .iphoneNum-box {
  226. border-bottom: 1rpx solid #F3F4F5;
  227. height: 100rpx;
  228. width: 600rpx;
  229. .loginIcon {
  230. width: 40rpx;
  231. height: 53rpx;
  232. }
  233. input {
  234. font-size: 28rpx;
  235. }
  236. .iphoneNum-input {
  237. color: #999999;
  238. font-size: 28rpx;
  239. font-weight: 400;
  240. }
  241. .iphoneNum-inputbox {
  242. width: 400rpx;
  243. }
  244. }
  245. .code-box {
  246. border-bottom: 1rpx solid #F3F4F5;
  247. height: 100rpx;
  248. width: 350rpx;
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: space-between;
  252. align-items: center;
  253. .loginIcon {
  254. width: 44rpx;
  255. height: 50rpx;
  256. }
  257. input {
  258. font-size: 28rpx;
  259. }
  260. .code-lab {
  261. width: 200rpx;
  262. }
  263. .codeNum-input {
  264. color: #999999;
  265. font-size: 28rpx;
  266. font-weight: 400;
  267. width: 300rpx;
  268. }
  269. .codeNum-inputbox {
  270. width: 300rpx;
  271. }
  272. }
  273. .getcode {
  274. background-color: #C5AA7B;
  275. height: 100rpx;
  276. width: 230rpx;
  277. display: flex;
  278. flex-direction: row;
  279. justify-content: center;
  280. align-items: center;
  281. margin-left: 20rpx;
  282. color: #FFFFFF;
  283. }
  284. .getcodeActive {
  285. background-color: #DDDDDD;
  286. height: 100rpx;
  287. width: 220rpx;
  288. border-radius: 44rpx;
  289. display: flex;
  290. flex-direction: row;
  291. justify-content: center;
  292. align-items: center;
  293. margin-left: 20rpx;
  294. color: #333333;
  295. }
  296. .registerBut {
  297. background: #333333;
  298. color: #FFFFFF;
  299. height: 88rpx;
  300. width: 600rpx;
  301. text-align: center;
  302. line-height: 88rpx;
  303. margin-top: 140rpx;
  304. }
  305. .agreement {
  306. margin: 100rpx 50rpx;
  307. line-height: 50rpx;
  308. image {
  309. width: 34rpx;
  310. height: 34rpx;
  311. margin-right: 15upx;
  312. }
  313. }
  314. }
  315. </style>