set.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="address-form">
  3. <view class="bg-white p-0-30 f30">
  4. <view class="d-b-c border-b info-item avatar">
  5. <text class="key-name">头像</text>
  6. <view class="d-e-c" @click="changeAvatarUrl">
  7. <view class="info-image">
  8. <image :src="userInfo.avatarUrl || '/static/default.png'" mode=""></image>
  9. </view>
  10. <text class="icon iconfont icon-jiantou"></text>
  11. </view>
  12. </view>
  13. <view class="d-b-c p-30-0 border-b">
  14. <text class="key-name">会员ID</text>
  15. <view class="d-e-c">
  16. <text class="mr20">{{userInfo.user_id}}</text>
  17. </view>
  18. </view>
  19. <view class="d-b-c p-30-0 border-b">
  20. <text class="key-name">昵称</text>
  21. <view class="d-e-c" @click="changeName('nickName')">
  22. <text class="mr20">{{userInfo.nickName}}</text>
  23. <text class="icon iconfont icon-jiantou"></text>
  24. </view>
  25. </view>
  26. <view class="d-b-c p-30-0">
  27. <text class="key-name">手机号码</text>
  28. <view class="d-e-c" v-if="userInfo.mobile">
  29. <text class="mr20">{{userInfo.mobile}}</text>
  30. </view>
  31. <view class="d-e-c" v-if="!userInfo.mobile" @click="gotoBind">
  32. <text class="mr20">未绑定</text>
  33. <text class="iconfont icon-jiantou"></text>
  34. </view>
  35. </view>
  36. <view class="setup-btn" @tap="logout()">退出登录</view>
  37. </view>
  38. <!-- 修改资料 -->
  39. <Popup :show="isPopup" type='bottom' :width="750" :padding="0" @hidePopup="hidePopupFunc">
  40. <view class="d-s-s d-c p20 mpservice-wrap">
  41. <view class="tc f32 fb ww100">修改</view>
  42. <template v-if="type=='mobile' || type=='nickName' ||type=='user_name' ||type=='email'||type=='idcard'">
  43. <view class="pop-input d-b-c">
  44. <input type="text" class="flex-1" placeholder="请输入" :value="newName" @input="changeinput" />
  45. <view class="icon-guanbi icon iconfont" @click="clearName"></view>
  46. </view>
  47. </template>
  48. <view class="d-a-c ww100">
  49. <button class="btn-gray-border" @click="hidePopupFunc">取消</button>
  50. <button class="btn-gcred" @click="subName">确认</button>
  51. </view>
  52. </view>
  53. </Popup>
  54. <!-- 上传头像 -->
  55. <Upload v-if="isUpload" :num='1' @getImgs="getImgsFunc"></Upload>
  56. </view>
  57. </template>
  58. <script>
  59. import Upload from '@/components/upload/upload.vue';
  60. import Popup from '@/components/uni-popup.vue';
  61. export default {
  62. components: {
  63. Upload,
  64. Popup
  65. },
  66. data() {
  67. return {
  68. userInfo: {},
  69. isUpload: false,
  70. isPopup: false,
  71. newName: '',
  72. type: ''
  73. };
  74. },
  75. onShow() {
  76. /*获取个人中心数据*/
  77. this.getData();
  78. },
  79. methods: {
  80. /*获取数据*/
  81. getData() {
  82. let self = this;
  83. uni.showLoading({
  84. title: '加载中'
  85. });
  86. self._get('user.index/setting', {}, function(res) {
  87. self.userInfo = res.data.userInfo;
  88. uni.hideLoading();
  89. });
  90. },
  91. gotoBind() {
  92. this.gotoPage("/pages/user/modify-phone/modify-phone");
  93. },
  94. logout() {
  95. uni.removeStorageSync('token');
  96. uni.removeStorageSync('user_id');
  97. this.gotoPage('/pages/index/index');
  98. },
  99. changeName(type) {
  100. let self = this;
  101. if (type == 'mobile') {
  102. self.oldmobile = self.userInfo.mobile;
  103. }
  104. self.type = type;
  105. self.newName = self.userInfo[type];
  106. self.isPopup = true;
  107. },
  108. hidePopupFunc() {
  109. this.newName = '';
  110. this.isPopup = false;
  111. },
  112. changeinput(e) {
  113. this.newName = e.target.value;
  114. },
  115. clearName() {
  116. this.newName = '';
  117. },
  118. subName() {
  119. let self = this;
  120. if (self.loading) {
  121. return
  122. }
  123. self.userInfo[self.type] = this.newName;
  124. self.update()
  125. },
  126. /* 修改头像 */
  127. changeAvatarUrl() {
  128. let self = this;
  129. self.isUpload = true;
  130. },
  131. /*获取上传的图片*/
  132. getImgsFunc(e) {
  133. let self = this;
  134. self.isUpload = false;
  135. if (e && typeof(e) != 'undefined') {
  136. let self = this;
  137. self.userInfo.avatarUrl = e[0].file_path;
  138. self.update();
  139. }
  140. },
  141. update() {
  142. let self = this;
  143. if (self.loading) {
  144. return
  145. }
  146. uni.showLoading({
  147. title: '加载中'
  148. })
  149. let params = self.userInfo;
  150. self.loading = true;
  151. self._post('user.user/updateInfo', params, function(res) {
  152. self.showSuccess('修改成功', function() {
  153. self.loading = false;
  154. self.isPopup = false;
  155. uni.hideLoading();
  156. self.getData();
  157. },
  158. function(err) {
  159. uni.hideLoading();
  160. self.loading = false;
  161. self.isPopup = false;
  162. }
  163. )
  164. });
  165. },
  166. }
  167. };
  168. </script>
  169. <style lang="scss">
  170. .address-form .key-name {
  171. width: 200rpx;
  172. }
  173. .address-form .btn-red {
  174. height: 88rpx;
  175. line-height: 88rpx;
  176. border-radius: 44rpx;
  177. box-shadow: 0 8rpx 16rpx 0 rgba(226, 35, 26, .6);
  178. }
  179. .setup-btn {
  180. position: fixed;
  181. bottom: 20rpx;
  182. left: 5%;
  183. width: 90%;
  184. height: 80rpx;
  185. line-height: 80rpx;
  186. border-radius: 80rpx;
  187. background-color: #fd3826;
  188. color: #fff;
  189. font-size: 30rpx;
  190. display: flex;
  191. justify-content: center;
  192. margin: 0 auto;
  193. }
  194. .info-item.avatar {
  195. height: 162rpx;
  196. }
  197. .info-image {
  198. width: 112rpx;
  199. height: 112rpx;
  200. border-radius: 10rpx;
  201. margin-right: 20rpx;
  202. image {
  203. width: 112rpx;
  204. height: 112rpx;
  205. border-radius: 10rpx;
  206. }
  207. }
  208. .make-item {
  209. height: 60rpx;
  210. }
  211. .btn-red.code-btn {
  212. height: 54rpx;
  213. line-height: 54rpx;
  214. }
  215. .btn-red.code-btn.issend {
  216. background: #666666;
  217. border: none;
  218. color: #FFFFFF;
  219. box-shadow: none;
  220. }
  221. .pop-input {
  222. width: 100%;
  223. margin: 26rpx 0;
  224. box-sizing: border-box;
  225. border-bottom: 2rpx solid #D9D9D9;
  226. }
  227. .pop-input input {
  228. width: 100%;
  229. padding-left: 15rpx;
  230. font-size: 26rpx;
  231. color: #333333;
  232. margin: 16rpx 0;
  233. text-align: left;
  234. height: 60rpx;
  235. line-height: 60rpx;
  236. }
  237. .pop-input .icon.icon-guanbi {
  238. width: 38rpx;
  239. height: 38rpx;
  240. background-color: #999999;
  241. color: #FFFFFF;
  242. font-size: 22rpx;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. border-radius: 50%;
  247. opacity: 0.8;
  248. }
  249. .sub-box {
  250. padding: 40rpx 0;
  251. .setup-btn {
  252. width: 686rpx;
  253. height: 84rpx;
  254. background: #E03325;
  255. border-radius: 6rpx;
  256. line-height: 84rpx;
  257. color: #fff;
  258. font-size: 30rpx;
  259. display: flex;
  260. justify-content: center;
  261. margin: 0 auto;
  262. }
  263. }
  264. </style>