register.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view>
  3. <image class="syslogo" mode="widthFix" :src="param.syslogo"></image>
  4. <view class="formbox">
  5. <view class="finput">
  6. <input placeholder="请输入姓名..." @input="bindInput" data-val="realname" :value="userinfo.realname" />
  7. </view>
  8. <view class="finput">
  9. <input type="number" maxlength="11" placeholder="请输入手机号..." @input="bindInput" data-val="mobile" :value="userinfo.mobile" />
  10. </view>
  11. <view class="finput codebox">
  12. <input type="number" maxlength="6" placeholder="请输入短信验证码..." @input="bindInput" data-val="smscode" :value="userinfo.smscode" />
  13. <view class="codeimg" @tap="getSmsCode">{{smsbtn.text}}</view>
  14. </view>
  15. <view class="finput">
  16. <input placeholder="请输入登录密码(至少8位)..." @input="bindInput" data-val="password" :value="userinfo.password" />
  17. </view>
  18. <button class="registerbtn" type="primary" @click="goRegister"> {{ loading ? "注册中...":"立即注册"}} </button>
  19. <view class="pagetip">
  20. <view class="left">
  21. <navigator open-type="switchTab" url="/pages/index/index">返回首页</navigator>
  22. </view>
  23. <view class="right"><text>已有账号,</text>
  24. <navigator open-type="redirect" url="/pages/login/login">立即登录</navigator>
  25. </view>
  26. </view>
  27. <view class="registertip">
  28. <text>注册即表示同意</text>
  29. <navigator open-type="navigate" url="/pages/sinpage/sinpage?op=register">《用户协议》</navigator>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. var that;
  36. export default {
  37. data() {
  38. return {
  39. param: {},
  40. loading: false,
  41. userinfo: {
  42. workerid: 0,
  43. parentid: 0,
  44. realname: "",
  45. mobile: "",
  46. smscode: "",
  47. password: ""
  48. },
  49. smsbtn: {
  50. text: '获取验证码',
  51. status: false,
  52. codeTime: 60
  53. },
  54. smscodemd5: "",
  55. timerId: null
  56. }
  57. },
  58. onLoad: function(option) {
  59. that = this;
  60. that.smscodemd5 = uni.getStorageSync('smscodemd5') || "";
  61. that.$req.ajax({
  62. data: {
  63. do: 'register',
  64. op: 'display'
  65. },
  66. }).then((data) => {
  67. that.param = data.param;
  68. }).catch((err) => {
  69. console.log("err: " + JSON.stringify(err));
  70. });
  71. // #ifdef H5
  72. that.userinfo.workerid = workerid;
  73. that.userinfo.parentid = parentid;
  74. // #endif
  75. },
  76. onShareAppMessage: function(res) {
  77. return {
  78. title: that.param.sharetitle,
  79. path: '/pages/index/index'
  80. }
  81. },
  82. onNavigationBarButtonTap: function(e) {
  83. uni.switchTab({
  84. url: '/pages/index/index'
  85. });
  86. },
  87. methods: {
  88. getSmsCode: function() {
  89. if (that.smsbtn.status == true) {
  90. return true;
  91. }
  92. var myreg = /^((1)+\d{10})$/;
  93. if (!myreg.test(that.userinfo.mobile)) {
  94. uni.showModal({
  95. title: '温馨提示',
  96. content: '手机号格式不对。',
  97. showCancel: false
  98. });
  99. return;
  100. }
  101. that.smsbtn.status = true;
  102. that.$req.ajax({
  103. data: {
  104. do: 'register',
  105. op: 'getsmscode',
  106. mobile: that.userinfo.mobile
  107. }
  108. }).then((data) => {
  109. uni.setStorageSync('smscodemd5', data.smscodemd5);
  110. that.smscodemd5 = data.smscodemd5;
  111. that.timerId = setInterval(() => {
  112. var codeTime = that.smsbtn.codeTime;
  113. codeTime--;
  114. that.smsbtn.codeTime = codeTime;
  115. that.smsbtn.text = codeTime + "S";
  116. if (codeTime < 1) {
  117. clearInterval(that.timerId);
  118. that.smsbtn.text = "重新获取";
  119. that.smsbtn.codeTime = 60;
  120. that.smsbtn.status = false;
  121. }
  122. }, 1000);
  123. }).catch((err) => {
  124. uni.showModal({
  125. title: '温馨提示',
  126. content: err,
  127. showCancel: false
  128. });
  129. that.smsbtn.status = false;
  130. });
  131. return false;
  132. },
  133. goRegister: function() {
  134. that.loading = true;
  135. that.$req.ajax({
  136. data: {
  137. do: 'register',
  138. op: 'goregister',
  139. workerid: that.userinfo.workerid,
  140. parentid: that.userinfo.parentid,
  141. realname: that.userinfo.realname,
  142. mobile: that.userinfo.mobile,
  143. smscode: that.userinfo.smscode,
  144. password: that.userinfo.password,
  145. smscodemd5: that.smscodemd5
  146. }
  147. }).then((data) => {
  148. if (data.regstatus == 2) {
  149. uni.setStorageSync('userinfo', data.user);
  150. uni.showModal({
  151. title: '温馨提示',
  152. content: '注册成功,请尽快完善个人信息。',
  153. showCancel: false,
  154. success: function(res) {
  155. if (res.confirm) {
  156. uni.reLaunch({
  157. url: "/pages/my/my"
  158. })
  159. }
  160. }
  161. });
  162. } else if (data.regstatus == 1) {
  163. uni.showModal({
  164. title: '温馨提示',
  165. content: '注册成功,请耐心等待审核。',
  166. showCancel: false,
  167. success: function(res) {
  168. if (res.confirm) {
  169. uni.reLaunch({
  170. url: "/pages/login/login"
  171. })
  172. }
  173. }
  174. });
  175. }
  176. uni.removeStorageSync('smscodemd5');
  177. that.loading = false;
  178. }).catch((err) => {
  179. uni.showModal({
  180. title: '温馨提示',
  181. content: err,
  182. showCancel: false
  183. });
  184. that.loading = false;
  185. });
  186. },
  187. bindInput: function(e) {
  188. const that = this;
  189. var dataval = e.currentTarget.dataset.val;
  190. that.userinfo[dataval] = e.detail.value;
  191. }
  192. }
  193. }
  194. </script>
  195. <style>
  196. page {
  197. background-color: #FFFFFF;
  198. }
  199. .syslogo {
  200. width: 750rpx;
  201. }
  202. .formbox {
  203. width: 80%;
  204. margin: 0 auto;
  205. }
  206. .finput {
  207. padding-bottom: 30rpx;
  208. }
  209. .finput input {
  210. height: 72rpx;
  211. font-size: 32rpx;
  212. border: 1rpx solid #DDDDDD;
  213. padding: 5rpx 30rpx;
  214. border-radius: 40rpx;
  215. }
  216. .codebox {
  217. position: relative;
  218. }
  219. .codebox .codeimg {
  220. position: absolute;
  221. right: 0rpx;
  222. top: 0rpx;
  223. line-height: 80rpx;
  224. width: 200rpx;
  225. text-align: center;
  226. z-index: 999;
  227. }
  228. .registerbtn {
  229. border-radius: 50rpx;
  230. margin-top: 20rpx;
  231. }
  232. .pagetip {
  233. display: flex;
  234. justify-content: space-between;
  235. padding-top: 30rpx;
  236. color: #888888;
  237. }
  238. .pagetip>view.left {
  239. display: flex;
  240. justify-content: flex-start;
  241. }
  242. .pagetip>view.right {
  243. display: flex;
  244. justify-content: flex-end;
  245. }
  246. .pagetip navigator {
  247. color: #007AFF;
  248. }
  249. .registertip {
  250. display: flex;
  251. justify-content: center;
  252. padding-top: 40rpx;
  253. padding-bottom: 80rpx;
  254. color: #888888;
  255. font-size: 32rpx;
  256. }
  257. .registertip navigator {
  258. color: #007AFF;
  259. }
  260. </style>