index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view :data-theme="theme">
  3. <view class="ChangePassword">
  4. <view class="list">
  5. <block v-if="isNew">
  6. <view class="item">
  7. <input disabled='true' :value="userInfo.phone"></input>
  8. </view>
  9. <view class="item acea-row row-between-wrapper">
  10. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput"
  11. v-model="captcha" maxlength="6"></input>
  12. <button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  13. {{ text }}
  14. </button>
  15. </view>
  16. </block>
  17. <block v-else>
  18. <view class="item">
  19. <input type='number' placeholder='新手机号' placeholder-class='placeholder' v-model="phone"
  20. maxlength="11"></input>
  21. </view>
  22. <view class="item acea-row row-between-wrapper">
  23. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput"
  24. v-model="bindingCaptcha" maxlength="6"></input>
  25. <button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  26. {{ text }}
  27. </button>
  28. </view>
  29. </block>
  30. </view>
  31. <button form-type="submit" v-if="isNew" class="confirmBnt bg_color" @click="next">下一步</button>
  32. <button form-type="submit" v-if="!isNew" class="confirmBnt bg_color" @click="editPwd">保存</button>
  33. </view>
  34. <Verify @success="handlerOnVerSuccess" :captchaType="'clickWord'" :imgSize="{ width: '330px', height: '155px' }"
  35. ref="verify"></Verify>
  36. </view>
  37. </template>
  38. <script>
  39. // +----------------------------------------------------------------------
  40. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  41. // +----------------------------------------------------------------------
  42. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  43. // +----------------------------------------------------------------------
  44. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  45. // +----------------------------------------------------------------------
  46. // | Author: CRMEB Team <admin@crmeb.com>
  47. // +----------------------------------------------------------------------
  48. import sendVerifyCode from "@/mixins/SendVerifyCode";
  49. import {
  50. registerVerify,
  51. bindingPhone,
  52. verifyCode,
  53. bindingPhoneCode
  54. } from '@/api/api.js';
  55. import {
  56. toLogin
  57. } from '@/libs/login.js';
  58. import {
  59. mapGetters
  60. } from "vuex";
  61. import {
  62. setThemeColor
  63. } from '@/utils/setTheme.js'
  64. import {
  65. Debounce
  66. } from '@/utils/validate.js'
  67. import Verify from '../components/verifition/verify.vue';
  68. const app = getApp();
  69. export default {
  70. components: {
  71. Verify
  72. },
  73. mixins: [sendVerifyCode],
  74. data() {
  75. return {
  76. phone: '',
  77. captcha: '',
  78. isAuto: false, //没有授权的不会自动授权
  79. isShowAuth: false, //是否隐藏授权
  80. key: '',
  81. isNew: true,
  82. timer: '',
  83. text: '获取验证码',
  84. nums: 60,
  85. theme: app.globalData.theme,
  86. bgColor: '',
  87. bindingCaptcha: ''
  88. };
  89. },
  90. mounted() {
  91. // this.timer = setInterval(this.getTimes, 1000);
  92. },
  93. computed: mapGetters(['isLogin', 'userInfo']),
  94. onLoad() {
  95. let that = this;
  96. that.bgColor = setThemeColor();
  97. uni.setNavigationBarColor({
  98. frontColor: '#ffffff',
  99. backgroundColor: that.bgColor,
  100. });
  101. if (this.isLogin) {
  102. } else {
  103. toLogin();
  104. }
  105. },
  106. methods: {
  107. getTimes() {
  108. this.nums = this.nums - 1;
  109. this.text = "剩余 " + this.nums + "s";
  110. if (this.nums < 0) {
  111. clearInterval(this.timer);
  112. }
  113. this.text = "剩余 " + this.nums + "s";
  114. if (this.text < "剩余 " + 0 + "s") {
  115. this.disabled = false;
  116. this.text = "重新获取";
  117. }
  118. },
  119. onLoadFun: function() {},
  120. // 授权关闭
  121. authColse: function(e) {
  122. this.isShowAuth = e
  123. },
  124. next() {
  125. if (!this.captcha) return this.$util.Tips({
  126. title: '请填写验证码'
  127. });
  128. this.isNew = false;
  129. clearInterval(this.timer);
  130. this.disabled = false;
  131. this.text = "获取验证码";
  132. },
  133. editPwd: Debounce(function(e) {
  134. let that = this;
  135. if (!that.phone) return that.$util.Tips({
  136. title: '请填写手机号码!'
  137. });
  138. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  139. title: '请输入正确的手机号码!'
  140. });
  141. if (!that.bindingCaptcha) return that.$util.Tips({
  142. title: '请填写验证码'
  143. });
  144. uni.showModal({
  145. title: '是否更换绑定账号',
  146. // #ifdef H5
  147. title: '是否更换绑定账号,更换之后需重新登录',
  148. // #endif
  149. confirmText: '绑定',
  150. success(res) {
  151. uni.showLoading({
  152. title: '加载中',
  153. mask: true
  154. });
  155. if (res.confirm) {
  156. bindingPhone({
  157. phone: that.phone,
  158. captcha: that.bindingCaptcha
  159. }).then(res => {
  160. uni.hideLoading();
  161. that.$store.dispatch('GETLOGOUT');
  162. }).catch(err => {
  163. uni.hideLoading();
  164. return that.$util.Tips({
  165. title: err
  166. });
  167. })
  168. } else if (res.cancel) {
  169. return that.$util.Tips({
  170. title: '您已取消更换绑定!'
  171. }, {
  172. tab: 5,
  173. url: '/pages/users/user_info/index'
  174. });
  175. }
  176. }
  177. });
  178. }),
  179. //滑块验证成功
  180. handlerOnVerSuccess(data) {
  181. this.$refs.verify.hide();
  182. this.codeSend();
  183. },
  184. codeSend() {
  185. let that = this;
  186. bindingPhoneCode({
  187. phone: that.phone,
  188. captcha: that.captcha
  189. }).then(res => {
  190. that.$util.Tips({
  191. title: res.message
  192. });
  193. that.timer = setInterval(that.getTimes, 1000);
  194. that.disabled = true;
  195. uni.hideLoading();
  196. }).catch(err => {
  197. return that.$util.Tips({
  198. title: err.toString()
  199. }, {
  200. tab: 3,
  201. url: 1
  202. });
  203. uni.hideLoading();
  204. });
  205. },
  206. /**
  207. * 发送验证码
  208. *
  209. */
  210. code: Debounce(function() {
  211. this.nums = 60;
  212. uni.showLoading({
  213. title: '加载中',
  214. mask: true
  215. });
  216. let that = this;
  217. if (that.isNew) {
  218. registerVerify().then(res => {
  219. that.$util.Tips({
  220. title: res.message
  221. });
  222. that.timer = setInterval(that.getTimes, 1000);
  223. that.disabled = true;
  224. uni.hideLoading();
  225. }).catch(err => {
  226. return that.$util.Tips({
  227. title: err
  228. });
  229. uni.hideLoading();
  230. });
  231. } else {
  232. uni.hideLoading();
  233. if (!that.phone) return that.$util.Tips({
  234. title: '请填写手机号码!'
  235. });
  236. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  237. title: '请输入正确的手机号码!'
  238. });
  239. that.$refs.verify.show();
  240. }
  241. })
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .shading {
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. width: 100%;
  251. /* #ifdef APP-VUE */
  252. margin-top: 50rpx;
  253. /* #endif */
  254. /* #ifndef APP-VUE */
  255. margin-top: 200rpx;
  256. /* #endif */
  257. image {
  258. width: 180rpx;
  259. height: 180rpx;
  260. }
  261. }
  262. page {
  263. background-color: #fff !important;
  264. }
  265. .ChangePassword {
  266. padding-top: 100rpx;
  267. }
  268. .ChangePassword .phone {
  269. font-size: 32rpx;
  270. font-weight: bold;
  271. text-align: center;
  272. margin-top: 55rpx;
  273. }
  274. .ChangePassword .list {
  275. width: 580rpx;
  276. margin: 0 auto;
  277. }
  278. .ChangePassword .list .item {
  279. width: 100%;
  280. height: 110rpx;
  281. border-bottom: 2rpx solid #f0f0f0;
  282. }
  283. .ChangePassword .list .item input {
  284. width: 100%;
  285. height: 100%;
  286. font-size: 32rpx;
  287. }
  288. .ChangePassword .list .item .placeholder {
  289. color: #b9b9bc;
  290. }
  291. .ChangePassword .list .item input.codeIput {
  292. width: 340rpx;
  293. }
  294. .ChangePassword .list .item .code {
  295. font-size: 32rpx;
  296. @include main_color(theme);
  297. background-color: #f5f5f5;
  298. }
  299. .ChangePassword .list .item .code.on {
  300. color: #b9b9bc !important;
  301. }
  302. .ChangePassword .confirmBnt {
  303. font-size: 32rpx;
  304. width: 580rpx;
  305. height: 90rpx;
  306. border-radius: 45rpx;
  307. color: #fff;
  308. margin: 92rpx auto 0 auto;
  309. text-align: center;
  310. line-height: 90rpx;
  311. }
  312. .bg_color {
  313. @include main_bg_color(theme);
  314. }
  315. </style>