system_setting.vue 6.5 KB

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