index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <!-- pages/staff/password/index.wxml -->
  3. <view class="container">
  4. <view class="user-cell">
  5. <view class="user-title">原密码</view>
  6. <input class="user_input" type="password" :value="oldPW" placeholder-class="phcolor" placeholder="请输入原密码" @input="oldPWInput" />
  7. </view>
  8. <view class="sepline" />
  9. <view class="user-cell">
  10. <view class="user-title">新密码</view>
  11. <input class="user_input" type="password" :value="newPW" placeholder-class="phcolor" placeholder="请输入新密码" @input="newPWInput" />
  12. </view>
  13. <view class="sepline" />
  14. <view class="user-cell">
  15. <view class="user-title">确认新密码</view>
  16. <input class="user_input" type="password" :value="againPW" placeholder-class="phcolor" placeholder="请再次输入新密码" @input="againPWInput" />
  17. </view>
  18. <view class="sepline" />
  19. <view class="password-commit" @tap="changePassword">提交</view>
  20. <van-toast id="van-toast" />
  21. </view>
  22. </template>
  23. <script>
  24. // pages/password/index.js
  25. let myPro = require('../../../utils/wxRequest.js');
  26. let util = require('../../../utils/util.js');
  27. var app = getApp();
  28. export default {
  29. data() {
  30. return {
  31. oldPW: '',
  32. newPW: '',
  33. againPW: ''
  34. };
  35. }
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */,
  39. onLoad: function (options) {},
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {},
  44. /**
  45. * 生命周期函数--监听页面显示
  46. */
  47. onShow: function () {},
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide: function () {},
  52. /**
  53. * 生命周期函数--监听页面卸载
  54. */
  55. onUnload: function () {},
  56. /**
  57. * 页面相关事件处理函数--监听用户下拉动作
  58. */
  59. onPullDownRefresh: function () {},
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom: function () {},
  64. /**
  65. * 用户点击右上角分享
  66. */
  67. onShareAppMessage: function () {},
  68. methods: {
  69. oldPWInput(e) {
  70. this.setData({
  71. oldPW: e.detail.value
  72. });
  73. },
  74. newPWInput(e) {
  75. this.setData({
  76. newPW: e.detail.value
  77. });
  78. },
  79. againPWInput(e) {
  80. this.setData({
  81. againPW: e.detail.value
  82. });
  83. },
  84. changePassword() {
  85. if (this.oldPW == null || this.oldPW == undefined || this.oldPW == '') {
  86. Toast('请输入原密码');
  87. return;
  88. }
  89. if (this.newPW == null || this.newPW == undefined || this.newPW == '') {
  90. Toast('请输入新密码');
  91. return;
  92. }
  93. if (this.againPW == null || this.againPW == undefined || this.againPW == '') {
  94. Toast('请再次输入新密码');
  95. return;
  96. }
  97. if (this.newPW == this.oldPW) {
  98. Toast('原密码和新密码相同,请检查');
  99. return;
  100. }
  101. if (this.newPW != this.againPW) {
  102. Toast('两次输入的密码不一致,请检查');
  103. return;
  104. }
  105. uni.showLoading({
  106. mask: true
  107. });
  108. var that = this;
  109. var params = {
  110. token: app.globalData.token,
  111. old_pwd: this.oldPW,
  112. new_pwd: this.newPW
  113. };
  114. myPro
  115. .wxRequest('staff/login', 'POST', params)
  116. .then((res) => {
  117. uni.hideLoading();
  118. var res = res.data;
  119. if (res.code == 200) {
  120. Toast('修改密码成功,请重新登录');
  121. setTimeout(function () {
  122. uni.reLaunch({
  123. url: '/pages/login/index'
  124. });
  125. }, 1000);
  126. } else {
  127. if (res.code == 401) {
  128. Toast('登录失效');
  129. setTimeout(function () {
  130. uni.reLaunch({
  131. url: '/pages/login/index'
  132. });
  133. }, 1000);
  134. } else {
  135. Toast(res.msg);
  136. }
  137. }
  138. })
  139. .catch((err) => {
  140. uni.hideLoading();
  141. console.log(err);
  142. });
  143. }
  144. }
  145. };
  146. </script>
  147. <style>
  148. /* pages/staff/password/index.wxss */
  149. .user-cell {
  150. width: 100%;
  151. height: 100rpx;
  152. display: flex;
  153. flex-direction: row;
  154. align-items: center;
  155. }
  156. .user-title {
  157. width: 130rpx;
  158. font-size: 26rpx;
  159. color: #525666;
  160. margin-left: 32rpx;
  161. }
  162. .user_input {
  163. width: 374rpx;
  164. height: 48rpx;
  165. font-size: 26rpx;
  166. padding-left: 20rpx;
  167. }
  168. .sepline {
  169. margin-left: 32rpx;
  170. margin-right: 32rpx;
  171. height: 2rpx;
  172. background-color: #e6e6e6;
  173. }
  174. .password-commit {
  175. margin-top: 60rpx;
  176. text-align: center;
  177. font-size: 30rpx;
  178. color: white;
  179. background-color: #558de0;
  180. height: 80rpx;
  181. margin-left: 32rpx;
  182. margin-right: 32rpx;
  183. border-radius: 12rpx;
  184. line-height: 80rpx;
  185. }
  186. </style>