user.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <scroll-view scroll-y class="content">
  3. <view class="top">
  4. <view class="avabox">
  5. <van-image
  6. round
  7. class="img"
  8. width="200rpx"
  9. height="200rpx"
  10. :src="userData.headImage"
  11. />
  12. <view class="avatitbox">
  13. <text>{{ userData.nickName }}</text>
  14. <text v-if="userData.gzptUserId">{{ studentInfo.logincode }}</text>
  15. <view class="sync-btn" @tap="getUserProfile"
  16. >点击同步用户头像昵称</view
  17. >
  18. </view>
  19. </view>
  20. </view>
  21. <view class="serviceBox">
  22. <view class="tit">
  23. <text>我的服务</text>
  24. </view>
  25. <view class="btnBox">
  26. <button
  27. class="item-box"
  28. :plain="true"
  29. @click="$utils.goPage('/pages/user/order')"
  30. >
  31. <van-icon name="/static/imgs/order-icon.png" size="22px" />
  32. <text class="text">我的订单</text>
  33. </button>
  34. <button
  35. class="item-box"
  36. :plain="true"
  37. @click="$utils.goPage('/pages/user/collectionList')"
  38. >
  39. <van-icon name="/static/imgs/wdsc.png" size="22px" />
  40. <text class="text">我的收藏</text>
  41. </button>
  42. <button
  43. class="item-box"
  44. :plain="true"
  45. @click="$utils.goPage('/pages/user/browserecord')"
  46. >
  47. <van-icon name="/static/imgs/llzj.png" size="22px" />
  48. <text class="text">浏览足迹</text>
  49. </button>
  50. <button class="item-box" :plain="true" open-type="feedback">
  51. <van-icon name="/static/imgs/yjfk.png" size="22px" />
  52. <text class="text">意见反馈</text>
  53. </button>
  54. </view>
  55. </view>
  56. <view class="serviceBox">
  57. <view class="tit">
  58. <text>我的信息</text>
  59. </view>
  60. <van-cell
  61. title="我的设置"
  62. icon="/static/imgs/wdsz.png"
  63. is-link
  64. @tap="$utils.goPage('/pages/user/set')"
  65. />
  66. <button class="server" open-type="contact" :plain="true">
  67. <van-cell title="联系客服" icon="/static/imgs/lxkf.png" is-link />
  68. </button>
  69. </view>
  70. <view class="ad-box serviceBox">
  71. <ad unit-id="adunit-d8c1548cc9663765"></ad>
  72. </view>
  73. </scroll-view>
  74. </template>
  75. <script>
  76. import { updateUserInfo } from "@/api/login.js";
  77. export default {
  78. computed: {
  79. userData() {
  80. return this.$store.state.user.userInfo;
  81. },
  82. },
  83. mounted() {
  84. this.$store.dispatch("GetInfo");
  85. },
  86. methods: {
  87. async getUserProfile(e) {
  88. let userInfo = await wx.getUserProfile({
  89. desc: "业务需要",
  90. });
  91. let updateRes = await updateUserInfo({
  92. headImage: userInfo.userInfo.avatarUrl,
  93. nickName: userInfo.userInfo.nickName,
  94. });
  95. if (updateRes.code == 200) {
  96. this.$store.state.user.userInfo.headImage = userInfo.userInfo.avatarUrl;
  97. this.$store.state.user.userInfo.nickName = userInfo.userInfo.nickName;
  98. }
  99. },
  100. },
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .content {
  105. height: 100%;
  106. }
  107. .ad-box {
  108. margin: 40rpx;
  109. padding: 20rpx;
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. }
  114. .top {
  115. padding-top: 100rpx;
  116. background-image: url("/static/imgs/bg.png");
  117. background-size: 100% 100%;
  118. background-repeat: no-repeat;
  119. .avabox {
  120. display: flex;
  121. padding: 10%;
  122. .img {
  123. border-radius: 50%;
  124. }
  125. .sync-btn {
  126. margin-top: 20rpx;
  127. height: 40rpx;
  128. }
  129. .avatitbox {
  130. flex: 1;
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: space-between;
  134. padding: 30rpx;
  135. color: #ffffff;
  136. height: 100rpx;
  137. }
  138. }
  139. }
  140. .serviceBox {
  141. background-color: #fff;
  142. margin: 30rpx;
  143. border-radius: 10rpx;
  144. .tit {
  145. padding: 26rpx;
  146. border-bottom: 1rpx solid #e8e8e8;
  147. }
  148. .btnBox {
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. .item-box {
  153. display: flex;
  154. flex-direction: column;
  155. justify-content: space-between;
  156. align-items: center;
  157. width: 200rpx;
  158. margin-top: 20rpx;
  159. padding: 20rpx;
  160. border: none;
  161. .text {
  162. font-size: 26rpx;
  163. font-family: PingFang SC;
  164. font-weight: 400;
  165. color: #666666;
  166. }
  167. }
  168. }
  169. .server {
  170. border: none;
  171. background-color: none;
  172. margin: 0;
  173. padding: 0;
  174. text-align: left;
  175. display: flexbox;
  176. }
  177. }
  178. </style>