index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. <view class="scroll-box">
  27. <view class="flex align_center justify_between item-box" v-for="item in 26" @click="toDetail(item)">
  28. <view class="l_box">99会员礼包</view>
  29. <view class="flex align_center r_box">
  30. <view>
  31. <view>2022-05-28</view>
  32. <view>高新天佑店</view>
  33. </view>
  34. <view>
  35. <u-icon name="arrow-right"></u-icon>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- <view style="padding: 20upx;">
  40. <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>
  41. <u-loadmore v-if="status=='loading'" :status="status" />
  42. </view> -->
  43. <view class="des">请登录后查看套餐记录</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState,
  51. mapMutations,
  52. } from 'vuex'
  53. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  54. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  55. export default {
  56. components: {
  57. },
  58. data() {
  59. return {
  60. status: 'loading',
  61. noDataText: '暂无数据',
  62. vinList: [],
  63. }
  64. },
  65. computed: {
  66. ...mapState(['hasLogin']),
  67. userInfo(){
  68. return this.$store.state.vuex_userInfo
  69. }
  70. },
  71. onReady() {
  72. // 检测是否登录
  73. this.$store.dispatch('checkLogin',()=>{
  74. this.pageInit()
  75. })
  76. },
  77. onLoad() {
  78. // 获取数据字典
  79. this.getListLookUp();
  80. // 获取支付,收款方式
  81. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  82. // 刷新首页数据
  83. uni.$on("refashHome",()=>{
  84. this.pageInit()
  85. })
  86. },
  87. onUnload() {
  88. uni.$off('refashHome')
  89. },
  90. // 下拉刷新
  91. onPullDownRefresh(){
  92. this.pageInit()
  93. setTimeout(function () {
  94. uni.stopPullDownRefresh();
  95. }, 1000);
  96. },
  97. onShareAppMessage() {},
  98. methods: {
  99. pageInit(){
  100. if(this.hasLogin){
  101. // 获取扫描记录
  102. this.getVinLog()
  103. }
  104. },
  105. // 获取数据字典
  106. getListLookUp() {
  107. const _this = this;
  108. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  109. if (res.status == 200) {
  110. _this.$store.state.vuex_allLookUp = res.data;
  111. }
  112. });
  113. },
  114. // 或某一项字典列表,参数code
  115. getLookUpList(code, vuexKey) {
  116. getLookUpDatas({ type: code }).then(res => {
  117. if (res.status == 200) {
  118. this.$store.state[vuexKey] = res.data || [];
  119. }
  120. });
  121. },
  122. getVinLog(){
  123. this.vinList = []
  124. this.status = "loading"
  125. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  126. this.vinList = res.data.list || []
  127. this.vinList = this.vinList.filter(item => item.vinCode)
  128. this.status = 'nomore'
  129. })
  130. },
  131. toUser(){
  132. if(!this.hasLogin){
  133. uni.navigateTo({
  134. url:"/pages/login/login"
  135. })
  136. }
  137. },
  138. toDetail(item){
  139. uni.navigateTo({
  140. url:"/pages/bundelDetail/index"
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="less">
  147. .content {
  148. margin: 0;
  149. padding: 0;
  150. height: 100vh;
  151. display: flex;
  152. flex-direction: column;
  153. .userCard{
  154. padding:1.2em 1em;
  155. background-image: linear-gradient(#58c4c4 10%,#65e2e2);
  156. .userCard-info{
  157. > view{
  158. &:last-child{
  159. margin-left: 0.5em;
  160. >view{
  161. padding: 0.2em;
  162. }
  163. }
  164. }
  165. }
  166. .user-photo{
  167. display: block;
  168. width: 120rpx;
  169. height: 120rpx;
  170. border-radius: 50%;
  171. overflow: hidden;
  172. }
  173. }
  174. .ml10{
  175. margin-left: 0.2em;
  176. }
  177. .list-box{
  178. flex-grow: 1;
  179. overflow: auto;
  180. .scroll-box{
  181. height: 100%;
  182. .item-box{
  183. border-bottom: 1px solid #eee;
  184. padding: 1em;
  185. &:active{
  186. background: #f8f8f8;
  187. }
  188. .l_box{
  189. font-size: 1.1em;
  190. flex-grow: 1;
  191. }
  192. .r_box{
  193. color: #999;
  194. > view{
  195. padding: 0 0.1em;
  196. }
  197. }
  198. }
  199. .des{
  200. text-align: center;
  201. padding: 3em 0;
  202. color: #999;
  203. font-size: 0.9em;
  204. }
  205. }
  206. }
  207. }
  208. </style>