userinfo.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <view class="background-img" @click.stop="imgsub()"><image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill"></image></view>
  6. </view>
  7. <view class="row">
  8. <text class="tit">昵称</text>
  9. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row">
  12. <text class="tit">ID</text>
  13. <input class="input" type="text" disabled="true" v-model="userInfo.uid" placeholder-class="placeholder" />
  14. </view>
  15. <view class="row">
  16. <text class="tit">账户</text>
  17. <input class="input" type="text" disabled="true" v-model="userInfo.phone" placeholder-class="placeholder" />
  18. </view>
  19. <view class="add-btn" @click="confirm">提交</view>
  20. <!-- <view class="out" @click="cancel">注销账户</view> -->
  21. <uni-popup ref="popup" type="center">
  22. <view class="psw-wrapper">
  23. <view class="psw-title">请输入自己的账户</view>
  24. <input type="text" v-model="password" class="psw-ipt" />
  25. <view class="psw-btn">
  26. <text @click.stop="qx">取消</text>
  27. <text class="psw-qd" @click.stop="pswQd">确定</text>
  28. </view>
  29. </view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. import { mapState,mapMutations } from 'vuex';
  35. import { upload } from '@/api/order.js';
  36. import {userEdit,logout} from '@/api/set.js';
  37. export default {
  38. data(){
  39. return{
  40. show:false,
  41. password: '',
  42. upFileLoding:false,
  43. }
  44. },
  45. onLoad() {
  46. console.log(this.userInfo)
  47. },
  48. computed: {
  49. ...mapState('user',['userInfo'])
  50. },
  51. methods: {
  52. ...mapMutations('user',['logout']),
  53. imgsub() {
  54. const that = this;
  55. if (that.upFileLoding) {
  56. return
  57. }
  58. that.upFileLoding = true;
  59. setTimeout(()=>{
  60. that.upFileLoding = false;
  61. },1000);
  62. upload({
  63. filename: ''
  64. }).then(data => {
  65. this.userInfo.avatar = data[0].url;
  66. }).catch((err) => {
  67. console.log(err);
  68. })
  69. },
  70. confirm() {
  71. userEdit({ avatar: this.userInfo.avatar ,nickname: this.userInfo.nickname})
  72. .then(e => {
  73. this.$api.msg('修改成功');
  74. setTimeout(()=> {
  75. uni.switchTab({
  76. url:'/pages/user/user'
  77. });
  78. }, 1000);
  79. console.log(e);
  80. })
  81. .catch(e => {
  82. console.log(e);
  83. });
  84. },
  85. toLogout(){
  86. let obj = this;
  87. uni.showModal({
  88. content: '确定要退出登录么',
  89. success: (e)=>{
  90. if(e.confirm){
  91. logout({}).then((e) => {
  92. uni.navigateBack();
  93. }).catch((e) => {
  94. console.log(e);
  95. })
  96. obj.logout();
  97. }
  98. }
  99. });
  100. },
  101. cancel(){
  102. this.$refs.popup.open();
  103. },
  104. qx() {
  105. this.password = '';
  106. this.$refs.popup.close();
  107. },
  108. pswQd() {
  109. if(this.password != this.userInfo.phone){
  110. this.$refs.popup.close();
  111. this.password = '';
  112. this.$api.msg("请输入自己的账户")
  113. return
  114. }
  115. this.$refs.popup.close();
  116. this.password = '';
  117. this.$api.msg("申请注销成功,请耐心等待审核")
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .row1 {
  124. display: flex;
  125. align-items: center;
  126. justify-content: space-between;
  127. position: relative;
  128. padding: 0 30upx;
  129. height: 110upx;
  130. background: #fff;
  131. margin-bottom: 20upx;
  132. .tit {
  133. flex-shrink: 0;
  134. width: 120upx;
  135. font-size: $font-lg;
  136. color: $font-color-dark;
  137. }
  138. .background-img {
  139. width: 80rpx;
  140. height: 80rpx;
  141. border-radius: 50%;
  142. background: #f2f2f2;
  143. }
  144. }
  145. .row {
  146. display: flex;
  147. align-items: center;
  148. padding: 0 30upx;
  149. height: 110upx;
  150. background: #fff;
  151. .tit {
  152. flex-shrink: 0;
  153. width: 120upx;
  154. font-size: $font-lg;
  155. color: $font-color-dark;
  156. }
  157. .input {
  158. flex: 1;
  159. text-align: right;
  160. font-size: $font-base;
  161. color: $color-gray;
  162. }
  163. }
  164. .add-btn {
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. margin: 158rpx auto 30rpx;
  169. width: 560rpx;
  170. height: 80rpx;
  171. background: #ECC697;
  172. border-radius: 40px;
  173. color: #FFFFFF;
  174. }
  175. .out {
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. margin: 0 auto 30rpx;
  180. width: 560rpx;
  181. height: 80rpx;
  182. border: 1px solid #32C6FF;
  183. background: #FFFFFF;
  184. border-radius: 40px;
  185. color: #32C6FF;
  186. }
  187. .psw-wrapper {
  188. width: 548rpx;
  189. height: 344rpx;
  190. background-color: #ffffff;
  191. .psw-title {
  192. width: 100%;
  193. font-size: 35rpx;
  194. padding: 43rpx 0 49rpx;
  195. text-align: center;
  196. font-weight: 800;
  197. }
  198. .psw-ipt {
  199. display: block;
  200. background-color: #dce3ed;
  201. height: 90rpx;
  202. width: 464rpx;
  203. padding-left: 30rpx;
  204. margin: 0 auto;
  205. font-size: 80rpx;
  206. }
  207. .psw-btn text {
  208. display: inline-block;
  209. text-align: center;
  210. width: 50%;
  211. padding-top: 29rpx;
  212. font-size: 35rpx;
  213. }
  214. .psw-qd {
  215. color: #32C6FF;
  216. }
  217. }
  218. </style>