userinfo.vue 6.9 KB

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