userinfo.vue 5.3 KB

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