register.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="container edit_wrap">
  3. <view class="flex justify-between " style="padding: 40rpx 30rpx;;box-sizing: border-box;">
  4. <view class="" style="font-size: 38rpx;">
  5. <text class="text-bold text-black">注册认证</text>
  6. </view>
  7. <view class="text-red" style="padding-top: 12rpx;">
  8. <text style="font-size: 38rpx;">1</text>
  9. <text class="text-df">/3</text>
  10. </view>
  11. </view>
  12. <form>
  13. <view class="form_group">
  14. <text class="red">*</text>
  15. <text class="sex">姓名:</text>
  16. <input placeholder="请与物业登记处保持一致" placeholder-class="placeholder_style" type="text"
  17. class="placeholder_style" @input="nameInput">
  18. </input>
  19. </view>
  20. <view class="form_group">
  21. <text class="red">*</text>
  22. <text class="sex">手机:</text>
  23. <input placeholder="请与物业登记处保持一致" v-model="tel" placeholder-class="placeholder_style" type="number"
  24. maxlength="11" class="placeholder_style">
  25. </input>
  26. </view>
  27. <view class="form_group">
  28. <text class="red">*</text>
  29. <text class="sex">身份证:</text>
  30. <input placeholder="请输入身份证号" v-model="idcard" placeholder-class="placeholder_style" type="number"
  31. maxlength="11" class="placeholder_style">
  32. </input>
  33. </view>
  34. <view class="form_group">
  35. <text class="red">*</text>
  36. <text class="sex">验证码:</text>
  37. <input type="text" class="sendmsg_input" @input="verifyCodeInput"></input>
  38. <view style="position: relative;bottom: -10rpx;">
  39. <button class="right code_btn " @tap="sendMsgButton" :disabled="disabled"
  40. :style="'background-color:' + color">{{text}}</button>
  41. </view>
  42. </view>
  43. <view style="display:flex;margin:20rpx 20rpx">
  44. <u-checkbox v-model="isCheck" active-color="#2f7ff5">
  45. </u-checkbox>
  46. <view style="display: flex;" class="text-sm">
  47. <text>请阅读并同意</text>
  48. <navigator class="text-red" :url="webviewUrl1">《隐私协议》</navigator>
  49. <text>和</text>
  50. <navigator class="text-red" :url="webviewUrl2">《用户协议》</navigator>
  51. </view>
  52. </view>
  53. <view class="tips">
  54. <text style="padding-left: 40rpx;">认证后用户可享受更多权益,随时获取到您所在小区的动态</text>
  55. </view>
  56. <button style="border-radius: 0;" :style="{bottom:safeAreaBottom+'rpx'}" open-type="getUserInfo" @getuserinfo="showDialogBtn"
  57. class=" footer-fixed">
  58. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  59. 确认
  60. </view>
  61. </button>
  62. </form>
  63. </view>
  64. </template>
  65. <script>
  66. //获取app实例
  67. var app = getApp();
  68. export default {
  69. data() {
  70. return {
  71. webviewUrl1: '/pages/webview/webview?url=https://community.58fo.com/appfile/protocal.htm&title=隐私协议',
  72. webviewUrl2: '/pages/webview/webview?url=https://community.58fo.com/appfile/userprotocal.html&title=用户协议',
  73. text: '获取验证码',
  74. //按钮文字
  75. currentTime: 61,
  76. //倒计时
  77. disabled: false,
  78. //按钮是否禁用
  79. name: null,
  80. //姓名
  81. tel: null,
  82. //身份证号
  83. idcard:null,
  84. //获取到的手机栏中的值
  85. verify_code: null,
  86. //验证码
  87. isCheck: true,
  88. color: ""
  89. };
  90. },
  91. onLoad() {
  92. let userinfo = this.$auth.getMineBase().user
  93. if (!this.$isEmpty(userinfo)) {
  94. if (userinfo.mobile != '13800000000') {
  95. this.tel = this.$auth.getMineBase().user.mobile
  96. }
  97. }
  98. },
  99. methods: {
  100. //获取姓名栏input中的值
  101. nameInput: function(e) {
  102. this.setData({
  103. name: e.detail.value
  104. });
  105. },
  106. //获取验证码栏input中的值
  107. verifyCodeInput: function(e) {
  108. this.setData({
  109. verify_code: e.detail.value
  110. });
  111. },
  112. //获取验证码按钮
  113. sendMsgButton: function() {
  114. let that = this;
  115. that.setData({
  116. disabled: true,
  117. //只要点击了按钮就让按钮禁用 (避免正常情况下多次触发定时器事件)
  118. color: '#ccc'
  119. });
  120. let name = that.name;
  121. let tel = that.tel; //把手机号跟倒计时值变例成js值
  122. let currentTime = that.currentTime; //warn为当手机号为空或格式不正确时提示用户的文字,默认为空
  123. let warn = null;
  124. if (name == null) {
  125. warn = "姓名不能为空";
  126. } else if (tel == null) {
  127. warn = "手机号码不能为空";
  128. } else if (!this.$u.test.mobile(tel)) {
  129. warn = "手机号格式不正确";
  130. } else {
  131. //发送短信
  132. that.sendMessage(); //设置一分钟的倒计时
  133. let interval = setInterval(function() {
  134. currentTime--; //每执行一次让倒计时秒数减一
  135. that.setData({
  136. text: currentTime + 's' //按钮文字变成倒计时对应秒数
  137. }); //如果当秒数小于等于0时 停止计时器 且按钮文字变成重新发送 且按钮变成可用状态 倒计时的秒数也要恢复成默认秒数 即让获取验证码的按钮恢复到初始化状态只改变按钮文字
  138. if (currentTime <= 0) {
  139. clearInterval(interval);
  140. that.setData({
  141. text: '重新发送',
  142. currentTime: 61,
  143. disabled: false,
  144. color: '#59a5f0'
  145. });
  146. }
  147. }, 1000);
  148. }; //判断 当提示错误信息文字不为空 即手机号输入有问题时提示用户错误信息 并且提示完之后一定要让按钮为可用状态 因为点击按钮时设置了只要点击了按钮就让按钮禁用的情况
  149. if (warn != null) {
  150. //自动关闭提示弹窗
  151. app.globalData.autoFailHint(warn);
  152. that.setData({
  153. disabled: false,
  154. color: '#59a5f0'
  155. });
  156. return;
  157. }
  158. ;
  159. },
  160. //确认
  161. async showDialogBtn(e) {
  162. console.log(e);
  163. app.globalData.totalStep = 3
  164. let that = this;
  165. let name = that.name;
  166. if (name == null) {
  167. //自动关闭提示弹窗
  168. app.globalData.autoFailHint("请填写姓名");
  169. return;
  170. }
  171. let tel = that.tel;
  172. if (tel == null) {
  173. //自动关闭提示弹窗
  174. app.globalData.autoFailHint("请输入手机号");
  175. return;
  176. }
  177. if (this.$isNotEmpty(this.idcard)) {
  178. this.$u.toast('请输入身份证号')
  179. return
  180. }
  181. if (!this.$u.test.mobile(tel)) {
  182. //自动关闭提示弹窗
  183. app.globalData.autoFailHint("请填写正确的手机号码");
  184. return;
  185. }
  186. let verify_code = that.verify_code;
  187. if (verify_code == null) {
  188. //自动关闭提示弹窗
  189. app.globalData.autoFailHint("请填写验证码");
  190. return;
  191. }
  192. if (!that.isCheck) {
  193. app.globalData.autoFailHint("请同意用户协议");
  194. return;
  195. } //注册
  196. //构建参数
  197. let params = {};
  198. params['name'] = name;
  199. params['tel'] = tel;
  200. params['idcard']=this.idcard
  201. params['verify_code'] = verify_code;
  202. params['create_type'] = 0;
  203. params['openid'] = uni.getStorageSync("openid");
  204. // let operation = 'miniprogram/memberRegister';
  205. let res = await this.$http.memberRegister(params)
  206. if (res.data.result_code == 0) {
  207. app.globalData.oneFailHint(res.data.result_msg);
  208. return
  209. }
  210. let houseList=res.data.result_data
  211. //注册成功
  212. this.$dialog.showModal("注册成功", false).then(async () => {
  213. //注册成功之后重新拉取一次会员信息
  214. let params = {
  215. openid: uni.getStorageSync("openid")
  216. };
  217. let resp = await that.$http.getMemberByOpenid(params)
  218. if (resp.data.result_code == 0) {
  219. app.globalData.oneFailHint(resp.data.result_msg);
  220. return
  221. }
  222. let member = resp.data.member;
  223. app.globalData.member = member;
  224. this.$u.vuex('vuex_member',member)
  225. if (member.state == 1 || member.state == 2) {
  226. uni.reLaunch({
  227. url: '/pages/index/index',
  228. })
  229. return
  230. }
  231. //去认证
  232. if (this.$isNotEmpty(houseList)) {
  233. uni.setStorageSync("houseList",houseList)
  234. uni.redirectTo({
  235. url: "/pages/bindRoom/bindRoom",
  236. fail: (err) => {
  237. console.log(err);
  238. }
  239. })
  240. } else {
  241. uni.redirectTo({
  242. url: "../auth/auth",
  243. })
  244. }
  245. })
  246. },
  247. //申请短信验证码
  248. sendMessage: function() {
  249. //构建参数
  250. let params = {};
  251. params['tel'] = this.tel;
  252. // params['play_type'] = '2';
  253. // let operation = 'member/getSmsCode';
  254. this.$http.getSmsCode(params).then(res => {
  255. //短信发送成功
  256. if (res.data.result_code == 1) {
  257. app.globalData.autoFailHint(res.data.result_msg);
  258. } else {
  259. app.globalData.oneFailHint(res.data.result_msg);
  260. }
  261. });
  262. }
  263. }
  264. };
  265. </script>
  266. <style lang="scss">
  267. page {
  268. background: #fff;
  269. }
  270. .edit_wrap {
  271. font-size: 30rpx;
  272. padding: 0rpx 20rpx 20rpx;
  273. color: #333;
  274. }
  275. .form_group {
  276. display: flex;
  277. flex-direction: row;
  278. justify-content: space-between;
  279. margin: 20rpx 20rpx;
  280. line-height: 100rpx;
  281. position: relative;
  282. font-size: 26rpx;
  283. border-bottom: 1rpx solid #eee;
  284. }
  285. .form_group .item {
  286. text-align: right;
  287. line-height: 80rpx;
  288. }
  289. .form_group .red {
  290. color: red;
  291. position: absolute;
  292. left: 0;
  293. }
  294. .form_group text.sex {
  295. margin-left: 15px;
  296. text-align: right;
  297. }
  298. .form_group .radio-group {
  299. text-align: left;
  300. }
  301. .form_group input,
  302. .form_group picker {
  303. width: 500rpx;
  304. border-radius: 8rpx;
  305. height: 100rpx;
  306. line-height: 100rpx;
  307. padding: 0rpx 20rpx;
  308. color: #333;
  309. box-sizing: border-box;
  310. position: relative;
  311. z-index: 1;
  312. }
  313. .form_group button {
  314. font-size: 24rpx;
  315. background: $base-btn-color;
  316. margin: 10rpx 0 0 10rpx;
  317. color: #fff;
  318. }
  319. .form_group .sendmsg_input {
  320. width: 340rpx;
  321. margin-left: 36rpx;
  322. }
  323. .tips {
  324. padding: 0 10rpx;
  325. text-align: center;
  326. font-size: 24rpx;
  327. color: #999;
  328. margin-top: 20rpx;
  329. }
  330. .placeholder_style {
  331. font-family: '微软雅黑';
  332. color: #adadad;
  333. font-size: 26rpx;
  334. }
  335. .save_btn {
  336. width: 600rpx;
  337. background: #d24a58;
  338. font-size: 32rpx;
  339. color: #fff;
  340. border-radius: 0rpx;
  341. margin: 40rpx 0rpx 10rpx;
  342. }
  343. .code_btn {
  344. width: 150rpx;
  345. background: $base-btn-color;
  346. height: 50rpx;
  347. line-height: 50rpx;
  348. text-align: center;
  349. border-radius: 8rpx;
  350. color: #fff;
  351. font-size: 33rpx;
  352. padding: 0 10rpx;
  353. }
  354. .password_contet image {
  355. width: 48rpx;
  356. height: 48rpx;
  357. position: absolute;
  358. left: 50%;
  359. top: 50%;
  360. transform: translate(-50%, -50%);
  361. }
  362. .password_contet {
  363. position: absolute;
  364. right: 0;
  365. top: 50%;
  366. transform: translate(0, -50%);
  367. width: 80rpx;
  368. height: 80rpx;
  369. z-index: 999;
  370. }
  371. checkbox .wx-checkbox-input {
  372. width: 34rpx;
  373. height: 34rpx;
  374. }
  375. checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
  376. color: $base-btn-color;
  377. }
  378. </style>