register.vue 9.7 KB

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