register.vue 9.9 KB

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