index.vue 8.6 KB

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