indexs.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="ChangePassword">
  4. <form @submit="editPwd">
  5. <view class="phone">{{$t(`当前手机号`)}}:{{phone}}</view>
  6. <view class="list">
  7. <view class="item">
  8. <input type='password' :placeholder='$t(`设置新六位交易密码`)' placeholder-class='placeholder'
  9. name="password" :value="password"></input>
  10. </view>
  11. <view class="item">
  12. <input type='password' :placeholder='$t(`确认新交易密码`)' placeholder-class='placeholder'
  13. name="qr_password" :value="qr_password"></input>
  14. </view>
  15. <view class="item acea-row row-between-wrapper">
  16. <input type='number' :placeholder='$t(`填写验证码`)' placeholder-class='placeholder' class="codeIput"
  17. name="captcha" :value="captcha"></input>
  18. <button class="code font-num" :class="disabled === true ? 'on' : ''" :disabled='disabled'
  19. @click="code">
  20. {{ text }}
  21. </button>
  22. </view>
  23. </view>
  24. <button form-type="submit" class="confirmBnt bg-color">{{$t(`确认修改`)}}</button>
  25. </form>
  26. </view>
  27. <!-- #ifdef MP -->
  28. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  29. <!-- #endif -->
  30. <Verify @success="success" :captchaType="captchaType" :imgSize="{ width: '330px', height: '155px' }"
  31. ref="verify"></Verify>
  32. </view>
  33. </template>
  34. <script>
  35. import sendVerifyCode from "@/mixins/SendVerifyCode";
  36. import {
  37. phoneRegisterReset,
  38. verifyCode
  39. } from '@/api/api.js';
  40. import {
  41. getUserInfo,
  42. registerVerify,
  43. setTrade
  44. } from '@/api/user.js';
  45. import {
  46. toLogin
  47. } from '@/libs/login.js';
  48. import {
  49. mapGetters
  50. } from "vuex";
  51. // #ifdef MP
  52. import authorize from '@/components/Authorize';
  53. // #endif
  54. import colors from '@/mixins/color.js';
  55. import Verify from '../components/verify/index.vue';
  56. export default {
  57. mixins: [sendVerifyCode, colors],
  58. components: {
  59. // #ifdef MP
  60. authorize,
  61. // #endif
  62. Verify
  63. },
  64. data() {
  65. return {
  66. userInfo: {},
  67. phone: '',
  68. password: '',
  69. captcha: '',
  70. qr_password: '',
  71. isAuto: false, //没有授权的不会自动授权
  72. isShowAuth: false, //是否隐藏授权
  73. key: '',
  74. };
  75. },
  76. computed: mapGetters(['isLogin']),
  77. watch: {
  78. isLogin: {
  79. handler: function(newV, oldV) {
  80. if (newV) {
  81. this.getUserInfo();
  82. }
  83. },
  84. deep: true
  85. }
  86. },
  87. onLoad() {
  88. if (this.isLogin) {
  89. this.getUserInfo();
  90. verifyCode().then(res => {
  91. this.$set(this, 'key', res.data.key)
  92. });
  93. } else {
  94. toLogin()
  95. }
  96. },
  97. methods: {
  98. /**
  99. * 授权回调
  100. */
  101. onLoadFun: function(e) {
  102. this.getUserInfo();
  103. },
  104. // 授权关闭
  105. authColse: function(e) {
  106. this.isShowAuth = e
  107. },
  108. /**
  109. * 获取个人用户信息
  110. */
  111. getUserInfo: function() {
  112. let that = this;
  113. getUserInfo().then(res => {
  114. let tel = res.data.phone;
  115. let phone = tel.substr(0, 3) + "****" + tel.substr(7);
  116. that.$set(that, 'userInfo', res.data);
  117. that.phone = phone;
  118. });
  119. },
  120. /**
  121. * 发送验证码
  122. *
  123. */
  124. async code() {
  125. let that = this;
  126. if (!that.userInfo.phone) return that.$util.Tips({
  127. title: that.$t(`手机号码不存在,无法发送验证码!`)
  128. });
  129. this.$refs.verify.show()
  130. },
  131. async success(data) {
  132. let that = this;
  133. this.$refs.verify.hide()
  134. await registerVerify({
  135. phone: that.userInfo.phone,
  136. type: 'login',
  137. key: that.key,
  138. captchaType: this.captchaType,
  139. captchaVerification: data.captchaVerification
  140. }).then(res => {
  141. this.sendCode()
  142. that.$util.Tips({
  143. title: res.msg
  144. });
  145. }).catch(err => {
  146. return that.$util.Tips({
  147. title: err
  148. });
  149. });
  150. },
  151. /**
  152. * H5登录 修改密码
  153. *
  154. */
  155. editPwd: function(e) {
  156. let that = this,
  157. password = e.detail.value.password,
  158. qr_password = e.detail.value.qr_password,
  159. captcha = e.detail.value.captcha;
  160. if (!password) return that.$util.Tips({
  161. title: that.$t(`请输入新密码`)
  162. });
  163. if (qr_password != password) return that.$util.Tips({
  164. title: that.$t(`两次输入的密码不一致!`)
  165. });
  166. if (!captcha) return that.$util.Tips({
  167. title: that.$t(`请输入验证码`)
  168. });
  169. setTrade({
  170. account: that.userInfo.phone,
  171. captcha: captcha,
  172. trade: password
  173. }).then(res => {
  174. return that.$util.Tips({
  175. title: res.msg
  176. }, {
  177. tab: 3,
  178. url: 1
  179. });
  180. }).catch(err => {
  181. return that.$util.Tips({
  182. title: err
  183. });
  184. });
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss">
  190. page {
  191. background-color: #fff !important;
  192. }
  193. .ChangePassword .phone {
  194. font-size: 32rpx;
  195. font-weight: bold;
  196. text-align: center;
  197. margin-top: 55rpx;
  198. }
  199. .ChangePassword .list {
  200. width: 580rpx;
  201. margin: 53rpx auto 0 auto;
  202. }
  203. .ChangePassword .list .item {
  204. width: 100%;
  205. height: 110rpx;
  206. border-bottom: 2rpx solid #f0f0f0;
  207. }
  208. .ChangePassword .list .item input {
  209. width: 100%;
  210. height: 100%;
  211. font-size: 32rpx;
  212. }
  213. .ChangePassword .list .item .placeholder {
  214. color: #b9b9bc;
  215. }
  216. .ChangePassword .list .item input.codeIput {
  217. width: 340rpx;
  218. }
  219. .ChangePassword .list .item .code {
  220. font-size: 32rpx;
  221. background-color: #fff;
  222. }
  223. .ChangePassword .list .item .code.on {
  224. color: #b9b9bc !important;
  225. }
  226. .ChangePassword .confirmBnt {
  227. font-size: 32rpx;
  228. width: 580rpx;
  229. height: 90rpx;
  230. border-radius: 45rpx;
  231. color: #fff;
  232. margin: 92rpx auto 0 auto;
  233. text-align: center;
  234. line-height: 90rpx;
  235. }
  236. </style>