register.vue 9.8 KB

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