index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="content">
  3. <!-- 用户信息 -->
  4. <view class="userCard flex align_center justify_between" @click="toUser">
  5. <view class="userCard-info flex align_center justify_between">
  6. <view>
  7. <u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
  8. <open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
  9. </view>
  10. <view>
  11. <view v-if="!hasLogin" style="font-size: 40rpx;">
  12. 请点击登录
  13. </view>
  14. <view v-else>
  15. <view>{{userInfo.userNameCN}}</view>
  16. <view>{{userInfo.orgName}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view>
  21. <u-icon name="arrow-right"></u-icon>
  22. </view>
  23. </view>
  24. <!-- 套餐记录 -->
  25. <view class="list-box">
  26. <u-cell-group :border="false" v-if="hasLogin">
  27. <u-cell-item v-for="item in vinList" @click="toChoosePart(item)" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :label="item.brandName +' '+item.modelName">
  28. <text slot="icon"></text>
  29. </u-cell-item>
  30. <view style="padding: 20upx;">
  31. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="vinList.length==0 && status!='loading'" mode="list"></u-empty>
  32. <u-loadmore v-if="status=='loading'" :status="status" />
  33. </view>
  34. </u-cell-group>
  35. <view class="des" v-if="!hasLogin">请登录后查看套餐记录</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapState,
  42. mapMutations,
  43. } from 'vuex'
  44. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  45. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  46. export default {
  47. components: {
  48. },
  49. data() {
  50. return {
  51. status: 'loading',
  52. noDataText: '暂无数据',
  53. vinList: [],
  54. }
  55. },
  56. computed: {
  57. ...mapState(['hasLogin']),
  58. userInfo(){
  59. return this.$store.state.vuex_userInfo
  60. }
  61. },
  62. onReady() {
  63. // 检测是否登录
  64. this.$store.dispatch('checkLogin',()=>{
  65. this.pageInit()
  66. })
  67. },
  68. onLoad() {
  69. // 获取数据字典
  70. this.getListLookUp();
  71. // 获取支付,收款方式
  72. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  73. // 刷新首页数据
  74. uni.$on("refashHome",()=>{
  75. this.pageInit()
  76. })
  77. },
  78. onUnload() {
  79. uni.$off('refashHome')
  80. },
  81. // 下拉刷新
  82. onPullDownRefresh(){
  83. this.pageInit()
  84. setTimeout(function () {
  85. uni.stopPullDownRefresh();
  86. }, 1000);
  87. },
  88. onShareAppMessage() {},
  89. methods: {
  90. pageInit(){
  91. if(this.hasLogin){
  92. // 获取扫描记录
  93. this.getVinLog()
  94. }
  95. },
  96. // 获取数据字典
  97. getListLookUp() {
  98. const _this = this;
  99. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  100. if (res.status == 200) {
  101. _this.$store.state.vuex_allLookUp = res.data;
  102. }
  103. });
  104. },
  105. // 或某一项字典列表,参数code
  106. getLookUpList(code, vuexKey) {
  107. getLookUpDatas({ type: code }).then(res => {
  108. if (res.status == 200) {
  109. this.$store.state[vuexKey] = res.data || [];
  110. }
  111. });
  112. },
  113. getVinLog(){
  114. this.vinList = []
  115. this.status = "loading"
  116. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  117. this.vinList = res.data.list || []
  118. this.vinList = this.vinList.filter(item => item.vinCode)
  119. this.status = 'nomore'
  120. })
  121. },
  122. }
  123. }
  124. </script>
  125. <style lang="less">
  126. .content {
  127. margin: 0;
  128. padding: 0;
  129. height: 100vh;
  130. display: flex;
  131. flex-direction: column;
  132. .userCard{
  133. padding:1.2em 1em;
  134. background-image: linear-gradient(#58c4c4 10%,#65e2e2);
  135. .userCard-info{
  136. > view{
  137. &:last-child{
  138. margin-left: 0.5em;
  139. >view{
  140. padding: 0.2em;
  141. }
  142. }
  143. }
  144. }
  145. .user-photo{
  146. display: block;
  147. width: 120rpx;
  148. height: 120rpx;
  149. border-radius: 50%;
  150. overflow: hidden;
  151. }
  152. }
  153. .ml10{
  154. margin-left: 0.2em;
  155. }
  156. .list-box{
  157. flex-grow: 1;
  158. padding: 0 1em;
  159. overflow: auto;
  160. .des{
  161. text-align: center;
  162. padding: 3em 0;
  163. color: #999;
  164. font-size: 0.9em;
  165. }
  166. }
  167. }
  168. </style>