index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view>
  3. <view class="user-bg">
  4. <!--<image src="../../images/userbg.png"></image>-->
  5. </view>
  6. <view class="user-top">
  7. <view class="user-info">
  8. <view class="user-info-avatar">
  9. <image v-if="img" :src="img"></image>
  10. <image v-if="!img" src="../../images/avatar.png"></image>
  11. </view>
  12. <view class="user-info-nick">{{nickName}}</view>
  13. </view>
  14. <view class="menu-box">
  15. <view class="menu-box-list" @click="goOrder">
  16. <text class="menu-box-list-text">我的订单</text>
  17. <image class="menu-box-list-right" src="../../images/jiantouyou.png"></image>
  18. </view>
  19. <view class="menu-box-list" @click="goIndex">
  20. <text class="menu-box-list-text">去下单</text>
  21. <image class="menu-box-list-right" src="../../images/jiantouyou.png"></image>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. var app = getApp();
  29. export default {
  30. data() {
  31. return {
  32. nickName: '',
  33. img: '',
  34. imgLoad: true
  35. }
  36. },
  37. onLoad() {
  38. },
  39. onShow() {
  40. var that = this;
  41. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  42. that.nickName = res.data.data.nickname;
  43. that.img = res.data.data.img;
  44. }
  45. this.getUserInfo();
  46. },
  47. methods: {
  48. goAddress(){
  49. uni.navigateTo({
  50. url: '/pages/address/index'
  51. });
  52. },
  53. goOrder(){
  54. uni.navigateTo({
  55. url: '/pages/order/index'
  56. });
  57. },
  58. goIndex(){
  59. uni.switchTab({
  60. url: '/pages/index/index'
  61. });
  62. },
  63. getUserInfo(){
  64. app.ajax({
  65. url: app.globalData.serverUrl + 'Worker/userInfo',
  66. type: 'POST',
  67. apiname: 'user'
  68. });
  69. },
  70. onErrorImg(item){
  71. this.imgLoad = false;
  72. this.$forceUpdate();
  73. },
  74. onSuccessImg(item){
  75. this.imgLoad = true;
  76. this.$forceUpdate();
  77. },
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .user-bg{
  83. position: absolute;
  84. width: 750rpx;
  85. height: 475rpx;
  86. top: 0;
  87. left: 0;
  88. z-index: 1;
  89. background-color: var(--themeColor);
  90. }
  91. .user-bg image{
  92. width: 100%;
  93. height: 100%;
  94. }
  95. .user-top{
  96. position: absolute;
  97. width: 100%;
  98. height: 100%;
  99. top: 0;
  100. left: 0;
  101. z-index: 2;
  102. }
  103. .user-info{
  104. overflow: hidden;
  105. padding-top: 160rpx;
  106. padding-bottom: 40rpx;
  107. text-align: center;
  108. color: #FFFFFF;
  109. }
  110. .user-info-avatar{
  111. overflow: hidden;
  112. }
  113. .user-info-avatar image{
  114. width: 128rpx;
  115. height: 128rpx;
  116. // border: 4rpx solid #FFFFFF;
  117. border-radius: 66rpx;
  118. }
  119. .menu-box{
  120. width: 687rpx;
  121. height: auto;
  122. border-radius: 10rpx;
  123. background-color: #FFFFFF;
  124. margin: 0 auto;
  125. padding: 0 15rpx;
  126. }
  127. .menu-box .menu-box-list{
  128. height: 108rpx;
  129. line-height: 108rpx;
  130. border-bottom: 1px solid #CCCCCC;
  131. }
  132. .menu-box .menu-box-list .menu-box-list-text{
  133. display: inline-block;
  134. width: 660rpx;
  135. vertical-align: middle;
  136. }
  137. .menu-box .menu-box-list .menu-box-list-right{
  138. width: 12rpx;
  139. height: 22rpx;
  140. vertical-align: middle;
  141. }
  142. .menu-box .menu-box-list:last-child{
  143. border: 0;
  144. }
  145. </style>