register.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="register-box">
  3. <view class="register-logo">
  4. <image class="logo-icon" src="../static/img/img_22.png" mode=""></image>
  5. <image class="logo-name" src="../static/img/img_23.png" mode=""></image>
  6. </view>
  7. <view class="register-from">
  8. <view class="from-lable">
  9. <text @click.stop="setRegisterType(1)"
  10. :class="['lable-title' , registerType === 1 ? 'active-lable-title' : '']">手机注册</text>
  11. <text @click.stop="setRegisterType(2)"
  12. :class="['lable-title' , registerType === 2 ? 'active-lable-title' : '']">邮箱注册</text>
  13. </view>
  14. <view class="from-val">
  15. <view class="from-item" v-show="registerType === 1">
  16. <view class="area">
  17. <text class="area-val">{{ from.areaCode ? `+${from.areaCode}` : '国家地区'}}</text>
  18. <image class="select-area" src="../static/img/img_26.png" mode="aspectFit"></image>
  19. </view>
  20. <input v-model="from.user_string" class="item-input" type="text"
  21. placeholder-class="placeholder-class" placeholder="请输入手机号">
  22. </view>
  23. <view class="from-item" v-show="registerType === 2">
  24. <input v-model="from.user_string" class="item-input" type="text"
  25. placeholder-class="placeholder-class" placeholder="请输入邮箱号">
  26. </view>
  27. <view class="from-item">
  28. <input class="item-input" v-model="from.password.code" type="text"
  29. placeholder-class="placeholder-class" placeholder="验证码">
  30. <text class="item-code" @click.stop="getCode()">{{ CodeText }}</text>
  31. </view>
  32. <view class="from-item">
  33. <input class="item-input" v-model="from.password" :type="showPass ? 'number' : 'password'"
  34. placeholder-class="placeholder-class" placeholder="请输入密码">
  35. <view class="pass-icon-box" @click.stop="showPass = !showPass">
  36. <image v-show="!showPass" class="pass-icon" src="../static/img/img_25.png" mode="aspectFit">
  37. </image>
  38. <image v-show="showPass" class="pass-icon" src="../static/img/img_24.png" mode="aspectFit">
  39. </image>
  40. </view>
  41. </view>
  42. <view class="from-item">
  43. <input class="item-input" v-model="from.extension_code" type="number"
  44. placeholder-class="placeholder-class" placeholder="邀请码">
  45. </view>
  46. <view class="from-agreement" @click.stop="readAgreement = !readAgreement">
  47. <view class="agreement-status">
  48. <image v-show="readAgreement" class="read-agreement" src="../static/img/img_28.png"
  49. mode="aspectFit">
  50. </image>
  51. </view>
  52. 我已阅读并同意<text class="agreement-name">《服务与隐私条款》</text>
  53. </view>
  54. <view class="from-submit" @click.stop="submitRegister">注册</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. Api_setRegister,
  63. Api_getEmailCode,
  64. Api_getSmsSend
  65. } from "@/api/index.js"
  66. export default {
  67. name: 'register',
  68. data() {
  69. return {
  70. showPass: false,
  71. readAgreement: false,
  72. registerType: 1, // 1: 手机注册 2 : 邮箱注册
  73. CodeText: '获取验证码',
  74. from: {
  75. user_string: '',
  76. password: '',
  77. areaCode: 86,
  78. code: '',
  79. extension_code: ''
  80. }
  81. };
  82. },
  83. onLoad(opt) {
  84. this.from.extension_code = opt?.extension_code || ''
  85. },
  86. methods: {
  87. setRegisterType(type) {
  88. this.from.user_string = '';
  89. this.registerType = type;
  90. },
  91. getCode() {
  92. if (this.CodeText !== '获取验证码') {
  93. return false
  94. }
  95. let Api_ = '',
  96. obj = {};
  97. obj.user_string = this.from.user_string;
  98. switch (this.registerType) {
  99. case 1:
  100. // 手机号 - 获取验证码
  101. Api_ = Api_getSmsSend;
  102. obj.area_code = this.areaCode;
  103. break;
  104. case 2:
  105. // 邮箱 - 获取验证码
  106. Api_ = Api_getEmailCode;
  107. break;
  108. default:
  109. break;
  110. }
  111. if (Api_) {
  112. Api_(obj).then(res => {
  113. }).catch(err => {
  114. })
  115. let num = 60
  116. this.timeInterval = setInterval(() => {
  117. num--;
  118. if (num <= 0) {
  119. clearInterval(this.timeInterval);
  120. this.CodeText = '重新发送';
  121. return false
  122. };
  123. this.CodeText = `${num}秒后重新发送`;
  124. 123456
  125. }, 1000)
  126. }
  127. },
  128. submitRegister() {
  129. if (this.readAgreement) {
  130. const obj = {
  131. user_string: this.from.user_string,
  132. password: this.from.password,
  133. extension_code: this.from.extension_code,
  134. code: this.from.code,
  135. type: this.registerType === 1 ? 'mogile' : ' email'
  136. };
  137. uni.showLoading()
  138. Api_setRegister(obj).then(res => {
  139. uni.showToast({
  140. title: '注册成功',
  141. icon: 'none'
  142. })
  143. }).catch(err => {
  144. }).finally(() => {
  145. uni.hideLoading()
  146. })
  147. } else {
  148. uni.showToast({
  149. title: '请先阅读协议',
  150. icon: 'none'
  151. })
  152. }
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .register-box {
  159. width: 100%;
  160. min-height: 100vh;
  161. background-color: #0D9780;
  162. padding: 126rpx 37rpx 165rpx;
  163. .register-logo {
  164. width: 100%;
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. .logo-icon {
  169. width: 87rpx;
  170. height: 85rpx;
  171. }
  172. .logo-name {
  173. margin-left: 8rpx;
  174. width: 127rpx;
  175. height: 50rpx;
  176. }
  177. }
  178. .register-from {
  179. width: 100%;
  180. background-color: #fff;
  181. border-radius: 20rpx;
  182. padding-bottom: 63rpx;
  183. // <view class="from-lable">
  184. // <text class="lable-title">手机注册</text>
  185. // <text class="lable-title">邮箱注册</text>
  186. // </view>
  187. .from-lable {
  188. width: 100%;
  189. display: flex;
  190. align-items: stretch;
  191. .lable-title {
  192. flex: 1;
  193. flex-shrink: 0;
  194. height: 114rpx;
  195. line-height: 114rpx;
  196. text-align: center;
  197. font-size: 34rpx;
  198. font-family: PingFang SC, PingFang SC-Bold;
  199. font-weight: 700;
  200. color: #1a1a1a;
  201. letter-spacing: 0.68rpx;
  202. border-bottom: 1rpx solid #e6e6e6;
  203. }
  204. .active-lable-title {
  205. color: #20b482;
  206. border-bottom: 2rpx solid #20b482;
  207. }
  208. }
  209. .from-val {
  210. width: 100%;
  211. padding: 0 43rpx;
  212. .from-item {
  213. width: 100%;
  214. height: 115rpx;
  215. border-bottom: 1rpx solid #e6e6e6;
  216. padding-top: 25rpx;
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. // <view class="area">
  221. // <text class="area-val">国家地区</text>
  222. // <image class="select-area" src="../static/img/img_26.png" mode="aspectFit"></image>
  223. // </view>
  224. .area {
  225. min-width: 160rpx;
  226. .area-val {
  227. font-size: 28rpx;
  228. font-family: PingFang SC, PingFang SC-Regular;
  229. font-weight: 400;
  230. color: #b3b3b3;
  231. letter-spacing: 0.56rpx;
  232. }
  233. .select-area {
  234. width: 20rpx;
  235. height: 20rpx;
  236. }
  237. }
  238. .item-input {
  239. flex-shrink: 0;
  240. font-size: 28rpx;
  241. flex: 1;
  242. height: 100%;
  243. border: none;
  244. font-family: PingFang SC, PingFang SC-Regular;
  245. font-weight: 400;
  246. color: #666666;
  247. letter-spacing: 0.56rpx;
  248. }
  249. .placeholder-class {
  250. font-size: 28rpx;
  251. font-family: PingFang SC, PingFang SC-Regular;
  252. font-weight: 400;
  253. color: #b3b3b3;
  254. letter-spacing: 0.56rpx;
  255. }
  256. .item-code {
  257. font-size: 28rpx;
  258. font-family: PingFang SC, PingFang SC-Regular;
  259. font-weight: 400;
  260. color: #1cac7b;
  261. line-height: 38rpx;
  262. letter-spacing: 0.56rpx;
  263. }
  264. .pass-icon-box {
  265. width: 88rpx;
  266. height: 88rpx;
  267. display: flex;
  268. justify-content: flex-end;
  269. align-items: center;
  270. .pass-icon {
  271. width: 42rpx;
  272. height: 42rpx;
  273. }
  274. }
  275. }
  276. // .<view class="from-agreement">
  277. // <view class="agreement-status">
  278. // </view>
  279. // 我已阅读并同意<text class="agreement-name">《服务与隐私条款》</text>
  280. // </view>\
  281. .from-agreement {
  282. width: 100%;
  283. padding: 52rpx 0;
  284. display: flex;
  285. align-items: center;
  286. font-size: 24rpx;
  287. font-family: PingFang SC, PingFang SC-Regular;
  288. font-weight: 400;
  289. color: #666666;
  290. .agreement-status {
  291. width: 29rpx;
  292. height: 29rpx;
  293. border: 1px solid #3b6afd;
  294. margin-right: 15rpx;
  295. display: flex;
  296. justify-content: center;
  297. align-items: center;
  298. .read-agreement {
  299. width: 19rpx;
  300. height: 14rpx;
  301. }
  302. }
  303. .agreement-name {
  304. color: #3b6afd;
  305. }
  306. }
  307. .from-submit {
  308. width: 100%;
  309. height: 90rpx;
  310. text-align: center;
  311. line-height: 90rpx;
  312. background: #00b99a;
  313. border-radius: 10rpx;
  314. font-size: 32rpx;
  315. font-family: PingFang SC, PingFang SC-Regular;
  316. font-weight: 400;
  317. color: #ffffff;
  318. letter-spacing: 0.64rpx;
  319. }
  320. }
  321. }
  322. }
  323. </style>