userinfo.vue 5.1 KB

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