index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="wrap">
  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-group> -->
  52. <view class="action-item flex" @click="toOrder">
  53. <view class="action-item-left flex">
  54. <image src="../../static/user/user_order.png" mode="scaleToFill"></image>
  55. <view class="title">我的订单</view>
  56. </view>
  57. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  58. </view>
  59. <view class="action-item flex" @click="toAddress">
  60. <view class="action-item-left flex">
  61. <image src="../../static/user/user_addr.png" mode="scaleToFill"></image>
  62. <view class="title">我的地址</view>
  63. </view>
  64. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  65. </view>
  66. <!-- #ifdef MP-WEIXIN -->
  67. <view class="action-item flex" @click="contactService">
  68. <view class="action-item-left flex">
  69. <image src="../../static/user/user_kefu.png" mode="scaleToFill"></image>
  70. <view class="title">联系客服</view>
  71. </view>
  72. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  73. </view>
  74. <!-- #endif -->
  75. <view class="action-item flex" @click="toAbout">
  76. <view class="action-item-left flex">
  77. <image src="../../static/user/user_about.png" mode="scaleToFill"></image>
  78. <view class="title">关于我们</view>
  79. </view>
  80. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  81. </view>
  82. </view>
  83. <view class="action">
  84. <!-- <u-cell icon="close-circle" title="退出登录" :isLink="true" :border="false" @click="logout" /> -->
  85. <view class="action-item flex" @click="logout">
  86. <view class="action-item-left flex">
  87. <image class="close" src="../../static/user/user_close.png" mode="scaleToFill"></image>
  88. <view class="title">退出登录</view>
  89. </view>
  90. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  91. </view>
  92. </view>
  93. <custom-tab-bar :activeValue="'user'" />
  94. </view>
  95. </template>
  96. <script>
  97. import env from '../../config/env.js'
  98. import $http from '@/utils/request.js'
  99. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  100. import Auth from '../../components/auth/auth.vue'
  101. export default {
  102. components: {
  103. CustomTabBar,
  104. Auth,
  105. },
  106. data() {
  107. return {
  108. loginState: false, // 判断是否登录
  109. authState: false,
  110. userInfo: {}, //
  111. avatar: '',
  112. certifyStatus: {},
  113. info: {},
  114. authShow: false,
  115. initData: {},
  116. };
  117. },
  118. onShow() {
  119. this.loginState = uni.getStorageSync('token') ? true : false
  120. if (this.loginState) {
  121. this.getInit()
  122. this.getBaseInfo()
  123. }
  124. },
  125. methods: {
  126. // 我的数据
  127. getInit() {
  128. uni.showLoading({
  129. title: '加载中'
  130. });
  131. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  132. uni.hideLoading();
  133. if (res.code == 0) {
  134. this.initData = res.data
  135. }
  136. }).catch(() => {
  137. uni.hideLoading();
  138. })
  139. },
  140. getBaseInfo() {
  141. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  142. if (res.code == 0) {
  143. this.userInfo = res.data
  144. this.avatar = env.filePublic + res.data.avatar
  145. }
  146. }).catch(() => {
  147. })
  148. },
  149. // 跳转登录
  150. toLogin() {
  151. uni.navigateTo({
  152. url: "/pages/login/index"
  153. })
  154. },
  155. // 我的订单
  156. toOrder() {
  157. if (!this.loginState) {
  158. uni.$u.toast('请登录');
  159. return
  160. }
  161. uni.navigateTo({
  162. url: '/packageGoods/order/index'
  163. })
  164. },
  165. // 我的地址
  166. toAddress() {
  167. if (!this.loginState) {
  168. uni.$u.toast('请登录');
  169. return
  170. }
  171. uni.navigateTo({
  172. url: '/packageOperate/address/index'
  173. })
  174. },
  175. // 关于我们
  176. toAbout() {
  177. uni.navigateTo({
  178. url: '/packageOther/about/index'
  179. })
  180. },
  181. // 没有登录
  182. notLogin() {
  183. uni.$u.toast('请登录');
  184. },
  185. // 注销登录
  186. logout() {
  187. let _this = this
  188. if (!this.loginState) {
  189. uni.$u.toast('已退出登录');
  190. return
  191. }
  192. uni.showModal({
  193. title: '退出登录',
  194. content: '确定要退出登录吗?',
  195. success(res) {
  196. if (res.confirm) {
  197. uni.clearStorage()
  198. _this.loginState = false
  199. _this.authState = false
  200. }
  201. }
  202. })
  203. },
  204. // 联系客服
  205. contactService() {
  206. // #ifdef MP-WEIXIN
  207. wx.openCustomerServiceChat({
  208. extInfo: {
  209. url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
  210. },
  211. corpId: 'ww02da63d80c66284b',
  212. })
  213. // #endif
  214. },
  215. },
  216. onShareAppMessage(res) {
  217. return {
  218. title: '盲票,玩的就是有趣',
  219. path: '/pages/index/index'
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. ::v-deep .u-cell__body {
  226. padding: 20rpx 0;
  227. }
  228. .status_bar {
  229. width: 100%;
  230. height: var(--status-bar-height);
  231. }
  232. </style>
  233. <style lang="scss" scoped>
  234. .wrap {
  235. padding-bottom: 200rpx;
  236. }
  237. .user {
  238. display: flex;
  239. align-items: center;
  240. height: 560rpx;
  241. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/mine_bkg.png) center center no-repeat;
  242. background-size: 100vw 560rpx;
  243. }
  244. .account {
  245. margin-top: -350rpx;
  246. margin-bottom: 34rpx;
  247. // 头像
  248. &-ava {
  249. justify-content: flex-start;
  250. margin-bottom: 34rpx;
  251. padding: 0 30rpx;
  252. image {
  253. width: 170rpx;
  254. height: 170rpx;
  255. border-radius: 50%;
  256. border: 2px solid #FFFFFF;
  257. overflow: hidden;
  258. }
  259. .no-ava {
  260. width: 170rpx;
  261. height: 170rpx;
  262. border-radius: 50%;
  263. overflow: hidden;
  264. background: #fff;
  265. }
  266. &-name {
  267. margin-left: 20rpx;
  268. font-size: 34rpx;
  269. color: #FFFFFF;
  270. }
  271. &-no {
  272. margin-left: 20rpx;
  273. color: #FFFFFF;
  274. font-size: 34rpx;
  275. }
  276. }
  277. // 信息
  278. &-info {
  279. height: 216rpx;
  280. justify-content: space-around;
  281. background-color: #FFFFFF;
  282. border-radius: 18rpx;
  283. &-item {
  284. flex-direction: column;
  285. font-size: 34rpx;
  286. view {
  287. line-height: 52rpx;
  288. }
  289. view:first-child {
  290. color: #FD7B24;
  291. line-height: 60rpx;
  292. font-size: 52rpx;
  293. }
  294. }
  295. }
  296. }
  297. .action {
  298. margin: 0 34rpx;
  299. padding: 0 34rpx;
  300. background-color: #FFFFFF;
  301. border-radius: 18rpx;
  302. margin-bottom: 34rpx;
  303. &-item {
  304. justify-content: space-between;
  305. padding: 36rpx 0;
  306. border-bottom: 1px solid #eee;
  307. &-left {
  308. color: #666;
  309. image {
  310. width: 52rpx;
  311. height: 52rpx;
  312. margin-right: 20rpx;
  313. }
  314. .title {
  315. font-size: 30rpx;
  316. line-height: 30rpx;
  317. }
  318. .close {
  319. width: 62rpx;
  320. height: 62rpx;
  321. }
  322. }
  323. }
  324. &-item:last-child {
  325. border-bottom: none;
  326. }
  327. }
  328. </style>