index.vue 7.8 KB

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