index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="pages">
  3. <!-- <u-navbar
  4. title="修改密码"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. bgColor="#ED0000"
  9. :titleStyle="{color:'#fff'}"
  10. leftIconColor="#fff"
  11. >
  12. </u-navbar> -->
  13. <!-- 头部主要内容 开始 -->
  14. <view class="passwordset-content-header">
  15. <customNavbar
  16. title="修改密码"
  17. bgColor="var(--gd-bgm-color)"
  18. :contentStyle="{color: '#fff'}"
  19. :leftStyle="{color: '#fff'}"
  20. ></customNavbar>
  21. </view>
  22. <view class="form-wrap">
  23. <u--form labelPosition="left" labelWidth="70px" :model="form" :rules="rules" ref="uForm" >
  24. <u-form-item label="旧密码" prop="oldPassword" borderBottom ref="oldPassword" >
  25. <u--input
  26. v-model="form.oldPassword"
  27. border="none"
  28. placeholder="请输入旧密码"
  29. :customStyle="inputCustomStyle"
  30. ></u--input>
  31. </u-form-item>
  32. <u-form-item label="新密码" prop="password" borderBottom ref="password" >
  33. <u--input
  34. v-model="form.password"
  35. border="none"
  36. :password="true"
  37. placeholder="请输入新密码"
  38. :customStyle="inputCustomStyle"
  39. ></u--input>
  40. </u-form-item>
  41. <u-form-item label="确认密码" prop="comfpassword" :borderBottom="false" ref="comfpassword" >
  42. <u--input
  43. v-model="form.comfpassword"
  44. border="none"
  45. :password="true"
  46. placeholder="请确认新密码"
  47. :customStyle="inputCustomStyle"
  48. ></u--input>
  49. </u-form-item>
  50. </u--form>
  51. </view>
  52. <u-button
  53. @click="submit"
  54. text="确定"
  55. type="primary"
  56. shape="circle"
  57. :customStyle="{'margin':'60rpx 32rpx',height:'80rpx','box-sizing':'border-box',width:'auto'}"
  58. color="linear-gradient(90deg, #FF7979 0%, #ED0000 100%)">
  59. </u-button>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. form:{
  67. oldPassword:'',
  68. password:'',
  69. comfpassword:'',
  70. },
  71. rules: {
  72. oldPassword: {
  73. type: 'string',
  74. required: true,
  75. message: '请输入旧密码',
  76. trigger: ['blur', 'change']
  77. },
  78. password: [
  79. {
  80. type: 'string',
  81. required: true,
  82. message: '请输入新密码',
  83. trigger: ['blur', 'change']
  84. },
  85. {
  86. min: 6,
  87. max: 10,
  88. message: '长度在6-10个字符之间',
  89. trigger: 'blur',
  90. },
  91. ],
  92. comfpassword: [
  93. {
  94. type: 'string',
  95. required: true,
  96. message: '请确认密码',
  97. trigger: ['blur', 'change']
  98. },
  99. {
  100. validator: (rule, value, callback) => {
  101. if (value === '') {
  102. callback(new Error('请再次输入密码'));
  103. } else if (value !== this.form.password) {
  104. callback(new Error('两次输入密码不一致!'));
  105. } else {
  106. callback();
  107. }
  108. },
  109. trigger: 'blur',
  110. }
  111. ],
  112. },
  113. inputCustomStyle:{
  114. height:'98rpx',
  115. 'border-color':'#eee',
  116. 'padding-left':'30rpx',
  117. 'box-sizing':'border-box',
  118. }
  119. }
  120. },
  121. onShow() {
  122. },
  123. onReady() {
  124. this.$refs.uForm.setRules(this.rules)
  125. },
  126. onLoad() {
  127. },
  128. methods: {
  129. chekPass(){
  130. console.log('chekPass---',this.form);
  131. return new Promise((resolve, reject)=>{
  132. if(!password){
  133. reject('needAuth');
  134. }
  135. })
  136. },
  137. async submit(){
  138. let that = this;
  139. // console.log('form',this.form);
  140. this.$refs.uForm.validate().then(res => {
  141. // let chekPassResult = await this.chekPass();
  142. // return
  143. // uni.$u.toast('校验通过')
  144. const param = {
  145. oldPassword:this.form.oldPassword,
  146. newPassword:this.form.password
  147. }
  148. this.$u.api.marketPersonsUpdatePwd(param).then(res=>{
  149. // console.log('res',res.data);
  150. this.$u.vuex('distribution_user_info', {});
  151. uni.showToast({
  152. title:res.msg,
  153. icon:'success',
  154. duration: 3000
  155. })
  156. setTimeout(()=>{
  157. that.redirectToAuth();
  158. },500)
  159. }).catch(err=>{
  160. console.log('login',err);
  161. })
  162. }).catch(errors => {
  163. uni.$u.toast('请正确填写表单')
  164. })
  165. },
  166. redirectToAuth() {
  167. uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
  168. uni.setStorageSync('backUrlDistribution','')
  169. uni.reLaunch({
  170. url: "/pages/login/index"
  171. })
  172. },
  173. }
  174. }
  175. </script>
  176. <style>
  177. page{
  178. background-color: #F4F5F7;
  179. }
  180. </style>
  181. <style lang="scss" scoped>
  182. .form-wrap{
  183. margin: 40rpx 32rpx;
  184. padding: 20rpx 40rpx;
  185. background-color: #fff;
  186. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(226,226,226,0.5);
  187. border-radius: 24rpx;
  188. }
  189. </style>