register.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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['tel'] = 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. console.log(resp,"resp");
  203. if (resp.data.result_code == 0) {
  204. app.globalData.oneFailHint(resp.data.result_msg);
  205. return
  206. }
  207. let member = resp.data.member;
  208. app.globalData.member = member;
  209. if (member.state == 1 || member.state == 2) {
  210. uni.reLaunch({
  211. url: '/pages/index/index',
  212. })
  213. return
  214. }
  215. //去认证
  216. if (this.$isNotEmpty(houseList)) {
  217. uni.setStorageSync("houseList",houseList)
  218. uni.redirectTo({
  219. url: "/pages/bindRoom/bindRoom",
  220. fail: (err) => {
  221. console.log(err);
  222. }
  223. })
  224. } else {
  225. uni.redirectTo({
  226. url: "../auth/auth",
  227. })
  228. }
  229. })
  230. },
  231. //申请短信验证码
  232. sendMessage: function() {
  233. //构建参数
  234. let params = {};
  235. params['tel'] = this.tel;
  236. // params['play_type'] = '2';
  237. // let operation = 'member/getSmsCode';
  238. this.$http.getSmsCode(params).then(res => {
  239. //短信发送成功
  240. if (res.data.result_code == 1) {
  241. app.globalData.autoFailHint(res.data.result_msg);
  242. } else {
  243. app.globalData.oneFailHint(res.data.result_msg);
  244. }
  245. });
  246. }
  247. }
  248. };
  249. </script>
  250. <style lang="scss">
  251. page {
  252. background: #fff;
  253. }
  254. .edit_wrap {
  255. font-size: 30rpx;
  256. padding: 0rpx 20rpx 20rpx;
  257. color: #333;
  258. }
  259. .form_group {
  260. display: flex;
  261. flex-direction: row;
  262. justify-content: space-between;
  263. margin: 20rpx 20rpx;
  264. line-height: 100rpx;
  265. position: relative;
  266. font-size: 26rpx;
  267. border-bottom: 2rpx solid #ddd;
  268. }
  269. .form_group .item {
  270. text-align: right;
  271. line-height: 80rpx;
  272. }
  273. .form_group .red {
  274. color: red;
  275. position: absolute;
  276. left: 0;
  277. }
  278. .form_group text.sex {
  279. margin-left: 15px;
  280. text-align: right;
  281. }
  282. .form_group .radio-group {
  283. text-align: left;
  284. }
  285. .form_group input,
  286. .form_group picker {
  287. width: 500rpx;
  288. border-radius: 8rpx;
  289. height: 100rpx;
  290. line-height: 100rpx;
  291. padding: 0rpx 20rpx;
  292. color: #333;
  293. box-sizing: border-box;
  294. position: relative;
  295. z-index: 1;
  296. }
  297. .form_group button {
  298. font-size: 24rpx;
  299. background: $base-btn-color;
  300. margin: 10rpx 0 0 10rpx;
  301. color: #fff;
  302. }
  303. .form_group .sendmsg_input {
  304. width: 340rpx;
  305. margin-left: 36rpx;
  306. }
  307. .tips {
  308. padding: 0 10rpx;
  309. text-align: center;
  310. font-size: 24rpx;
  311. color: #999;
  312. margin-top: 20rpx;
  313. }
  314. .placeholder_style {
  315. font-family: '微软雅黑';
  316. color: #adadad;
  317. font-size: 26rpx;
  318. }
  319. .save_btn {
  320. width: 600rpx;
  321. background: #d24a58;
  322. font-size: 32rpx;
  323. color: #fff;
  324. border-radius: 0rpx;
  325. margin: 40rpx 0rpx 10rpx;
  326. }
  327. .code_btn {
  328. width: 150rpx;
  329. background: $base-btn-color;
  330. height: 60rpx;
  331. line-height: 60rpx;
  332. text-align: center;
  333. border-radius: 10rpx;
  334. color: #fff;
  335. font-size: 33rpx;
  336. padding: 0 10rpx;
  337. }
  338. .password_contet image {
  339. width: 48rpx;
  340. height: 48rpx;
  341. position: absolute;
  342. left: 50%;
  343. top: 50%;
  344. transform: translate(-50%, -50%);
  345. }
  346. .password_contet {
  347. position: absolute;
  348. right: 0;
  349. top: 50%;
  350. transform: translate(0, -50%);
  351. width: 80rpx;
  352. height: 80rpx;
  353. z-index: 999;
  354. }
  355. checkbox .wx-checkbox-input {
  356. width: 34rpx;
  357. height: 34rpx;
  358. }
  359. checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
  360. color: $base-btn-color;
  361. }
  362. </style>