setting-transaction-password.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="container">
  3. <view class="login-wrap">
  4. <view class="login-form">
  5. <u--form
  6. labelPosition="left"
  7. :model="userInfo"
  8. :rules="rules"
  9. ref="form1"
  10. >
  11. <u-form-item
  12. label="原密码"
  13. prop="oldPassword"
  14. labelWidth="auto"
  15. labelAlign="right"
  16. >
  17. <u--input
  18. v-model="userInfo.oldPassword"
  19. placeholder="请输入原密码"
  20. border="bottom"
  21. maxlength="6"
  22. type="password"
  23. ></u--input>
  24. </u-form-item>
  25. <u-form-item
  26. label="密码"
  27. prop="password"
  28. labelWidth="auto"
  29. labelAlign="right"
  30. >
  31. <u--input
  32. v-model="userInfo.password"
  33. placeholder="请输入密码"
  34. border="bottom"
  35. maxlength="6"
  36. type="password"
  37. ></u--input>
  38. </u-form-item>
  39. <u-form-item
  40. labelWidth="auto"
  41. labelAlign="right"
  42. label="确认密码"
  43. prop="password1"
  44. width="120"
  45. >
  46. <u--input
  47. maxlength="6"
  48. v-model="userInfo.password1"
  49. placeholder="请再次输入密码"
  50. border="bottom"
  51. type="password"
  52. ></u--input>
  53. </u-form-item>
  54. </u--form>
  55. </view>
  56. </view>
  57. <view @click="submitData" class="op-btn-wrap">
  58. <view class="h-btn">
  59. <text>确定</text>
  60. </view>
  61. </view>
  62. <!-- 提示 -->
  63. <view class="h-mark-desc">
  64. <view class="h-text">
  65. <text>*交易密码建议输入不连续的6位数密码</text>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. export default {
  72. data() {
  73. return {
  74. userInfo: {
  75. oldPassword: '',
  76. auth: true,
  77. password: '',
  78. password1: '',
  79. },
  80. tips2: '',
  81. rules: {
  82. oldPassword: {
  83. required: true,
  84. min: 6,
  85. max: 18,
  86. message: '请输入6到18位密码',
  87. trigger: ['blur', 'change'],
  88. },
  89. password: {
  90. required: true,
  91. min: 6,
  92. max: 6,
  93. message: '请输入6位密码',
  94. trigger: ['blur', 'change'],
  95. },
  96. password1: [
  97. {
  98. required: true,
  99. min: 6,
  100. max: 6,
  101. message: '请输入6位密码',
  102. trigger: ['blur', 'change'],
  103. },
  104. {
  105. validator: (rule, value, callback) => {
  106. if(this.userInfo.password === value){
  107. return true;
  108. }
  109. return false;
  110. },
  111. message: "两次输入密码不一致",
  112. trigger: ['blur', 'change'],
  113. }
  114. ],
  115. },
  116. }
  117. },
  118. onLoad() {
  119. this.$refs.form1.setRules(this.rules)
  120. },
  121. methods: {
  122. // 提交交易密码
  123. submitData(){
  124. // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true
  125. this.$refs.form1.validate().then(res => {
  126. this.updateUserTransactionPassword();
  127. }).catch(errors => {
  128. uni.$u.toast('校验失败,请认真填写')
  129. })
  130. },
  131. updateUserTransactionPassword(){
  132. // 保存数据
  133. updateUserTransactionPassword(null,{data:this.userInfo}).then((res)=>{
  134. uni.showToast({
  135. title: '设置成功'
  136. })
  137. setTimeout(function() {
  138. // 选择完成后返回上一页
  139. uni.navigateBack({
  140. delta: 1,
  141. success: function(res) {
  142. // 在这里可以处理选择结果
  143. // 可以将选择的内容保存到本地或通过事件传递给上一个页面
  144. uni.$emit('selectedServiceObjectChild', item);
  145. }
  146. });
  147. }, 2000); // 延迟2秒执行
  148. }).catch(() =>{
  149. uni.showToast({
  150. title: "操作失败"
  151. })
  152. });
  153. },
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. page,body{
  159. background: #fff;
  160. }
  161. .container{
  162. background: #fff;
  163. height: 300px;
  164. .login-wrap {
  165. display: flex;
  166. justify-content: center;
  167. .login-form{
  168. width: 90%;
  169. }
  170. .account{
  171. display: flex;
  172. }
  173. .identifying-code{
  174. }
  175. }
  176. .op-btn-wrap{
  177. margin-top: 30px;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. .h-btn{
  182. text-align: center;
  183. width: 343px;
  184. height: 42px;
  185. background: #FFE05C;
  186. border-radius: 27px;
  187. line-height: 42px;
  188. }
  189. }
  190. }
  191. </style>