index.vue 3.1 KB

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