userinfo.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 {
  119. upload
  120. } from '@/api/order.js'
  121. export default {
  122. components: {
  123. uniList,
  124. uniListItem
  125. },
  126. data() {
  127. return {
  128. userInfo: {},
  129. pics: [],
  130. };
  131. },
  132. onLoad() {
  133. this.userInfo = uni.getStorageSync('userInfo') || '';
  134. console.log(this.userInfo)
  135. },
  136. methods: {
  137. ...mapMutations('user', ['logout']),
  138. //退出登录
  139. toLogout() {
  140. let obj = this;
  141. uni.showModal({
  142. content: '确定要退出登录么',
  143. success: e => {
  144. if (e.confirm) {
  145. logout({}).then(e => {
  146. obj.logout();
  147. uni.switchTab({
  148. url: '/pages/index/index'
  149. })
  150. })
  151. .catch(e => {
  152. console.log(e);
  153. });
  154. }
  155. }
  156. });
  157. },
  158. imgsub() {
  159. let obj = this
  160. console.log('上传头像')
  161. // this.$util.uploadImageOne('upload/image', function(res) {
  162. // console.log('------',res);
  163. // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'https://hy.liuniu946.com'));
  164. // // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  165. // obj.$set(this, 'pics', this.pics);
  166. // obj.$set(this, 'extract_pic', this.pics[0])
  167. // });
  168. // uploads({
  169. // filename: ''
  170. // }).then(data => {
  171. // console.log("data",data);
  172. // this.userInfo.avatar = data[0].url;
  173. // })
  174. upload({
  175. filename: ''
  176. }).then(res => {
  177. console.log(res[0].url)
  178. obj.userInfo.avatar = res[0].url
  179. // console.log(obj.userInfo.avatar)
  180. });
  181. },
  182. edit() {
  183. const that = this;
  184. uni.showLoading({
  185. title: '提交中...',
  186. mask: true
  187. })
  188. edit({
  189. avatar: this.userInfo.avatar,
  190. nickname: this.userInfo.nickname
  191. }).then(e => {
  192. uni.hideLoading()
  193. that.$api.msg('修改成功');
  194. setTimeout(() => {
  195. uni.switchTab({
  196. url: '/pages/user/user'
  197. });
  198. }, 1000);
  199. }).catch(e => {
  200. console.log(e);
  201. that.$api.msg('修改失败');
  202. })
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang='scss'>
  208. /* page{
  209. background: $page-color-base;
  210. }
  211. .list-cell{
  212. display:flex;
  213. align-items:baseline;
  214. padding: 20rpx $page-row-spacing;
  215. line-height:60rpx;
  216. position:relative;
  217. background: #fff;
  218. justify-content: center;
  219. &.log-out-btn{
  220. margin-top: 40rpx;
  221. .cell-tit{
  222. color: $uni-color-primary;
  223. text-align: center;
  224. margin-right: 0;
  225. }
  226. }
  227. .cell-tit{
  228. flex: 1;
  229. font-size: $font-base + 2rpx;
  230. color: $font-color-dark;
  231. margin-right:10rpx;
  232. }
  233. .cell-tip{
  234. font-size: $font-base;
  235. color: $font-color-light;
  236. }
  237. switch{
  238. transform: translateX(16rpx) scale(.84);
  239. }
  240. } */
  241. page {
  242. background-color: #f3f3f3;
  243. min-height: 100%;
  244. .container {
  245. height: 100%;
  246. }
  247. }
  248. .row {
  249. background-color: #fff;
  250. padding: 42rpx 25rpx;
  251. font-size: 30rpx;
  252. color: #333333;
  253. image {
  254. width: 80rpx;
  255. height: 80rpx;
  256. border-radius: 50%;
  257. }
  258. .input {
  259. text-align: right;
  260. color: #333333;
  261. }
  262. }
  263. .submit-box {
  264. display: flex;
  265. flex-direction: column;
  266. padding-top: 157rpx;
  267. .submit {
  268. margin: 40rpx auto;
  269. width: 560rpx;
  270. background-color: #ff4c4b;
  271. color: #FFFFFF;
  272. text-align: center;
  273. padding: 26rpx 0rpx;
  274. border-radius: 50rpx;
  275. }
  276. .dl {
  277. background-color: #FFFFFF;
  278. color: #ff4c4b;
  279. }
  280. }
  281. .jg {
  282. margin-bottom: 20rpx;
  283. }
  284. </style>