index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head" @click="toUserPage">
  5. <view class="user-photo">
  6. <open-data type="userAvatarUrl"></open-data>
  7. <u-image v-show="!hasLogin" src="/static/logo.png" width="100" height="100"></u-image>
  8. </view>
  9. <view class="user-info">
  10. <text v-if="hasLogin">{{user.mobile||'--'}}</text>
  11. <u-button v-else="!hasLogin" plain size="mini" shape="circle" @click="toLoginPage">立即登录</u-button>
  12. </view>
  13. <view v-if="hasLogin">
  14. <u-icon name="arrow-right" color="#fff"></u-icon>
  15. </view>
  16. </view>
  17. <view class="my-ledou" v-if="hasLogin">
  18. <view class="user-jifen">
  19. <view>我的乐豆:<text>{{user.currentGold||0}}</text></view>
  20. <u-image mode="scaleToFill" width="35rpx" height="35rpx" src="/static/ledou.png"></u-image>
  21. </view>
  22. <view>
  23. <u-button size="mini" type="warning" shape="circle" @click="toLdPage">查看明细</u-button>
  24. </view>
  25. </view>
  26. <!-- 列表 -->
  27. <view class="user-list">
  28. <u-cell-group>
  29. <u-cell-item v-if="hasLogin" icon="order" icon-size="38" :icon-style="{color:'#ff5500'}" index="0" @click="toPage" title="我的订单"></u-cell-item>
  30. <u-cell-item v-if="hasLogin" icon="gift" icon-size="40" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="投递记录"></u-cell-item>
  31. <u-cell-item icon="question-circle" icon-size="40" :icon-style="{color:'#19be6b'}" index="2" @click="toPage" title="常见问题"></u-cell-item>
  32. <u-cell-item icon="phone" icon-size="40" :icon-style="{color:'#f00'}" @click="callPhone" title="联系客服"></u-cell-item>
  33. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="3" @click="toPage" title="服务协议"></u-cell-item>
  34. <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="4" @click="toPage" title="关于我们"></u-cell-item>
  35. </u-cell-group>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { checkLogin, getUserInfo } from '@/api/login.js'
  41. export default {
  42. data() {
  43. return {
  44. hasLogin: false,
  45. userData: {}
  46. };
  47. },
  48. onShow() {
  49. checkLogin().then(res => {
  50. this.hasLogin = res.status == 200
  51. if(this.hasLogin){
  52. this.getUserInfo()
  53. }else{
  54. uni.navigateTo({
  55. url:"/pages/login/login"
  56. })
  57. }
  58. })
  59. },
  60. computed: {
  61. user() {
  62. return this.userData
  63. }
  64. },
  65. onLoad() {
  66. },
  67. methods:{
  68. // 获取用户信息
  69. getUserInfo(){
  70. getUserInfo().then(res => {
  71. console.log(res,'getUserInfo')
  72. if(res.status == 200){
  73. this.$u.vuex("vuex_userData",res.data)
  74. this.userData = res.data
  75. }
  76. })
  77. },
  78. // 打开对应的页面
  79. toPage(index){
  80. console.log(index)
  81. let pageUrl=[
  82. '/pages/order/order',
  83. '/pages/userCenter/deliveryRecord',
  84. '/pages/userCenter/question',
  85. '/pages/agreement/agreement?fromPage=usercenter',
  86. '/pages/userCenter/aboutUs'
  87. ]
  88. uni.navigateTo({
  89. url: pageUrl[index]
  90. })
  91. },
  92. // 电话客服
  93. callPhone () {
  94. uni.makePhoneCall({
  95. phoneNumber: this.$store.state.vuex_kfMobile
  96. })
  97. },
  98. // 跳转
  99. toUserPage(){
  100. // 未登录跳转登录,已登录跳转用户信息页
  101. if(this.hasLogin){
  102. uni.navigateTo({
  103. url: '/pages/userCenter/userInfo/userInfo'
  104. })
  105. }else{
  106. this.toLoginPage()
  107. }
  108. },
  109. // 乐豆明细
  110. toLdPage(){
  111. uni.navigateTo({
  112. url: '/pages/userCenter/ldDetailed'
  113. })
  114. },
  115. bindGetUserInfo(res){
  116. console.log(res)
  117. },
  118. toLoginPage(){
  119. uni.navigateTo({
  120. url: '/pages/login/login'
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss">
  127. .user-content{
  128. width: 100%;
  129. .user-head{
  130. background: #01c9b2;
  131. display: flex;
  132. align-items: center;
  133. padding: 35rpx 55rpx;
  134. .user-info{
  135. flex-grow: 1;
  136. padding: 0 20rpx;
  137. color: #FFFFFF;
  138. }
  139. .user-photo{
  140. width: 100rpx;
  141. height: 100rpx;
  142. border-radius: 50%;
  143. overflow: hidden;
  144. margin-right: 5rpx;
  145. }
  146. }
  147. .my-ledou{
  148. background: #FFFFFF;
  149. border-radius: 15upx;
  150. display: flex;
  151. align-items: center;
  152. justify-content: space-between;
  153. padding: 20upx;
  154. margin: 20upx;
  155. box-shadow: 0upx 3upx 6upx #eee;
  156. .user-jifen{
  157. display: flex;
  158. align-items: center;
  159. text{
  160. font-size: 40upx;
  161. font-weight: bold;
  162. color: red;
  163. }
  164. >view{
  165. &:first-child{
  166. display: flex;
  167. align-items: center;
  168. }
  169. }
  170. }
  171. }
  172. .user-list{
  173. border-radius: 15upx;
  174. margin: 20upx;
  175. overflow: hidden;
  176. box-shadow: 0upx 3upx 6upx #eee;
  177. }
  178. .user-btn{
  179. padding: 85rpx 200rpx;
  180. }
  181. }
  182. </style>