index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view>
  3. <!-- 非H5撑高元素 -->
  4. <view class="status_bar"></view>
  5. <!-- 头部背景 -->
  6. <view class="user"></view>
  7. <!-- 账户信息 -->
  8. <view class="account">
  9. <view class="flex account-ava">
  10. <image :src="avatar" mode="aspectFill" v-if="loginState"></image>
  11. <image src="../../static/logo.png" mode="aspectFill" v-else></image>
  12. <view class="account-ava-name" v-if="loginState">{{ userInfo.nickName }}</view>
  13. <view class="account-ava-no" @click="toLogin" v-else>登录</view>
  14. </view>
  15. <view class="flex account-info" v-if="loginState">
  16. <navigator url="/pages/prize/index" class="flex account-info-item" hover-class="navigator-hover">
  17. <view>7</view>
  18. <view>我的奖品库</view>
  19. </navigator>
  20. <navigator url="/pages/ticket/index" class="flex account-info-item" hover-class="navigator-hover">
  21. <view>7</view>
  22. <view>我的盲票包</view>
  23. </navigator>
  24. <navigator url="/pages/bean/index" class="flex account-info-item" hover-class="navigator-hover">
  25. <view>7</view>
  26. <view>我的盲豆</view>
  27. </navigator>
  28. </view>
  29. <view class="flex account-info" v-else @click="notLogin">
  30. <view class="flex account-info-item">
  31. <view>-</view>
  32. <view>我的奖品库</view>
  33. </view>
  34. <view class="flex account-info-item">
  35. <view>-</view>
  36. <view>我的盲票包</view>
  37. </view>
  38. <view class="flex account-info-item">
  39. <view>-</view>
  40. <view>我的盲豆</view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 操作项 -->
  45. <view class="action">
  46. <u-cell-group :border="false">
  47. <u-cell icon="order" title="我的订单" :isLink="true" @click="toOrder"></u-cell>
  48. <u-cell icon="map" title="我的地址" :isLink="true" @click="toAddress"></u-cell>
  49. <u-cell icon="kefu-ermai" title="联系客服" :isLink="true"></u-cell>
  50. <u-cell icon="info-circle" title="关于我们" :border="false" :isLink="true" :url="'/pages/about/index'">
  51. </u-cell>
  52. </u-cell-group>
  53. </view>
  54. <view class="cancel">
  55. <u-cell icon="close-circle" title="注销登录" :isLink="true" :border="false" @click="logout"></u-cell>
  56. </view>
  57. <custom-tab-bar :activeValue="'user'" />
  58. </view>
  59. </template>
  60. <script>
  61. import env from '../../config/env.js'
  62. import $http from '@/utils/request.js'
  63. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  64. import Auth from '../../components/auth/auth.vue'
  65. export default {
  66. components: {
  67. CustomTabBar,
  68. Auth
  69. },
  70. data() {
  71. return {
  72. loginState: false, // 判断是否登录
  73. authState: false,
  74. userInfo: {}, //
  75. avatar: '',
  76. certifyStatus: {},
  77. info: {},
  78. authShow: false,
  79. };
  80. },
  81. onShow() {
  82. this.loginState = uni.getStorageSync('token') ? true : false
  83. this.userInfo = uni.getStorageSync('userInfo')
  84. this.avatar = env.filePublic + this.userInfo.avatar
  85. },
  86. methods: {
  87. // 跳转登录
  88. toLogin() {
  89. uni.navigateTo({
  90. url: "/pages/login/index"
  91. })
  92. },
  93. // 我的订单
  94. toOrder(){
  95. if(!this.loginState){
  96. uni.$u.toast('请登录!');
  97. return
  98. }
  99. uni.navigateTo({
  100. url:'/pages/order/index'
  101. })
  102. },
  103. // 我的地址
  104. toAddress(){
  105. if(!this.loginState){
  106. uni.$u.toast('请登录!');
  107. return
  108. }
  109. uni.navigateTo({
  110. url:'/pages/address/index'
  111. })
  112. },
  113. // 没有登录
  114. notLogin(){
  115. uni.$u.toast('请登录!');
  116. },
  117. // 注销登录
  118. logout() {
  119. let _this = this
  120. if(!this.loginState){
  121. uni.$u.toast('已注销登录!');
  122. return
  123. }
  124. uni.showModal({
  125. title: '注销登录',
  126. content: '确定要注销登录吗?',
  127. success(res) {
  128. if (res.confirm) {
  129. uni.clearStorage()
  130. _this.loginState = false
  131. _this.authState = false
  132. }
  133. }
  134. })
  135. },
  136. },
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. /deep/ .u-cell__body {
  141. padding: 20rpx 0;
  142. }
  143. .status_bar {
  144. width: 100%;
  145. height: var(--status-bar-height);
  146. }
  147. </style>
  148. <style lang="scss" scoped>
  149. .user {
  150. display: flex;
  151. align-items: center;
  152. height: 230rpx;
  153. padding: 0 36rpx;
  154. background: url(https://file02.16sucai.com/d/file/2014/1103/1b73e5346d5579badbc83cb15586f0a8.jpg) center no-repeat;
  155. }
  156. .account {
  157. margin: 0 20rpx;
  158. padding: 34rpx;
  159. background-color: #FFFFFF;
  160. border-radius: 10rpx;
  161. margin-top: -106rpx;
  162. margin-bottom: 40rpx;
  163. &-ava {
  164. justify-content: flex-start;
  165. margin-bottom: 46rpx;
  166. image {
  167. width: 106rpx;
  168. height: 106rpx;
  169. border-radius: 50%;
  170. overflow: hidden;
  171. }
  172. &-name {
  173. margin-left: 20rpx;
  174. font-size: 32rpx;
  175. }
  176. &-no {
  177. margin-left: 20rpx;
  178. color: #C0C0C0;
  179. font-size: 32rpx;
  180. }
  181. }
  182. &-info {
  183. justify-content: space-around;
  184. &-item {
  185. flex-direction: column;
  186. view {
  187. line-height: 40rpx;
  188. }
  189. view:first-child {
  190. line-height: 56rpx;
  191. font-size: 40rpx;
  192. }
  193. }
  194. }
  195. }
  196. .action {
  197. margin: 0 20rpx;
  198. padding: 10rpx 20rpx 0;
  199. background-color: #FFFFFF;
  200. border-radius: 10rpx;
  201. margin-bottom: 40rpx;
  202. }
  203. .cancel {
  204. margin: 0 20rpx;
  205. padding: 10rpx 20rpx;
  206. background-color: #FFFFFF;
  207. border-radius: 10rpx;
  208. }
  209. </style>