userinfo.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. <vie<!-- w class="row">
  12. <text class="tit">{{$t('set.a3')}}</text>
  13. <view class="input">
  14. {{userInfo.account}}
  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">{{$t('safe.f3')}}</view>
  27. <input type="text" v-model="password" class="psw-ipt" />
  28. <view class="psw-btn">
  29. <text @click.stop="qx">{{$t('zy.b4')}}</text>
  30. <text class="psw-qd" @click.stop="pswQd">{{$t('zy.b3')}}</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. uni.showToast({
  68. // title: '修改成功',
  69. title: this.$t("safe.d3"),
  70. icon:"success",
  71. mask:true
  72. });
  73. setTimeout(()=> {
  74. uni.switchTab({
  75. url:'/pages/user/user'
  76. });
  77. }, 1000);
  78. console.log(e);
  79. })
  80. .catch(e => {
  81. console.log(e);
  82. });
  83. },
  84. toLogout(){
  85. let obj = this;
  86. uni.showModal({
  87. content: this.$t('login.b7'),
  88. success: (e)=>{
  89. if(e.confirm){
  90. logout({}).then((e) => {
  91. uni.navigateBack();
  92. }).catch((e) => {
  93. console.log(e);
  94. })
  95. obj.logout();
  96. }
  97. }
  98. });
  99. },
  100. cancel(){
  101. // this.$refs.popup.open();
  102. let obj = this;
  103. uni.showModal({
  104. content: this.$t('login.b7'),
  105. success: e => {
  106. if (e.confirm) {
  107. logout({}).then(e => {
  108. obj.logout();
  109. uni.switchTab({
  110. url: '/pages/index/index'
  111. })
  112. })
  113. .catch(e => {
  114. console.log(e);
  115. });
  116. }
  117. }
  118. });
  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(obj.$t("safe.f3"))
  129. return
  130. }
  131. this.$refs.popup.close();
  132. this.password = '';
  133. this.$api.msg(obj.$t("safe.f4"))
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. page{
  140. background-color: #f3f3f3;
  141. }
  142. .list-cell{
  143. display:flex;
  144. align-items:baseline;
  145. padding: 20rpx $page-row-spacing;
  146. line-height:60rpx;
  147. position:relative;
  148. background: #fff;
  149. justify-content: center;
  150. &.log-out-btn{
  151. margin-top: 40rpx;
  152. .cell-tit{
  153. text-align: center;
  154. margin-right: 0;
  155. }
  156. }
  157. .cell-tit{
  158. flex: 1;
  159. font-size: $font-base + 2rpx;
  160. color: $font-color-dark;
  161. margin-right:10rpx;
  162. }
  163. }
  164. .row1 {
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. position: relative;
  169. padding: 0 30upx;
  170. height: 110upx;
  171. background: #fff;
  172. margin-bottom: 20upx;
  173. .tit {
  174. flex-shrink: 0;
  175. width: 120upx;
  176. font-size: $font-lg;
  177. color: $font-color-dark;
  178. }
  179. .background-img {
  180. width: 80rpx;
  181. height: 80rpx;
  182. border-radius: 50%;
  183. background: #f2f2f2;
  184. }
  185. }
  186. .row {
  187. display: flex;
  188. align-items: center;
  189. padding: 0 30upx;
  190. height: 110upx;
  191. background: #fff;
  192. border-bottom:1px solid $border-color-light ;
  193. .tit {
  194. flex-shrink: 0;
  195. width: 120upx;
  196. font-size: $font-lg;
  197. color: $font-color-dark;
  198. }
  199. .input {
  200. flex: 1;
  201. text-align: right;
  202. font-size: $font-base;
  203. color: $color-gray;
  204. }
  205. }
  206. .add-btn {
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. margin: 158rpx auto 30rpx;
  211. width: 560rpx;
  212. height: 80rpx;
  213. background: #feca00;
  214. border-radius: 40px;
  215. color: #FFFFFF;
  216. }
  217. .out {
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. margin: 0 auto 30rpx;
  222. width: 560rpx;
  223. height: 80rpx;
  224. border: 1px solid #feca00;
  225. background: #FFFFFF;
  226. border-radius: 40px;
  227. color: #feca00;
  228. }
  229. .psw-wrapper {
  230. width: 548rpx;
  231. height: 344rpx;
  232. background-color: #ffffff;
  233. .psw-title {
  234. width: 100%;
  235. font-size: 35rpx;
  236. padding: 43rpx 0 49rpx;
  237. text-align: center;
  238. font-weight: 800;
  239. }
  240. .psw-ipt {
  241. display: block;
  242. background-color: #dce3ed;
  243. height: 90rpx;
  244. width: 464rpx;
  245. padding-left: 30rpx;
  246. margin: 0 auto;
  247. font-size: 80rpx;
  248. }
  249. .psw-btn text {
  250. display: inline-block;
  251. text-align: center;
  252. width: 50%;
  253. padding-top: 29rpx;
  254. font-size: 35rpx;
  255. }
  256. .psw-qd {
  257. color: #32C6FF;
  258. }
  259. }
  260. </style>