index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. <view class="no-ava" v-else @click="toLogin"></view>
  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="/packagePrize/prize/index" class="flex account-info-item" hover-class="navigator-hover">
  17. <view>{{ initData.prizeNum }}</view>
  18. <view>我的奖品库</view>
  19. </navigator>
  20. <navigator url="/packagePrize/ticket/index" class="flex account-info-item" hover-class="navigator-hover">
  21. <view>{{ initData.ticketNum }}</view>
  22. <view>我的盲票</view>
  23. </navigator>
  24. <navigator url="/packagePrize/bean/index" class="flex account-info-item" hover-class="navigator-hover">
  25. <view>{{ initData.coinNum }}</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" />
  48. <u-cell icon="map" title="我的地址" :isLink="true" @click="toAddress" />
  49. <u-cell icon="kefu-ermai" title="联系我们" :isLink="true" @click="contactService" />
  50. <u-cell icon="info-circle" title="关于我们" :border="false" :isLink="true" :url="'/packageOther/about/index'" />
  51. <u-cell icon="info-circle" title="奖品滚动" :border="false" :isLink="true" :url="'/packagePrize/rolling/index'" />
  52. </u-cell-group>
  53. </view>
  54. <view class="cancel">
  55. <u-cell icon="close-circle" title="退出登录" :isLink="true" :border="false" @click="logout" />
  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. initData: {},
  80. };
  81. },
  82. onShow() {
  83. this.loginState = uni.getStorageSync('token') ? true : false
  84. if (this.loginState) {
  85. this.getInit()
  86. this.getBaseInfo()
  87. }
  88. },
  89. methods: {
  90. // 我的数据
  91. getInit() {
  92. uni.showLoading({
  93. title: '加载中'
  94. });
  95. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  96. uni.hideLoading();
  97. if (res.code == 0) {
  98. this.initData = res.data
  99. }
  100. }).catch(() => {
  101. uni.hideLoading();
  102. })
  103. },
  104. getBaseInfo() {
  105. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  106. if (res.code == 0) {
  107. this.userInfo = res.data
  108. this.avatar = env.filePublic + res.data.avatar
  109. }
  110. }).catch(() => {
  111. })
  112. },
  113. // 跳转登录
  114. toLogin() {
  115. uni.navigateTo({
  116. url: "/pages/login/index"
  117. })
  118. },
  119. // 我的订单
  120. toOrder() {
  121. if (!this.loginState) {
  122. uni.$u.toast('请登录!');
  123. return
  124. }
  125. uni.navigateTo({
  126. url: '/packageGoods/order/index'
  127. })
  128. },
  129. // 我的地址
  130. toAddress() {
  131. if (!this.loginState) {
  132. uni.$u.toast('请登录!');
  133. return
  134. }
  135. uni.navigateTo({
  136. url: '/packageOperate/address/index'
  137. })
  138. },
  139. // 没有登录
  140. notLogin() {
  141. uni.$u.toast('请登录!');
  142. },
  143. // 注销登录
  144. logout() {
  145. let _this = this
  146. if (!this.loginState) {
  147. uni.$u.toast('已退出登录!');
  148. return
  149. }
  150. uni.showModal({
  151. title: '退出登录',
  152. content: '确定要退出登录吗?',
  153. success(res) {
  154. if (res.confirm) {
  155. uni.clearStorage()
  156. _this.loginState = false
  157. _this.authState = false
  158. }
  159. }
  160. })
  161. },
  162. // 联系客服
  163. contactService() {
  164. // #ifdef MP-WEIXIN
  165. wx.openCustomerServiceChat({
  166. extInfo: {
  167. url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
  168. },
  169. corpId: 'ww02da63d80c66284b',
  170. })
  171. // #endif
  172. },
  173. },
  174. onShareAppMessage(res) {
  175. return {
  176. title: '盲票,玩的就是有趣',
  177. path: '/pages/index/index'
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. /deep/ .u-cell__body {
  184. padding: 20rpx 0;
  185. }
  186. .status_bar {
  187. width: 100%;
  188. height: var(--status-bar-height);
  189. }
  190. </style>
  191. <style lang="scss" scoped>
  192. .user {
  193. display: flex;
  194. align-items: center;
  195. height: 300rpx;
  196. padding: 0 36rpx;
  197. // background: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%);
  198. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/my-bkgd.png) center center;
  199. }
  200. .account {
  201. margin: 0 20rpx;
  202. padding: 34rpx;
  203. background-color: #FFFFFF;
  204. border-radius: 10rpx;
  205. margin-top: -90rpx;
  206. margin-bottom: 40rpx;
  207. &-ava {
  208. justify-content: flex-start;
  209. margin-bottom: 46rpx;
  210. image {
  211. width: 106rpx;
  212. height: 106rpx;
  213. border-radius: 50%;
  214. overflow: hidden;
  215. }
  216. .no-ava {
  217. width: 106rpx;
  218. height: 106rpx;
  219. border-radius: 50%;
  220. overflow: hidden;
  221. background: #C0C0C0;
  222. }
  223. &-name {
  224. margin-left: 20rpx;
  225. font-size: 32rpx;
  226. }
  227. &-no {
  228. margin-left: 20rpx;
  229. color: #C0C0C0;
  230. font-size: 32rpx;
  231. }
  232. }
  233. &-info {
  234. justify-content: space-around;
  235. &-item {
  236. flex-direction: column;
  237. view {
  238. line-height: 40rpx;
  239. }
  240. view:first-child {
  241. line-height: 56rpx;
  242. font-size: 40rpx;
  243. }
  244. }
  245. }
  246. }
  247. .action {
  248. margin: 0 20rpx;
  249. padding: 10rpx 20rpx 0;
  250. background-color: #FFFFFF;
  251. border-radius: 10rpx;
  252. margin-bottom: 40rpx;
  253. }
  254. .cancel {
  255. margin: 0 20rpx;
  256. padding: 10rpx 20rpx;
  257. background-color: #FFFFFF;
  258. border-radius: 10rpx;
  259. }
  260. </style>