register.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <view class="pageTop x-c">
  5. <view class="loginBox">
  6. <view class="login-item">
  7. <view class="input-account">
  8. <input v-model="userName" placeholder="手机号" type="number" />
  9. </view>
  10. <view class="line"></view>
  11. </view>
  12. <view class="login-item">
  13. <view class="input-pwd">
  14. <input v-model="password" placeholder="密码(6-15个字符)" type="password" />
  15. </view>
  16. <view class="line"></view>
  17. </view>
  18. <view class="login-item">
  19. <view class="input-pwd">
  20. <input v-model="password1" placeholder="确认密码" type="password" />
  21. </view>
  22. <view class="line"></view>
  23. </view>
  24. <!-- <view class="login-item">
  25. <view class="input-yzcode x-bc">
  26. <input v-model="yzcode" placeholder="验证码" type="number" ></input>
  27. <view style="color:#666">获取验证码</view>
  28. </view>
  29. <view class="line"></view>
  30. </view> -->
  31. <view class="btns">
  32. <view class="login-btn" @click="doRegister">注册</view>
  33. </view>
  34. </view>
  35. <view class="checkbox">
  36. <view class="checkbox-icon" @tap="handleAgree">
  37. <image src="/static/images/radio_default.png" v-show="!agree"></image>
  38. <image src="/static/images/radio_choose.png" v-show="agree"></image>
  39. </view>
  40. <view>我已阅读并同意<text @tap="goToWeb(0)">《用户协议》</text><text @tap="goToWeb(1)">《隐私政策》</text> 并使用本机号码登录
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. register,
  50. loginByApp
  51. } from '@/api/login'
  52. // import { register,login } from '@/api/user'
  53. export default {
  54. components: {},
  55. data() {
  56. return {
  57. userName: "",
  58. password: "",
  59. password1: "",
  60. registrationID: "",
  61. yzcode: "",
  62. aback: true,
  63. agree: false,
  64. }
  65. },
  66. onLoad(option) {
  67. let that = this;
  68. uni.$on('getRegistrationID', function(data) {
  69. that.registrationID = data;
  70. });
  71. },
  72. onShow() {
  73. this.$getRegistrationID();
  74. },
  75. onUnload() {
  76. uni.$off('getRegistrationID');
  77. },
  78. mounted() {
  79. },
  80. methods: {
  81. doRegister() {
  82. if (this.$isEmpty(this.userName)) {
  83. uni.showToast({
  84. title: "请输入帐号",
  85. icon: 'none',
  86. });
  87. return
  88. }
  89. if (this.$isEmpty(this.password)) {
  90. uni.showToast({
  91. title: "请输入密码",
  92. icon: 'none',
  93. });
  94. return
  95. }
  96. if (this.password != this.password1) {
  97. uni.showToast({
  98. title: "两次密码输入不一致",
  99. icon: 'none'
  100. });
  101. }
  102. if (!this.agree) {
  103. uni.showToast({
  104. title: "请同意相关协议",
  105. icon: 'none'
  106. });
  107. return
  108. }
  109. var data = {
  110. phone: this.userName,
  111. password: this.password,
  112. // jpushId: this.registrationID || uni.getStorageSync("registrationID"),
  113. // loginType: 1
  114. };
  115. var that = this;
  116. uni.showLoading({
  117. title: "注册中..."
  118. });
  119. register(data).then(res => {
  120. if (res.code == 200) {
  121. console.log("注册好了")
  122. // uni.setStorageSync('AppToken',res.data.token);
  123. // this.$Router.pushTab({name: 'home'});
  124. this.doLogin();
  125. } else {
  126. uni.hideLoading()
  127. uni.showToast({
  128. title: res.msg,
  129. icon: 'none'
  130. });
  131. }
  132. },
  133. rej => {}
  134. );
  135. },
  136. doLogin() {
  137. var data = {
  138. phone: this.userName,
  139. password: this.password,
  140. // jpushId: this.registrationID || uni.getStorageSync("registrationID"),
  141. loginType: 1
  142. };
  143. var that = this;
  144. loginByApp(data).then(res => {
  145. uni.hideLoading()
  146. if (res.code == 200) {
  147. uni.setStorageSync('AppToken', res.token);
  148. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  149. uni.$emit('refreshIM');
  150. uni.$emit('showHealthButler');
  151. uni.reLaunch({
  152. url: '/pages/list/index',
  153. animationType: 'pop-in',
  154. animationDuration: 100
  155. })
  156. } else {
  157. uni.showToast({
  158. title: res.msg,
  159. icon: 'none'
  160. });
  161. }
  162. },
  163. rej => {}
  164. );
  165. },
  166. getRegistrationID() {
  167. // #ifdef APP-PLUS
  168. // #endif
  169. },
  170. handleAgree() { // 同意
  171. this.agree = !this.agree
  172. },
  173. goToWeb(index) {
  174. uni.setStorageSync('url', index == 0 ? "https://userapp.his.cdwjyyh.com/web/userAgreement" :
  175. "https://userapp.his.cdwjyyh.com/web/privacyPolicy");
  176. uni.navigateTo({
  177. url: "/pages/index/h5"
  178. })
  179. },
  180. },
  181. }
  182. </script>
  183. <style lang="scss">
  184. page {
  185. background-color: #ffffff;
  186. }
  187. .content {
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. height: calc(100vh);
  192. width: 100%;
  193. justify-content: space-between;
  194. //padding-top: calc(100% - 32vh);
  195. }
  196. .pageTop {
  197. display: flex;
  198. flex-direction: column;
  199. width: 100%;
  200. }
  201. .content .head {
  202. text-align: center;
  203. width: 100%;
  204. height: 100rpx;
  205. background-size: cover;
  206. box-sizing: border-box;
  207. font-size: 36rpx;
  208. font-weight: bold;
  209. color: #666;
  210. }
  211. .content .head image {
  212. width: 150rpx;
  213. height: 150rpx;
  214. border-radius: 10rpx;
  215. box-shadow: 0px 0px 20rpx rgba(0, 0, 0, 0.2);
  216. }
  217. .title {
  218. color: #141414;
  219. margin: 50upx 0upx 30upx 0rpx;
  220. font-size: 38rpx;
  221. font-weight: 500;
  222. }
  223. .desc {
  224. color: #686866;
  225. padding: 0 0 30rpx 0rpx;
  226. font-size: 28rpx;
  227. }
  228. .loginBox {
  229. padding: 10px 10px 30rpx;
  230. width: calc(100% - 20px);
  231. margin-top: 0rpx;
  232. background: #FDFDFD;
  233. //box-shadow: 0rpx 4rpx 27rpx 0rpx rgba(155,155,155,0.25);
  234. border-radius: 7rpx;
  235. }
  236. .login-item p {
  237. text-align: left;
  238. }
  239. .line {
  240. height: 0.5rpx;
  241. background-color: #efefef;
  242. margin-top: 10rpx;
  243. }
  244. .input-account {
  245. margin-top: 20rpx;
  246. margin-bottom: 0rpx;
  247. border-radius: 40rpx;
  248. border: solid 0rpx #efefef;
  249. height: 80rpx;
  250. width: 100%;
  251. // background: url(/static/account.png) no-repeat 0 center;
  252. background-size: 30rpx 30rpx;
  253. background-position: 30rpx;
  254. }
  255. .input-yzcode {
  256. margin-top: 20rpx;
  257. margin-bottom: 0rpx;
  258. border-radius: 40rpx;
  259. border: solid 0rpx #efefef;
  260. height: 80rpx;
  261. width: 100%;
  262. // background: url(/static/image/login/cz_icon.png) no-repeat 0 center;
  263. background-size: 30rpx 30rpx;
  264. background-position: 30rpx;
  265. }
  266. .input-pwd {
  267. margin-top: 40rpx;
  268. margin-bottom: 20rpx;
  269. border-radius: 40rpx;
  270. border: solid 0rpx #efefef;
  271. height: 80rpx;
  272. width: 100%;
  273. // background: url(/static/password.png) no-repeat 0 center;
  274. background-size: 30rpx 30rpx;
  275. background-position: 30rpx;
  276. }
  277. input {
  278. margin-left: 80rpx;
  279. height: 80rpx;
  280. line-height: 80rpx
  281. }
  282. .footer {
  283. color: #686866;
  284. width: 100%;
  285. position: fixed;
  286. text-align: center;
  287. bottom: 60upx;
  288. font-size: 28rpx;
  289. }
  290. .btns {
  291. margin: 50rpx 0rpx;
  292. margin-bottom: 0rpx;
  293. }
  294. .login-btn {
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. width: 100%;
  299. height: 80rpx;
  300. background: linear-gradient(to right, #FF5C03 0%, #FF5C03 100%);
  301. background: -moz-linear-gradient(to right, #FF5C03 0%, #FF5C03 100%);
  302. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  303. border-radius: 40rpx;
  304. font-size: 30rpx;
  305. font-family: PingFang SC;
  306. font-weight: 500;
  307. color: rgba(255, 255, 255, 1);
  308. }
  309. .reg-box {
  310. padding-bottom: 20rpx;
  311. margin: 0 10px;
  312. .reg-btn {
  313. font-size: 16px;
  314. color: #FF5C03;
  315. }
  316. }
  317. .pageBottom {
  318. height: 260rpx;
  319. width: 75%;
  320. display: flex;
  321. flex-direction: column;
  322. }
  323. .tips {
  324. color: #999;
  325. font-size: 36rpx;
  326. }
  327. .menu {
  328. margin-top: 30rpx;
  329. image {
  330. width: 78rpx;
  331. height: 78rpx;
  332. }
  333. }
  334. .checkbox {
  335. margin: 20rpx;
  336. margin-top: 16rpx;
  337. display: flex;
  338. flex-direction: row;
  339. align-items: flex-start;
  340. justify-content: flex-start;
  341. font-family: PingFang SC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 26rpx;
  344. color: #999999;
  345. line-height: 38rpx;
  346. text-align: left;
  347. text {
  348. color: #FF5C03;
  349. }
  350. &-icon {
  351. flex-shrink: 0;
  352. margin-right: 12rpx;
  353. image {
  354. height: 24rpx;
  355. width: 24rpx;
  356. }
  357. }
  358. }
  359. </style>