index.vue 4.7 KB

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