editinfo.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="main">
  3. <view class="cu-list menu">
  4. <view class="cu-item arrow" @click="isShowConfirm=true">
  5. <view class="content">
  6. <text class="text-grey">昵称</text>
  7. </view>
  8. <view class="action">
  9. <text class="text-grey text-sm">{{newName}}</text>
  10. </view>
  11. </view>
  12. <view class="cu-item arrow" @click="gotophone">
  13. <view class="content">
  14. <text class="text-grey">已绑定电话</text>
  15. </view>
  16. <view class="action">
  17. <text class="text-grey text-sm">{{phone!=''?phone:'未绑定手机号'}}</text>
  18. </view>
  19. </view>
  20. <view class="cu-item arrow" @click="gotopwd">
  21. <view class="content">
  22. <text class="text-grey">支付密码</text>
  23. </view>
  24. <view class="action">
  25. </view>
  26. </view>
  27. <view class="cu-item arrow" @click="switchNum">
  28. <view class="content">
  29. <text class="text-grey">退出登录</text>
  30. </view>
  31. <view class="action">
  32. </view>
  33. </view>
  34. </view>
  35. <block v-if="isShowConfirm">
  36. <view class='toast-box'>
  37. <view class='toastbg' @click.stop="isShowConfirm=false"></view>
  38. <view class='showToast'>
  39. <view class='toast-title'>
  40. <text>修改昵称</text>
  41. </view>
  42. <view class='toast-main'>
  43. <view class='toast-input'>
  44. <input type='text' placeholder='输入昵称' v-model="newName" data-name='stuEidtName'></input>
  45. </view>
  46. </view>
  47. <view class='toast-button'>
  48. <view class='button2'>
  49. <button type="default" @click.stop="editName">保存</button>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </block>
  55. <u-no-network></u-no-network>
  56. </view>
  57. </template>
  58. <script>
  59. import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
  60. export default {
  61. onLoad(options) {
  62. this.newName = options.name
  63. this.phone = options.phone
  64. },
  65. mounted() {
  66. },
  67. data() {
  68. return {
  69. isShowConfirm: false,
  70. newName: "",
  71. phone: "",
  72. }
  73. },
  74. methods: {
  75. ...mapMutations(['logout']),
  76. editName: async function() {
  77. let res = await this.$request.post("/api/v1/user/updateUser", {
  78. nickname: this.newName
  79. })
  80. if (res.status == 0) {
  81. this.isShowConfirm = false
  82. uni.showToast({
  83. title: "修改成功",
  84. icon: "none"
  85. })
  86. }
  87. },
  88. gotophone() {
  89. uni.navigateTo({
  90. url: "editphone"
  91. })
  92. },
  93. gotopwd() {
  94. uni.navigateTo({
  95. url: "paypassword"
  96. })
  97. },
  98. switchNum() {
  99. uni.showModal({
  100. title: "提示",
  101. content: "是否要注销当前账号",
  102. success: (res) => {
  103. if (res.confirm) {
  104. let that = this
  105. uni.showLoading({
  106. title: '清除中...'
  107. });
  108. setTimeout(function() {
  109. that.logout()
  110. uni.clearStorage();
  111. uni.hideLoading();
  112. uni.reLaunch({
  113. url:"index"
  114. })
  115. }, 2000);
  116. } else if (res.cancel) {
  117. }
  118. }
  119. })
  120. }
  121. }
  122. };
  123. </script>
  124. <style scoped lang="scss">
  125. .main {}
  126. .button2 button {
  127. width: 100%;
  128. font-size: 26rpx;
  129. height: 70rpx;
  130. color: #606266;
  131. background-color: #FFFFFF;
  132. border-radius: 0;
  133. border-top: 2rpx solid rgba(0, 0, 0, .2);
  134. }
  135. .button2 button::after {
  136. border: none;
  137. }
  138. .toast-box {
  139. width: 100%;
  140. height: 100%;
  141. opacity: 1;
  142. position: fixed;
  143. top: 0px;
  144. left: 0px;
  145. }
  146. .toastbg {
  147. opacity: 0.2;
  148. background-color: black;
  149. position: absolute;
  150. width: 100%;
  151. min-height: 100vh;
  152. }
  153. .showToast {
  154. position: absolute;
  155. opacity: 1;
  156. width: 70%;
  157. margin-left: 15%;
  158. margin-top: 40%;
  159. }
  160. .toast-title {
  161. padding-left: 5%;
  162. background-color: #2196f3;
  163. color: white;
  164. padding-top: 2vh;
  165. padding-bottom: 2vh;
  166. border-top-right-radius: 16rpx;
  167. border-top-left-radius: 16rpx;
  168. }
  169. .toast-main {
  170. padding-top: 2vh;
  171. padding-bottom: 2vh;
  172. background-color: white;
  173. text-align: center;
  174. }
  175. .toast-input {
  176. margin-left: 5%;
  177. margin-right: 5%;
  178. border: 1px solid #ddd;
  179. padding-left: 2vh;
  180. padding-right: 2vh;
  181. padding-top: 1vh;
  182. padding-bottom: 1vh;
  183. }
  184. </style>