login-register.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="wrap">
  3. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  4. @clickLeft="toBack">
  5. <view class="nav-title">
  6. <text>{{title}}</text>
  7. </view>
  8. </uni-nav-bar>
  9. <view class="container">
  10. <view class="view-flex-inline"
  11. style="padding-left: 50rpx;font-size: 1.2rem;margin-top: 50rpx;margin-bottom: 50rpx;">帐号密码注册</view>
  12. <view class="content">
  13. <view class="top">
  14. <view class="cell">
  15. <uni-easyinput v-model="username" placeholder="输入手机号"></uni-easyinput>
  16. <view v-if="showPhoneTips"
  17. style="padding-left: 2px;padding-top: 4px;color: orangered;font-size: 0.5rem;">手机号不符合要求
  18. </view>
  19. </view>
  20. <view class="cell">
  21. <uni-easyinput type="password" v-model="password" placeholder="输入登录密码"
  22. @focus="passwordInputFocus"></uni-easyinput>
  23. <view v-if="showPassowrdTips"
  24. style="padding-left: 2px;padding-top: 4px;color: orangered;font-size: 0.5rem;">
  25. 密码只能包含字母、数字及特殊字符.@?!$#%*&</view>
  26. </view>
  27. <view class="cell">
  28. <uni-easyinput type="password" v-model="againPassword" placeholder="再次输入登录密码"></uni-easyinput>
  29. <view v-if="passowrdDifferentTips"
  30. style="padding-left: 2px;padding-top: 4px;color: orangered;font-size: 0.5rem;">
  31. 两次输入的密码不一样,请重新输入</view>
  32. </view>
  33. <view class="view-flex-inline" style="padding-left: 50rpx;padding-right: 50rpx;margin-top: 40px;">
  34. <view>
  35. <checkbox-group @change="checkboxChange">
  36. <label>
  37. <checkbox value="0" color="#FF0000" style="transform:scale(0.7);" />
  38. </label>
  39. </checkbox-group>
  40. </view>
  41. <view class="agree">
  42. 我已阅读并同意
  43. <text class="a" @click="userAgreement">《用户协议》</text>
  44. <text class="a" @click="privacyPolicy">《隐私政策》</text>
  45. </view>
  46. </view>
  47. <view class="cell">
  48. <button class="submit" @click="submit">注册</button>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import md5 from '@/utils/md5.js'
  57. import uIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
  58. import {
  59. tenantId
  60. } from '@/common/setting.js'
  61. import {
  62. devUrl,
  63. prodUrl,
  64. contentType
  65. } from '@/common/setting'
  66. export default {
  67. components: {
  68. uIcons,
  69. },
  70. data() {
  71. return {
  72. title: '注册',
  73. // tenantId: '000000',
  74. username: '',
  75. password: '',
  76. againPassword: '',
  77. agreeCheck: false,
  78. showPassowrdTips: false,
  79. passowrdDifferentTips: false,
  80. showPhoneTips: false,
  81. };
  82. },
  83. onLoad() {
  84. console.log("register "+tenantId)
  85. },
  86. methods: {
  87. //返回上一页
  88. toBack() {
  89. uni.navigateBack({
  90. delta: 1
  91. })
  92. },
  93. checkboxChange: function(e) {
  94. var values = e.detail.value;
  95. if (values.includes("0")) {
  96. this.agreeCheck = true;
  97. } else {
  98. this.agreeCheck = false;
  99. }
  100. },
  101. submit() {
  102. var that = this;
  103. let validateCheck = true;
  104. this.showPhoneTips = false;
  105. if (this.username != null && this.username != '') {
  106. let reg2 = /^1[3456789]\d{9}$/;
  107. if (!reg2.test(this.username)) {
  108. this.showPhoneTips = true;
  109. validateCheck = false;
  110. }
  111. } else {
  112. this.showPhoneTips = true;
  113. validateCheck = false;
  114. }
  115. this.showPassowrdTips = false;
  116. if (this.password != null && this.password != '') {
  117. let reg = /[\a-\z\A-\Z0-9\.\@\?\!\$\#\%\*\&]/g;
  118. let pw = this.password;
  119. let value = pw.replace(reg, '');
  120. if (value != '') {
  121. this.showPassowrdTips = true;
  122. validateCheck = false;
  123. }
  124. } else {
  125. this.showPassowrdTips = true;
  126. validateCheck = false;
  127. }
  128. this.passowrdDifferentTips = false;
  129. if (this.againPassword != null && this.againPassword != '') {
  130. if (this.againPassword !== this.password) {
  131. this.passowrdDifferentTips = true;
  132. validateCheck = false;
  133. }
  134. } else {
  135. this.passowrdDifferentTips = true;
  136. validateCheck = false;
  137. }
  138. if (validateCheck) {
  139. if (this.agreeCheck) {
  140. this.$u.api.userReg(tenantId, this.username, md5(this.password)).then(data => {
  141. uni.showModal({
  142. content: '注册成功',
  143. showCancel: false,
  144. success(res) {
  145. if (res.confirm) {
  146. that.toBack();
  147. }
  148. }
  149. });
  150. }).catch(err => {
  151. console.log(err)
  152. this.$u.func.showToast({
  153. title: '注册失败' + err,
  154. })
  155. })
  156. } else {
  157. this.$u.func.showToast({
  158. title: '请认真阅读用户协议及隐私政策后勾选同意',
  159. })
  160. }
  161. }
  162. },
  163. passwordInputFocus(e) {
  164. console.log(JSON.stringify(e))
  165. this.showPassowrdTips = true;
  166. },
  167. userAgreement() {
  168. var url = '/pages/user/user-agreement';
  169. uni.navigateTo({
  170. url: url
  171. })
  172. },
  173. privacyPolicy() {
  174. var url = '/pages/user/privacy-policy';
  175. uni.navigateTo({
  176. url: url
  177. })
  178. },
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. .container {
  184. min-height: 100vh;
  185. overflow: hidden;
  186. .set-icon {
  187. vertical-align: middle;
  188. width: 41rpx;
  189. height: auto;
  190. margin-right: 35rpx;
  191. }
  192. }
  193. .content {
  194. display: flex;
  195. flex-direction: column;
  196. justify-content: flex-start;
  197. align-items: center;
  198. height: 90vh;
  199. width: 100%;
  200. .top {
  201. width: 100%;
  202. }
  203. .logo {
  204. display: block;
  205. width: 160rpx;
  206. height: auto;
  207. margin: 0 auto 40rpx;
  208. }
  209. .cell {
  210. width: 100%;
  211. padding: 0 50rpx;
  212. box-sizing: border-box;
  213. margin-top: 50rpx;
  214. margin-bottom: 50rpx;
  215. .name {
  216. font-size: 22rpx;
  217. font-family: Source Han Sans CN;
  218. font-weight: 400;
  219. color: #3e4a59;
  220. line-height: 30rpx;
  221. opacity: 0.72;
  222. }
  223. .input-box {
  224. padding: 30rpx 0;
  225. border-bottom: 2rpx solid #f6f6f6;
  226. display: flex;
  227. align-items: center;
  228. .code {
  229. font-size: 22rpx;
  230. font-family: Source Han Sans CN;
  231. font-weight: 400;
  232. color: #0d0d0d;
  233. line-height: 30rpx;
  234. text {
  235. color: #14b9c8;
  236. }
  237. }
  238. .ipt {
  239. flex: 1;
  240. // height: 24rpx;
  241. font-size: 24rpx;
  242. padding-left: 10rpx;
  243. }
  244. .hold {
  245. font-size: 24rpx;
  246. font-family: Source Han Sans CN;
  247. font-weight: 400;
  248. color: #3e4a59;
  249. line-height: 30px;
  250. opacity: 0.45;
  251. }
  252. }
  253. }
  254. .agree {
  255. // margin: 27rpx 95rpx 0;
  256. font-size: 22rpx;
  257. font-family: Adobe Heiti Std;
  258. font-weight: normal;
  259. color: black;
  260. line-height: 34rpx;
  261. .a {
  262. color: royalblue
  263. }
  264. }
  265. .submit {
  266. margin-top: 40rpx;
  267. border: none;
  268. width: 100%;
  269. height: 80rpx;
  270. line-height: 80rpx;
  271. box-sizing: border-box;
  272. border-radius: 10rpx;
  273. // font-size: 36rpx;
  274. // background: linear-gradient(to right, #, #3976f7);
  275. background-color: orangered;
  276. color: #ffffff;
  277. &::after {
  278. content: none;
  279. }
  280. &::before {
  281. content: none;
  282. }
  283. // &[disabled='true'] {
  284. // background: linear-gradient(to right, #48b1f8, #3976f7);
  285. // font-size: 36rpx;
  286. // font-family: Source Han Sans CN;
  287. // font-weight: 500;
  288. // color: #ffffff;
  289. // }
  290. }
  291. .tip {
  292. margin-top: 30rpx;
  293. text-align: center;
  294. font-size: 22rpx;
  295. font-family: Adobe Heiti Std;
  296. font-weight: normal;
  297. color: #cacaca;
  298. line-height: 34rpx;
  299. }
  300. .change {
  301. margin-top: 20rpx;
  302. text-align: center;
  303. font-size: 22rpx;
  304. font-family: Adobe Heiti Std;
  305. font-weight: normal;
  306. color: #14b9c8;
  307. line-height: 34rpx;
  308. }
  309. .tag {
  310. display: flex;
  311. justify-content: center;
  312. align-items: center;
  313. font-size: 22rpx;
  314. font-family: Adobe Heiti Std;
  315. font-weight: normal;
  316. color: #9f9f9f;
  317. line-height: 34rpx;
  318. &::before {
  319. content: '';
  320. display: block;
  321. width: 160rpx;
  322. height: 1px;
  323. background: #d8d8d8;
  324. opacity: 0.86;
  325. }
  326. &::after {
  327. content: '';
  328. display: block;
  329. width: 160rpx;
  330. height: 1px;
  331. background: #d8d8d8;
  332. opacity: 0.86;
  333. }
  334. }
  335. .chat-arr {
  336. margin-top: 50rpx;
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. .icon {
  341. width: 73rpx;
  342. height: 73rpx;
  343. }
  344. }
  345. }
  346. </style>