register.vue 9.7 KB

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