userinfo.vue 6.9 KB

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