index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <form @submit="editPwd" report-submit='true'>
  4. <view class="ChangePassword">
  5. <view class="list">
  6. <view class="item">
  7. <input type='number' placeholder='填写手机号码' placeholder-class='placeholder' v-model="phone"></input>
  8. </view>
  9. <view class="item acea-row row-between-wrapper">
  10. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" v-model="captcha"></input>
  11. <button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  12. {{ text }}
  13. </button>
  14. </view>
  15. </view>
  16. <button form-type="submit" class="confirmBnt bg-color">确认绑定</button>
  17. </view>
  18. </form>
  19. <!-- #ifdef MP -->
  20. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  21. <!-- #endif -->
  22. </view>
  23. </template>
  24. <script>
  25. import sendVerifyCode from "@/mixins/SendVerifyCode";
  26. import {
  27. registerVerify,
  28. bindingPhone
  29. } from '@/api/api.js';
  30. import {
  31. toLogin
  32. } from '@/libs/login.js';
  33. import {
  34. mapGetters
  35. } from "vuex";
  36. // #ifdef MP
  37. import authorize from '@/components/Authorize';
  38. // #endif
  39. export default {
  40. mixins: [sendVerifyCode],
  41. components: {
  42. // #ifdef MP
  43. authorize
  44. // #endif
  45. },
  46. data() {
  47. return {
  48. phone:'',
  49. captcha:'',
  50. isAuto: false, //没有授权的不会自动授权
  51. isShowAuth: false //是否隐藏授权
  52. };
  53. },
  54. computed: mapGetters(['isLogin']),
  55. onLoad() {
  56. if (this.isLogin) {
  57. } else {
  58. // #ifdef H5 || APP-PLUS
  59. toLogin();
  60. // #endif
  61. // #ifdef MP
  62. this.isAuto = true;
  63. this.$set(this, 'isShowAuth', true)
  64. // #endif
  65. }
  66. },
  67. methods: {
  68. onLoadFun:function(){},
  69. // 授权关闭
  70. authColse: function(e) {
  71. this.isShowAuth = e
  72. },
  73. editPwd: function() {
  74. let that = this;
  75. if (!that.phone) return that.$util.Tips({
  76. title: '请填写手机号码!'
  77. });
  78. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  79. title: '请输入正确的手机号码!'
  80. });
  81. if (!that.captcha) return that.$util.Tips({
  82. title: '请填写验证码'
  83. });
  84. bindingPhone({
  85. phone: that.phone,
  86. captcha: that.captcha
  87. }).then(res => {
  88. if (res.data !== undefined && res.data.is_bind) {
  89. uni.showModal({
  90. title: '是否绑定账号',
  91. content: res.msg,
  92. confirmText: '绑定',
  93. success(res) {
  94. if (res.confirm) {
  95. bindingPhone({
  96. phone: that.phone,
  97. captcha: that.captcha,
  98. step: 1
  99. }).then(res => {
  100. return that.$util.Tips({
  101. title: res.msg,
  102. icon: 'success'
  103. }, {
  104. tab: 5,
  105. url: '/pages/user_info/index'
  106. });
  107. }).catch(err => {
  108. return that.$util.Tips({
  109. title: err
  110. });
  111. })
  112. } else if (res.cancel) {
  113. return that.$util.Tips({
  114. title: '您已取消绑定!'
  115. }, {
  116. tab: 5,
  117. url: '/pages/user_info/index'
  118. });
  119. }
  120. }
  121. });
  122. } else
  123. return that.$util.Tips({
  124. title: '绑定成功!',
  125. icon: 'success'
  126. }, {
  127. tab: 5,
  128. url: '/pages/user_info/index'
  129. });
  130. }).catch(err => {
  131. return that.$util.Tips({
  132. title: err
  133. });
  134. })
  135. },
  136. /**
  137. * 发送验证码
  138. *
  139. */
  140. async code() {
  141. let that = this;
  142. if (!that.phone) return that.$util.Tips({
  143. title: '请填写手机号码!'
  144. });
  145. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  146. title: '请输入正确的手机号码!'
  147. });
  148. await registerVerify(that.phone).then(res => {
  149. that.$util.Tips({
  150. title: res.msg
  151. });
  152. that.sendCode();
  153. }).catch(err => {
  154. return that.$util.Tips({
  155. title: err
  156. });
  157. });
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. page {
  164. background-color: #fff !important;
  165. }
  166. .ChangePassword .phone {
  167. font-size: 32rpx;
  168. font-weight: bold;
  169. text-align: center;
  170. margin-top: 55rpx;
  171. }
  172. .ChangePassword .list {
  173. width: 580rpx;
  174. margin: 53rpx auto 0 auto;
  175. }
  176. .ChangePassword .list .item {
  177. width: 100%;
  178. height: 110rpx;
  179. border-bottom: 2rpx solid #f0f0f0;
  180. }
  181. .ChangePassword .list .item input {
  182. width: 100%;
  183. height: 100%;
  184. font-size: 32rpx;
  185. }
  186. .ChangePassword .list .item .placeholder {
  187. color: #b9b9bc;
  188. }
  189. .ChangePassword .list .item input.codeIput {
  190. width: 340rpx;
  191. }
  192. .ChangePassword .list .item .code {
  193. font-size: 32rpx;
  194. background-color: #fff;
  195. }
  196. .ChangePassword .list .item .code.on {
  197. color: #b9b9bc !important;
  198. }
  199. .ChangePassword .confirmBnt {
  200. font-size: 32rpx;
  201. width: 580rpx;
  202. height: 90rpx;
  203. border-radius: 45rpx;
  204. color: #fff;
  205. margin: 92rpx auto 0 auto;
  206. text-align: center;
  207. line-height: 90rpx;
  208. }
  209. </style>