userinfo.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <!-- <view class="container">
  3. <uni-list>
  4. <uni-list-item title="个人资料" @click="navTo('/pages/set/userinfo')" ></uni-list-item>
  5. <uni-list-item title="修改密码" @click="navTo('/pages/set/password')" ></uni-list-item>
  6. <uni-list-item title="实名认证" @click="navTo('/pages/set/phone')" ></uni-list-item>
  7. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')" ></uni-list-item>
  8. </uni-list>
  9. <uni-list class="margin-t-20">
  10. <uni-list-item title="消息推送" :switch-checked='true' :show-switch="true" :show-arrow="false" switch-color='#5dbc7c' @switchChange='switchChange'>
  11. </uni-list-item>
  12. </uni-list>
  13. <uni-list class="margin-t-20">
  14. <uni-list-item title="清除缓存" ></uni-list-item>
  15. <uni-list-item title="检查更新" >
  16. <template slot="right">
  17. 当前版本 1.0.3
  18. </template>
  19. </uni-list-item>
  20. </uni-list>
  21. <view class="list-cell log-out-btn" @click="toLogout">
  22. <text class="cell-tit">退出登录</text>
  23. </view>
  24. </view> -->
  25. <view class="container">
  26. <view class="row b-b flex jg">
  27. <text class="tit">头像</text>
  28. <image :src="userInfo.avatar" @click.stop="imgsub"></image>
  29. </view>
  30. <view class="row b-b flex">
  31. <text class="tit">昵称</text>
  32. <input class="input" v-model="userInfo.nickname" type="text" placeholder-class="placeholder" />
  33. </view>
  34. <view class="row b-b flex">
  35. <text class="tit">ID</text>
  36. <input class="input" v-model="userInfo.uid" type="text" disabled="true" placeholder-class="placeholder" />
  37. </view>
  38. <view class="row b-b flex">
  39. <text class="tit">用户账号</text>
  40. <input class="input" v-model="userInfo.account || userInfo.phone" type="number" disabled="true" placeholder-class="placeholder" />
  41. </view>
  42. <view class="submit-box flex" >
  43. <view class="submit" @click="edit">确认修改</view>
  44. <!-- <view class="submit" @click="toLogout">退出登录</view> -->
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. // import uniList from "@/components/uni-list/uni-list.vue"
  50. // import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
  51. // import { logout } from '@/api/set.js';
  52. // import {
  53. // mapMutations
  54. // } from 'vuex';
  55. // export default {
  56. // components: {
  57. // uniList,uniListItem
  58. // },
  59. // data() {
  60. // return {
  61. // };
  62. // },
  63. // methods:{
  64. // ...mapMutations('user',['logout']),
  65. // navTo(url){
  66. // uni.navigateTo({
  67. // url:url
  68. // })
  69. // },
  70. // //退出登录
  71. // toLogout(){
  72. // let obj = this;
  73. // uni.showModal({
  74. // content: '确定要退出登录么',
  75. // success: (e)=>{
  76. // if(e.confirm){
  77. // logout({}).then((e) => {
  78. // uni.navigateBack();
  79. // }).catch((e) => {
  80. // console.log(e);
  81. // })
  82. // obj.logout();
  83. // }
  84. // }
  85. // });
  86. // },
  87. // //switch切换触发方法
  88. // switchChange(e){
  89. // console.log(e);
  90. // let statusTip = e.value ? '打开': '关闭';
  91. // this.$api.msg(`${statusTip}消息推送`);
  92. // },
  93. // }
  94. // }
  95. import uniList from '@/components/uni-list/uni-list.vue';
  96. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  97. import { mapState, mapMutations } from 'vuex';
  98. import { logout } from '@/api/set.js';
  99. import {
  100. uploads,edit,upload
  101. } from '@/api/user.js';
  102. export default {
  103. components: {
  104. uniList,
  105. uniListItem
  106. },
  107. data() {
  108. return {
  109. // nickName:'李淡淡',
  110. // id:'HFBNXISN',
  111. // account:'13745262356',
  112. userInfo:{},
  113. pics:[]
  114. };
  115. },
  116. onLoad() {
  117. this.userInfo = uni.getStorageSync('userInfo') || '';
  118. console.log(this.userInfo)
  119. },
  120. methods: {
  121. ...mapMutations('user',['logout']),
  122. //退出登录
  123. toLogout() {
  124. let obj = this;
  125. uni.showModal({
  126. content: '确定要退出登录么',
  127. success: e => {
  128. if (e.confirm) {
  129. logout({}).then(e => {
  130. obj.logout();
  131. uni.navigateTo({
  132. url:'/pages/public/login'
  133. })
  134. })
  135. .catch(e => {
  136. console.log(e);
  137. });
  138. }
  139. }
  140. });
  141. },
  142. imgsub() {
  143. let obj = this
  144. // console.log('上传头像')
  145. // this.$util.uploadImageOne('upload/image', function(res) {
  146. // console.log('------',res);
  147. // // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'http://zccy.liuniu946.com'));
  148. // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  149. // // obj.$set(this, 'pics', this.pics);
  150. // // obj.$set(this, 'extract_pic', this.pics[0])
  151. // });
  152. // uploads({
  153. // filename: ''
  154. // }).then(data => {
  155. // console.log("data",data);
  156. // this.userInfo.avatar = data[0].url;
  157. // })
  158. upload({
  159. filename: ''
  160. }).then(res => {
  161. console.log(res[0].url)
  162. obj.userInfo.avatar = res[0].url
  163. // console.log(obj.userInfo.avatar)
  164. });
  165. },
  166. edit() {
  167. const that = this;
  168. uni.showLoading({
  169. title: '提交中...',
  170. mask:true
  171. })
  172. edit({
  173. avatar: this.userInfo.avatar,
  174. nickname: this.userInfo.nickname
  175. }).then( e =>{
  176. uni.hideLoading()
  177. that.$api.msg('修改成功');
  178. setTimeout(()=> {
  179. uni.switchTab({
  180. url:'/pages/user/user'
  181. });
  182. }, 1000);
  183. }).catch(e =>{
  184. console.log(e);
  185. that.$api.msg('修改失败');
  186. })
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang='scss'>
  192. /* page{
  193. background: $page-color-base;
  194. }
  195. .list-cell{
  196. display:flex;
  197. align-items:baseline;
  198. padding: 20rpx $page-row-spacing;
  199. line-height:60rpx;
  200. position:relative;
  201. background: #fff;
  202. justify-content: center;
  203. &.log-out-btn{
  204. margin-top: 40rpx;
  205. .cell-tit{
  206. color: $uni-color-primary;
  207. text-align: center;
  208. margin-right: 0;
  209. }
  210. }
  211. .cell-tit{
  212. flex: 1;
  213. font-size: $font-base + 2rpx;
  214. color: $font-color-dark;
  215. margin-right:10rpx;
  216. }
  217. .cell-tip{
  218. font-size: $font-base;
  219. color: $font-color-light;
  220. }
  221. switch{
  222. transform: translateX(16rpx) scale(.84);
  223. }
  224. } */
  225. page {
  226. background-color: #f3f3f3;
  227. min-height: 100%;
  228. .container{
  229. height: 100%;
  230. }
  231. }
  232. .row {
  233. background-color: #fff;
  234. padding: 42rpx 25rpx;
  235. font-size: 30rpx;
  236. color: #333333;
  237. image{
  238. width: 80rpx;
  239. height: 80rpx;
  240. border-radius: 50%;
  241. }
  242. .input {
  243. text-align: right;
  244. color: #333333;
  245. }
  246. }
  247. .submit-box{
  248. padding-top: 157rpx;
  249. .submit{
  250. margin: 40rpx auto;
  251. width: 560rpx;
  252. background-color: #ff4c4b;
  253. color: #FFFFFF;
  254. text-align: center;
  255. padding:26rpx 0rpx;
  256. border-radius: 50rpx;
  257. }
  258. }
  259. .jg {
  260. margin-bottom: 20rpx;
  261. }
  262. </style>