system_setting.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="total-page page-box task-bg">
  3. <Nav :type="1" :genre="2" :title="title" :is_fixed="true">
  4. <view class="sys-background-fff m-30 r-30 p-lr30">
  5. <view class="from-animation animate__animated animate__fadeIn" v-if="id === 2">
  6. <view class="p-tb30 bor-bottom-1 row-c" :class="{'apply-shake':phoneShake}">
  7. <text class="size-28 sys-weight-400 input-text">原密码</text>
  8. <en-input focus type="password" class="m-l30" placeholder="请输入原密码"
  9. v-model="passData.old_password" maxlength="11"></en-input>
  10. </view>
  11. <view class="p-tb30 row-c">
  12. <text class="size-28 sys-weight-400 input-text">新密码</text>
  13. <en-input :type="is_password?'text':'password'" class="m-l30" placeholder="请输入新密码"
  14. v-model="passData.password"></en-input>
  15. <image class="eye-class wh-45" :src="`https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/login/${is_password?'eye-filled':'eye'}.png`"
  16. mode="aspectFill" @click="is_password = !is_password"></image>
  17. </view>
  18. <view class="p-tb30 row-c">
  19. <text class="size-28 sys-weight-400 input-text">确认密码</text>
  20. <en-input :type="is_pass_two?'text':'password'" class="m-l30" placeholder="请确认密码"
  21. v-model="passData.pass_two"></en-input>
  22. <image class="eye-class wh-45" :src="`https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/login/${is_pass_two?'eye-filled':'eye'}.png`"
  23. mode="aspectFill" @click="is_pass_two = !is_pass_two"></image>
  24. </view>
  25. </view>
  26. <view class="from-animation animate__animated animate__fadeIn" v-if="id === 3">
  27. <view class="p-tb30 bor-bottom-1 row-c" :class="{'apply-shake':phoneShake}">
  28. <text class="size-28 sys-weight-400">手机号</text>
  29. <en-input focus type="number" class="m-l30" placeholder="请输入手机号" v-model="memberData.phone"
  30. maxlength="11"></en-input>
  31. </view>
  32. <view class="p-tb30 row-c">
  33. <text class="size-28 sys-weight-400 p-r30">验证码</text>
  34. <en-input type="password" class="flex" placeholder="验证码" v-model="memberData.code"></en-input>
  35. <view class="text-color-dominant sys-size-28 sys-weight-400" @click="getVerifiedCode"
  36. v-if="timeNum<=0">发送验证码
  37. </view>
  38. <view class="login-send text-color-dominant sys-size-28 sys-weight-400" v-else>{{timeNum}} s
  39. </view>
  40. </view>
  41. </view>
  42. <view class="p-tb30 row-c" :class="{'apply-shake':phoneShake}" v-if="id === 4">
  43. <text class="size-28 sys-weight-400">昵称</text>
  44. <en-input focus class="m-l30" placeholder="请输入昵称" v-model="memberData.nickname"
  45. maxlength="11"></en-input>
  46. </view>
  47. <view class="p-tb30 row-c" :class="{'apply-shake':phoneShake}" v-if="id === 5">
  48. <text class="size-28 sys-weight-400">姓名</text>
  49. <en-input focus class="m-l30" placeholder="请输入姓名" v-model="memberData.name"
  50. maxlength="11"></en-input>
  51. </view>
  52. </view>
  53. <EnButton :text="'保存'" :is_fixed="false" @onSubmit="onSubmit"></EnButton>
  54. </Nav>
  55. </view>
  56. </template>
  57. <script>
  58. import EnInput from "@/components/en-from/en-input/index.vue";
  59. import {
  60. getMemberInfo,
  61. setPassword,
  62. updateMemberInfo,
  63. updatePhone
  64. } from "@/api/user";
  65. import tools from "@/service/tools";
  66. import {
  67. commonSend
  68. } from "@/api/common";
  69. export default {
  70. components: {
  71. EnInput
  72. },
  73. data() {
  74. return {
  75. id: 0,
  76. timeNum: 0,
  77. title: '',
  78. placeholder: '',
  79. phoneShake: false,
  80. is_password: false,
  81. is_pass_two: false,
  82. memberData: {
  83. 'head_img': "",
  84. 'name': "",
  85. 'nickname': "",
  86. 'phone': "",
  87. 'position_name': "",
  88. code: '',
  89. },
  90. passData: {
  91. old_password: '',
  92. password: '',
  93. pass_two: '',
  94. },
  95. }
  96. },
  97. onLoad(options) {
  98. this.id = options.id * 1
  99. this.title = options.title
  100. this.getMemberInfo()
  101. },
  102. methods: {
  103. getMemberInfo() {
  104. getMemberInfo({
  105. 'type': 2
  106. }).then((res) => {
  107. if (res.code === 1) {
  108. this.memberData = res.data;
  109. }
  110. })
  111. },
  112. updateMemberInfo() {
  113. updateMemberInfo(this.memberData).then((res) => {
  114. if (res.code === 1) {
  115. tools.success('设置成功')
  116. uni.$emit('updateMemberInfo')
  117. setTimeout(() => {
  118. tools.leftClick()
  119. }, 1500)
  120. } else {
  121. tools.error(res.msg)
  122. }
  123. })
  124. },
  125. onSubmit() {
  126. // this.phoneShake = true
  127. // setTimeout(() => {
  128. // this.phoneShake = false
  129. // this.passwordShake = false
  130. // this.codedShake = false
  131. // }, 500)
  132. if (this.id >= 4) {
  133. this.updateMemberInfo()
  134. } else if (this.id === 3) {
  135. this.updatePhone()
  136. } else {
  137. this.setPassword()
  138. }
  139. },
  140. setPassword() {
  141. if (this.passData.password !== this.passData.pass_two) {
  142. tools.error('两次密码不一致')
  143. return
  144. }
  145. setPassword(this.passData).then((res) => {
  146. if (res.code === 1) {
  147. tools.success(res.msg)
  148. setTimeout(() => {
  149. this.leftClick();
  150. }, 1500)
  151. } else {
  152. tools.error(res.msg)
  153. }
  154. })
  155. },
  156. updatePhone() {
  157. updatePhone(this.memberData).then((res) => {
  158. if (res.code === 1) {
  159. tools.success(res.msg)
  160. uni.$emit('updateMemberInfo')
  161. setTimeout(() => {
  162. this.leftClick();
  163. }, 1500)
  164. } else {
  165. tools.error(res.msg)
  166. }
  167. })
  168. },
  169. getVerifiedCode() {
  170. if (this.timeNum > 0) {
  171. return;
  172. }
  173. if (this.memberData.phone === '') {
  174. tools.error("请输入手机号码")
  175. return;
  176. }
  177. let regPhone = /^(?:(?:\+|00)86)?1\d{10}$/;
  178. if (!regPhone.test(this.memberData.phone)) {
  179. tools.error("手机号码格式错误")
  180. return;
  181. }
  182. commonSend({
  183. 'phone': this.memberData.phone,
  184. 'send_type': 'retrieve'
  185. }).then((res) => {
  186. if (res.code === 1) {
  187. tools.success(res.msg);
  188. this.timeNum = 60;
  189. this.timer = setInterval(() => {
  190. this.timeNum--;
  191. if (this.timeNum <= 0) {
  192. clearInterval(this.timer);
  193. }
  194. }, 1000);
  195. } else {
  196. tools.error(res.msg);
  197. }
  198. })
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .input-text {
  205. display: block;
  206. width: 120rpx;
  207. text-align: right;
  208. }
  209. .input-item {
  210. height: 96rpx;
  211. padding: 28rpx 40rpx;
  212. box-sizing: border-box;
  213. .login-input {
  214. width: 100%;
  215. }
  216. }
  217. .input-item:last-child {
  218. margin-top: 30rpx;
  219. }
  220. .input-send {
  221. display: flex;
  222. justify-content: flex-start;
  223. align-items: center;
  224. .login-input {
  225. width: calc(100% - 140rpx);
  226. }
  227. .login-send {
  228. width: 140rpx;
  229. text-align: center;
  230. }
  231. }
  232. .input-but {
  233. margin-top: 40rpx;
  234. width: 100%;
  235. height: 96rpx;
  236. line-height: 96rpx;
  237. text-align: center;
  238. }
  239. .eye-class {}
  240. </style>