mine.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="container">
  3. <view class="user">
  4. <view class="userInfo">
  5. <image @click="toUserInfo" class="userPhoto" :src="userInfo.avatar"></image>
  6. <uni-badge class="message" :text="massageNum" absolute="rightTop" size="small" :max-num="99" :offset="[4, 4]">
  7. <image
  8. class="icon"
  9. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/massage.png'"
  10. mode="widthFix"
  11. @click="$navigateTo('/pages/message/message')"
  12. ></image>
  13. </uni-badge>
  14. <view class="info">
  15. <view class="name" v-if="hasLogin">
  16. {{ userInfo.nickname || '' }}
  17. </view>
  18. <view class="loginText" @click="toLogin" v-else>点击登录</view>
  19. <view class="id">
  20. ID:
  21. <span v-if="hasLogin">{{ userId || '' }}</span>
  22. <image
  23. class="copy"
  24. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/copy.png'"
  25. mode="widthFix"
  26. ></image>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="row">
  31. <view class="box" @click="$navigateTo('/pages/integralRecord/integralRecord')">
  32. <view class="value" style="color: #ff2c43">
  33. {{ userInfoDetail.integral || 0 }}
  34. </view>
  35. <view class="label">积分</view>
  36. </view>
  37. <view class="box" @click="$navigateTo('/pages/coupon/coupon')">
  38. <view class="value">
  39. {{ userInfoDetail.couponNum || 0 }}
  40. </view>
  41. <view class="label">优惠券</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="menus">
  46. <view class="title">
  47. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/title.png'" mode=""></image>
  48. </view>
  49. <view class="menuList">
  50. <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
  51. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu1.png'"></image>
  52. <span>地址管理</span>
  53. </view>
  54. <view class="menu" @click="pageTo('/pages/consumptionRecords/consumptionRecords')">
  55. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu2.png'"></image>
  56. <span>消费记录</span>
  57. </view>
  58. <view class="menu" @click="showQRcode">
  59. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu3.png'"></image>
  60. <span>加群交流</span>
  61. </view>
  62. <view class="menu" @click="$navigateTo('/pages/rule/rule', { type: 0 })">
  63. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu4.png'"></image>
  64. <span>游戏规则</span>
  65. </view>
  66. <view class="menu" @click="$navigateTo('/pages/userAgreement/userAgreement')">
  67. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu5.png'"></image>
  68. <span>用户协议</span>
  69. </view>
  70. <button class="menu btn" open-type="contact">
  71. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu6.png'"></image>
  72. <span>联系客服</span>
  73. </button>
  74. </view>
  75. </view>
  76. <uni-popup class="popup" ref="popup" type="center">
  77. <image
  78. class="qrcodeImg"
  79. :show-menu-by-longpress="true"
  80. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/QRcode.png'"
  81. mode="widthFix"
  82. />
  83. </uni-popup>
  84. </view>
  85. </template>
  86. <script>
  87. import { userInfoApi } from '@/api/user.js'
  88. import { messageListApi } from '@/api/message.js'
  89. export default {
  90. data() {
  91. return {
  92. isLogin: false,
  93. userInfo: null,
  94. userId: '-',
  95. hasLogin: false,
  96. userInfoDetail: {},
  97. massageNum: 0,
  98. }
  99. },
  100. onShow() {
  101. // this.userInfo = wx.getStorageSync('userInfo');
  102. this.userId = wx.getStorageSync('userId')
  103. //获取用户的登录信息
  104. if (wx.getStorageSync('token')) {
  105. this.hasLogin = true
  106. getApp().globalData.hasLogin = true
  107. // 获取用户信息详情
  108. this.getUserInfo()
  109. this.getMassage()
  110. } else {
  111. this.userInfo = null
  112. this.hasLogin = false
  113. getApp().globalData.hasLogin = false
  114. this.userInfoDetail = {}
  115. }
  116. },
  117. methods: {
  118. getMassage() {
  119. let params = {
  120. page: 1,
  121. limit: 1,
  122. status: 0,
  123. }
  124. messageListApi(params).then(res => {
  125. this.massageNum = res.data.total
  126. })
  127. },
  128. toUserInfo() {
  129. this.$navigateTo('/pages/user/user')
  130. if (this.isLogin) {
  131. this.$navigateTo('/pages/user/user')
  132. }
  133. },
  134. getUserInfo() {
  135. userInfoApi().then(res => {
  136. console.log(res, '详细用户信息')
  137. this.userInfoDetail = res.data
  138. // wx.setStorageSync('userInfo', res.data)
  139. this.userInfo = res.data
  140. })
  141. },
  142. toLogin() {
  143. wx.navigateTo({ url: '/pages/login/login' })
  144. },
  145. pageTo(url) {
  146. wx.navigateTo({ url: url })
  147. },
  148. showQRcode() {
  149. this.$refs.popup.open()
  150. },
  151. },
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. .btn {
  156. border: none;
  157. outline: none;
  158. background-color: #fff;
  159. &::after {
  160. border: none;
  161. }
  162. }
  163. .container {
  164. background: #9ec8f9;
  165. padding: 0 10px;
  166. overflow: scroll;
  167. }
  168. .user {
  169. background: #fff;
  170. border-radius: 10px;
  171. padding: 0 10px;
  172. position: relative;
  173. margin-top: 10vw;
  174. .userInfo {
  175. display: flex;
  176. .message {
  177. position: absolute;
  178. right: 10px;
  179. top: 8px;
  180. .icon {
  181. width: 30px;
  182. }
  183. }
  184. .userPhoto {
  185. width: 74px;
  186. height: 74px;
  187. border-radius: 50%;
  188. border: solid 3px #6bafff;
  189. position: relative;
  190. top: -20px;
  191. background: #dedede;
  192. }
  193. .info {
  194. padding: 10px;
  195. .name {
  196. font-weight: 600;
  197. }
  198. .loginText {
  199. font-weight: 600;
  200. }
  201. .id {
  202. margin-top: 5px;
  203. font-size: 13px;
  204. display: flex;
  205. align-items: center;
  206. .copy {
  207. width: 14px;
  208. margin-left: 5px;
  209. }
  210. }
  211. }
  212. }
  213. .row {
  214. display: flex;
  215. justify-content: space-around;
  216. .box {
  217. display: flex;
  218. flex-direction: column;
  219. text-align: center;
  220. padding: 20px 10px;
  221. .label {
  222. margin-top: 5px;
  223. font-size: 15px;
  224. }
  225. .value {
  226. font-size: 20px;
  227. font-weight: 600;
  228. }
  229. }
  230. }
  231. }
  232. .menus {
  233. margin-top: 20px;
  234. background: #fff;
  235. border-radius: 10px;
  236. // padding: 0 10px;
  237. .title {
  238. position: relative;
  239. left: -10px;
  240. top: -10px;
  241. width: calc(100% + 10px);
  242. height: 55px;
  243. image {
  244. width: 100%;
  245. height: 100%;
  246. }
  247. }
  248. .menuList {
  249. display: grid;
  250. grid-template-columns: 1fr 1fr 1fr;
  251. padding: 20px 20px 0 20px;
  252. .menu {
  253. margin-bottom: 30px;
  254. display: flex;
  255. flex-direction: column;
  256. justify-content: center;
  257. align-items: center;
  258. image {
  259. width: 36px;
  260. height: 36px;
  261. }
  262. span {
  263. margin-top: 10px;
  264. font-size: 14px;
  265. }
  266. }
  267. }
  268. }
  269. .qrcodeImg {
  270. width: 70vw;
  271. border-radius: 5px;
  272. }
  273. </style>