index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <zzx-navbar :scrollable="true" :back="false" title="我的"></zzx-navbar>
  3. <view class="m-header">
  4. <image class="header-bgImg" src="@/static/mine_bg.png" mode="widthFix"></image>
  5. </view>
  6. <view class="m-content-box">
  7. <view class="m-content">
  8. <view class="m-header-info">
  9. <view class="user-info">
  10. <image class="user-header" v-if="token&&userinfo.userAvatar!==null" :src="userinfo.userAvatar" mode=""></image>
  11. <image class="user-header" v-else src="@/static/default-header.png" mode=""></image>
  12. <view class="user-nickname">{{token?userinfo.userName:'暂未登录'}}</view>
  13. </view>
  14. <view class="user-setting" @click="RouterUtils.to_page('/pages/mine/accountSetting/index')">
  15. <image src="@/static/account-setting.png" mode="widthFix"></image>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="height: 100rpx;"></view>
  21. <view class="content">
  22. <view class="m-mineinfo-card">
  23. <view class="item-info" v-for="(item,index) in cardList" :key="index"
  24. @click="RouterUtils.to_page(`/pages/mine/orderInfo/index?selIndex=${index}`)">
  25. <zzx-icon :name="item.icon" size="30"></zzx-icon>
  26. <view class="item-text">{{item.name}}</view>
  27. </view>
  28. </view>
  29. <view class="m-function-list">
  30. <view class="list-title">我的功能</view>
  31. <view class="cell-list">
  32. <view class="item-cell-contact">
  33. <view class="">客服</view>
  34. <zzx-icon name="ashRight" size="10"></zzx-icon>
  35. <button class="contact-btn" open-type="contact"></button>
  36. </view>
  37. <zzx-cell text="发票" url=''></zzx-cell>
  38. <zzx-cell text="意见反馈" url='/pages/mine/feedback/index'></zzx-cell>
  39. <zzx-cell text="家庭成员" url="/pages/index/userList/index?name=家庭成员"></zzx-cell>
  40. <zzx-cell text="评价" url='/pages/mine/mineComments/index'></zzx-cell>
  41. </view>
  42. </view>
  43. <view class="login-tips" v-if="!token">
  44. <view class="">终于等到你!快去登录吧~</view>
  45. <view class="" @click="submitLogin">马上登录</view>
  46. </view>
  47. </view>
  48. </template>
  49. <script lang="ts" setup>
  50. import { ref, onMounted,computed } from 'vue'
  51. import zzxNavbar from '@/components/zzx-navbar/zzx-navbar.vue';
  52. import zzxCell from '@/components/zzx-cell/zzx-cell.vue';
  53. import { RouterUtils,TipsUtils } from '@/utils/util';
  54. import { http } from '@/utils/http'
  55. import { useCacheStore } from '@/stores/cache'
  56. import { onLoad, onPageScroll } from '@dcloudio/uni-app';
  57. const cache = useCacheStore()
  58. const token=computed(()=>{
  59. return cache.get('TOKEN')
  60. })
  61. const userinfo=computed(()=>{
  62. return cache.get('USER_INFO')
  63. })
  64. const userAvatar=ref('/src/static/default-header.png')
  65. const cardList = ref([{
  66. name: '全部订单',
  67. icon: 'm-allorder'
  68. }, {
  69. name: '待付款',
  70. icon: 'm-pendPay'
  71. }, {
  72. name: '待使用',
  73. icon: 'm-pendUse'
  74. }, {
  75. name: '已完成',
  76. icon: 'm-done'
  77. }, {
  78. name: '售后',
  79. icon: 'm-after-sales'
  80. },])
  81. onMounted(()=>{
  82. get_userinfo()
  83. })
  84. onPageScroll((e) => { })
  85. const submitLogin = () => {
  86. uni.login({
  87. provider: 'weixin',
  88. success: (res) => {
  89. get_logininfo(res.code)
  90. }
  91. })
  92. }
  93. const get_logininfo = (item:string) => {
  94. http.get('/user/loginByCode', {data:{code:item}, loading: true }).then(res => {
  95. cache.set('TOKEN',res.result.token)
  96. cache.set('USER_INFO',res.result)
  97. get_userinfo()
  98. TipsUtils.tips_toast('登录成功')
  99. })
  100. }
  101. const get_userinfo=()=>{
  102. http.get('/user/getUserInfo', { loading: true }).then(res => {
  103. cache.set('USER_INFO',res.result)
  104. })
  105. }
  106. </script>
  107. <style>
  108. page {
  109. background: #fff;
  110. }
  111. </style>
  112. <style lang="less" scoped>
  113. .m-header {
  114. .header-bgImg {
  115. width: 100%;
  116. }
  117. }
  118. .m-content-box {
  119. position: relative;
  120. .m-content {
  121. position: absolute;
  122. border-radius: 32rpx 32rpx 0 0;
  123. background: #fff;
  124. top: -60rpx;
  125. width: 100%;
  126. height: 160rpx;
  127. .m-header-info {
  128. .user-info {
  129. text-align: center;
  130. position: relative;
  131. .user-header {
  132. position: absolute;
  133. left: 50%;
  134. transform: translate(-50%, -50%);
  135. width: 160rpx;
  136. height: 160rpx;
  137. border-radius: 50%;
  138. }
  139. .user-nickname {
  140. position: absolute;
  141. left: 50%;
  142. transform: translate(-50%, -50%);
  143. top: 130rpx;
  144. font-weight: 800;
  145. font-size: 36rpx;
  146. color: #222222;
  147. }
  148. }
  149. .user-setting {
  150. position: absolute;
  151. right: 0;
  152. top: 24rpx;
  153. &>image {
  154. width: 170rpx;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. .m-mineinfo-card {
  161. background: #F6F6F6;
  162. border-radius: 32rpx;
  163. padding: 20rpx;
  164. display: flex;
  165. align-items: center;
  166. justify-content: space-around;
  167. margin-top: 20rpx;
  168. .item-info {
  169. text-align: center;
  170. .item-text {
  171. font-size: 24rpx;
  172. color: #222222;
  173. }
  174. }
  175. }
  176. .m-function-list {
  177. margin-top: 28rpx;
  178. .list-title {
  179. font-weight: 800;
  180. font-size: 32rpx;
  181. color: #222222;
  182. }
  183. .cell-list {
  184. .item-cell-contact {
  185. display: flex;
  186. align-items: center;
  187. justify-content: space-between;
  188. font-size: 28rpx;
  189. color: #181818;
  190. height: 70rpx;
  191. padding: 10rpx;
  192. position: relative;
  193. .contact-btn {
  194. position: absolute;
  195. width: 100%;
  196. height: 70rpx;
  197. opacity: 0;
  198. // background-color: #C8FF0C;
  199. }
  200. }
  201. .item-cell-contact:active {
  202. background-color: #ececec;
  203. border-radius: 20rpx;
  204. }
  205. }
  206. }
  207. .login-tips {
  208. position: fixed;
  209. bottom: 22rpx;
  210. width: 686rpx;
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. padding: 10rpx;
  215. background: rgba(0, 0, 0, 0.6);
  216. border-radius: 8rpx;
  217. z-index: 9999;
  218. &>view:first-child {
  219. font-size: 28rpx;
  220. color: #FFFFFF;
  221. }
  222. &>view:last-child {
  223. width: 160rpx;
  224. height: 60rpx;
  225. background: #C8FF0C;
  226. border-radius: 8rpx;
  227. font-size: 28rpx;
  228. color: #222222;
  229. text-align: center;
  230. line-height: 60rpx;
  231. }
  232. }
  233. </style>