register.vue 9.7 KB

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