register.vue 7.8 KB

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