index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view>
  3. <!-- 头像区域 -->
  4. <view class="avatar-region">
  5. <view class="flex-items">
  6. <view class="font32 mar-l-20">
  7. 头像
  8. </view>
  9. <view class="mar-l-auto mar-r-20">
  10. <u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" :maxCount="1">
  11. <view class="flex-items">
  12. <image class="avatar" :src="user.avatar||'../../../static/images/avatar.png'"
  13. mode="aspectFill">
  14. </image>
  15. <uni-icons color="#d0d7df" type="right" size="30"></uni-icons>
  16. </view>
  17. </u-upload>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 基本信息区域 -->
  22. <view class="info-region">
  23. <view class="font-gray mar-l-20 mar-b-30">
  24. 基本信息
  25. </view>
  26. <view class="flex-items mar-b-50">
  27. <view class="font32 mar-l-20">
  28. 昵称
  29. </view>
  30. <view class="mar-l-auto mar-r-20" @click="changeAccount">
  31. <view class="flex-items">
  32. <view class="font32 font-gray">
  33. {{user.account}}
  34. </view>
  35. <view>
  36. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="flex-items mar-b-50" @click="changeBirthday">
  42. <view class="font32 mar-l-20 ">
  43. 生日
  44. </view>
  45. <view class="mar-l-auto mar-r-20">
  46. <view class="flex-items">
  47. <view class="font32 font-gray">
  48. {{user.birthday}}
  49. </view>
  50. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="flex-items mar-b-50" @click="changeSex">
  55. <view class="font32 mar-l-20 ">
  56. 性别
  57. </view>
  58. <view class="mar-l-auto mar-r-20">
  59. <view class="flex-items">
  60. <view class="font32 font-gray" v-if="user.sex==0">
  61. </view>
  62. <view class="font32 font-gray" v-if="user.sex==1">
  63. </view>
  64. <view class="font32 font-gray " v-if="user.sex==2">
  65. 其他
  66. </view>
  67. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="flex-items mar-b-50">
  72. <view class="font32 mar-l-20 ">
  73. 上级昵称
  74. </view>
  75. <view class="mar-l-auto mar-r-20">
  76. <view class="flex-items">
  77. <view class="font32 font-gray ">
  78. {{user.parentAccount||'-'}}
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="flex-items mar-b-50" @tap="goLevelPath">
  84. <view class="font32 mar-l-20 ">
  85. 会员等级
  86. </view>
  87. <view class="mar-l-auto mar-r-20">
  88. <view class="flex-items">
  89. <view class="font32 font-gray ">
  90. <text v-if="user.level == '0'">普通会员</text>
  91. <text v-else-if="user.level == '1'">S级会员</text>
  92. <text v-else-if="user.level == '2'">SS级会员</text>
  93. <text v-else-if="user.level == '3'">SSS级会员</text>
  94. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="flex-items mar-b-50" @tap="goAgentPath">
  100. <view class="font32 mar-l-20 ">
  101. 代理等级
  102. </view>
  103. <view class="mar-l-auto mar-r-20">
  104. <view class="flex-items">
  105. <view class="font32 font-gray ">
  106. <text v-if="user.agent == 2">荣耀代理</text>
  107. <text v-else-if="user.agent == 3">超凡代理</text>
  108. <text v-else>无</text>
  109. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- <view class="flex-items mar-b-20">
  115. <view class="font32 mar-l-20 ">
  116. 国家/地区
  117. </view>
  118. <view class="mar-l-auto mar-r-20">
  119. <view class="flex-items">
  120. <view class="font32 font-gray">
  121. {{user.nation}}
  122. </view>
  123. <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
  124. </view>
  125. </view>
  126. </view> -->
  127. </view>
  128. <view class=" flex-center">
  129. <!-- <button class="loginBtn" style="background-color: #3C86F7;" type="primary"
  130. @click="handlerLogout">退出登录</button> -->
  131. <button @click="handlerLogout" class="logout-button">
  132. 退出登录
  133. </button>
  134. </view>
  135. </view>
  136. </template>
  137. <script>
  138. import {
  139. memberDetail,
  140. memberUpdate
  141. } from '@/config/api';
  142. import {
  143. mapMutations,
  144. mapActions,
  145. mapGetters
  146. } from 'vuex';
  147. import {
  148. UPLOAD_URL
  149. } from '@/common/config.js'
  150. export default {
  151. data() {
  152. return {
  153. fileList: [],
  154. user: {},
  155. token: "",
  156. };
  157. },
  158. computed: {
  159. ...mapGetters(['userInfo'])
  160. },
  161. onLoad() {
  162. this.token = uni.getStorageSync('access_token')
  163. },
  164. onShow() {
  165. this.detail()
  166. console.log(this.user)
  167. },
  168. methods: {
  169. ...mapActions(['logout']),
  170. goAgentPath() {
  171. uni.showModal({
  172. title: '升级/续费代理',
  173. content: '购买代理套餐即可升级或续费代理,\n立即前往?',
  174. success: (res) => {
  175. if (res.confirm) {
  176. // 这里可以跳转到代理升级页面
  177. this.$route('/packageShop/pages/search/product-list?serachKey=' + "代理")
  178. }
  179. }
  180. });
  181. },
  182. goLevelPath() {
  183. this.$route('/packageUser/pages/level/index')
  184. },
  185. handlerLogout() {
  186. this.logout()
  187. uni.$u.toast("退出登录")
  188. uni.navigateBack({
  189. delta: 1 // delta 表示返回的页面数,1 表示返回上一页
  190. });
  191. },
  192. changeSex() {
  193. this.$route('/packageUser/pages/user-info/sex-change?id=' + this.user.sex + '&id=' + this.user.id)
  194. },
  195. changeAccount() {
  196. this.$route('/packageUser/pages/user-info/account-change?id=' + this.user.account + '&id=' + this.user.id)
  197. },
  198. changeBirthday() {
  199. this.$route('/packageUser/pages/user-info/birthday-change?account=' + this.user.birthdat + '&id=' + this
  200. .user.id)
  201. },
  202. // 删除图片
  203. deletePic(event) {
  204. this.fileList.splice(event.index, 1)
  205. },
  206. // 新增图片
  207. async afterRead(event) {
  208. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  209. let lists = [].concat(event.file)
  210. console.log(lists, "list")
  211. let fileListLen = this.fileList.length
  212. for (let i = 0; i < lists.length; i++) {
  213. const result = await this.uploadFilePromise(lists[i].thumb)
  214. this.user.avatar = result.data.link
  215. let item = this.fileList[fileListLen]
  216. }
  217. memberUpdate(this.user)
  218. },
  219. uploadFilePromise(url) {
  220. return new Promise((resolve, reject) => {
  221. let a = uni.uploadFile({
  222. url: UPLOAD_URL,
  223. filePath: url,
  224. header: {
  225. "Blade-Auth": this.token
  226. },
  227. name: 'file',
  228. formData: {
  229. user: 'test'
  230. },
  231. success: (res) => {
  232. resolve(JSON.parse(res.data))
  233. }
  234. });
  235. })
  236. },
  237. async detail() {
  238. const data = await memberDetail()
  239. if (data.code == 200) {
  240. this.user = data.data
  241. uni.setStorageSync('user', this.user)
  242. }
  243. },
  244. goPage() {
  245. // this.$Router.push({ path: '/pages/user/set-avatar' });
  246. }
  247. },
  248. };
  249. </script>
  250. <style>
  251. .arrow {
  252. width: 32rpx;
  253. height: 32rpx;
  254. margin-top: 13rpx;
  255. }
  256. .h28 {
  257. height: 56rpx;
  258. }
  259. .avatar-region {
  260. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  261. border-radius: 40rpx;
  262. width: 700rpx;
  263. height: auto;
  264. padding-bottom: 30rpx;
  265. padding-top: 30rpx;
  266. background-color: white;
  267. margin-top: 30rpx;
  268. margin-bottom: 30rpx;
  269. margin-left: 25rpx;
  270. }
  271. .info-region {
  272. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  273. border-radius: 40rpx;
  274. width: 700rpx;
  275. height: auto;
  276. padding-bottom: 30rpx;
  277. padding-top: 30rpx;
  278. background-color: white;
  279. margin-top: 30rpx;
  280. margin-bottom: 30rpx;
  281. margin-left: 25rpx;
  282. }
  283. .avatar-container {
  284. margin-left: 50rpx;
  285. margin-right: 50rpx;
  286. }
  287. .avatar {
  288. width: 130rpx;
  289. height: 130rpx;
  290. border-radius: 50%;
  291. overflow: hidden;
  292. }
  293. .logout-button {
  294. width: 686rpx;
  295. height: 88rpx;
  296. background: #FF4748;
  297. border-radius: 44rpx;
  298. font-size: 32rpx;
  299. color: #FFFFFF;
  300. margin-top: 100rpx;
  301. }
  302. </style>