index.vue 5.3 KB

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